From 157f88d6299e70510223ff1abc74e3af2f141726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=B7=A7?= <625215135@qq.com> Date: Wed, 24 Sep 2025 13:57:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E8=A1=A8=E3=80=81?= =?UTF-8?q?=E6=94=B9=E5=8F=96=E4=BD=99=E6=B6=B2=E8=A1=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AF=B9=E5=BE=85=E6=A0=B8=E5=AF=B9=EF=BC=8C=E4=BD=99=E6=B6=B2?= =?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0dm=5Fstatus=E3=80=81quantity?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E3=80=82=20account=5Fbook=5Fg2=E8=A1=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0Use=5FDose=E3=80=81Residual=5FDose=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/App.xaml.cs | 5 + DM_Weight/Models/AccountBookG2.cs | 10 + DM_Weight/Models/SurgicalResidual.cs | 41 +- DM_Weight/Models/TotalDrug.cs | 14 + DM_Weight/Report/GridReportUtil.cs | 8 +- .../ReportTemp/account_book_new - 副本.grf | 712 +++++++++++ .../CheckOrderNewWindowNewViewModel.cs | 1130 +++++++++++++++++ .../CheckOrderNewWindowViewModel.cs | 27 +- .../CheckSelfOrderWindowNewViewModel.cs | 1117 ++++++++++++++++ .../CheckSelfOrderWindowViewModel.cs | 1 + .../ViewModels/RoleManagerWindowViewModel.cs | 4 +- DM_Weight/Views/CheckOrderNewWindowNew.xaml | 233 ++++ .../Views/CheckOrderNewWindowNew.xaml.cs | 28 + DM_Weight/Views/CheckSelfOrderWindowNew.xaml | 232 ++++ .../Views/CheckSelfOrderWindowNew.xaml.cs | 28 + 15 files changed, 3569 insertions(+), 21 deletions(-) create mode 100644 DM_Weight/Models/TotalDrug.cs create mode 100644 DM_Weight/ReportTemp/account_book_new - 副本.grf create mode 100644 DM_Weight/ViewModels/CheckOrderNewWindowNewViewModel.cs create mode 100644 DM_Weight/ViewModels/CheckSelfOrderWindowNewViewModel.cs create mode 100644 DM_Weight/Views/CheckOrderNewWindowNew.xaml create mode 100644 DM_Weight/Views/CheckOrderNewWindowNew.xaml.cs create mode 100644 DM_Weight/Views/CheckSelfOrderWindowNew.xaml create mode 100644 DM_Weight/Views/CheckSelfOrderWindowNew.xaml.cs diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs index a35b60c..e9ffc04 100644 --- a/DM_Weight/App.xaml.cs +++ b/DM_Weight/App.xaml.cs @@ -174,6 +174,11 @@ namespace DM_Weight containerRegistry.RegisterForNavigation(); + //管理员根据药箱进行核对处方 + containerRegistry.RegisterForNavigation(); + //麻醉师核对其名下单子 + containerRegistry.RegisterForNavigation(); + #endregion diff --git a/DM_Weight/Models/AccountBookG2.cs b/DM_Weight/Models/AccountBookG2.cs index dba0104..186631a 100644 --- a/DM_Weight/Models/AccountBookG2.cs +++ b/DM_Weight/Models/AccountBookG2.cs @@ -154,5 +154,15 @@ namespace DM_Weight.Models /// [SugarColumn(ColumnName = "shoushuJian")] public string ShoushuJian { get;set; } + /// + /// 使用剂量 + /// + [SugarColumn(ColumnName = "Use_Dose")] + public string UseDose { get; set; } + /// + /// 剩余剂量 + /// + [SugarColumn(ColumnName = "Residual_Dose")] + public string ResidualDose { get; set; } } } diff --git a/DM_Weight/Models/SurgicalResidual.cs b/DM_Weight/Models/SurgicalResidual.cs index 5a5aa07..0297df5 100644 --- a/DM_Weight/Models/SurgicalResidual.cs +++ b/DM_Weight/Models/SurgicalResidual.cs @@ -1,14 +1,15 @@ -using System; +using Prism.Mvvm; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using SqlSugar; namespace DM_Weight.Models { [SugarTable("surgical_residual")] - public class SurgicalResidual + public class SurgicalResidual : BindableBase { //[SugarColumn(ColumnName = "id")] //public int Id { get; set; } @@ -23,7 +24,7 @@ namespace DM_Weight.Models //public string residual_dose { get; set; } [SugarColumn(ColumnName = "create_time")] - public string CreateTime { get; set; } + public DateTime CreateTime { get; set; } //使用量 [SugarColumn(ColumnName = "use_dose")] public string UseDose { get; set; } @@ -35,11 +36,35 @@ namespace DM_Weight.Models //余液处置时间 [SugarColumn(ColumnName = "disposal_time")] public string DisposalTime { get; set; } + //数量 + [SugarColumn(ColumnName = "quantity")] + public int Quantity { get; set; } + //病人ID + [SugarColumn(ColumnName = "patient_id")] + public string PatientId { get; set; } + //病人 + [SugarColumn(ColumnName = "patient_name")] + public string PName { get; set; } + //性别 + [SugarColumn(ColumnName = "sex")] + public string Sex { get; set; } + //毒麻柜使用的状态 + [SugarColumn(ColumnName = "dm_status")] + public int DmStatus { get; set; } + //批次 + [SugarColumn(ColumnName = "manu_no")] + public string ManuNo { get; set; } + //麻醉师工号 + [SugarColumn(ColumnName = "anaesthetist_code")] + public string DoctorCode { get; set; } + //药品信息 + [Navigate(NavigateType.ManyToOne, nameof(DrugId))] + public DrugInfo DrugInfo { get; set; } //使用量+单位 [SugarColumn(IsIgnore = true)] public string UseDoseInfo { - get => UseDose==null ? "" : UseDose + DoseUnit; + get => UseDose == null ? "" : UseDose + DoseUnit; } /// /// 剩余量+单位 @@ -49,5 +74,11 @@ namespace DM_Weight.Models { get => ResidualDose == null ? "" : ResidualDose + DoseUnit; } + /// + /// 是否选中 + /// + private bool _itemIsChecked; + [SugarColumn(IsIgnore = true)] + public bool ItemIsChecked { get => _itemIsChecked; set => SetProperty(ref _itemIsChecked, value); } } } diff --git a/DM_Weight/Models/TotalDrug.cs b/DM_Weight/Models/TotalDrug.cs new file mode 100644 index 0000000..908846f --- /dev/null +++ b/DM_Weight/Models/TotalDrug.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.Models +{ + public class TotalDrug + { + public string DrugName { get; set; } + public int TotalCount { get; set; } + } +} diff --git a/DM_Weight/Report/GridReportUtil.cs b/DM_Weight/Report/GridReportUtil.cs index 785f179..dfd2be1 100644 --- a/DM_Weight/Report/GridReportUtil.cs +++ b/DM_Weight/Report/GridReportUtil.cs @@ -378,8 +378,8 @@ namespace DM_Weight.Report string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); string SQL = $@" select ab.drug_id, ab.type, di.drug_name AS DrugName,di.Drug_spec AS DrugSpec,di.big_unit AS BigUnit,di.small_unit AS SmallUnit, - DATE_FORMAT(ab.create_date,'%Y/%m/%d') AS YearMD,ab.manu_no AS ManuNo,DATE_FORMAT(ab.eff_date,'%Y%m%d') AS effDate,IF(ab.type=1,ab.add_quantity,'') AS InQuantity,ab.shoushuJian AS shoushuJian, - re.Patient_name AS PName,re.sex AS Sex,re.age AS Age,re.use_dose AS UseDose,re.residual_dose AS ResidualDose,re.create_time AS DiposalTime + DATE_FORMAT(ab.create_date,'%Y/%m/%d') AS YearMD,ab.manu_no AS ManuNo,DATE_FORMAT(ab.eff_date,'%Y%m%d') AS effDate,IF(ab.type=2,'',ab.add_quantity) AS InQuantity,ab.shoushuJian AS shoushuJian, + re.Patient_name AS PName,re.sex AS Sex,re.age AS Age,IF(ab.type=3,ab.use_dose,re.use_dose) AS UseDose,IF(ab.type=3,ab.residual_dose,re.residual_dose) AS ResidualDose,re.create_time AS DiposalTime ,re.operator_name, ab.manu_stock AS Stock,ab.total_stock AS empty,ab.total_stock,UL.User_name AS SendUser, IF(ab.type=1,UL.User_name,UL2.User_name) AS InCheckUser, re.supervisor_name AS CheckUser,ab.manu_stock,ab.total_stock,ab.user_id1,ab.user_id2,ab.out_Quantity @@ -391,13 +391,13 @@ namespace DM_Weight.Report LEFT JOIN order_info_sm oi on ab.invoice_no=oi.order_no LEFT JOIN user_list UL ON ab.user_id1=UL.ID LEFT JOIN user_list UL2 ON ab.user_id2=UL.ID - LEFT JOIN surgical_residual re on ab.invoice_no=re.order_no WHERE ab.machine_id='DM3' and ab.type in(1,2) and + LEFT JOIN surgical_residual re on ab.invoice_no=re.order_no WHERE ab.machine_id='DM3' and ab.type in(1,2,3) and ab.create_time>'{p_startDate}' AND ab.create_time<'{p_endDate}' "; if (!string.IsNullOrEmpty(drug_id)) { SQL += " AND ab.drug_id='" + drug_id + "' "; } - SQL += " ORDER BY ab.create_date asc,ab.drug_id,ab.Manu_No,ab.id "; + SQL += " ORDER BY ab.type,ab.drug_id,ab.Manu_No,ab.id "; Report.DetailGrid.Recordset.QuerySQL = SQL; Report.PrintPreview(true); diff --git a/DM_Weight/ReportTemp/account_book_new - 副本.grf b/DM_Weight/ReportTemp/account_book_new - 副本.grf new file mode 100644 index 0000000..2723e51 --- /dev/null +++ b/DM_Weight/ReportTemp/account_book_new - 副本.grf @@ -0,0 +1,712 @@ +{ + "Version":"6.8.1.1", + "Font":{ + "Name":"宋体", + "Size":105000, + "Weight":400, + "Charset":134 + }, + "Printer":{ + "Oriention":"Landscape", + "TopMargin":0.3175, + "RightMargin":1, + "BottomMargin":0.3969 + }, + "DetailGrid":{ + "CenterView":true, + "Recordset":{ + "QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n CONCAT(dmr.`quantity`,IF(dmr.`type`=32,\"(空瓶)\",\"\")) AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` in (31, 32)\r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate", + "Field":[ + { + "Name":"药品名称", + "DBFieldName":"DrugName" + }, + { + "Name":"日期", + "DBFieldName":"YearMD" + }, + { + "Name":"批号", + "DBFieldName":"ManuNo" + }, + { + "Name":"效期", + "Format":"yyyy/MM/dd", + "DBFieldName":"effDate" + }, + { + "Name":"领入", + "DBFieldName":"InQuantity" + }, + { + "Name":"规格", + "DBFieldName":"DrugSpec" + }, + { + "Name":"大单位", + "DBFieldName":"BigUnit" + }, + { + "Name":"小单位", + "DBFieldName":"SmallUnit" + }, + { + "Name":"基数", + "DBFieldName":"BaseQuantity" + }, + { + "Name":"手术间", + "DBFieldName":"shoushuJian" + }, + { + "Name":"患者姓名", + "DBFieldName":"PName" + }, + { + "Name":"性别", + "DBFieldName":"Sex" + }, + { + "Name":"年龄", + "DBFieldName":"Age" + }, + { + "Name":"住院号", + "DBFieldName":"ZYH" + }, + { + "Name":"科室", + "DBFieldName":"KS" + }, + { + "Name":"使用剂量", + "DBFieldName":"UseDose" + }, + { + "Name":"剩余剂量", + "DBFieldName":"ResidualDose" + }, + { + "Name":"余液处理时间", + "DBFieldName":"DiposalTime" + }, + { + "Name":"医师", + "DBFieldName":"YS" + }, + { + "Name":"复核人", + "DBFieldName":"CheckUser" + }, + { + "Name":"实物", + "DBFieldName":"Stock" + }, + { + "Name":"空瓶", + "DBFieldName":"empty" + }, + { + "Name":"发药人", + "DBFieldName":"SendUser" + }, + { + "Name":"领药人", + "DBFieldName":"InUser" + }, + { + "Name":"领药复核人", + "DBFieldName":"InCheckUser" + }, + { + "Name":"空瓶回收人", + "DBFieldName":"emptyUser" + }, + { + "Name":"批次库存", + "DBFieldName":"CurrentStock" + } + ] + }, + "Column":[ + { + "Name":"日期", + "Width":2.77813 + }, + { + "Name":"批次", + "Width":2.19604 + }, + { + "Name":"有效期", + "Width":2.77813 + }, + { + "Name":"领入", + "Width":0.820208 + }, + { + "Name":"手术间", + "Width":0.79375 + }, + { + "Name":"患者姓名", + "Width":1.61396 + }, + { + "Name":"性别", + "Width":1.00542 + }, + { + "Name":"年龄", + "Width":0.79375 + }, + { + "Name":"住院号", + "Width":1.5875 + }, + { + "Name":"科室", + "Width":2.2225 + }, + { + "Name":"使用剂量", + "Width":1.82563 + }, + { + "Name":"剩余剂量", + "Width":1.5875 + }, + { + "Name":"余液处理时间", + "Width":2.59292 + }, + { + "Name":"医师", + "Width":1.5875 + }, + { + "Name":"复核人", + "Width":1.79917 + }, + { + "Name":"空瓶回收人", + "Width":1.5875 + }, + { + "Name":"Column7", + "Width":1.61396 + }, + { + "Name":"实物", + "Width":1.40229 + }, + { + "Name":"空瓶", + "Width":1.19063 + }, + { + "Name":"发药人", + "Width":1.79917 + }, + { + "Name":"Column2", + "Width":1.79917 + }, + { + "Name":"Column8", + "Width":1.79917 + } + ], + "ColumnContent":{ + "Height":2.01083, + "ColumnContentCell":[ + { + "Column":"日期", + "TextAlign":"MiddleCenter", + "DataField":"日期" + }, + { + "Column":"批次", + "TextAlign":"MiddleCenter", + "DataField":"批号" + }, + { + "Column":"有效期", + "TextAlign":"MiddleCenter", + "DataField":"效期" + }, + { + "Column":"领入", + "TextAlign":"MiddleCenter", + "DataField":"领入" + }, + { + "Column":"手术间", + "TextAlign":"MiddleCenter", + "DataField":"手术间" + }, + { + "Column":"患者姓名", + "TextAlign":"MiddleCenter", + "DataField":"患者姓名" + }, + { + "Column":"性别", + "TextAlign":"MiddleCenter", + "DataField":"性别" + }, + { + "Column":"年龄", + "DataField":"年龄" + }, + { + "Column":"住院号", + "DataField":"住院号" + }, + { + "Column":"科室", + "DataField":"科室" + }, + { + "Column":"使用剂量", + "DataField":"使用剂量" + }, + { + "Column":"剩余剂量", + "DataField":"剩余剂量" + }, + { + "Column":"余液处理时间", + "DataField":"余液处理时间" + }, + { + "Column":"医师", + "DataField":"医师" + }, + { + "Column":"复核人", + "DataField":"复核人" + }, + { + "Column":"空瓶回收人", + "DataField":"空瓶回收人" + }, + { + "Column":"Column7" + }, + { + "Column":"实物", + "DataField":"实物" + }, + { + "Column":"空瓶", + "DataField":"空瓶" + }, + { + "Column":"发药人", + "DataField":"发药人" + }, + { + "Column":"Column2", + "DataField":"领药复核人" + }, + { + "Column":"Column8", + "DataField":"批次库存" + } + ] + }, + "ColumnTitle":{ + "Height":2.59292, + "RepeatStyle":"OnPage", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"日期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"日期" + }, + { + "GroupTitle":false, + "Column":"批次", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"批号" + }, + { + "GroupTitle":false, + "Column":"有效期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"有效期" + }, + { + "GroupTitle":false, + "Column":"领入", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"领\r\n入" + }, + { + "GroupTitle":true, + "Name":"Column1", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"手术间", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"手\r\n术\r\n间" + }, + { + "GroupTitle":false, + "Column":"患者姓名", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"患者\r\n姓名" + }, + { + "GroupTitle":false, + "Column":"性别", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"性\r\n别" + }, + { + "GroupTitle":false, + "Column":"年龄", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"年\r\n龄" + }, + { + "GroupTitle":false, + "Column":"住院号", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"住院号" + }, + { + "GroupTitle":false, + "Column":"科室", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"科室" + }, + { + "GroupTitle":false, + "Column":"使用剂量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"使用\r\n剂量" + }, + { + "GroupTitle":false, + "Column":"剩余剂量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"剩余\r\n剂量" + }, + { + "GroupTitle":false, + "Column":"余液处理时间", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"余液\r\n处理\r\n时间" + }, + { + "GroupTitle":false, + "Column":"医师", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"医师" + }, + { + "GroupTitle":false, + "Column":"复核人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"复核人" + } + ], + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"使用" + }, + { + "GroupTitle":true, + "Name":"Column6", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"空瓶回收人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"回收人" + }, + { + "GroupTitle":false, + "Column":"Column7", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"药房\r\n回收人" + } + ], + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"空瓶回收" + }, + { + "GroupTitle":true, + "Name":"Column3", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"实物", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"实物" + }, + { + "GroupTitle":false, + "Column":"空瓶", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"空瓶" + } + ], + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"结存数" + }, + { + "GroupTitle":false, + "Column":"发药人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"发药人" + }, + { + "GroupTitle":true, + "Name":"Column5", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"Column2", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"复核人" + } + ], + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"领药人" + }, + { + "GroupTitle":false, + "Column":"Column8", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"批次\r\n库存" + } + ] + } + }, + "PageHeader":{ + "Height":0 + }, + "Parameter":[ + { + "Name":"startDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/1/1" + }, + { + "Name":"endDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/4/28 23:59:59" + }, + { + "Name":"machine_id", + "Value":"DM1" + } + ], + "ReportHeader":[ + { + "Name":"ReportHeader1", + "Height":1.5875, + "Control":[ + { + "Type":"MemoBox", + "Name":"MemoBox2", + "Dock":"Fill", + "Font":{ + "Name":"宋体", + "Size":217500, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"湘谭县人民医院麻醉药品、精神药品专用账册、使用登记册(手术室)" + } + ], + "RepeatOnPage":true + }, + { + "Name":"ReportHeader2", + "Height":1.00542, + "Control":[ + { + "Type":"MemoBox", + "Name":"MemoBox3", + "Dock":"Fill", + "Border":{ + "Styles":"[DrawLeft|DrawTop|DrawRight]" + }, + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "Text":"药品名称:[#药品名称#] 规格:[#规格#] 单位:[#大单位#] 基数:[#基数#]" + } + ], + "RepeatOnPage":true + } + ] +} \ No newline at end of file diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowNewViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowNewViewModel.cs new file mode 100644 index 0000000..5dc0941 --- /dev/null +++ b/DM_Weight/ViewModels/CheckOrderNewWindowNewViewModel.cs @@ -0,0 +1,1130 @@ +using DM_Weight.Models; +using DM_Weight.msg; +using DM_Weight.Port; +using DM_Weight.select; +using DM_Weight.util; +using log4net; +using log4net.Repository.Hierarchy; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Timers; +using System.Windows; +using System.Windows.Media; + +namespace DM_Weight.ViewModels +{ + public class CheckOrderNewWindowNewViewModel : BindableBase, INavigationAware, IRegionMemberLifetime + { + private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowNewViewModel)); + // System.Timers.Timer CheckBoxStatusTimer; + + private int _pageNum = 1; + public int PageNum + { + get => _pageNum; + set + { + SetProperty(ref _pageNum, value); + RequestData(); + } + } + + private int _pageCount = 1; + public int PageCount + { + get => _pageCount; + set + { + SetProperty(ref _pageCount, value); + } + } + + private int _pageSize = 8; + public int PageSize + { + get => _pageSize; + set + { + SetProperty(ref _pageSize, value); + } + } + + private int _totalCount = 0; + public int TotalCount + { + get => _totalCount; + set + { + SetProperty(ref _totalCount, value); + } + } + //所选药箱号 + private int _drawerNo = -1; + + public int DrawerNo + { + get => _drawerNo; + set => SetProperty(ref _drawerNo, value); + } + + private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd"); + /// + /// 查询条件 处方日期 + /// + public string OrderDate + { + get { return _orderDate; } + set + { + if (!String.IsNullOrEmpty(value)) + { + SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd")); + } + else + { + SetProperty(ref _orderDate, value); + } + + RequestData(); + } + } + private bool _isEnable = true; + public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); } + private int _status = 0; + public int Status { get => _status; set { SetProperty(ref _status, value); } } + + + + //private List _ordersList = new List(); + //public List OrderInfoList + //{ + // get => _ordersList; + // set => SetProperty(ref _ordersList, value); + //} + + private List _surgicalResidualList = new List(); + public List SurgicalResidualList + { + get => _surgicalResidualList; + set => SetProperty(ref _surgicalResidualList, value); + } + private SurgicalResidual _surgicalResidual; + public SurgicalResidual surgicalResidual { get=>_surgicalResidual; set => SetProperty(ref _surgicalResidual, value); } + + private List? _totalDrugList = new List(); + public List? TotalDrugList + { + get => _totalDrugList; + set => SetProperty(ref _totalDrugList, value); + } + + //private OrderInfo _selectOrderInfo; + //public OrderInfo selectOrderInfo { get => _selectOrderInfo; set => SetProperty(ref _selectOrderInfo, value); } + + #region 18个药箱号的可用状态 + private bool _IsEnabled1 = true; + public bool IsEnabled1 { get => _IsEnabled1; set => SetProperty(ref _IsEnabled1, value); } + private bool _IsEnabled2 = true; + public bool IsEnabled2 { get => _IsEnabled2; set => SetProperty(ref _IsEnabled2, value); } + private bool _IsEnabled3 = true; + public bool IsEnabled3 { get => _IsEnabled3; set => SetProperty(ref _IsEnabled3, value); } + private bool _IsEnabled4 = true; + public bool IsEnabled4 { get => _IsEnabled4; set => SetProperty(ref _IsEnabled4, value); } + private bool _IsEnabled5 = true; + public bool IsEnabled5 { get => _IsEnabled5; set => SetProperty(ref _IsEnabled5, value); } + private bool _IsEnabled6 = true; + public bool IsEnabled6 { get => _IsEnabled6; set => SetProperty(ref _IsEnabled6, value); } + private bool _IsEnabled7 = true; + public bool IsEnabled7 { get => _IsEnabled7; set => SetProperty(ref _IsEnabled7, value); } + private bool _IsEnabled8 = true; + public bool IsEnabled8 { get => _IsEnabled8; set => SetProperty(ref _IsEnabled8, value); } + private bool _IsEnabled9 = true; + public bool IsEnabled9 { get => _IsEnabled9; set => SetProperty(ref _IsEnabled9, value); } + private bool _IsEnabled10 = true; + public bool IsEnabled10 { get => _IsEnabled10; set => SetProperty(ref _IsEnabled10, value); } + private bool _IsEnabled11 = true; + public bool IsEnabled11 { get => _IsEnabled11; set => SetProperty(ref _IsEnabled11, value); } + private bool _IsEnabled12 = true; + public bool IsEnabled12 { get => _IsEnabled12; set => SetProperty(ref _IsEnabled12, value); } + private bool _IsEnabled13 = true; + public bool IsEnabled13 { get => _IsEnabled13; set => SetProperty(ref _IsEnabled13, value); } + private bool _IsEnabled14 = true; + public bool IsEnabled14 { get => _IsEnabled14; set => SetProperty(ref _IsEnabled14, value); } + private bool _IsEnabled15 = true; + public bool IsEnabled15 { get => _IsEnabled15; set => SetProperty(ref _IsEnabled15, value); } + private bool _IsEnabled16 = true; + public bool IsEnabled16 { get => _IsEnabled16; set => SetProperty(ref _IsEnabled16, value); } + private bool _IsEnabled17 = true; + public bool IsEnabled17 { get => _IsEnabled17; set => SetProperty(ref _IsEnabled17, value); } + private bool _IsEnabled18 = true; + public bool IsEnabled18 { get => _IsEnabled18; set => SetProperty(ref _IsEnabled18, value); } + #endregion + + #region 按钮颜色 + private Brush _button1Color = Brushes.White; + public Brush Button1Color + { + get => _button1Color; + set => SetProperty(ref _button1Color, value); + } + private Brush _button2Color = Brushes.White; + public Brush Button2Color + { + get => _button2Color; + set => SetProperty(ref _button2Color, value); + } + private Brush _button3Color = Brushes.White; + public Brush Button3Color + { + get => _button3Color; + set => SetProperty(ref _button3Color, value); + } + private Brush _button4Color = Brushes.White; + public Brush Button4Color + { + get => _button4Color; + set => SetProperty(ref _button4Color, value); + } + private Brush _button5Color = Brushes.White; + public Brush Button5Color + { + get => _button5Color; + set => SetProperty(ref _button5Color, value); + } + private Brush _button6Color = Brushes.White; + public Brush Button6Color + { + get => _button6Color; + set => SetProperty(ref _button6Color, value); + } + private Brush _button7Color = Brushes.White; + public Brush Button7Color + { + get => _button7Color; + set => SetProperty(ref _button7Color, value); + } + private Brush _button8Color = Brushes.White; + public Brush Button8Color + { + get => _button8Color; + set => SetProperty(ref _button8Color, value); + } + private Brush _button9Color = Brushes.White; + public Brush Button9Color + { + get => _button9Color; + set => SetProperty(ref _button9Color, value); + } + private Brush _button10Color = Brushes.White; + public Brush Button10Color + { + get => _button10Color; + set => SetProperty(ref _button10Color, value); + } + private Brush _button11Color = Brushes.White; + public Brush Button11Color + { + get => _button11Color; + set => SetProperty(ref _button11Color, value); + } + private Brush _button12Color = Brushes.White; + public Brush Button12Color + { + get => _button12Color; + set => SetProperty(ref _button12Color, value); + } + private Brush _button13Color = Brushes.White; + public Brush Button13Color + { + get => _button13Color; + set => SetProperty(ref _button13Color, value); + } + private Brush _button14Color = Brushes.White; + public Brush Button14Color + { + get => _button14Color; + set => SetProperty(ref _button14Color, value); + } + private Brush _button15Color = Brushes.White; + public Brush Button15Color + { + get => _button15Color; + set => SetProperty(ref _button15Color, value); + } + private Brush _button16Color = Brushes.White; + public Brush Button16Color + { + get => _button16Color; + set => SetProperty(ref _button16Color, value); + } + private Brush _button17Color = Brushes.White; + public Brush Button17Color + { + get => _button17Color; + set => SetProperty(ref _button17Color, value); + } + private Brush _button18Color = Brushes.White; + public Brush Button18Color + { + get => _button18Color; + set => SetProperty(ref _button18Color, value); + } + #endregion + + IEventAggregator _eventAggregator; + //private PortUtil _portUtil; + SocketHelper _socketHelper; + public CheckOrderNewWindowNewViewModel(IEventAggregator eventAggregator, SocketHelper socketHelper) + { + //_portUtil = portUtil; + _eventAggregator = eventAggregator; + _socketHelper = socketHelper; + } + + private string? _searchValue; + + /// + /// 查询条件 查询字段值 + /// + public string? SearchValue + { + get { return _searchValue; } + set + { + SetProperty(ref _searchValue, value); + RequestData(); + } + } + void RequestData() + { + int totalCount = 0; + if (DrawerNo >= 0) + { + //查询当前药箱归属的药师 + ChannelList currentList = SqlSugarHelper.Db.Queryable().Where(cl => cl.DrawerNo == DrawerNo + 1 && cl.MachineId == "DM5").First();//.Select(cl => cl.BelongUser).First(); + + //OrderInfoList = SqlSugarHelper.Db.Queryable() + // .Includes(oi => oi._OrderDetail, od => od.DrugInfo) + // .Includes(oi => oi._OrderDetail, od => od.surgicalResidual) + // .WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate) + // .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"]) + // .Where(oi => oi.DmStatus == 1) + // .Where(oi => oi.HisDispFlag == 0) + // .Where(oi => oi.CancelFlag == 0) + // .Where(oi => oi.DrawerCode == DrawerNo + 1) + // .Where(oi => oi._OrderDetail.SetManuNo != null) + // .Where(oi => oi._OrderDetail.Quantity > 0) + // .OrderBy(oi => oi.OrderId) + // .ToPageList(PageNum, PageSize, ref totalCount); + + //if (OrderInfoList != null && OrderInfoList.Count() > 0) + //{ + // OrderInfoList.ForEach(oi => oi.ItemIsChecked = true); + // OrderInfoList.ForEach(oi => oi._OrderDetail.DrugInfo = oi._OrderDetail.DrugInfo ?? new DrugInfo()); + // TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).Select(OrderDetailList => OrderDetailList._OrderDetail).GroupBy(item => item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); + + //} + //else + //{ + // TotalDrugList = null; + //} + SurgicalResidualList = SqlSugarHelper.Db.Queryable() + .Includes(sr => sr.DrugInfo) + .WhereIF(OrderDate != null, sr => sr.CreateTime.ToString("yyyy-MM-dd") == OrderDate) + .Where(sr => sr.SendNo == (DrawerNo + 1).ToString() && sr.DmStatus == 1) + .OrderBy(sr => sr.OrderNo) + .ToPageList(PageNum, PageSize, ref totalCount); + if (SurgicalResidualList != null && SurgicalResidualList.Count > 0) + { + SurgicalResidualList.ForEach(sr => sr.ItemIsChecked = true); + TotalDrugList = SurgicalResidualList.Where(sr => sr.ItemIsChecked) + // .Select(OrderDetailList => OrderDetailList._OrderDetail) + .GroupBy(item => item.DrugInfo.DrugName) + .Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); + } + else + { + TotalDrugList = null; + } + TotalCount = totalCount; + PageCount = (int)Math.Ceiling((double)TotalCount / PageSize); + if (currentList != null && currentList.EffDate != null) + { + switch (DrawerNo + 1) + { + case 1: + _button1Color = Brushes.Yellow; + break; + case 2: + _button2Color = Brushes.Yellow; + break; + case 3: + _button3Color = Brushes.Yellow; + break; + case 4: + _button4Color = Brushes.Yellow; + break; + case 5: + _button5Color = Brushes.Yellow; + break; + case 6: + _button6Color = Brushes.Yellow; + break; + case 7: + _button7Color = Brushes.Yellow; + break; + case 8: + _button8Color = Brushes.Yellow; + break; + case 9: + _button9Color = Brushes.Yellow; + break; + case 10: + _button10Color = Brushes.Yellow; + break; + case 11: + _button11Color = Brushes.Yellow; + break; + case 12: + _button12Color = Brushes.Yellow; + break; + case 13: + _button13Color = Brushes.Yellow; + break; + case 14: + _button14Color = Brushes.Yellow; + break; + case 15: + _button15Color = Brushes.Yellow; + break; + case 16: + _button16Color = Brushes.Yellow; + break; + case 17: + _button17Color = Brushes.Yellow; + break; + case 18: + _button18Color = Brushes.Yellow; + break; + default: + break; + } + } + } + + } + public DelegateCommand RowSelected + { + get => new DelegateCommand(() => + { + if (surgicalResidual != null) + { + SurgicalResidualList = SurgicalResidualList.Select(x => + { + if (x.OrderNo == surgicalResidual.OrderNo) + { + x.ItemIsChecked = !x.ItemIsChecked; + } + return x; + }).ToList(); + if (SurgicalResidualList != null && SurgicalResidualList.Count() > 0) + { + TotalDrugList = SurgicalResidualList + .Where(oi => oi.ItemIsChecked) + .GroupBy(item => item.DrugInfo.DrugName) + .Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }) + .ToList(); + + } + } + }); + } + public DelegateCommand Query + { + get => new DelegateCommand(() => + { + RequestData(); + }); + } + + //确认 + public DelegateCommand CheckOrder + { + get => new DelegateCommand(() => + { + if (DrawerNo == -1) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "请先选择手术间", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } + CheckOrderAction(); + }); + } + + + void CheckOrderAction() + { + logger.Info($"管理员{HomeWindowViewModel.Operator?.Nickname}开始确认手麻单"); + var confirmData = SurgicalResidualList.Where(oi => oi.ItemIsChecked == true).ToList(); + if (confirmData.Count > 0) + { + + var f = SqlSugarHelper.Db.UseTran(() => + { + string empChannelStock = string.Empty; + + for (int i = 0; i < confirmData.Count; i++) + { + SurgicalResidual oi = confirmData[i]; + + //更新处方状态 + if (oi.DmStatus == 1) + { + SqlSugarHelper.Db.Updateable(new SurgicalResidual() + { + DmStatus = 2, + OrderNo = oi.OrderNo + }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand(); + + SqlSugarHelper.Db.Insertable(new OrderFinish() + { + OrderNo = oi.OrderNo, + PatientId = oi.PatientId, + //Pharmacy = oi.Pharmacy, + State = 2, + WinNo = DrawerNo + 1 + "号手术间", + Operator = HomeWindowViewModel.Operator?.Nickname, + }).ExecuteCommand(); + } + int drawerNo = DrawerNo + 1; + ChannelStock cs = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.DrugId == oi.DrugId + && cs.ManuNo == oi.ManuNo + // && cs.EffDate == oi._OrderDetail.SetEffDate + && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5") + && cs.DrawerNo == drawerNo + && cs.Quantity >= oi.Quantity).First(); + if (cs == null) + { + empChannelStock += $"{oi.OrderNo},{oi.DrugId},{oi.ManuNo};"; + logger.Info($"手麻单{oi.OrderNo}核对药品批次{oi.DrugId}-{oi.ManuNo}在{drawerNo}手术间无库存"); + continue; + } + cs.Quantity = cs.Quantity - oi.Quantity; + cs.NeedNum = cs.NeedNum > 0 ? cs.NeedNum + oi.Quantity : oi.Quantity; + logger.Info($"更新手术间{cs.DrawerNo}药品{cs.DrugId}批次{cs.ManuNo}库存为{cs.Quantity},需补药数量为{cs.NeedNum}"); + // 更新数据 库存信息 + SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity, it.NeedNum }).ExecuteCommand(); + + // 获取更新完库存后的药品库存 + List nowChannels = SqlSugarHelper.Db.Queryable() + .Where(it => it.MachineId.Equals(ConfigurationManager.AppSettings["machineId"]) || it.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"])) + .Where(it => it.DrugId.Equals(cs.DrugId)) + .Where(it => it.ManuNo.Equals(cs.ManuNo)) + .Where(it => it.DrawerType == 1) + .ToList(); + + SqlSugarHelper.Db.Insertable(new MachineRecord() + { + MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), + DrawerNo = cs.DrawerNo, + ColNo = cs.ColNo, + DrugId = cs.DrugId, + ManuNo = cs.ManuNo, + EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, + Operator = HomeWindowViewModel.Operator?.Id, + Reviewer = HomeWindowViewModel.Reviewer?.Id, + OperationTime = DateTime.Now, + Quantity = oi.Quantity, + Type = 2, + InvoiceId = oi.OrderNo + //, StockQuantity = nowChannels.Sum(it => it.Quantity) + }).ExecuteCommand(); + + #region 记录 注射剂使用与交接记录报表 + //查询发药时间 + //MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2) + //.OrderByDescending(mr => mr.OperationTime) + //.First(); + //string retUser = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo) + //.Select(cl => cl.BelongUser).First(); + + RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First(); + if (rejectionReport != null) + { + //发药信息 + //RejectionReport rejectionReport = new RejectionReport(); + //rejectionReport.SendDate = SendMachineRecord.OperationTime; + //rejectionReport.SendUser = SendMachineRecord.Operator.ToString(); + //rejectionReport.ReceiveUser = retUser; + rejectionReport.RealNum = cs.BaseQuantity; + + //还药信息 + rejectionReport.InfactNum = cs.BaseQuantity - oi.Quantity; + rejectionReport.EmptyNum = oi.Quantity; + rejectionReport.ReturnTime = DateTime.Now.ToString(); + rejectionReport.ReturnUser = rejectionReport.SendUser; + rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString(); + rejectionReport.DrugId = oi.DrugId; + rejectionReport.DrugName = oi.DrugInfo.DrugName; + rejectionReport.DrugSpec = oi.DrugInfo.DrugSpec; + + rejectionReport.OperationTime = DateTime.Now; + + int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand(); + } + #endregion + + //} + //查询上一条账册中的空瓶数 + AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable() + .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) + .Where(ab => ab.Type == 1 || ab.Type == 2) + .Where(ab => ab.DrugId == oi.DrugId) + .Where(ab => ab.ManuNo == cs.ManuNo).OrderByDescending(ab => ab.Id).First(); + //修改凌晨生成的日结存与总结存数据 + AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() + .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) + .Where(ab => ab.Type == 3) + .Where(ab => ab.DrugId == oi.DrugId) + .Where(ab => ab.ManuNo == cs.ManuNo) + .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); + int manuStock = 0; + if (accountBookG2Day != null) + { + accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi.Quantity; + accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + oi.Quantity; + accountBookG2Day.UseDose =!string.IsNullOrEmpty(accountBookG2Day.UseDose)?(Convert.ToInt32(accountBookG2Day.UseDose) + Convert.ToInt32(oi.UseDose)).ToString(): oi.UseDose; + accountBookG2Day.ResidualDose = !string.IsNullOrEmpty(accountBookG2Day.ResidualDose) ? (Convert.ToInt32(accountBookG2Day.ResidualDose) + Convert.ToInt32(oi.ResidualDose)).ToString(): oi.ResidualDose; + accountBookG2Day.TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi.Quantity; + accountBookG2Day.CreateTime = DateTime.Now; + SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand(); + manuStock = accountBookG2Day.ManuStock; + } + else + { + //生成日结存时可能没有该库位的绑定信息,需要写入日结存 + int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() + { + DrugId = oi.DrugId, + Type = 3, + ManuNo = cs.ManuNo, + EffDate = cs.EffDate, + YQuantity = 0, + ManuStock = nowChannels.Sum(it => it.Quantity), //oi._OrderDetail.Quantity, + TotalStock = oi.Quantity, + UserId1 = HomeWindowViewModel.Operator?.Id, + UserId2 = HomeWindowViewModel.Reviewer?.Id, + MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), + CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), + CreateTime = DateTime.Now, + InvoiceNo = "日结存", + OutQuantity = oi.Quantity, + UseDose=oi.UseDose, + ResidualDose=oi.ResidualDose + }).ExecuteCommand(); + if (iDayResult <= 0) + { + logger.Info($"未写入日结存数据{oi.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}"); + } + } + //保存账册 + int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() + { + DrugId = oi.DrugId, + Type = 2, + //Department = oi.DeptName, + OrderNo = oi.OrderNo, + ManuNo = cs.ManuNo, + EffDate = cs.EffDate, + OutQuantity = oi.Quantity, + UserId1 = HomeWindowViewModel.Operator?.Id, + UserId2 = HomeWindowViewModel.Reviewer?.Id, + MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), + CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), + CreateTime = DateTime.Now, + InvoiceNo = oi.OrderNo, + ManuStock = manuStock > 0 ? manuStock : nowChannels.Sum(it => it.Quantity), + TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi.Quantity, + ShoushuJian = drawerNo.ToString() + }).ExecuteCommand(); + //修改凌晨生成的日结存与总结存数据 + AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() + .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) + .Where(ab => ab.Type == 4) + .Where(ab => ab.DrugId == oi.DrugId) + .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); + if (accountBookG2Total != null) + { + accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - oi.Quantity; + SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand(); + } + else + { + //生成总结存时可能没有该库位的绑定信息,需要写入总结存 + int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() + { + DrugId = oi.DrugId, + Type = 4, + YQuantity = 0, + ManuStock = oi.Quantity, + TotalStock = oi.Quantity, + UserId1 = HomeWindowViewModel.Operator?.Id, + UserId2 = HomeWindowViewModel.Reviewer?.Id, + MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), + CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), + CreateTime = DateTime.Now, + InvoiceNo = "总结存" + }).ExecuteCommand(); + if (iTotalResult <= 0) + { + logger.Info($"未写入总结存数据{oi.DrugId}-{oi.Quantity}"); + } + } + } + if (!string.IsNullOrEmpty(empChannelStock)) + { + AlertMsg alertMsg = new AlertMsg + { + Message = $"所选单子中对应药品批次无效{empChannelStock}", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + logger.Info($"所选单子对应药品批次无效{empChannelStock}"); + throw new Exception("事务回滚"); + } + return true; + }); + if (f.Data) + { + RequestData(); + AlertMsg alertMsg = new AlertMsg + { + Message = "所选单子已核对完成", + Type = MsgType.SUCCESS, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + RequestData(); + } + if (!f.IsSuccess) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "核对失败!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + Status = 0; + } + else + { + AlertMsg alertMsg = new AlertMsg + { + Message = "请勾选要核对单数据", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + + logger.Info($"管理员{HomeWindowViewModel.Operator?.Nickname}结束确认手麻单"); + } + /// + /// 选择药箱,打开药箱 + /// + public DelegateCommand UpdateDrawerNo + { + get => new DelegateCommand(OpenBoxAction); + } + + public bool KeepAlive => false; + + public void OpenBoxAction(string strDrawerNo) + { + //if (ModbusHelper.BoxOperate) + //{ + // Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); }); + // return; + //} + if (!_socketHelper.OpenStatus) + { + _socketHelper.OpenStatus = true; + DrawerNo = Convert.ToInt32(strDrawerNo); + MachineRecord machineRecord = new MachineRecord(); + machineRecord.MachineId = "DM5"; + machineRecord.DrawerNo = DrawerNo + 1; + machineRecord.Operator = HomeWindowViewModel.Operator?.Id; + machineRecord.OperationTime = DateTime.Now; + machineRecord.Type = 55; + machineRecord.InvoiceId = $"管理员核对单,打开{DrawerNo + 1}号手术间"; + + + if (DrawerNo >= 0) + { + RequestData(); + Status = 1; + _socketHelper.speechSynthesizer.SpeakAsyncCancelAll(); + _socketHelper.speechSynthesizer.Resume(); + _socketHelper.SpeakAsync($"正在打开{DrawerNo + 1}号手术间"); + //logger.Info($"正在打开{DrawerNo + 1}号药箱"); + //记录开药箱日志 + SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand(); + //ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo); + try + { + _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo) }); + _socketHelper.dateTime = DateTime.Now; + } + catch (Exception ex) + { + AlertMsg alertMsg = new AlertMsg + { + Message = $"网口连接异常,正在重试{ex.Message}", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + logger.Info($"网口连接异常,正在重试{ex.Message}"); + _socketHelper.OpenStatus = false; + return; + } + //Task.Factory.StartNew(async () => + //{ + // bool loop = true; + // while (loop) + // { + // await Task.Delay(1000); + // bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState(); + // bool state = Array.TrueForAll(boolsl, b => b == false); + // if (state) + // { + // loop = false; + // ModbusHelper.BoxOperate = false; + // } + // else + // { + // ModbusHelper.BoxOperate = true; + // //ModbusHelper.SpeakAsync("药箱已打开,请及时关闭"); + // } + // } + //}); + int iException = 0; + Thread.Sleep(200); + new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) => + { + + _socketHelper.IsMultiThread = true; + try + { + if (_socketHelper.OpenStatus) + { + + //bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState(); + _socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 }); + + //ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}"); + //bool state = Array.TrueForAll(boolsl, b => b == false); + if (_socketHelper.OpenStatus) + { + logger.Info($"OpenStatus:{_socketHelper.OpenStatus}"); + //if (i == 0) + //{ + // //ModbusHelper.SpeakAsync("请及时关闭药箱"); + // i = 10; + //} + next(); + } + else + { + logger.Info($"OpenStatus:{_socketHelper.OpenStatus}"); + + _socketHelper.dateTime = DateTime.Now; + _socketHelper.IsMultiThread = false; + stop(); + } + } + else + { + _socketHelper.dateTime = DateTime.Now; + _socketHelper.IsMultiThread = false; + stop(); + } + + iException = 0; + } + catch (Exception ex) + { + iException++; + if (iException >= 3) + { + _socketHelper.OpenStatus = false; + } + // _socketHelper.OpenStatus = false; + AlertMsg alertMsg = new AlertMsg + { + Message = $"网口连接异常,正在重试{ex.Message}", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + logger.Info($"网口连接异常,正在重试{ex.Message}"); + next(); + } + }); + //设置对应药箱按钮可用状态 + //SetIsEnableStatus(DrawerNo, false); + ChannelList iList = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == DrawerNo + 1).First(); + if (iList != null) + { + iList.EffDate = null; + SqlSugarHelper.Db.Updateable(iList).UpdateColumns(it => new { it.EffDate }).ExecuteCommand(); + } + } + } + + else if (_socketHelper.OpenStatus) + { + + _socketHelper.speechSynthesizer.SpeakAsyncCancelAll(); + _socketHelper.speechSynthesizer.Resume(); + _socketHelper.SpeakAsync("请关闭手术间后再打开"); + return; + } + } + private void SetIsEnableStatus(int drawerNO, bool status) + { + switch (drawerNO) + { + case 0: + IsEnabled1 = status; + break; + case 1: + IsEnabled2 = status; + break; + case 2: + IsEnabled3 = status; + break; + case 3: + IsEnabled4 = status; + break; + case 4: + IsEnabled5 = status; + break; + case 5: + IsEnabled6 = status; + break; + case 6: + IsEnabled7 = status; + break; + case 7: + IsEnabled8 = status; + break; + case 8: + IsEnabled9 = status; + break; + case 9: + IsEnabled10 = status; + break; + case 10: + IsEnabled11 = status; + break; + case 11: + IsEnabled12 = status; + break; + case 12: + IsEnabled13 = status; + break; + case 13: + IsEnabled14 = status; + break; + case 14: + IsEnabled15 = status; + break; + case 15: + IsEnabled16 = status; + break; + case 16: + IsEnabled17 = status; + break; + case 17: + IsEnabled18 = status; + break; + } + } + + public void OnNavigatedTo(NavigationContext navigationContext) + { + logger.Info("进入OnNavigatedTo"); + //RequestData(); + NavigateToInfo(); + logger.Info("结束RequestData"); + } + void NavigateToInfo() + { + List chlList = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5").ToList();//.Select(cl => cl.BelongUser).First(); + if (chlList != null && chlList.Count > 0) + { + for (int i = 0; i < chlList.Count; i++) + { + ChannelList chl = chlList[i]; + if (chl != null && chl.EffDate != null) + { + switch (chl.DrawerNo) + { + case 1: + Button1Color = Brushes.Yellow; + break; + case 2: + Button2Color = Brushes.Yellow; + break; + case 3: + Button3Color = Brushes.Yellow; + break; + case 4: + Button4Color = Brushes.Yellow; + break; + case 5: + Button5Color = Brushes.Yellow; + break; + case 6: + Button6Color = Brushes.Yellow; + break; + case 7: + Button7Color = Brushes.Yellow; + break; + case 8: + Button8Color = Brushes.Yellow; + break; + case 9: + Button9Color = Brushes.Yellow; + break; + case 10: + Button10Color = Brushes.Yellow; + break; + case 11: + Button11Color = Brushes.Yellow; + break; + case 12: + Button12Color = Brushes.Yellow; + break; + case 13: + Button13Color = Brushes.Yellow; + break; + case 14: + Button14Color = Brushes.Yellow; + break; + case 15: + Button15Color = Brushes.Yellow; + break; + case 16: + Button16Color = Brushes.Yellow; + break; + case 17: + Button17Color = Brushes.Yellow; + break; + case 18: + Button18Color = Brushes.Yellow; + break; + default: + break; + } + } + } + } + } + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + } + + //void DoMyPrismEvent(DeviceMsg msg) + //{ + // switch (msg.EventType) + // { + // // 药箱打开 + // case EventType.DRAWEROPEN: + // if (Status == 1) + // { + // Status = 2; + // } + // //记录开药箱日志 + // SqlSugarHelper.Db.Insertable(new MachineRecord() + // { + // MachineId = "DM5", + // DrawerNo = _portUtil.DrawerNo, + // Operator = HomeWindowViewModel.Operator?.Id, + // OperationTime = DateTime.Now, + // Type = 55, + // InvoiceId = $"打开{DrawerNo}号药箱", + // }).ExecuteCommand(); + // _portUtil.GetBoxStatus(); + // break; + // // 药箱关闭 + // case EventType.DRAWERCLOSE: + // //记录药箱操作日志 + // SqlSugarHelper.Db.Insertable(new MachineRecord() + // { + // MachineId = "DM5", + // DrawerNo = _portUtil.DrawerNo, + // Operator = HomeWindowViewModel.Operator?.Id, + // OperationTime = DateTime.Now, + // Type = 55, + // InvoiceId = "药箱关闭", + // }).ExecuteCommand(); + + // if (Status == 2) + // { + // Status = 3; + // } + // _portUtil.Operate = false; + // break; + // // 打开失败 + // case EventType.OPENERROR: + // AlertMsg alertMsg = new AlertMsg + // { + // Message = msg.Message, + // Type = MsgType.ERROR + // }; + // _eventAggregator.GetEvent().Publish(alertMsg); + + // Status = 0; + + // //记录药箱操作日志 + // SqlSugarHelper.Db.Insertable(new MachineRecord() + // { + // MachineId = "DM5", + // DrawerNo = _portUtil.DrawerNo, + // Operator = HomeWindowViewModel.Operator?.Id, + // OperationTime = DateTime.Now, + // Type = 55, + // InvoiceId = "药箱打开失败", + // }).ExecuteCommand(); + // _portUtil.Operate = false; + // break; + // } + //} + } + //public class TotalDrug + //{ + // public string DrugName { get; set; } + // public int TotalCount { get; set; } + //} +} diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs index 245f8b0..55fba7a 100644 --- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs @@ -576,6 +576,12 @@ namespace DM_Weight.ViewModels #endregion //} + //查询上一条账册中的空瓶数 + AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable() + .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) + .Where(ab => ab.Type == 1 || ab.Type == 2) + .Where(ab => ab.DrugId == oi._OrderDetail.DrugId) + .Where(ab => ab.ManuNo == cs.ManuNo).OrderByDescending(ab => ab.Id).First(); //修改凌晨生成的日结存与总结存数据 AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) @@ -589,6 +595,9 @@ namespace DM_Weight.ViewModels accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity; accountBookG2Day.OutQuantity = accountBookG2Day.OutQuantity + oi._OrderDetail.Quantity; SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand(); + accountBookG2Day.UseDose = (Convert.ToInt32(accountBookG2Day.UseDose) + Convert.ToInt32(oi._OrderDetail.surgicalResidual.UseDose)).ToString(); + accountBookG2Day.ResidualDose = (Convert.ToInt32(accountBookG2Day.ResidualDose) + Convert.ToInt32(oi._OrderDetail.surgicalResidual.ResidualDose)).ToString(); + accountBookG2Day.TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi._OrderDetail.Quantity; manuStock = accountBookG2Day.ManuStock; } else @@ -610,6 +619,8 @@ namespace DM_Weight.ViewModels CreateTime = DateTime.Now, InvoiceNo = "日结存", OutQuantity = oi._OrderDetail.Quantity, + UseDose = oi._OrderDetail.surgicalResidual.UseDose, + ResidualDose = oi._OrderDetail.surgicalResidual.ResidualDose }).ExecuteCommand(); if (iDayResult <= 0) { @@ -617,11 +628,11 @@ namespace DM_Weight.ViewModels } } //查询上一条账册中的空瓶数 - AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable() - .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) - .Where(ab => ab.Type == 1 || ab.Type == 2) - .Where(ab => ab.DrugId == oi._OrderDetail.DrugId) - .Where(ab => ab.ManuNo == cs.ManuNo).OrderByDescending(ab => ab.Id).First(); + //AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable() + //.Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) + //.Where(ab => ab.Type == 1 || ab.Type == 2) + //.Where(ab => ab.DrugId == oi._OrderDetail.DrugId) + //.Where(ab => ab.ManuNo == cs.ManuNo).OrderByDescending(ab => ab.Id).First(); //保存账册 int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { @@ -1100,9 +1111,5 @@ namespace DM_Weight.ViewModels // } //} } - public class TotalDrug - { - public string DrugName { get; set; } - public int TotalCount { get; set; } - } + } diff --git a/DM_Weight/ViewModels/CheckSelfOrderWindowNewViewModel.cs b/DM_Weight/ViewModels/CheckSelfOrderWindowNewViewModel.cs new file mode 100644 index 0000000..a86ce32 --- /dev/null +++ b/DM_Weight/ViewModels/CheckSelfOrderWindowNewViewModel.cs @@ -0,0 +1,1117 @@ +using DM_Weight.Models; +using DM_Weight.msg; +using DM_Weight.Port; +using DM_Weight.util; +using DM_Weight.Views; +using log4net; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Timers; +using System.Windows.Media; + +namespace DM_Weight.ViewModels +{ + internal class CheckSelfOrderWindowNewViewModel : BindableBase, INavigationAware, IRegionMemberLifetime + { + private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel)); + //System.Timers.Timer CheckBoxStatusTimer; + private int _drawerType = -1; + + public int DrawerType + { + get => _drawerType; + set => SetProperty(ref _drawerType, value); + } + public bool KeepAlive => false; + + private int _pageNum = 1; + public int PageNum + { + get => _pageNum; + set + { + SetProperty(ref _pageNum, value); + RequestData(); + } + } + + private int _pageCount = 1; + public int PageCount + { + get => _pageCount; + set + { + SetProperty(ref _pageCount, value); + } + } + + private int _pageSize = 8; + public int PageSize + { + get => _pageSize; + set + { + SetProperty(ref _pageSize, value); + } + } + + private int _totalCount = 0; + public int TotalCount + { + get => _totalCount; + set + { + SetProperty(ref _totalCount, value); + } + } + //所选药箱号 + private int _drawerNo = -1; + + public int DrawerNo + { + get => _drawerNo; + set => SetProperty(ref _drawerNo, value); + } + //所选药箱号 + private int _currentDrawerNo = -1; + + public int CurrentDrawerNo + { + get => _currentDrawerNo; + set => SetProperty(ref _currentDrawerNo, value); + } + + //开公共药箱按钮的显示状态 + private bool _publicEnable = true; + public bool PublicEnable { get => _publicEnable; set => SetProperty(ref _publicEnable, value); } + + //公共药箱按钮显示内容 + private string _publicContent; + public string PublicContent { get => _publicContent; set => SetProperty(ref _publicContent, value); } + private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd"); + //名下药箱状态 + private int _selfStatus = 0; + public int SelfStatus { get => _selfStatus; set => SetProperty(ref _selfStatus, value); } + //抽屉号列表 + public static List iList = new List(); + /// + /// 查询条件 处方日期 + /// + public string OrderDate + { + get { return _orderDate; } + set + { + if (!String.IsNullOrEmpty(value)) + { + SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd")); + } + else + { + SetProperty(ref _orderDate, value); + } + + RequestData(); + } + } + private bool _isEnable = true; + public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); } + private int _status = 0; + public int Status { get => _status; set { SetProperty(ref _status, value); } } + + + + //private List _ordersList = new List(); + //public List OrderInfoList + //{ + // get => _ordersList; + // set => SetProperty(ref _ordersList, value); + //} + + //取余液表数据 + private List _surgicalResidualList = new List(); + public List SurgicalResidualList + { + get => _surgicalResidualList; + set => SetProperty(ref _surgicalResidualList, value); + } + + + private List? _totalDrugList = new List(); + public List? TotalDrugList + { + get => _totalDrugList; + set => SetProperty(ref _totalDrugList, value); + } + //选中行数据 + private SurgicalResidual _surgicalResidual; + public SurgicalResidual surgicalResidual + { + get => _surgicalResidual; + set => SetProperty(ref _surgicalResidual, value); + } + + //private OrderInfo _selectOrderInfo; + //public OrderInfo selectOrderInfo { get => _selectOrderInfo; set => SetProperty(ref _selectOrderInfo, value); } + + #region 按钮颜色 + private Brush _button1Color = Brushes.White; + public Brush Button1Color + { + get => _button1Color; + set => SetProperty(ref _button1Color, value); + } + private Brush _button2Color = Brushes.White; + public Brush Button2Color + { + get => _button2Color; + set => SetProperty(ref _button2Color, value); + } + private Brush _button3Color = Brushes.White; + public Brush Button3Color + { + get => _button3Color; + set => SetProperty(ref _button3Color, value); + } + private Brush _button4Color = Brushes.White; + public Brush Button4Color + { + get => _button4Color; + set => SetProperty(ref _button4Color, value); + } + private Brush _button5Color = Brushes.White; + public Brush Button5Color + { + get => _button5Color; + set => SetProperty(ref _button5Color, value); + } + private Brush _button6Color = Brushes.White; + public Brush Button6Color + { + get => _button6Color; + set => SetProperty(ref _button6Color, value); + } + private Brush _button7Color = Brushes.White; + public Brush Button7Color + { + get => _button7Color; + set => SetProperty(ref _button7Color, value); + } + private Brush _button8Color = Brushes.White; + public Brush Button8Color + { + get => _button8Color; + set => SetProperty(ref _button8Color, value); + } + private Brush _button9Color = Brushes.White; + public Brush Button9Color + { + get => _button9Color; + set => SetProperty(ref _button9Color, value); + } + private Brush _button10Color = Brushes.White; + public Brush Button10Color + { + get => _button10Color; + set => SetProperty(ref _button10Color, value); + } + private Brush _button11Color = Brushes.White; + public Brush Button11Color + { + get => _button11Color; + set => SetProperty(ref _button11Color, value); + } + private Brush _button12Color = Brushes.White; + public Brush Button12Color + { + get => _button12Color; + set => SetProperty(ref _button12Color, value); + } + private Brush _button13Color = Brushes.White; + public Brush Button13Color + { + get => _button13Color; + set => SetProperty(ref _button13Color, value); + } + private Brush _button14Color = Brushes.White; + public Brush Button14Color + { + get => _button14Color; + set => SetProperty(ref _button14Color, value); + } + private Brush _button15Color = Brushes.White; + public Brush Button15Color + { + get => _button15Color; + set => SetProperty(ref _button15Color, value); + } + private Brush _button16Color = Brushes.White; + public Brush Button16Color + { + get => _button16Color; + set => SetProperty(ref _button16Color, value); + } + private Brush _button17Color = Brushes.White; + public Brush Button17Color + { + get => _button17Color; + set => SetProperty(ref _button17Color, value); + } + private Brush _button18Color = Brushes.White; + public Brush Button18Color + { + get => _button18Color; + set => SetProperty(ref _button18Color, value); + } + private bool _button1Enable = false; + public bool Button1Enable + { + get => _button1Enable; + set => SetProperty(ref _button1Enable, value); + } + private bool _button2Enable = false; + public bool Button2Enable + { + get => _button2Enable; + set => SetProperty(ref _button2Enable, value); + } + private bool _button3Enable = false; + public bool Button3Enable + { + get => _button3Enable; + set => SetProperty(ref _button3Enable, value); + } + private bool _button4Enable = false; + public bool Button4Enable + { + get => _button4Enable; + set => SetProperty(ref _button4Enable, value); + } + private bool _button5Enable = false; + public bool Button5Enable + { + get => _button5Enable; + set => SetProperty(ref _button5Enable, value); + } + private bool _button6Enable = false; + public bool Button6Enable + { + get => _button6Enable; + set => SetProperty(ref _button6Enable, value); + } + private bool _button7Enable = false; + public bool Button7Enable + { + get => _button7Enable; + set => SetProperty(ref _button7Enable, value); + } + private bool _button8Enable = false; + public bool Button8Enable + { + get => _button8Enable; + set => SetProperty(ref _button8Enable, value); + } + private bool _button9Enable = false; + public bool Button9Enable + { + get => _button9Enable; + set => SetProperty(ref _button9Enable, value); + } + private bool _button10Enable = false; + public bool Button10Enable + { + get => _button10Enable; + set => SetProperty(ref _button10Enable, value); + } + private bool _button11Enable = false; + public bool Button11Enable + { + get => _button11Enable; + set => SetProperty(ref _button11Enable, value); + } + private bool _button12Enable = false; + public bool Button12Enable + { + get => _button12Enable; + set => SetProperty(ref _button12Enable, value); + } + private bool _button13Enable = false; + public bool Button13Enable + { + get => _button13Enable; + set => SetProperty(ref _button13Enable, value); + } + private bool _button14Enable = false; + public bool Button14Enable + { + get => _button14Enable; + set => SetProperty(ref _button14Enable, value); + } + private bool _button15Enable = false; + public bool Button15Enable + { + get => _button15Enable; + set => SetProperty(ref _button15Enable, value); + } + private bool _button16Enable = false; + public bool Button16Enable + { + get => _button16Enable; + set => SetProperty(ref _button16Enable, value); + } + private bool _button17Enable = false; + public bool Button17Enable + { + get => _button17Enable; + set => SetProperty(ref _button17Enable, value); + } + private bool _button18Enable = false; + public bool Button18Enable + { + get => _button18Enable; + set => SetProperty(ref _button18Enable, value); + } + #endregion + //设置按钮颜色 + private void SetBtnColor(int drawerNo) + { + switch (drawerNo) + { + case 1: + Button1Color = Brushes.Yellow; + break; + case 2: + Button2Color = Brushes.Yellow; + break; + case 3: + Button3Color = Brushes.Yellow; + break; + case 4: + Button4Color = Brushes.Yellow; + break; + case 5: + Button5Color = Brushes.Yellow; + break; + case 6: + Button6Color = Brushes.Yellow; + break; + case 7: + Button7Color = Brushes.Yellow; + break; + case 8: + Button8Color = Brushes.Yellow; + break; + case 9: + Button9Color = Brushes.Yellow; + break; + case 10: + Button10Color = Brushes.Yellow; + break; + case 11: + Button11Color = Brushes.Yellow; + break; + case 12: + Button12Color = Brushes.Yellow; + break; + case 13: + Button13Color = Brushes.Yellow; + break; + case 14: + Button14Color = Brushes.Yellow; + break; + case 15: + Button15Color = Brushes.Yellow; + break; + case 16: + Button16Color = Brushes.Yellow; + break; + case 17: + Button17Color = Brushes.Yellow; + break; + case 18: + Button18Color = Brushes.Yellow; + break; + default: + break; + } + } + //设置按钮可用状态 + private void SetBtnEnable(int drawerNo, bool status) + { + switch (drawerNo) + { + case 1: + Button1Enable = status; + //SelfEnable=status; + break; + case 2: + Button2Enable = status; + //SelfEnable = status; + break; + case 3: + Button3Enable = status; + //SelfEnable = status; + break; + case 4: + Button4Enable = status; + //SelfEnable = status; + break; + case 5: + Button5Enable = status; + //SelfEnable = status; + break; + case 6: + Button6Enable = status; + //SelfEnable = status; + break; + case 7: + Button7Enable = status; + //SelfEnable = status; + break; + case 8: + Button8Enable = status; + //SelfEnable = status; + break; + case 9: + Button9Enable = status; + //SelfEnable = status; + break; + case 10: + Button10Enable = status; + //SelfEnable = status; + break; + case 11: + Button11Enable = status; + //SelfEnable = status; + break; + case 12: + Button12Enable = status; + //SelfEnable = status; + break; + case 13: + Button13Enable = status; + //SelfEnable = status; + break; + case 14: + Button14Enable = status; + //SelfEnable = status; + break; + case 15: + Button15Enable = status; + //SelfEnable = status; + break; + case 16: + Button16Enable = status; + //SelfEnable = status; + break; + case 17: + Button17Enable = status; + //SelfEnable = status; + break; + case 18: + Button18Enable = status; + //SelfEnable = status; + break; + default: + break; + } + } + IEventAggregator _eventAggregator; + //private PortUtil _portUtil; + + SocketHelper _socketHelper; + public CheckSelfOrderWindowNewViewModel(IEventAggregator eventAggregator, SocketHelper socketHelper) + { + //_portUtil = portUtil; + _eventAggregator = eventAggregator; + _socketHelper = socketHelper; + } + private string? _searchValue; + + /// + /// 查询条件 查询字段值 + /// + public string? SearchValue + { + get { return _searchValue; } + set + { + SetProperty(ref _searchValue, value); + RequestData(); + } + } + void RequestData() + { + int totalCount = 0; + if (DrawerNo >= 0) + { + //查询当前药箱归属的药师 + ChannelList currentList = SqlSugarHelper.Db.Queryable().Where(cl => cl.DrawerNo == DrawerNo && cl.MachineId == "DM5").First();//.Select(cl => cl.BelongUser).First(); + DrawerType = currentList.DrawerType; + //string currentDrawerUser = currentList.BelongUser; + string currentDrawerUser = HomeWindowViewModel.Operator.UserBarcode; + //OrderInfoList = SqlSugarHelper.Db.Queryable() + // .Includes(oi => oi._OrderDetail, od => od.DrugInfo) + // .Includes(oi => oi._OrderDetail, od => od.surgicalResidual) + // .WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate) + // .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"]) + // .Where(oi => oi.DmStatus == 0) + // .Where(oi => oi.HisDispFlag == 0) + // .Where(oi => oi.CancelFlag == 0) + // .Where(oi => oi.DoctorCode == currentDrawerUser) + // .Where(oi => oi._OrderDetail.SetManuNo != null&&oi._OrderDetail.SetManuNo!="null") + // .Where(oi=>oi._OrderDetail.Quantity>0) + // .Where(oi=>oi._OrderDetail.surgicalResidual.SendNo== DrawerNo.ToString()) + // .OrderBy(oi => oi.OrderId) + // .ToPageList(PageNum, PageSize, ref totalCount); + //if (OrderInfoList != null && OrderInfoList.Count() > 0) + //{ + // OrderInfoList.ForEach(oi => oi.ItemIsChecked = true); + // OrderInfoList.ForEach(oi => oi._OrderDetail.DrugInfo = oi._OrderDetail.DrugInfo ?? new DrugInfo()); + // //TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).GroupBy(oi => oi.OrderDetailList.DrugInfo.DrugName).Select(oi => new TotalDrug { DrugName = oi.Key, TotalCount = oi.Sum(item => item.OrderDetailList.Quantity) }).ToList(); + // TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).Select(OrderDetailList => OrderDetailList._OrderDetail).GroupBy(item => item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); + //} + //else + //{ + // TotalDrugList = null; + //} + + SurgicalResidualList = SqlSugarHelper.Db.Queryable() + .Includes(sr => sr.DrugInfo) + .WhereIF(OrderDate != null, sr => sr.CreateTime.ToString("yyyy-MM-dd") == OrderDate) + .Where(sr => sr.SendNo == DrawerNo.ToString() && sr.DmStatus == 0 && sr.DoctorCode == currentDrawerUser) + .OrderBy(sr => sr.OrderNo) + .ToPageList(PageNum, PageSize, ref totalCount); + if (SurgicalResidualList != null && SurgicalResidualList.Count > 0) + { + SurgicalResidualList.ForEach(sr => sr.ItemIsChecked = true); + TotalDrugList = SurgicalResidualList.Where(sr => sr.ItemIsChecked) + // .Select(OrderDetailList => OrderDetailList._OrderDetail) + .GroupBy(item => item.DrugInfo.DrugName) + .Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); + } + else + { + TotalDrugList = null; + } + + + + + TotalCount = totalCount; + PageCount = (int)Math.Ceiling((double)TotalCount / PageSize); + if (Convert.ToDateTime(currentList.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) + { + switch (DrawerNo) + { + case 1: + _button1Color = Brushes.Yellow; + break; + case 2: + _button2Color = Brushes.Yellow; + break; + case 3: + _button3Color = Brushes.Yellow; + break; + case 4: + _button4Color = Brushes.Yellow; + break; + case 5: + _button5Color = Brushes.Yellow; + break; + case 6: + _button6Color = Brushes.Yellow; + break; + case 7: + _button7Color = Brushes.Yellow; + break; + case 8: + _button8Color = Brushes.Yellow; + break; + case 9: + _button9Color = Brushes.Yellow; + break; + case 10: + _button10Color = Brushes.Yellow; + break; + case 11: + _button11Color = Brushes.Yellow; + break; + case 12: + _button12Color = Brushes.Yellow; + break; + case 13: + _button13Color = Brushes.Yellow; + break; + case 14: + _button14Color = Brushes.Yellow; + break; + case 15: + _button15Color = Brushes.Yellow; + break; + case 16: + _button16Color = Brushes.Yellow; + break; + case 17: + _button17Color = Brushes.Yellow; + break; + case 18: + _button18Color = Brushes.Yellow; + break; + default: + break; + } + } + } + else + { + GetUseBox(); + } + } + /// + /// 选择药箱,打开药箱 + /// + public DelegateCommand UpdateDrawerNo + { + get => new DelegateCommand(OpenBoxAction); + } + public void OpenBoxAction(string strDrawerNo) + { + //if (ModbusHelper.BoxOperate) + //{ + // Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); }); + // return; + //} + if (_socketHelper.OpenStatus) + { + _socketHelper.speechSynthesizer.SpeakAsyncCancelAll(); + _socketHelper.speechSynthesizer.Resume(); + _socketHelper.SpeakAsync("请关闭手术间后再打开"); + return; + } + //SetAllBtnEnableFalse(); + DrawerNo = Convert.ToInt32(strDrawerNo); + //DrawerType = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == Convert.ToInt32(strDrawerNo)).Select(cl => cl.DrawerType).First(); + //SelfEnable = true; + //int listSelfState = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5") + // .WhereIf(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First(); + + //int listDrawerState = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType) + // .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First(); + + DrawerNo = Convert.ToInt32(strDrawerNo); + CurrentDrawerNo += DrawerNo + 1; + MachineRecord machineRecord = new MachineRecord(); + machineRecord.MachineId = "DM5"; + machineRecord.DrawerNo = DrawerNo; + machineRecord.Operator = HomeWindowViewModel.Operator?.Id; + machineRecord.OperationTime = DateTime.Now; + machineRecord.Type = 55; + machineRecord.InvoiceId = $"麻醉师核对单,打开{DrawerNo}号手术间"; + + + if (DrawerNo > 0) + { + RequestData(); + Status = 1; + _socketHelper.speechSynthesizer.SpeakAsyncCancelAll(); + _socketHelper.speechSynthesizer.Resume(); + _socketHelper.SpeakAsync($"正在打开{DrawerNo}号手术间"); + logger.Info($"正在打开{DrawerNo}号手术间"); + //记录开药箱日志 + SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand(); + //ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo-1); + try + { + _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) }); + _socketHelper.dateTime = DateTime.Now; + } + catch (Exception ex) + { + AlertMsg alertMsg = new AlertMsg + { + Message = $"网口连接异常,正在重试{ex.Message}", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + logger.Info($"网口连接异常,正在重试{ex.Message}"); + return; + } + _socketHelper.OpenStatus = true; + //SetBtnEnable(DrawerNo, false); + //if (CheckBoxStatusTimer is null) + //{ + // CheckBoxStatusTimer = new System.Timers.Timer(); + //} + //if (!CheckBoxStatusTimer.Enabled) + //{ + // CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState); + // CheckBoxStatusTimer.Interval = 3000; + // CheckBoxStatusTimer.Start(); + //} + //记录药箱打开时间 + ChannelList channelList = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == DrawerNo).First(); + if (channelList != null && (channelList.EffDate is null || Convert.ToDateTime(channelList.EffDate).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))) + { + + channelList.EffDate = DateTime.Now.ToString(); + SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate }).ExecuteCommand(); + } + //Task.Factory.StartNew(async () => + //{ + // bool loop = true; + // while (loop) + // { + // await Task.Delay(1000); + // bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState(); + // bool state = Array.TrueForAll(boolsl, b => b == false); + // if (state) + // { + // loop = false; + // ModbusHelper.BoxOperate = false; + // } + // else + // { + // ModbusHelper.BoxOperate = true; + // //ModbusHelper.SpeakAsync("药箱已打开,请及时关闭"); + // } + // } + //}); + Thread.Sleep(200); + int iException = 0; + new PromiseUtil().taskAsyncLoop(500, 0, async (options, next, stop) => + { + try + { + if (_socketHelper.OpenStatus) + { + + //bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState(); + _socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 }); + + //ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}"); + //bool state = Array.TrueForAll(boolsl, b => b == false); + if (_socketHelper.OpenStatus) + { + //if (i == 0) + //{ + // ModbusHelper.SpeakAsync("请及时关闭药箱"); + // i = 10; + //} + next(); + } + else + { + _socketHelper.IsMultiThread = false; + _socketHelper.dateTime = DateTime.Now; + stop(); + } + } + else + { + _socketHelper.IsMultiThread = false; + _socketHelper.dateTime = DateTime.Now; + stop(); + } + iException = 0; + } + catch (Exception ex) + { + iException++; + if (iException >= 3) + { + _socketHelper.OpenStatus = false; + } + // _socketHelper.OpenStatus = false; + AlertMsg alertMsg = new AlertMsg + { + Message = $"网口连接异常,正在重试{ex.Message}", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + logger.Info($"网口连接异常,正在重试{ex.Message}"); + next(); + } + }); + } + //if (DrawerType == 1) //公共药箱 + //{ + // if (listDrawerState == 0) + // { + // SelfContent = "还公共药箱"; + // } + // else + // { + // SelfContent = "取公共药箱"; + // } + + //} + //else + //{ + // if (listDrawerState == 0) + // { + // SelfContent = "还名下药箱"; + // } + // else + // { + // SelfContent = "取名下药箱"; + // } + + //} + + } + //public DelegateCommand OpenBoxDelegate + //{ + // get => new DelegateCommand((DrawerType) => + // { + // SearchBox(); + // } + // ); + //} + //private void SearchBox() + //{ + + // SetAllBtnEnableFalse(); + // iList = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType) + // .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).ToList(); + // // .Select(cl => cl.DrawerNo).ToList(); + // if (iList.Count > 0) + // { + // //_portUtil.SpeakAsync("正在打开药箱"); + // //_portUtil.DrawerNo = iList[iNumber]; + // //iNumber++; + // //_portUtil.OpenBox(); + + // for (int i = 0; i < iList.Count; i++) + // { + // ChannelList channelList = iList[i]; + // //记录开药箱日志 + // SqlSugarHelper.Db.Insertable(new MachineRecord() + // { + // MachineId = "DM5", + // DrawerNo = channelList.DrawerNo, + // Operator = HomeWindowViewModel.Operator?.Id, + // OperationTime = DateTime.Now, + // Type = 55, + // InvoiceId = $"打开{iList[i].DrawerNo}号药箱", + // OptionType = SelfContent.Substring(0, 1) == "取" ? 0 : 1 + // }).ExecuteCommand(); + // //记录药箱打开时间 + // channelList.EffDate = DateTime.Now.ToString(); + // channelList.DrawerState = SelfContent.Substring(0, 1) == "取" ? 0 : 1; + // SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate, it.DrawerState }).ExecuteCommand(); + + // _portUtil.SpeakAsync($"正在打开{channelList.DrawerNo}号药箱"); + // logger.Info($"正在打开{channelList.DrawerNo}号药箱"); + // ModbusHelper.GetInstance().OpenBoxDoor(channelList.DrawerNo - 1); + // } + + // SelfStatus = 0; + // PublicEnable = true; + // //SelfEnable = true; + // DrawerType = -1; + // } + //} + public DelegateCommand RowSelected + { + get => new DelegateCommand(() => + { + if (surgicalResidual != null) + { + SurgicalResidualList = SurgicalResidualList.Select(x => + { + if (x.OrderNo == surgicalResidual.OrderNo) + { + x.ItemIsChecked = !x.ItemIsChecked; + } + return x; + }).ToList(); + if (SurgicalResidualList != null && SurgicalResidualList.Count() > 0) + { + //TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).GroupBy(oi => oi._OrderDetail.DrugInfo.DrugName).Select(oi => new TotalDrug { DrugName = oi.Key, TotalCount = oi.Sum(item => item._OrderDetail.Quantity) }).ToList(); + + TotalDrugList = SurgicalResidualList.Where(oi => oi.ItemIsChecked).GroupBy(item => item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); + + } + } + }); + } + public DelegateCommand Query + { + get => new DelegateCommand(() => + { + RequestData(); + }); + } + + //确认 + public DelegateCommand CheckOrder + { + get => new DelegateCommand(() => + { + if (DrawerNo == -1) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "请先选择手术间", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } + GetUseBox(); + CheckOrderAction(); + }); + } + + + void CheckOrderAction() + { + var confirmData = SurgicalResidualList.Where(oi => oi.ItemIsChecked == true).ToList(); + if (confirmData.Count > 0) + { + + var f = SqlSugarHelper.Db.UseTran(() => + { + for (int i = 0; i < confirmData.Count; i++) + { + //OrderInfo oi = confirmData[i]; + SurgicalResidual surgicalResidual = confirmData[i]; + //查询该药箱是否有该批次的药品,没有则无法确认(避免管理进行确认时确认不过去) + + int drawerNo = DrawerNo; + ChannelStock cs = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.DrugId ==surgicalResidual.DrugId + && cs.ManuNo == surgicalResidual.ManuNo + && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5") + && cs.DrawerNo == drawerNo).First(); + if (cs == null) + { + AlertMsg alertMsg = new AlertMsg + { + Message = $"处方{surgicalResidual.OrderNo}因药品批次{surgicalResidual.ManuNo}无库存,无法确认", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return false; + } + + + + SqlSugarHelper.Db.Updateable(new SurgicalResidual() + { + DmStatus = 1, + OrderNo = surgicalResidual.OrderNo + }).UpdateColumns(it => it.DmStatus).WhereColumns(it => new { it.OrderNo }).ExecuteCommand(); + + SqlSugarHelper.Db.Insertable(new OrderFinish() + { + OrderNo = surgicalResidual.OrderNo, + PatientId = surgicalResidual.PatientId, + //Pharmacy = surgicalResidual.Pharmacy, + State = 1, + Operator = HomeWindowViewModel.Operator?.Nickname, + }).ExecuteCommand(); + } + return true; + }); + if (f.Data) + { + RequestData(); + AlertMsg alertMsg = new AlertMsg + { + Message = "所选单子已确认", + Type = MsgType.SUCCESS, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + RequestData(); + } + if (!f.IsSuccess) + { + AlertMsg alertMsg = new AlertMsg + { + Message = "核对失败!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + Status = 0; + } + else + { + AlertMsg alertMsg = new AlertMsg + { + Message = "请勾选要核对的数据", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + + } + + //取消 + public DelegateCommand CancleTake + { + get => new DelegateCommand(() => + { + GetUseBox(); + }); + } + private void GetUseBox() + { + List chlList = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5").ToList();//.Select(cl => cl.BelongUser).First(); + if (chlList != null && chlList.Count > 0) + { + for (int i = 0; i < chlList.Count; i++) + { + ChannelList chl = chlList[i]; + if (chl != null && chl.EffDate != null) + { + SetBtnColor(chl.DrawerNo); + } + + //DrawerType== 1为公共药箱 + if (chl.DrawerType == 1) + { + SetBtnEnable(chl.DrawerNo, true); + } + if (!string.IsNullOrEmpty(chl.BelongUser) && chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode) + { + if (DrawerType == -1) + { + DrawerType = chl.DrawerType; + } + SetBtnEnable(chl.DrawerNo, true); + } + } + } + } + public void OnNavigatedTo(NavigationContext navigationContext) + { + logger.Info("进入OnNavigatedTo"); + RequestData(); + logger.Info("结束RequestData"); + } + + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + // 取消消息订阅 + //_eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent); + } + } +} diff --git a/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs b/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs index 5043521..5fe790c 100644 --- a/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs @@ -588,6 +588,7 @@ namespace DM_Weight.ViewModels .Where(oi => oi.DoctorCode == currentDrawerUser) .Where(oi => oi._OrderDetail.SetManuNo != null&&oi._OrderDetail.SetManuNo!="null") .Where(oi=>oi._OrderDetail.Quantity>0) + .Where(oi=>oi._OrderDetail.surgicalResidual.SendNo== DrawerNo.ToString()) .OrderBy(oi => oi.OrderId) .ToPageList(PageNum, PageSize, ref totalCount); diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs index a29889f..ad75605 100644 --- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs @@ -201,7 +201,7 @@ namespace DM_Weight.ViewModels { Id = 11, PremissionName = "操作手术间", - PremissionPath = "CheckSelfOrderWindow", + PremissionPath = "CheckSelfOrderWindowNew", }; //核对处方 PremissionDm checkOrder = new PremissionDm @@ -209,7 +209,7 @@ namespace DM_Weight.ViewModels Id = 12, PremissionName = "核对处方", //PremissionPath = "CheckOrderWindow", - PremissionPath = "CheckOrderNewWindow", + PremissionPath = "CheckOrderNewWindowNew", }; //核对处方 PremissionDm addition = new PremissionDm diff --git a/DM_Weight/Views/CheckOrderNewWindowNew.xaml b/DM_Weight/Views/CheckOrderNewWindowNew.xaml new file mode 100644 index 0000000..a6c0ba9 --- /dev/null +++ b/DM_Weight/Views/CheckOrderNewWindowNew.xaml @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DM_Weight/Views/CheckOrderNewWindowNew.xaml.cs b/DM_Weight/Views/CheckOrderNewWindowNew.xaml.cs new file mode 100644 index 0000000..a70639c --- /dev/null +++ b/DM_Weight/Views/CheckOrderNewWindowNew.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace DM_Weight.Views +{ + /// + /// CheckOrderNewWindow.xaml 的交互逻辑 + /// + public partial class CheckOrderNewWindowNew : UserControl + { + public CheckOrderNewWindowNew() + { + InitializeComponent(); + } + } +} diff --git a/DM_Weight/Views/CheckSelfOrderWindowNew.xaml b/DM_Weight/Views/CheckSelfOrderWindowNew.xaml new file mode 100644 index 0000000..6113e62 --- /dev/null +++ b/DM_Weight/Views/CheckSelfOrderWindowNew.xaml @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DM_Weight/Views/CheckSelfOrderWindowNew.xaml.cs b/DM_Weight/Views/CheckSelfOrderWindowNew.xaml.cs new file mode 100644 index 0000000..c0bf865 --- /dev/null +++ b/DM_Weight/Views/CheckSelfOrderWindowNew.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace DM_Weight.Views +{ + /// + /// CheckSelfOrderWindow.xaml 的交互逻辑 + /// + public partial class CheckSelfOrderWindowNew : UserControl + { + public CheckSelfOrderWindowNew() + { + InitializeComponent(); + } + } +}