From 659e35c35eb285f030c2c86bfb313b510e03d76b Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Fri, 23 Aug 2024 15:55:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=B1=89=E5=8A=A0=E8=8D=AF=E3=80=81?= =?UTF-8?q?=E6=8A=BD=E5=B1=89=E5=8F=96=E8=8D=AF=E9=A1=B5=E9=9D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BC=80=E8=8D=AF=E7=9B=92=E6=8C=89=E9=92=AE=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=89=E8=89=B2=E7=81=AF=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=86=99=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Port/PortUtil.cs | 8 ++++-- .../ViewModels/ApplyInStockWindowViewModel.cs | 6 ++-- .../BindingChannelDialogViewModel.cs | 10 +++---- .../ViewModels/CheckStockWindowViewModel.cs | 10 ++----- .../DrawerAddDrugWindowViewModel.cs | 28 ++++++++++++++++++- .../DrawerTakeDrugWindowViewModel.cs | 28 +++++++++++++++++-- .../ViewModels/InvoiceAddDialogViewModel.cs | 3 +- .../ViewModels/InvoiceTakeDialogViewModel.cs | 3 +- .../ViewModels/OrderReturnDialogViewModel.cs | 3 +- .../ViewModels/OrderTakeDialogViewModel.cs | 3 +- .../ViewModels/ReturnDrugDialogViewModel.cs | 1 + .../ViewModels/SelfAddDialogViewModel.cs | 4 ++- .../ViewModels/SelfTakeDialogViewModel.cs | 3 +- DM_Weight/Views/DrawerAddDrugWindow.xaml | 12 ++++++-- DM_Weight/Views/DrawerTakeDrugWindow.xaml | 8 ++++++ 15 files changed, 101 insertions(+), 29 deletions(-) diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index f73b344..8bdc39a 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -1019,10 +1019,14 @@ namespace DM_Weight.Port #region 2.4寸汉显屏 // 基础数据写入方法 - public async void WriteChannelInfo(int type, string content, int drawerNo, int colNo) + public async Task WriteChannelInfo(int type, string content, int drawerNo, int colNo) { try { + if (content.Length > 10) + { + content = content.Substring(0, 10); + } canBusSerial.DiscardInBuffer(); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content)); @@ -1117,7 +1121,7 @@ namespace DM_Weight.Port } } // 写入数量 - public void WriteQuantity(int drawerNo, int colNo, int quantity) + public async Task WriteQuantity(int drawerNo, int colNo, int quantity) { try { diff --git a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs index 11f7c67..32a3189 100644 --- a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs +++ b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs @@ -761,11 +761,11 @@ namespace DM_Weight.ViewModels int totalQuantity = channelStockEffDate.Sum(it => it.Quantity); //将库位多批次的总库存数更新标签 - _portUtil.WriteQuantity(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo, totalQuantity); + await _portUtil.WriteQuantity(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo, totalQuantity); Thread.Sleep(200); - _portUtil.WriteChannelInfo(6, channelStockEffDate[0].EffDate == null ? "" : channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); + await _portUtil.WriteChannelInfo(6, channelStockEffDate[0].EffDate == null ? "" : channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); Thread.Sleep(200); - _portUtil.WriteChannelInfo(5, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); + await _portUtil.WriteChannelInfo(5, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); Thread.Sleep(200); _portUtil.ShowContent(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); //} diff --git a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs index 7fef8ee..5156593 100644 --- a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs @@ -309,15 +309,15 @@ namespace DM_Weight.ViewModels { _portUtil.WindowName = "BindingChannelDialog"; // 向显示屏写入库位信息 - _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo); + await _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo); await Task.Delay(200); - _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo); + await _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo); await Task.Delay(200); - _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo); + await _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo); await Task.Delay(200); - _portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo); + await _portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo); await Task.Delay(200); - _portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo); + await _portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo); await Task.Delay(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } diff --git a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs index 63bd5bd..c231b6d 100644 --- a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs @@ -201,19 +201,13 @@ namespace DM_Weight.ViewModels List singleChannels = record.FindAll(it => it.BoardType != 1); if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) { - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity); }); } if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) - { - singleChannels.ForEach(it => - { - _portUtil.WriteChannelInfoMethod(2, (it.Quantity - it.TakeQuantity).ToString(), it.DrawerNo, it.ColNo); - }); - } - if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) { for (int i = 0; i < singleChannels.Count; i++) { diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs index 0273ead..8e00c99 100644 --- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs @@ -39,10 +39,13 @@ namespace DM_Weight.ViewModels private PortUtil _portUtil; IEventAggregator _eventAggregator; + //开药盒 + public DelegateCommand OpenBoxCommand { get; private set; } public DrawerAddDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator) { _portUtil = portUtil; _eventAggregator = eventAggregator; + OpenBoxCommand = new DelegateCommand(param => OpenBoxAction(param)); } void DoMyPrismEvent(DeviceMsg msg) @@ -148,6 +151,27 @@ namespace DM_Weight.ViewModels }, () => Status == 0).ObservesProperty(() => Status); } + private void OpenBoxAction(object parameter) + { + ChannelStock cs = parameter as ChannelStock; + if(cs.BoardType==35) + { + _portUtil.BoardType = cs.BoardType; + _portUtil.DrawerNo = cs.DrawerNo; + _portUtil.ColNos = new int[] { cs.ColNo}; + _portUtil.OpenBox(); + } + else + { + + AlertMsg alertMsg = new AlertMsg + { + Message = "非药盒库位,无需开药盒", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + } private bool _isFinishClick = false; @@ -311,8 +335,10 @@ namespace DM_Weight.ViewModels //将库位多批次的总库存数更新标签 //_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity)); - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); }); } diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs index a85cb36..8409556 100644 --- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs @@ -44,11 +44,13 @@ namespace DM_Weight.ViewModels private PortUtil _portUtil; IEventAggregator _eventAggregator; - + //开药盒 + public DelegateCommand OpenBoxCommand { get; private set; } public DrawerTakeDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator) { _portUtil = portUtil; _eventAggregator = eventAggregator; + OpenBoxCommand = new DelegateCommand(param => OpenBoxAction(param)); } void DoMyPrismEvent(DeviceMsg msg) @@ -151,6 +153,27 @@ namespace DM_Weight.ViewModels }); } + private void OpenBoxAction(object parameter) + { + ChannelStock cs = parameter as ChannelStock; + if (cs.BoardType == 35) + { + _portUtil.BoardType = cs.BoardType; + _portUtil.DrawerNo = cs.DrawerNo; + _portUtil.ColNos = new int[] { cs.ColNo }; + _portUtil.OpenBox(); + } + else + { + + AlertMsg alertMsg = new AlertMsg + { + Message = "非药盒库位,无需开药盒", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + } + } private bool _isFinishClick = false; @@ -316,8 +339,9 @@ namespace DM_Weight.ViewModels //将库位多批次的总库存数更新标签 //_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity)); - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); }); } diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs index a629242..328017b 100644 --- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs @@ -373,8 +373,9 @@ namespace DM_Weight.ViewModels List singleChannels = record.FindAll(it => it.BoardType != 1); if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) { - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); }); } diff --git a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs index b179401..d24ff07 100644 --- a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs @@ -437,8 +437,9 @@ namespace DM_Weight.ViewModels List singleChannels = record.FindAll(it => it.BoardType != 1); if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) { - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); }); } diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs index 2f6b6bc..03b8acc 100644 --- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs @@ -431,8 +431,9 @@ namespace DM_Weight.ViewModels List singleChannels = record.FindAll(it => it.BoardType != 1); if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) { - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity); }); } diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs index 742d7b8..53f23c2 100644 --- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs @@ -455,8 +455,9 @@ namespace DM_Weight.ViewModels List singleChannels = record.FindAll(it => it.BoardType == 5); if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) { - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); }); } diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs index d82c41e..4ddea6c 100644 --- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs +++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs @@ -362,6 +362,7 @@ namespace DM_Weight.ViewModels // 更新屏显库存 if (ChannelStock.BoardType == 5) { + await Task.Delay(200); _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity); } if(ChannelStock.BoardType==35) diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs index db5309b..53b7f78 100644 --- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs @@ -365,8 +365,10 @@ namespace DM_Weight.ViewModels List singleChannels = record.FindAll(it => it.BoardType != 1); if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) { - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); }); } diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs index d769f64..3e474a5 100644 --- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs @@ -339,8 +339,9 @@ namespace DM_Weight.ViewModels List singleChannels = record.FindAll(it => it.BoardType != 1); if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) { - singleChannels.ForEach(it => + singleChannels.ForEach(async it => { + await Task.Delay(200); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); }); } diff --git a/DM_Weight/Views/DrawerAddDrugWindow.xaml b/DM_Weight/Views/DrawerAddDrugWindow.xaml index 410fee2..b92d110 100644 --- a/DM_Weight/Views/DrawerAddDrugWindow.xaml +++ b/DM_Weight/Views/DrawerAddDrugWindow.xaml @@ -13,7 +13,7 @@ - + @@ -294,7 +294,15 @@ - + + + + +