From 85821c040f495240c36d488789397d78490862da Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Thu, 19 Sep 2024 10:28:38 +0800 Subject: [PATCH] =?UTF-8?q?channel=5Flist=E6=B7=BB=E5=8A=A0=E8=8D=AF?= =?UTF-8?q?=E7=AE=B1=E7=8A=B6=E6=80=81=E6=A0=87=E8=AF=86=EF=BC=8C=E8=8D=AF?= =?UTF-8?q?=E7=AE=B1=E5=9C=A8=E4=B8=8D=E5=9C=A8=20machine=5Frecord?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=93=8D=E4=BD=9C=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E5=8F=96=E8=8D=AF=E7=AE=B1=E3=80=81=E8=BF=98=E8=8D=AF=E7=AE=B1?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E5=BC=80=E8=8D=AF=E7=AE=B1=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E6=98=BE=E7=A4=BA=E5=85=A8=E9=83=A8=E8=8D=AF?= =?UTF-8?q?=E7=AE=B1=EF=BC=8C=E6=A0=B9=E6=8D=AE=E5=BD=93=E5=89=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E4=BA=BA=E6=9D=83=E9=99=90=E6=98=BE=E7=A4=BA=E8=8D=AF?= =?UTF-8?q?=E7=AE=B1=E5=8F=B7=E6=8C=89=E9=92=AE=E6=98=AF=E5=90=A6=E5=8F=AF?= =?UTF-8?q?=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/App.xaml.cs | 1 + DM_Weight/Models/ChannelList.cs | 6 + DM_Weight/Models/MachineRecord.cs | 5 + DM_Weight/ReportTemp/use_jiaojie.grf | 558 ++++++++++++++++++ .../CheckOrderNewWindowViewModel.cs | 86 +-- .../ViewModels/OpenBoxNewWindowViewModel.cs | 554 +++++++++++++++++ .../ViewModels/OpenBoxWindowViewModel.cs | 33 +- .../ViewModels/RoleManagerWindowViewModel.cs | 9 +- DM_Weight/Views/OpenBoxNewWindow.xaml | 97 +++ DM_Weight/Views/OpenBoxNewWindow.xaml.cs | 28 + DM_Weight/Views/OpenBoxWindow.xaml | 6 +- 11 files changed, 1337 insertions(+), 46 deletions(-) create mode 100644 DM_Weight/ReportTemp/use_jiaojie.grf create mode 100644 DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs create mode 100644 DM_Weight/Views/OpenBoxNewWindow.xaml create mode 100644 DM_Weight/Views/OpenBoxNewWindow.xaml.cs diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs index 2ca71d2..66800c5 100644 --- a/DM_Weight/App.xaml.cs +++ b/DM_Weight/App.xaml.cs @@ -164,6 +164,7 @@ namespace DM_Weight //containerRegistry.RegisterForNavigation(); //开药箱 containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); //核对处方 containerRegistry.RegisterForNavigation(); //管理员根据药箱进行核对处方 diff --git a/DM_Weight/Models/ChannelList.cs b/DM_Weight/Models/ChannelList.cs index be4fd1b..e0ad1a7 100644 --- a/DM_Weight/Models/ChannelList.cs +++ b/DM_Weight/Models/ChannelList.cs @@ -80,6 +80,12 @@ namespace DM_Weight.Models public int DrawerType { get; set; } /// /// + /// 药箱状态 1药箱在,0药箱不在;(药箱在时开药箱为:取药箱,药箱不在时开药箱为:还药箱) + /// + [SugarColumn(ColumnName = "drawer_state")] + public int DrawerState { get; set; } + /// + /// /// 默认值: 1 /// [SugarColumn(IsIgnore =true)] diff --git a/DM_Weight/Models/MachineRecord.cs b/DM_Weight/Models/MachineRecord.cs index 9b3cbfd..c84bb7f 100644 --- a/DM_Weight/Models/MachineRecord.cs +++ b/DM_Weight/Models/MachineRecord.cs @@ -78,6 +78,11 @@ namespace DM_Weight.Models [SugarColumn(ColumnName = "type")] public int Type { get; set; } /// + ///操作类型(1放入药箱;0取走药箱) + /// + [SugarColumn(ColumnName = "option_type")] + public int OptionType { get; set; } + /// /// 出入库调拨单id /// [SugarColumn(ColumnName = "invoice_id")] diff --git a/DM_Weight/ReportTemp/use_jiaojie.grf b/DM_Weight/ReportTemp/use_jiaojie.grf new file mode 100644 index 0000000..e26b821 --- /dev/null +++ b/DM_Weight/ReportTemp/use_jiaojie.grf @@ -0,0 +1,558 @@ +{ + "Version":"6.8.1.1", + "Font":{ + "Name":"宋体", + "Size":105000, + "Weight":400, + "Charset":134 + }, + "Printer":{ + "Oriention":"Landscape", + "LeftMargin":1, + "TopMargin":1.42875, + "RightMargin":1, + "BottomMargin":1.8 + }, + "DetailGrid":{ + "CenterView":true, + "IsCrossTab":true, + "FixCols":2, + "AppendBlankRow":true, + "Recordset":{ + "Field":[ + { + "Name":"DMYear" + }, + { + "Name":"DMMonth" + }, + { + "Name":"DMDay" + }, + { + "Name":"TotalBaseNum" + }, + { + "Name":"OperationTime" + }, + { + "Name":"SendUser" + }, + { + "Name":"ReceiveUser" + }, + { + "Name":"SendNum" + }, + { + "Name":"InfactNum" + }, + { + "Name":"EmptyNum" + }, + { + "Name":"ReturnTime" + }, + { + "Name":"ReturnUser" + }, + { + "Name":"ReturnReceiveUser" + }, + { + "Name":"AddUser" + }, + { + "Name":"AddCheckUser" + }, + { + "Name":"drugId" + }, + { + "Name":"drugName" + }, + { + "Name":"drugSpec" + } + ] + }, + "Column":[ + { + "Name":"Column4" + }, + { + "Name":"Column6" + }, + { + "Name":"Column31" + }, + { + "Name":"Column14" + }, + { + "Name":"Column19" + }, + { + "Name":"Column20" + }, + { + "Name":"Column22" + }, + { + "Name":"Column23" + }, + { + "Name":"Column24" + } + ], + "ColumnContent":{ + "Height":2.19604, + "ColumnContentCell":[ + { + "Column":"Column4", + "TextAlign":"MiddleCenter", + "DataField":"OperationTime" + }, + { + "Column":"Column6", + "TextAlign":"MiddleCenter", + "DataField":"SendUser" + }, + { + "Column":"Column31", + "TextAlign":"MiddleCenter", + "DataField":"ReceiveUser" + }, + { + "Column":"Column14", + "TextAlign":"MiddleCenter", + "DataField":"SendNum" + }, + { + "Column":"Column19", + "TextAlign":"MiddleCenter", + "DataField":"InfactNum" + }, + { + "Column":"Column20", + "TextAlign":"MiddleCenter", + "DataField":"EmptyNum" + }, + { + "Column":"Column22", + "TextAlign":"MiddleCenter", + "DataField":"ReturnTime" + }, + { + "Column":"Column23", + "TextAlign":"MiddleCenter", + "DataField":"ReturnUser" + }, + { + "Column":"Column24", + "DataField":"ReturnReceiveUser" + } + ] + }, + "ColumnTitle":{ + "Height":3.96875, + "RepeatStyle":"OnGroupHeaderPage", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column3", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column12", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column25", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column26", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"Column4", + "TextAlign":"BottomCenter", + "Text":"发药时间" + }, + { + "GroupTitle":false, + "Column":"Column6", + "TextAlign":"BottomCenter", + "Text":"发药者" + } + ], + "TextAlign":"MiddleRight", + "Text":"交接状态", + "BorderCustom":true, + "Border":{ + "Styles":"[DrawBottom]" + } + } + ] + } + ], + "TextAlign":"MiddleCenter", + "Text":"药品信息", + "BorderCustom":true, + "Border":{ + "Styles":"[DrawRight]" + } + } + ], + "BorderCustom":true, + "Border":{ + "Styles":"[DrawRight]" + } + }, + { + "GroupTitle":true, + "Name":"Column27", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column28", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column29", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column30", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"Column31", + "TextAlign":"BottomCenter", + "Text":"领药者" + } + ] + } + ], + "TextAlign":"MiddleCenter", + "Text":"总基数" + } + ], + "TextAlign":"MiddleCenter", + "Text":"规格" + } + ], + "TextAlign":"MiddleCenter", + "Text":"品名" + }, + { + "GroupTitle":true, + "Name":"Column32", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column33", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column34", + "ColumnTitleCell":[ + { + "GroupTitle":true, + "Name":"Column35", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"Column14", + "TextAlign":"BottomCenter", + "Text":"实发数" + }, + { + "GroupTitle":false, + "Column":"Column19", + "TextAlign":"BottomCenter", + "Text":"实物数" + }, + { + "GroupTitle":false, + "Column":"Column20", + "TextAlign":"BottomCenter", + "Text":"空安瓿" + } + ], + "FreeCell":true, + "Control":[ + { + "Type":"StaticBox", + "Name":"StaticBox1", + "Width":2.98979, + "Height":1.00542, + "Border":{ + "Styles":"[DrawRight]" + }, + "TextAlign":"MiddleCenter", + "Text":"发药" + }, + { + "Type":"StaticBox", + "Name":"StaticBox2", + "Left":2.98979, + "Width":6.00604, + "Height":1.00542, + "TextAlign":"MiddleCenter", + "Text":"还药" + } + ] + } + ], + "Text":"[#TotalNum#]" + } + ], + "Text":"[#drugSpec#]" + } + ], + "Text":"[drugName]" + }, + { + "GroupTitle":false, + "Column":"Column22", + "TextAlign":"BottomCenter", + "Text":"还药时间" + }, + { + "GroupTitle":false, + "Column":"Column23", + "TextAlign":"BottomCenter", + "Text":"还药者" + }, + { + "GroupTitle":false, + "Column":"Column24", + "TextAlign":"BottomCenter", + "Text":"接收者" + } + ] + }, + "Group":[ + { + "Name":"Group1", + "ByFields":"drugId", + "GroupHeader":{ + }, + "GroupFooter":{ + "Height":2.40771, + "Control":[ + { + "Type":"StaticBox", + "Name":"StaticBox4", + "AlignColumn":"Column31", + "AlignColumnEx":"Column4", + "Width":8.96938, + "Height":2, + "Border":{ + "Styles":"[DrawRight]" + }, + "TextAlign":"MiddleCenter", + "Text":"日消耗总计(支)" + }, + { + "Type":"StaticBox", + "Name":"StaticBox5", + "AlignColumn":"Column14", + "Left":8.96938, + "Width":2.98979, + "Height":1, + "Border":{ + "Styles":"[DrawRight|DrawBottom]" + }, + "TextAlign":"BottomCenter", + "Text":"安瓿" + }, + { + "Type":"StaticBox", + "Name":"StaticBox6", + "AlignColumn":"Column19", + "Left":11.9592, + "Width":2.99, + "Height":1, + "Border":{ + "Styles":"[DrawRight|DrawBottom]" + }, + "TextAlign":"BottomCenter", + "Text":"处方" + }, + { + "Type":"StaticBox", + "Name":"StaticBox7", + "AlignColumn":"Column20", + "Left":14.949, + "Width":2.99, + "Height":1, + "Border":{ + "Styles":"[DrawRight|DrawBottom]" + }, + "TextAlign":"BottomCenter", + "Text":"补充" + }, + { + "Type":"MemoBox", + "Name":"MemoBox2", + "AlignColumn":"Column14", + "Left":8.96938, + "Top":1.00542, + "Width":2.9898, + "Height":1, + "Border":{ + "Styles":"[DrawRight]" + }, + "TextAlign":"MiddleCenter", + "Text":"[#Sum(EmptyNum)#]" + }, + { + "Type":"MemoBox", + "Name":"MemoBox3", + "AlignColumn":"Column19", + "Left":11.9592, + "Top":1.0054, + "Width":2.98979, + "Height":1, + "Border":{ + "Styles":"[DrawRight]" + }, + "TextAlign":"MiddleCenter", + "Text":"[#Sum(SendNum-InfactNum)#]" + }, + { + "Type":"MemoBox", + "Name":"MemoBox4", + "AlignColumn":"Column20", + "Left":14.949, + "Top":1.0054, + "Width":2.98979, + "Height":1, + "Border":{ + "Styles":"[DrawRight]" + }, + "TextAlign":"MiddleCenter", + "Text":"[#Sum(SendNum-InfactNum)#]" + }, + { + "Type":"StaticBox", + "Name":"StaticBox8", + "AlignColumn":"Column22", + "AlignColumnEx":"Column23", + "Left":17.9388, + "Width":5.97958, + "Height":1, + "Border":{ + "Styles":"[DrawRight|DrawBottom]" + }, + "TextAlign":"BottomCenter", + "Text":"补充者" + }, + { + "Type":"StaticBox", + "Name":"StaticBox9", + "AlignColumn":"Column24", + "Left":23.9183, + "Width":2.98979, + "Height":1, + "Border":{ + "Styles":"[DrawRight|DrawBottom]" + }, + "TextAlign":"BottomCenter", + "Text":"核对者" + }, + { + "Type":"MemoBox", + "Name":"MemoBox5", + "AlignColumn":"Column22", + "AlignColumnEx":"Column23", + "Left":17.9388, + "Top":1.0054, + "Width":5.97958, + "Height":1.00542, + "Border":{ + "Styles":"[DrawRight]" + }, + "TextAlign":"MiddleCenter", + "Text":"[#AddUser#]" + }, + { + "Type":"MemoBox", + "Name":"MemoBox6", + "AlignColumn":"Column24", + "Left":23.9183, + "Top":1.00542, + "Width":2.96333, + "Height":1.00542, + "Border":{ + "Styles":"[DrawRight]" + }, + "TextAlign":"MiddleCenter", + "Text":"[#AddCheckUser#]" + } + ] + } + } + ], + "CrossTab":{ + "PercentFormat":"0.##%", + "HCrossFields":"drugId", + "VCrossFields":"OperationTime", + "ListCols":3, + "TotalCols":3 + } + }, + "Parameter":[ + { + "Name":"machine_id" + }, + { + "Name":"startDate", + "DataType":"DateTime" + }, + { + "Name":"endDate", + "DataType":"DateTime" + } + ], + "ReportHeader":[ + { + "Name":"ReportHeader1", + "Height":1.79917, + "Control":[ + { + "Type":"MemoBox", + "Name":"MemoBox1", + "Dock":"Fill", + "Center":"Both", + "Font":{ + "Name":"宋体", + "Size":262500, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"麻醉科小药箱麻醉、精神药品(注射剂)使用与交接记录([#Year#])年" + } + ], + "RepeatOnPage":true + }, + { + "Name":"ReportHeader2", + "Height":0.608542, + "Control":[ + { + "Type":"StaticBox", + "Name":"StaticBox3", + "Left":24.7915, + "Width":4.81542, + "Height":0.608542, + "Text":"[#DMYear#]年[#DMMonth#]月" + } + ] + } + ] +} \ No newline at end of file diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs index 857ca6a..735da52 100644 --- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs @@ -110,7 +110,7 @@ namespace DM_Weight.ViewModels set => SetProperty(ref _ordersList, value); } - private List? _totalDrugList=new List(); + private List? _totalDrugList = new List(); public List? TotalDrugList { get => _totalDrugList; @@ -124,110 +124,110 @@ namespace DM_Weight.ViewModels private Brush _button1Color = Brushes.White; public Brush Button1Color { - get => _button1Color; - set =>SetProperty(ref _button1Color, value); + get => _button1Color; + set => SetProperty(ref _button1Color, value); } private Brush _button2Color = Brushes.White; public Brush Button2Color { - get => _button2Color; - set =>SetProperty(ref _button2Color, value); + get => _button2Color; + set => SetProperty(ref _button2Color, value); } private Brush _button3Color = Brushes.White; public Brush Button3Color { - get => _button3Color; - set =>SetProperty(ref _button3Color, value); + get => _button3Color; + set => SetProperty(ref _button3Color, value); } private Brush _button4Color = Brushes.White; public Brush Button4Color { - get => _button4Color; - set =>SetProperty(ref _button4Color, value); + get => _button4Color; + set => SetProperty(ref _button4Color, value); } private Brush _button5Color = Brushes.White; public Brush Button5Color { - get => _button5Color; - set =>SetProperty(ref _button5Color, value); + get => _button5Color; + set => SetProperty(ref _button5Color, value); } private Brush _button6Color = Brushes.White; public Brush Button6Color { - get => _button6Color; - set =>SetProperty(ref _button6Color, value); + get => _button6Color; + set => SetProperty(ref _button6Color, value); } private Brush _button7Color = Brushes.White; public Brush Button7Color { - get => _button7Color; - set =>SetProperty(ref _button7Color, value); + get => _button7Color; + set => SetProperty(ref _button7Color, value); } private Brush _button8Color = Brushes.White; public Brush Button8Color { - get => _button8Color; - set =>SetProperty(ref _button8Color, value); + get => _button8Color; + set => SetProperty(ref _button8Color, value); } private Brush _button9Color = Brushes.White; public Brush Button9Color { - get => _button9Color; - set =>SetProperty(ref _button9Color, value); + get => _button9Color; + set => SetProperty(ref _button9Color, value); } private Brush _button10Color = Brushes.White; public Brush Button10Color { - get => _button10Color; - set =>SetProperty(ref _button10Color, value); + get => _button10Color; + set => SetProperty(ref _button10Color, value); } private Brush _button11Color = Brushes.White; public Brush Button11Color { - get => _button11Color; - set =>SetProperty(ref _button11Color, value); + get => _button11Color; + set => SetProperty(ref _button11Color, value); } private Brush _button12Color = Brushes.White; public Brush Button12Color { - get => _button12Color; - set =>SetProperty(ref _button12Color, value); + get => _button12Color; + set => SetProperty(ref _button12Color, value); } private Brush _button13Color = Brushes.White; public Brush Button13Color { - get => _button13Color; - set =>SetProperty(ref _button13Color, value); + get => _button13Color; + set => SetProperty(ref _button13Color, value); } private Brush _button14Color = Brushes.White; public Brush Button14Color { - get => _button14Color; - set =>SetProperty(ref _button14Color, value); + get => _button14Color; + set => SetProperty(ref _button14Color, value); } private Brush _button15Color = Brushes.White; public Brush Button15Color { - get => _button15Color; - set =>SetProperty(ref _button15Color, value); + get => _button15Color; + set => SetProperty(ref _button15Color, value); } private Brush _button16Color = Brushes.White; public Brush Button16Color { - get => _button16Color; - set =>SetProperty(ref _button16Color, value); + get => _button16Color; + set => SetProperty(ref _button16Color, value); } private Brush _button17Color = Brushes.White; public Brush Button17Color { - get => _button17Color; - set =>SetProperty(ref _button17Color, value); + get => _button17Color; + set => SetProperty(ref _button17Color, value); } private Brush _button18Color = Brushes.White; public Brush Button18Color { - get => _button18Color; - set =>SetProperty(ref _button18Color, value); + get => _button18Color; + set => SetProperty(ref _button18Color, value); } IEventAggregator _eventAggregator; @@ -278,7 +278,7 @@ namespace DM_Weight.ViewModels { OrderInfoList.ForEach(oi => oi.ItemIsChecked = true); //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).SelectMany(OrderDetailList => OrderDetailList.OrderDetailList).GroupBy(item=>item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); + TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).SelectMany(OrderDetailList => OrderDetailList.OrderDetailList).GroupBy(item => item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); } else @@ -288,7 +288,7 @@ namespace DM_Weight.ViewModels TotalCount = totalCount; PageCount = (int)Math.Ceiling((double)TotalCount / PageSize); - if(currentList.EffDate== DateTime.Now.ToString("yyyy-MM-dd")) + if (Convert.ToDateTime(currentList.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { switch (DrawerNo) { @@ -357,7 +357,7 @@ namespace DM_Weight.ViewModels for (int i = 0; i < chlList.Count; i++) { ChannelList chl = chlList[i]; - if (chl.EffDate == DateTime.Now.ToString("yyyy-MM-dd")) + if (Convert.ToDateTime(chl.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { switch (chl.DrawerNo) { @@ -528,6 +528,12 @@ namespace DM_Weight.ViewModels InvoiceId = oi.OrderNo //, StockQuantity = nowChannels.Sum(it => it.Quantity) }).ExecuteCommand(); + + #region 记录 注射剂使用与交接记录报表 + //1查询取走药箱时间 + DateTime? strEffDate= SqlSugarHelper.Db.Queryable().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 55 && mr.OptionType == 0).Select(mr => mr.EffDate).First(); + #endregion + } //保存账册 int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() diff --git a/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs b/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs new file mode 100644 index 0000000..f985980 --- /dev/null +++ b/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs @@ -0,0 +1,554 @@ +using DM_Weight.Models; +using DM_Weight.Port; +using DM_Weight.util; +using log4net; +using log4net.Repository.Hierarchy; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; +using System; +using System.Collections.Generic; +using System.Drawing.Printing; +using System.Linq; +using System.Security.Cryptography.Pkcs; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace DM_Weight.ViewModels +{ + public class OpenBoxNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime + { + private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel)); + private int _drawerType = -1; + + public int DrawerType + { + get => _drawerType; + set => SetProperty(ref _drawerType, value); + } + //所选药箱号 + private int _drawerNo = -1; + + public int DrawerNo + { + get => _drawerNo; + set => SetProperty(ref _drawerNo, value); + } + //开名下药箱按钮的显示状态 + private bool _selfEnable = false; + public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); } + + //名下药箱按钮显示内容 + private string _selfContent="打开药箱"; + public string SelfContent { get => _selfContent; set => SetProperty(ref _selfContent, 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 int _publicStatus = 0; + //public int PublicStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); } + //名下药箱状态 + private int _selfStatus = 0; + public int SelfStatus { get => _selfStatus; set => SetProperty(ref _selfStatus, value); } + //抽屉号列表 + public static List iList = new List(); + //第几个抽屉号 + //public static int iNumber = 1; + private PortUtil _portUtil; + IEventAggregator _eventAggregator; + public OpenBoxNewWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator) + { + _portUtil = portUtil; + _eventAggregator = eventAggregator; + } + #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 + public bool KeepAlive => false; + //设置按钮颜色 + 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: + Button9Color = Brushes.Yellow; + break; + case 11: + Button9Color = 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) + { + switch (drawerNo) + { + case 1: + Button1Enable = true; + break; + case 2: + Button2Enable = true; + break; + case 3: + Button3Enable = true; + break; + case 4: + Button4Enable = true; + break; + case 5: + Button5Enable = true; + break; + case 6: + Button6Enable = true; + break; + case 7: + Button7Enable = true; + break; + case 8: + Button8Enable = true; + break; + case 9: + Button9Enable = true; + break; + case 10: + Button10Enable = true; + break; + case 11: + Button11Enable = true; + break; + case 12: + Button12Enable = true; + break; + case 13: + Button13Enable = true; + break; + case 14: + Button14Enable = true; + break; + case 15: + Button15Enable = true; + break; + case 16: + Button16Enable = true; + break; + case 17: + Button17Enable = true; + break; + case 18: + Button18Enable = true; + break; + default: + break; + } + } + + void RequestData() + { + 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 (Convert.ToDateTime(chl.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) + { + SetBtnColor(chl.DrawerNo); + } + //DrawerType== 1为公共药箱 + if (chl.DrawerType == 1) + { + SetBtnEnable(chl.DrawerNo); + } + if (chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode) + { + SetBtnEnable(chl.DrawerNo); + } + } + } + } + /// + /// 选择药箱,打开药箱 + /// + public DelegateCommand UpdateDrawerNo + { + get => new DelegateCommand(OpenBoxAction); + } + public async void OpenBoxAction(string strDrawerNo) + { + 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(); + 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() + { + 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]}号药箱", + 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); + Thread.Sleep(1000); + } + + SelfStatus = 0; + PublicEnable = true; + SelfEnable = true; + DrawerType = -1; + } + } + public void OnNavigatedTo(NavigationContext navigationContext) + { + RequestData(); + } + + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + } + } +} diff --git a/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs b/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs index 67b4abc..98e96f2 100644 --- a/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs +++ b/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs @@ -37,10 +37,21 @@ namespace DM_Weight.ViewModels private bool _selfEnable = true; public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); } + //名下药箱按钮显示内容 + private string _selfContent; + public string SelfContent { get => _selfContent; set => SetProperty(ref _selfContent, 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 int _publicStatus = 0; public int PublicStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); } @@ -94,7 +105,7 @@ namespace DM_Weight.ViewModels for (int i = 0; i < iList.Count; i++) { - ChannelList channelList= iList[i]; + ChannelList channelList = iList[i]; //记录开药箱日志 SqlSugarHelper.Db.Insertable(new MachineRecord() { @@ -107,7 +118,8 @@ namespace DM_Weight.ViewModels }).ExecuteCommand(); //记录药箱打开时间 channelList.EffDate = DateTime.Now.ToString("yyyy-MM-dd"); - SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it=>new { it.EffDate }).ExecuteCommand(); + channelList.DrawerState = 0; + SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate, it.DrawerState }).ExecuteCommand(); _portUtil.SpeakAsync($"正在打开{channelList.DrawerNo}号药箱"); logger.Info($"正在打开{channelList.DrawerNo}号药箱"); @@ -225,11 +237,28 @@ namespace DM_Weight.ViewModels { // 取消消息订阅 //_eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent); + CheckDrawerState(); } public void OnNavigatedTo(NavigationContext navigationContext) { //_eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); } + //查询名下药箱与公共药箱状态 + private void CheckDrawerState() + { + PublicContent = "开公共药箱"; + int listSelfState = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5") + .Where(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First(); + if (listSelfState > 0) + { + SelfContent = "还名下药箱"; + } + else + { + SelfContent = "取名下药箱"; + } + + } } } diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs index fb593eb..dabcf36 100644 --- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs @@ -181,12 +181,19 @@ namespace DM_Weight.ViewModels // PremissionPath = "OrderTakeDrugNewWindow", //}; + //开药箱 + //PremissionDm openBox = new PremissionDm + //{ + // Id = 11, + // PremissionName = "开药箱", + // PremissionPath = "OpenBoxWindow", + //}; //开药箱 PremissionDm openBox = new PremissionDm { Id = 11, PremissionName = "开药箱", - PremissionPath = "OpenBoxWindow", + PremissionPath = "OpenBoxNewWindow", }; //核对处方 PremissionDm checkOrder = new PremissionDm diff --git a/DM_Weight/Views/OpenBoxNewWindow.xaml b/DM_Weight/Views/OpenBoxNewWindow.xaml new file mode 100644 index 0000000..239a837 --- /dev/null +++ b/DM_Weight/Views/OpenBoxNewWindow.xaml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +