diff --git a/SamplePre.Models/Ext/tube_input_ext.cs b/SamplePre.Models/Ext/tube_input_ext.cs index 1430342..19a676c 100644 --- a/SamplePre.Models/Ext/tube_input_ext.cs +++ b/SamplePre.Models/Ext/tube_input_ext.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace SamplePre.Models.Ext { - public class tube_input_ext : tube_input,INotifyPropertyChanged + public class tube_input_ext : sample_input,INotifyPropertyChanged { //public bool isChecked { get; set; } = false; diff --git a/SamplePre.Models/Tables/sample_exec.cs b/SamplePre.Models/Tables/sample_exec.cs index cf1b4b4..cb2c17b 100644 --- a/SamplePre.Models/Tables/sample_exec.cs +++ b/SamplePre.Models/Tables/sample_exec.cs @@ -1,12 +1,13 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SamplePre.Models.Models { - public class sample_exec + public class sample_exec :INotifyPropertyChanged { public string id { get; set; } public string standrad_id { get; set; } @@ -14,9 +15,22 @@ namespace SamplePre.Models.Models public string cmd_content2 { get; set; } public string qrcodes { get; set; } public int sample_count { get; set; } - public string exec_state { get; set; } + //public string exec_state { get; set; } + + private string _exec_state; + + public string exec_state + { + get { return _exec_state; } + set { _exec_state = value; + + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(exec_state))); + } + } + public DateTime exec_date { get; set; } + public event PropertyChangedEventHandler? PropertyChanged; } } diff --git a/SamplePre.Models/Tables/tube_input.cs b/SamplePre.Models/Tables/sample_input.cs similarity index 78% rename from SamplePre.Models/Tables/tube_input.cs rename to SamplePre.Models/Tables/sample_input.cs index c595680..36e44d0 100644 --- a/SamplePre.Models/Tables/tube_input.cs +++ b/SamplePre.Models/Tables/sample_input.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Models.Models { - public class tube_input + public class sample_input { public string qrcode { get; set; } public string item_name { get; set; } @@ -20,5 +20,11 @@ namespace Models.Models public int tube_count { get; set; } public string bach_no { get; set; } + public string exec_state { get; set; } + + public DateTime exec_date { get; set; } + + public string exec_id { get; set; } + } } diff --git a/SamplePre.ProcessBll/BLL/SampleSequenceBll.cs b/SamplePre.ProcessBll/BLL/SampleSequenceBll.cs index 4297158..4159229 100644 --- a/SamplePre.ProcessBll/BLL/SampleSequenceBll.cs +++ b/SamplePre.ProcessBll/BLL/SampleSequenceBll.cs @@ -106,7 +106,7 @@ namespace SamplePre.ProcessBll.SampleSequence { - int val = DBFactory.Instance.Deleteable().Where(p => p.qrcode == code).ExecuteCommand(); + int val = DBFactory.Instance.Deleteable().Where(p => p.qrcode == code).ExecuteCommand(); return val; } @@ -128,7 +128,23 @@ namespace SamplePre.ProcessBll.SampleSequence //主记录 int val = _db.Insertable(cmdExec).ExecuteCommand(); //明细 - int val2 = _db.Insertable(cmdExec.sampleExecDetails).ExecuteCommand(); + //int val2 = _db.Insertable(cmdExec.sampleExecDetails).ExecuteCommand(); + + //更新样品状态 + foreach (var item in cmdExec.sampleExecDetails) + { + + _db.Updateable() + .SetColumns(p => new sample_input() { exec_state = cmdExec.exec_state , + exec_date = cmdExec.exec_date , + exec_id = cmdExec.id + }) + .Where(p => p.qrcode == item.qrcode) + .ExecuteCommand(); + + + } + _db.CommitTran(); } @@ -165,7 +181,7 @@ namespace SamplePre.ProcessBll.SampleSequence } - public int SaveDataAndQrcode(tube_input qRcode, sys_dict sys_Dict) + public int SaveDataAndQrcode(sample_input qRcode, sys_dict sys_Dict) { var _db = DBFactory.Instance; @@ -175,7 +191,7 @@ namespace SamplePre.ProcessBll.SampleSequence _db.BeginTran(); //保存样品记录 - _db.Insertable(qRcode).ExecuteCommand(); + _db.Insertable(qRcode).ExecuteCommand(); //更新二维码 int val = _db.Updateable() @@ -196,9 +212,9 @@ namespace SamplePre.ProcessBll.SampleSequence return 1; } - public List GetTubeData(DateTime dt1, DateTime dt2) + public List GetTubeData(DateTime dt1, DateTime dt2) { - List data = DBFactory.Instance.Queryable().Where(p => p.input_date >= dt1 && p.input_date <= dt2).ToList(); + List data = DBFactory.Instance.Queryable().Where(p => p.input_date >= dt1 && p.input_date <= dt2).ToList(); return data;; @@ -484,33 +500,39 @@ namespace SamplePre.ProcessBll.SampleSequence - public List GetSampleExecDetails() + public List GetSampleExecDetails() { - var result = DBFactory.Instance.Queryable() - .LeftJoin((a, b) => a.master_id == b.id) - .LeftJoin((a, b, c) => a.qrcode == c.qrcode) - .Where((a, b, c) => b.exec_state == "执行中") - .Select((a, b, c) => new sample_exec_detail_ext { - id = a.id, - master_id = a.master_id, - qrcode = a.qrcode, - exec_state = b.exec_state, - item_name= c.item_name, - standrad_id = c.standrad_id, - standrad = c.standrad, - input_date = c.input_date, - input_user = c.input_user - - }) + //var result = DBFactory.Instance.Queryable() + // .LeftJoin((a, b) => a.master_id == b.id) + // .LeftJoin((a, b, c) => a.qrcode == c.qrcode) + // .Where((a, b, c) => b.exec_state == "执行中") + // .Select((a, b, c) => new sample_exec_detail_ext { + // id = a.id, + // master_id = a.master_id, + // qrcode = a.qrcode, + // exec_state = b.exec_state, + // item_name= c.item_name, + // standrad_id = c.standrad_id, + // standrad = c.standrad, + // input_date = c.input_date, + // input_user = c.input_user + + // }) + // .ToList(); + + var result = DBFactory.Instance.Queryable() + + .Where(b => b.exec_state == "执行中") + .ToList(); return result;// sampleSequenceDal.GetSampleExecDetails(); } - public List QueryTubeInputByBachNo(string bachNo) + public List QueryTubeInputByBachNo(string bachNo) { - return DBFactory.Instance.Queryable().Where(p => p.bach_no == bachNo).ToList(); + return DBFactory.Instance.Queryable().Where(p => p.bach_no == bachNo).ToList(); } public List GetStrandActionByStrandId(string standrad_id) diff --git a/SamplePreSystem.UI/ViewModel/Child/ImportSampleViewModel.cs b/SamplePreSystem.UI/ViewModel/Child/ImportSampleViewModel.cs index 067f3da..cb3043a 100644 --- a/SamplePreSystem.UI/ViewModel/Child/ImportSampleViewModel.cs +++ b/SamplePreSystem.UI/ViewModel/Child/ImportSampleViewModel.cs @@ -175,7 +175,7 @@ namespace SamplePreSystem.UI.ViewModel.Child [RelayCommand] public void ImportClick() { - List samples = new List(); + List samples = new List(); foreach (var tube in SampleList) { diff --git a/SamplePreSystem.UI/ViewModel/Monitor/MonitorViewModel.cs b/SamplePreSystem.UI/ViewModel/Monitor/MonitorViewModel.cs index 1c83548..c47fff3 100644 --- a/SamplePreSystem.UI/ViewModel/Monitor/MonitorViewModel.cs +++ b/SamplePreSystem.UI/ViewModel/Monitor/MonitorViewModel.cs @@ -170,10 +170,10 @@ namespace SamplePreSystem.UI.ViewModel.Monitor - private List _sampleExecList = new List(); + private List _sampleExecList = new List(); - public List SampleExecList + public List SampleExecList { get { return _sampleExecList; } set { @@ -204,7 +204,7 @@ namespace SamplePreSystem.UI.ViewModel.Monitor private void GetSampleData() { - List samples = sampleSequenceBll.GetSampleExecDetails(); + List samples = sampleSequenceBll.GetSampleExecDetails(); SampleExecList = samples; //设置当前SOP——ID diff --git a/SamplePreSystem.UI/ViewModel/QueryManager/SampleQueryViewModel.cs b/SamplePreSystem.UI/ViewModel/QueryManager/SampleQueryViewModel.cs index c3506ec..65c9406 100644 --- a/SamplePreSystem.UI/ViewModel/QueryManager/SampleQueryViewModel.cs +++ b/SamplePreSystem.UI/ViewModel/QueryManager/SampleQueryViewModel.cs @@ -51,9 +51,9 @@ namespace SamplePreSystem.UI.ViewModel.QueryManager } } - private List _sampleList = new List(); + private List _sampleList = new List(); - public List SampleList + public List SampleList { get { return _sampleList; } set { diff --git a/SamplePreSystem.UI/ViewModel/SampleManager/SampleExecViewModel.cs b/SamplePreSystem.UI/ViewModel/SampleManager/SampleExecViewModel.cs index 79a6d7e..72641d5 100644 --- a/SamplePreSystem.UI/ViewModel/SampleManager/SampleExecViewModel.cs +++ b/SamplePreSystem.UI/ViewModel/SampleManager/SampleExecViewModel.cs @@ -12,6 +12,7 @@ using SamplePre.UIWpf.ParamManager.chirld; using SamplePre.UIWpf.SampleManager.chirld; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; @@ -39,11 +40,11 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager } - private tube_input _tubeInput = new tube_input(); + private sample_input _tubeInput = new sample_input(); /// /// 样品录入实体 /// - public tube_input TubeInput + public sample_input TubeInput { get { return _tubeInput; } set { @@ -168,9 +169,9 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager return qrcode; } - private List _tubeInputs = new List(); + private List _tubeInputs = new List(); - public List TubeInputs + public List TubeInputs { get { return _tubeInputs; } set { @@ -214,14 +215,14 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager /// public bool SaveSample() { - List tempList = new List(); + List tempList = new List(); ////二维码序号 int sqno = int.Parse(TubeInput.qrcode.Substring(8));// int.Parse(txtSampleSeqno2.Text); string strDate = TubeInput.qrcode.Substring(0, 8); for (int i = 0; i < TubeInput.tube_count; i++) { - tube_input qRcode = new tube_input(); + sample_input qRcode = new sample_input(); qRcode.qrcode = strDate + sqno.ToString(); //TubeInput.qrcode; qRcode.item_name = TubeInput.item_name; //qRcode.seqno = txtSampleSeqno.Text + txtSampleSeqno2.Text; @@ -281,12 +282,12 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager } - private tube_input _selectSample; + private sample_input _selectSample; /// /// 选中的样品 /// - public tube_input SelectSample + public sample_input SelectSample { get { return _selectSample; } set { @@ -301,7 +302,7 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager public void DeleSelectSample() { - tube_input[] tube_Inputs = new tube_input[TubeInputs.Count]; + sample_input[] tube_Inputs = new sample_input[TubeInputs.Count]; TubeInputs.CopyTo(tube_Inputs); @@ -323,9 +324,9 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager } - private List _cmdList = new List(); + private ObservableCollection _cmdList = new ObservableCollection(); - public List CmdList + public ObservableCollection CmdList { get { return _cmdList; } set { @@ -341,9 +342,9 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager /// public void CreateCmdList() { - List temp_CmdList = new List(); + //List temp_CmdList = new List(); - //this.tubes = gridSamples.DataSource as List; + CmdList.Clear(); var groups = TubeInputs.GroupBy(p => new { p.standrad_id, p.standrad }); @@ -365,10 +366,10 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager sampleCmdExec.sampleExecDetails = details; sampleCmdExec.exec_state = "未执行"; - temp_CmdList.Add(sampleCmdExec); + CmdList.Add(sampleCmdExec); } - CmdList = temp_CmdList; + //CmdList = temp_CmdList; //BadingSopData(cmds); } @@ -482,8 +483,7 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager { if (!CmdExec()) return; - //保存下发记录 - + //保存下发记录 SelectItemCmd.exec_state = "执行中"; SelectItemCmd.cmd_content = sopStr; SelectItemCmd.exec_date = DateTime.Now; @@ -528,11 +528,11 @@ namespace SamplePreSystem.UI.ViewModel.SampleManager sopStr = string.Join("-", sop.ToArray()); - //写入PLC - bool val = communicationBll.WritePlcData(100, 0, sop.ToArray()); + ////写入PLC + //bool val = communicationBll.WritePlcData(100, 0, sop.ToArray()); //bool val = monitorBll.WritePlcData(1, 0, sop.ToArray()); - return val; + return true; } diff --git a/SamplePreSystem.UI/Views/MonitorManager/MonitorView.xaml b/SamplePreSystem.UI/Views/MonitorManager/MonitorView.xaml index f74e20d..b2ac085 100644 --- a/SamplePreSystem.UI/Views/MonitorManager/MonitorView.xaml +++ b/SamplePreSystem.UI/Views/MonitorManager/MonitorView.xaml @@ -38,10 +38,13 @@ - + + + + + + + - + + +