From d58b9967a9155f696fe3fdd0ff0d96a2888c4bae Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Tue, 27 May 2025 14:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=99=E6=A0=87=E7=AD=BE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=86=99=E6=89=B9=E6=AC=A1=E6=95=88=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Port/PortUtil.cs | 1 + .../BindingChannelNewDialogViewModel .cs | 6 + .../CheckStockNewWindowViewModel.cs | 11 +- .../ViewModels/InvoiceInNewWindowViewModel.cs | 2 +- DM_Weight/ViewModels/LoginWindowViewModel.cs | 104 +++++++++++------- .../MultiOrderTakeDialogViewModel.cs | 34 +++++- .../ViewModels/OrderReturnDialogViewModel.cs | 34 ++++-- .../ViewModels/OrderTakeDialogViewModel.cs | 33 ++++-- .../ViewModels/SelfTakeDialogViewModel.cs | 27 +++-- 9 files changed, 179 insertions(+), 73 deletions(-) diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index 046c7ec..6ef87b5 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -1036,6 +1036,7 @@ namespace DM_Weight.Port #region 2.4寸汉显屏 // 基础数据写入方法 + //三色灯写标签type:1药品名称;2规格;5批次;6效期;8厂家 public void WriteChannelInfo(int type, string content, int drawerNo, int colNo) { try diff --git a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs index 8639367..62a36f5 100644 --- a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs +++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel .cs @@ -565,6 +565,8 @@ namespace DM_Weight.ViewModels } else { + //查询绑定库位的最近效期绑定到标签 + ChannelStock cs = SqlSugarHelper.Db.Queryable().Where(cs => cs.DrawerNo == item.DrawerNo && cs.ColNo == item.ColNo&&cs.Quantity>0).OrderBy(cs => cs.EffDate).First(); DrugInfo drugSelected = item.Drug ?? new DrugInfo(); _portUtil.WindowName = "BindingChannelDialog"; // 向显示屏写入库位信息 @@ -574,6 +576,10 @@ namespace DM_Weight.ViewModels Thread.Sleep(200); _portUtil.WriteChannelInfo(8, drugSelected.Manufactory == null ? "" : drugSelected.Manufactory.Length > 10 ? drugSelected.Manufactory.Substring(0, 10) : drugSelected.Manufactory, item.DrawerNo, item.ColNo); Thread.Sleep(200); + _portUtil.WriteChannelInfo(5, (cs==null||cs.EffDate == null) ? "" : cs.EffDate, item.DrawerNo, item.ColNo); + Thread.Sleep(200); + _portUtil.WriteChannelInfo(6, (cs == null || cs.ManuNo == null) ? "" : cs.ManuNo, item.DrawerNo, item.ColNo); + Thread.Sleep(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); Thread.Sleep(200); _portUtil.WriteQuantity(item.DrawerNo, item.ColNo, item.totalCount); diff --git a/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs index b812aa0..768b983 100644 --- a/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs @@ -531,7 +531,7 @@ namespace DM_Weight.ViewModels { // 更新屏显库存 //List singleChannels = record.FindAll(it => it.BoardType != 1); - List singleChannels = record.FindAll(it => it.BoardType == 5) + List singleChannels = record.FindAll(it => it.BoardType == 5&&it.CheckQuantity>0).OrderBy(it => it.EffDate) .GroupBy(it => new { it.DrawerNo, @@ -547,9 +547,16 @@ namespace DM_Weight.ViewModels { singleChannels.ForEach(it => { + //将库位多批次的总库存数更新标签 + _portUtil.WriteChannelInfo(6, it.EffDate == null ? "" : it.EffDate, it.DrawerNo, it.ColNo); + Thread.Sleep(200); + _portUtil.WriteChannelInfo(5, it.ManuNo, it.DrawerNo, it.ColNo); + Thread.Sleep(200); // 将库位多批次的总库存数更新标签 _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity); Thread.Sleep(200); + _portUtil.ShowContent(it.DrawerNo, it.ColNo); + Thread.Sleep(200); }); } @@ -722,7 +729,7 @@ namespace DM_Weight.ViewModels List q = SqlSugarHelper.Db.Queryable() .Includes(cs => cs.DrugInfo) .InnerJoin((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId) - .Where(cs => cs.DrawerType == 1) + .Where(cs => cs.DrawerType == 1&&cs.DrawerNo==11) .Where(cs => cs.DrugId != null) .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")) .WhereIF(App.SingleModel, cs => cs.DrawerNo <= 2) //单人登录开前8个抽屉,双人登录开后8个抽屉 diff --git a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs index ee97e3b..f1c6b81 100644 --- a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs @@ -646,7 +646,7 @@ namespace DM_Weight.ViewModels List channelStockEffDate = SqlSugarHelper.Db.Queryable() .Where(cs => cs.MachineId == singleChannels[i].MachineId) .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) - .Where(cs => cs.ColNo == singleChannels[i].ColNo) + .Where(cs => cs.ColNo == singleChannels[i].ColNo&&cs.Quantity>0) .OrderBy(cs => cs.EffDate).ToList(); int totalQuantity = channelStockEffDate.Sum(it => it.Quantity); diff --git a/DM_Weight/ViewModels/LoginWindowViewModel.cs b/DM_Weight/ViewModels/LoginWindowViewModel.cs index 5c2951e..a96f79c 100644 --- a/DM_Weight/ViewModels/LoginWindowViewModel.cs +++ b/DM_Weight/ViewModels/LoginWindowViewModel.cs @@ -160,23 +160,29 @@ _exitCommand ??= new DelegateCommand(Exit); if (userList == null) { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "无此用户", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "无此用户", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); Username = ""; Password = ""; } else if (userList.Role == null) { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "用户还未设置权限,请联系管理员", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "用户还未设置权限,请联系管理员", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); Username = ""; Password = ""; } @@ -189,12 +195,15 @@ _exitCommand ??= new DelegateCommand(Exit); } else { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "密码错误", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "密码错误", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); Password = ""; } } @@ -202,12 +211,15 @@ _exitCommand ??= new DelegateCommand(Exit); } else { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "请输入账号或密码", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "请输入账号或密码", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); } LoginBtnEnable = true; } @@ -253,12 +265,15 @@ _exitCommand ??= new DelegateCommand(Exit); } else { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "该发药人账号已登录,请输入不同账号", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "该发药人账号已登录,请输入不同账号", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); } } // 如果已经录入了审核人, 已经有一个用户登录 @@ -282,12 +297,15 @@ _exitCommand ??= new DelegateCommand(Exit); } else { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "该审核人账号已登录,请输入不同账号", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "该审核人账号已登录,请输入不同账号", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); } } // 第一个用户登录 @@ -350,23 +368,29 @@ _exitCommand ??= new DelegateCommand(Exit); logger.Info($"userList是空?{userList == null}"); if (userList == null) { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "无此用户", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "无此用户", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); Username = ""; Password = ""; } else if (userList.Role == null) { - AlertMsg alertMsg = new AlertMsg + System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { - Message = "用户还未设置权限,请联系管理员", - Type = MsgType.ERROR - }; - _eventAggregator.GetEvent().Publish(alertMsg); + AlertMsg alertMsg = new AlertMsg + { + Message = "用户还未设置权限,请联系管理员", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + })); Username = ""; Password = ""; } diff --git a/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs index fc95386..634175d 100644 --- a/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs @@ -526,14 +526,36 @@ namespace DM_Weight.ViewModels //}); // 更新屏显库存 - List singleChannels = record.FindAll(it => it.BoardType != 1); - if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) + List singleChannels = record.FindAll(it => it.BoardType == 5); + if (singleChannels.Count > 0) { - singleChannels.ForEach(it => + for (int i = 0; i < singleChannels.Count; i++) { - _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); - Thread.Sleep(200); - }); + + + List csList = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.MachineId == singleChannels[i].MachineId) + .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) + .Where(cs => cs.ColNo == singleChannels[i].ColNo && cs.Quantity > 0).OrderBy(cs => cs.EffDate).ToList(); + + if (csList != null && csList.Count > 0) + { + int totalQuantity = csList.Sum(c => c.Quantity); + _portUtil.WriteChannelInfo(5, csList[0].EffDate == null ? "" : csList[0].EffDate, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.WriteChannelInfo(6, csList[0].ManuNo == null ? "" : csList[0].ManuNo, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.ShowContent(csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.WriteQuantity(csList[0].DrawerNo, csList[0].ColNo, totalQuantity); + Thread.Sleep(200); + } + // singleChannels.ForEach(it => + //{ + // _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); + // Thread.Sleep(200); + //}); + } } AlertMsg alertMsg = new AlertMsg { diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs index d9c96df..c45f955 100644 --- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs @@ -433,14 +433,32 @@ namespace DM_Weight.ViewModels { if (singleChannels[i].BoardType == 5) { - int totalQuantity = SqlSugarHelper.Db.Queryable() - .Where(cs => cs.MachineId == singleChannels[i].MachineId) - .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) - .Where(cs => cs.ColNo == singleChannels[i].ColNo) - .Sum(it => it.Quantity); - //将库位多批次的总库存数更新标签 - _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity); - Thread.Sleep(200); + List csList = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.MachineId == singleChannels[i].MachineId) + .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) + .Where(cs => cs.ColNo == singleChannels[i].ColNo && cs.Quantity > 0).OrderBy(cs => cs.EffDate).ToList(); + + if (csList != null && csList.Count > 0) + { + int totalQuantity = csList.Sum(c => c.Quantity); + _portUtil.WriteChannelInfo(5, csList[0].EffDate == null ? "" : csList[0].EffDate, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.WriteChannelInfo(6, csList[0].ManuNo == null ? "" : csList[0].ManuNo, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.ShowContent(csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + //将库位多批次的总库存数更新标签 + _portUtil.WriteQuantity(csList[i].DrawerNo, csList[i].ColNo, totalQuantity); + Thread.Sleep(200); + } + // int totalQuantity = SqlSugarHelper.Db.Queryable() + // .Where(cs => cs.MachineId == singleChannels[i].MachineId) + // .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) + // .Where(cs => cs.ColNo == singleChannels[i].ColNo) + // .Sum(it => it.Quantity); + ////将库位多批次的总库存数更新标签 + //_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity); + //Thread.Sleep(200); } } } diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs index 426f5d8..1ab9bfd 100644 --- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs @@ -453,14 +453,31 @@ namespace DM_Weight.ViewModels { if (singleChannels[i].BoardType == 5) { - int totalQuantity = SqlSugarHelper.Db.Queryable() - .Where(cs => cs.MachineId == singleChannels[i].MachineId) - .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) - .Where(cs => cs.ColNo == singleChannels[i].ColNo) - .Sum(it => it.Quantity); - //将库位多批次的总库存数更新标签 - _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity); - Thread.Sleep(200); + List csList = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.MachineId == singleChannels[i].MachineId) + .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) + .Where(cs => cs.ColNo == singleChannels[i].ColNo&&cs.Quantity>0).OrderBy(cs => cs.EffDate).ToList(); + + if (csList != null && csList.Count > 0) + { + int totalQuantity = csList.Sum(c => c.Quantity); + + //SqlSugarHelper.Db.Queryable() + // .Where(cs => cs.MachineId == singleChannels[i].MachineId) + // .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) + // .Where(cs => cs.ColNo == singleChannels[i].ColNo) + // .Sum(it => it.Quantity); + + _portUtil.WriteChannelInfo(5, csList[0].EffDate == null ? "" : csList[0].EffDate, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.WriteChannelInfo(6, csList[0].ManuNo == null ? "" : csList[0].ManuNo, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.ShowContent(csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + //将库位多批次的总库存数更新标签 + _portUtil.WriteQuantity(csList[i].DrawerNo, csList[i].ColNo, totalQuantity); + Thread.Sleep(200); + } } } } diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs index cc1ed03..e2ff876 100644 --- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs @@ -375,14 +375,25 @@ namespace DM_Weight.ViewModels { if (singleChannels[i].BoardType == 5) { - int totalQuantity = SqlSugarHelper.Db.Queryable() - .Where(cs => cs.MachineId == singleChannels[i].MachineId) - .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) - .Where(cs => cs.ColNo == singleChannels[i].ColNo) - .Sum(it => it.Quantity); - //将库位多批次的总库存数更新标签 - _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity); - Thread.Sleep(200); + List csList = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.MachineId == singleChannels[i].MachineId) + .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) + .Where(cs => cs.ColNo == singleChannels[i].ColNo && cs.Quantity > 0).OrderBy(cs => cs.EffDate).ToList(); + + if (csList != null && csList.Count > 0) + { + int totalQuantity = csList.Sum(c => c.Quantity); + + _portUtil.WriteChannelInfo(5, csList[0].EffDate == null ? "" : csList[0].EffDate, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.WriteChannelInfo(6, csList[0].ManuNo == null ? "" : csList[0].ManuNo, csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + _portUtil.ShowContent(csList[0].DrawerNo, csList[0].ColNo); + Thread.Sleep(200); + //将库位多批次的总库存数更新标签 + _portUtil.WriteQuantity(csList[i].DrawerNo, csList[i].ColNo, totalQuantity); + Thread.Sleep(200); + } } } }