From baf0747a7409704e8d65a093445e5435f75a0f4c Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Mon, 18 Nov 2024 14:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=A1=E6=8E=A7=E5=B8=A6?= =?UTF-8?q?=E8=8D=AF=E7=9B=92=E7=B1=BB=E5=9E=8B=E5=B9=B6=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=9B=B4=E6=96=B0=E6=A0=87=E7=AD=BE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Converter/BoardTypeConverter.cs | 13 ++ DM_Weight/Models/AccountBookG2.cs | 2 +- DM_Weight/Port/PortUtil.cs | 121 ++++++++++++++++++ .../ViewModels/ApplyInStockWindowViewModel.cs | 10 +- .../BindingChannelDialogViewModel.cs | 38 +++++- .../BindingChannelNewDialogViewModel.cs | 38 +++++- .../DrawerAddDrugWindowViewModel.cs | 71 ++++++++-- .../DrawerTakeDrugWindowViewModel.cs | 65 +++++++++- .../ViewModels/InvoiceAddDialogViewModel.cs | 21 ++- .../ViewModels/InvoiceTakeDialogViewModel.cs | 22 +++- .../ViewModels/OrderReturnDialogViewModel.cs | 22 +++- .../ViewModels/OrderTakeDialogViewModel.cs | 23 +++- .../ViewModels/ReturnDrugDialogViewModel.cs | 19 ++- .../ViewModels/SelfAddDialogViewModel.cs | 27 +++- .../ViewModels/SelfTakeDialogViewModel.cs | 23 +++- 15 files changed, 443 insertions(+), 72 deletions(-) diff --git a/DM_Weight/Converter/BoardTypeConverter.cs b/DM_Weight/Converter/BoardTypeConverter.cs index 54e5382..c1e57ec 100644 --- a/DM_Weight/Converter/BoardTypeConverter.cs +++ b/DM_Weight/Converter/BoardTypeConverter.cs @@ -55,6 +55,19 @@ namespace DM_Weight.Converter { return "外置回收"; } + case 35: + if (DrawerType == 1) + { + return "管控药盒带屏幕"; + } + else if (DrawerType == 2) + { + return "药盒带屏幕回收(内置)"; + } + else + { + return "外置回收"; + } case 4: if (DrawerType == 1) { diff --git a/DM_Weight/Models/AccountBookG2.cs b/DM_Weight/Models/AccountBookG2.cs index 2511025..74ede11 100644 --- a/DM_Weight/Models/AccountBookG2.cs +++ b/DM_Weight/Models/AccountBookG2.cs @@ -20,7 +20,7 @@ namespace DM_Weight.Models /// 药品id /// [SugarColumn(ColumnName = "drug_id")] - public int DrugId { get; set; } + public string DrugId { get; set; } /// /// 1领入2发出3日结4总结5转结 diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index 75c9a49..ce36c43 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -262,6 +262,12 @@ namespace DM_Weight.Port // 药盒指示灯使能 await BoxLockLightOn(); } + // 药盒 + if (BoardType == 35) + { + // 药盒带屏幕 + await OpenBox(); + } if (BoardType == 6) { // 药盒指示灯使能 @@ -963,7 +969,45 @@ namespace DM_Weight.Port canBusSerial.Write(buffer, 0, 8); } #endregion + #region 药盒操作 + /// + /// 打开药盒 + /// + /// + /// + public async Task OpenBox() + { + for (int i = 0; i < ColNos.Length; i++) + { + int ColNo = ColNos[i]; + int[] iNum = new int[] { 4, 2, 1 }; + var colNo2 = ColNo % 3 > 0 ? (ColNo % 3) - 1 : 2; + var bColNo = iNum[colNo2]; + decimal decolNO = (decimal)ColNo; + var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16); + byte[] buffer = new byte[] { 0xaa, (byte)channel, 5, (byte)bColNo, 0x00, 0x00, 0x00, 0xee }; + //byte[] buffer = new byte[] { 0xaa, 0x11, 0x05,0x01, 0x00,0x00,0x00,0xee}; + logger.Info($"{Convert.ToHexString(buffer)}"); + canBusSerial.Write(buffer, 0, 8); + await Task.Delay(800); + } + } + /// + /// 查询药盒状态 + /// + /// + /// + public async Task OpenBoxState(int ColNo) + { + decimal deColNo = (decimal)ColNo; + var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(deColNo / 3)).ToString(), 16); + byte[] buffer = new byte[] { 0xaa, (byte)channel, 2, 0, 0, 0, 0, 0xee }; + canBusSerial.Write(buffer, 0, 8); + return await GetBufferByPort(canBusSerial, 8); + } + + #endregion private string trim(string text) { //此处使用了转义字符如:\',\",\\,分别表示单引号,双引号,反斜杠 @@ -1097,7 +1141,84 @@ namespace DM_Weight.Port #endregion + #region 标签显示屏 + //清屏 + public void ClearContentMethod(int drawerNo, int colNo) + { + decimal deColNo = colNo; + //var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3); + int[] iNum = new int[] { 3, 2, 1 }; + var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2; + var bColNo = Convert.ToInt32((iNum[colNo2] + 10).ToString(), 16); + //var index = Convert.ToInt32(((colNo % 3 == 0 ? 3 : colNo % 3)+10).ToString(),16); + int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16); + byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x09, (byte)bColNo, 0, 0, 0, 0xee }; + canBusSerial.Write(buffer, 0, 8); + logger.Info($"清屏指令:{Convert.ToHexString(buffer)}"); + } + //刷新内容 + public async Task ShowContentMethod(int drawerNo, int colNo) + { + int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16); + byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xee }; + logger.Info($"刷新内容指令:{Convert.ToHexString(buffer)}"); + canBusSerial.Write(buffer, 0, 8); + } + // 基础数据写入方法 + public async Task WriteChannelInfoMethod(int type, string content, int drawerNo, int colNo) + { + try + { + canBusSerial.DiscardInBuffer(); + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content)); + if (content.Length > 10) + { + content = content.Substring(0, 10); + } + int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16); + int[] iNum = new int[] { 3, 2, 1 }; + var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2; + var bColNo = iNum[colNo2] + 160; + //var index = (colNo % 3 == 0 ? 3 : colNo % 3)+160; + if (contentBuf.Length % 2 != 0) + { + Array.Resize(ref contentBuf, contentBuf.Length + 1); + } + byte[] buffer = new byte[] { 0xaa, (byte)channel, (byte)bColNo, (byte)type, 0, 0, 0, 0xee }; + canBusSerial.Write(buffer, 0, 8); + logger.Info($"开始写标签指令:{Convert.ToHexString(buffer)}"); + await Task.Delay(30); + buffer[4] = 1; + for (int i = 0; i < contentBuf.Length; i += 2) + { + buffer[5] = contentBuf[i]; + buffer[6] = contentBuf[i + 1]; + canBusSerial.Write(buffer, 0, 8); + logger.Info($"写标签指令:{Convert.ToHexString(buffer)}"); + await Task.Delay(30); + } + buffer[4] = 2; + buffer[5] = 0; + buffer[6] = 0; + canBusSerial.Write(buffer, 0, 8); + logger.Info($"结束写标签指令:{Convert.ToHexString(buffer)}"); + await Task.Delay(30); + } + catch (Exception ex) + { + _eventAggregator.GetEvent().Publish(new util.DeviceMsg() + { + EventType = util.EventType.OPENERROR, + WindowName = WindowName, + Message = $"2.4寸汉显屏异常{ex.Message}" + }); + logger.Info($"2.4寸汉显屏异常:ex:{ex.Message}"); + } + } + + #endregion #region 回收箱操作 // 打开回收箱 public async Task OpenRecover() diff --git a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs index e3c4c29..8370a2a 100644 --- a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs +++ b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs @@ -651,7 +651,7 @@ namespace DM_Weight.ViewModels int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = dept, OrderNo = SelectDrugPleaseClaim.PleaseNo, @@ -670,7 +670,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId ==it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -683,7 +683,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -705,7 +705,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -717,7 +717,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, diff --git a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs index ac982f5..7d27d00 100644 --- a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs @@ -243,7 +243,21 @@ namespace DM_Weight.ViewModels _portUtil.ShowContent(item.DrawerNo, item.ColNo); } //_screenUtil.SetStockInfo(item, 1); - + if (item.BoardType == 35) + { + _portUtil.WindowName = "BindingChannelDialog"; + await _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(5, item.EffDate, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo); + } } else { @@ -301,6 +315,21 @@ namespace DM_Weight.ViewModels await Task.Delay(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } + if (item.BoardType == 35) + { + _portUtil.WindowName = "BindingChannelDialog"; + await _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(5, item.EffDate, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo); + } //_screenUtil.SetStockInfo(item, 1); }); GetChannelsByDrawerNo(); @@ -342,6 +371,13 @@ namespace DM_Weight.ViewModels await Task.Delay(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } + if (item.BoardType == 35) + { + _portUtil.ClearContentMethod(item.DrawerNo, item.ColNo); + await Task.Delay(300); + _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo); + } + //_screenUtil.SetStockInfo(item, 1); }); diff --git a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs index 4ef2073..3889ace 100644 --- a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs @@ -272,8 +272,8 @@ namespace DM_Weight.ViewModels item.PosNo = 0; } item.DrugId = DrugInfo.DrugId.ToString(); - item.DrugSpec= DrugInfo.DrugSpec.ToString(); - SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand(); + item.DrugSpec = DrugInfo.DrugSpec.ToString(); + SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo, it.DrugSpec }).ExecuteCommand(); GetChannelsByDrawerNo(); if (item.BoardType == 5) @@ -292,6 +292,15 @@ namespace DM_Weight.ViewModels //await Task.Delay(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } + if (item.BoardType == 35) + { + _portUtil.WindowName = "BindingChannelDialog"; + await _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo); + } //_screenUtil.SetStockInfo(item, 1); } @@ -325,8 +334,8 @@ namespace DM_Weight.ViewModels for (int i = 0; i < SelectChannels.Count; i++) { var item = SelectChannels[i]; - var channelStock = SqlSugarHelper.Db.Queryable().Where(cs => cs.Chnguid == item.Id&&cs.Quantity>0).ToList(); - if(channelStock.Count>0) + var channelStock = SqlSugarHelper.Db.Queryable().Where(cs => cs.Chnguid == item.Id && cs.Quantity > 0).ToList(); + if (channelStock.Count > 0) { //有库存,不能解绑 @@ -344,7 +353,7 @@ namespace DM_Weight.ViewModels item.Drug = DrugInfo; item.DrugSpec = DrugInfo.DrugSpec.ToString(); //item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate); - SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand(); + SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo, it.DrugSpec }).ExecuteCommand(); if (item.BoardType == 5) { @@ -367,9 +376,18 @@ namespace DM_Weight.ViewModels //Thread.Sleep(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } + if (item.BoardType == 35) + { + _portUtil.WindowName = "BindingChannelDialog"; + await _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo); + //_portUtil.ClearContentMethod(item.DrawerNo, item.ColNo); + } } - GetChannelsByDrawerNo(); } else @@ -412,7 +430,7 @@ namespace DM_Weight.ViewModels //item.EffDate = null; item.Drug = null; item.DrugSpec = null; - SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId,it.DrugSpec }).ExecuteCommand(); + SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.DrugSpec }).ExecuteCommand(); if (item.BoardType == 5) { // 清除显示屏库位信息 @@ -420,6 +438,12 @@ namespace DM_Weight.ViewModels await Task.Delay(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } + if (item.BoardType == 35) + { + _portUtil.ClearContentMethod(item.DrawerNo, item.ColNo); + await Task.Delay(300); + _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo); + } //_screenUtil.SetStockInfo(item, 1); }); diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs index 6cc03d1..10c9a52 100644 --- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs @@ -38,11 +38,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) @@ -149,12 +151,33 @@ 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; // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { if (!_isFinishClick) { @@ -170,7 +193,7 @@ namespace DM_Weight.ViewModels { ChannelStock it = record[i]; it.ManuNo = it.drugManuNo.ManuNo; - it.EffDate = it.drugManuNo.EffDate; + it.EffDate = it.drugManuNo.EffDate.Substring(0,10); // 更新数据 库存信息 @@ -210,7 +233,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -228,7 +251,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -242,7 +265,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -264,7 +287,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -276,7 +299,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, @@ -297,6 +320,38 @@ namespace DM_Weight.ViewModels }); if (f.Data) { + List singleChannels = ChannelStocks.Where(it => it.BoardType != 1) + .GroupBy(it => it.ColNo) + .Select(it => + { + var ret = it.First(); + ret.Quantity = it.Sum(itx => itx.Quantity); + ret.AddQuantity = it.Sum(itx => itx.AddQuantity); + return ret; + }).ToList(); + singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList(); + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) + { + //将库位多批次的总库存数更新标签 + //_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity)); + + singleChannels.ForEach(async it => + { + + await Task.Delay(200); + _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); + }); + } + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) + { + for (int i = 0; i < singleChannels.Count; i++) + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo); + } + } RequestData(); AlertMsg alertMsg = new AlertMsg { diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs index 21919b2..3ed710b 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,7 +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; // 完成按钮 @@ -212,7 +234,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId =it.DrugId, Type = 2, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -230,7 +252,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -243,7 +265,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId =it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -265,7 +287,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId ==it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -277,7 +299,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId =it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, @@ -303,6 +325,37 @@ namespace DM_Weight.ViewModels }); if (f.Data) { + List singleChannels = ChannelStocks.Where(it => it.BoardType != 1) + .GroupBy(it => it.ColNo) + .Select(it => + { + var ret = it.First(); + ret.Quantity = it.Sum(itx => itx.Quantity); + ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity); + return ret; + }).ToList(); + singleChannels = singleChannels.Where(it => it.TakeQuantity > 0).ToList(); + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) + { + //将库位多批次的总库存数更新标签 + //_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity)); + + singleChannels.ForEach(async it => + { + await Task.Delay(200); + _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); + }); + } + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) + { + singleChannels.ForEach(async it => + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (it.Quantity - it.TakeQuantity).ToString(), it.DrawerNo, it.ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(it.DrawerNo, it.ColNo); + }); + } RequestData(); AlertMsg alertMsg = new AlertMsg { diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs index 37e6a99..65a6c80 100644 --- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs @@ -283,7 +283,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -301,7 +301,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -314,7 +314,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -336,7 +336,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -348,7 +348,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, @@ -378,7 +378,16 @@ namespace DM_Weight.ViewModels _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); }); } - + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) + { + for (int i = 0; i < singleChannels.Count; i++) + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo); + } + } AlertMsg alertMsg = new AlertMsg { diff --git a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs index 7f768be..18e4162 100644 --- a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs @@ -288,7 +288,7 @@ namespace DM_Weight.ViewModels // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { if (!_isFinishClick) { @@ -346,7 +346,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 2, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -364,7 +364,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -377,7 +377,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -399,7 +399,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -411,7 +411,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, @@ -441,6 +441,16 @@ namespace DM_Weight.ViewModels _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); }); } + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) + { + for (int i = 0; i < singleChannels.Count; i++) + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo); + } + } AlertMsg alertMsg = new AlertMsg { Message = "调拨取药完成,库存已更新", diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs index 21e37f0..7d2eac3 100644 --- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs @@ -283,7 +283,7 @@ namespace DM_Weight.ViewModels // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { if (!_isFinishClick) { @@ -341,7 +341,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -359,7 +359,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -372,7 +372,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -394,7 +394,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -406,7 +406,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.ReturnQuantity, @@ -436,6 +436,16 @@ namespace DM_Weight.ViewModels _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity); }); } + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) + { + for (int i = 0; i < singleChannels.Count; i++) + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo); + } + } AlertMsg alertMsg = new AlertMsg { Message = "处方退药完成,库存已更新", diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs index b15d5f4..ad191e8 100644 --- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs @@ -298,7 +298,7 @@ namespace DM_Weight.ViewModels // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { if (!_isFinishClick) { @@ -362,7 +362,7 @@ namespace DM_Weight.ViewModels //保存账册 int iInsertResult= SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type= 2, Department= OrderInfo.DeptName, OrderNo=OrderInfo.OrderNo, @@ -381,7 +381,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day= SqlSugarHelper.Db.Queryable() .Where(ab=>ab.MachineId.Equals(it.MachineId)) .Where(ab=>ab.Type==3) - .Where(ab=>ab.DrugId==Convert.ToInt32(it.DrugId)) + .Where(ab=>ab.DrugId==it.DrugId) .Where(ab=>ab.ManuNo==it.ManuNo) .Where(ab=>ab.CreateDate==DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -394,7 +394,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -416,7 +416,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab=>ab.DrugId==Convert.ToInt32(it.DrugId)) + .Where(ab=>ab.DrugId==it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -428,7 +428,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, @@ -459,6 +459,17 @@ namespace DM_Weight.ViewModels _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); }); } + List singleChannelsBoxSmart = record.FindAll(it => it.BoardType == 35); + if ((singleChannelsBoxSmart.Count > 0 ? singleChannelsBoxSmart[0].BoardType : 1) == 35) + { + for (int i = 0; i < singleChannels.Count; i++) + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo); + } + } AlertMsg alertMsg = new AlertMsg { Message = "抽屉取药完成,库存已更新", diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs index 264c0d5..add6af3 100644 --- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs +++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs @@ -223,7 +223,7 @@ namespace DM_Weight.ViewModels // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { IsFinishClick = true; string InvoiceId = "RETURN_" + CurrentTimeMillis(); @@ -272,7 +272,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(ChannelStock.DrugId), + DrugId = ChannelStock.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -290,7 +290,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(ChannelStock.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId)) + .Where(ab => ab.DrugId ==ChannelStock.DrugId) .Where(ab => ab.ManuNo == ChannelStock.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -303,7 +303,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(ChannelStock.DrugId), + DrugId = ChannelStock.DrugId, Type = 3, ManuNo = ChannelStock.ManuNo, EffDate = ChannelStock.EffDate, @@ -325,7 +325,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(ChannelStock.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(ChannelStock.DrugId)) + .Where(ab => ab.DrugId == ChannelStock.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) { @@ -337,7 +337,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(ChannelStock.DrugId), + DrugId = ChannelStock.DrugId, Type = 4, YQuantity = 0, ManuStock = ChannelStock.ReturnQuantity, @@ -365,7 +365,12 @@ namespace DM_Weight.ViewModels { _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity); } - + if (ChannelStock.BoardType == 35) + { + await _portUtil.WriteChannelInfoMethod(2, (ChannelStock.Quantity + ChannelStock.ReturnQuantity).ToString(), ChannelStock.DrawerNo, ChannelStock.ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(ChannelStock.DrawerNo, ChannelStock.ColNo); + } AlertMsg alertMsg = new AlertMsg { Message = "操作完成,库存已更新", diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs index 17063ca..beb2b76 100644 --- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs @@ -272,7 +272,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 1, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -290,7 +290,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId ==it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -304,7 +304,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -326,7 +326,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) @@ -339,7 +339,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.AddQuantity, @@ -370,7 +370,22 @@ namespace DM_Weight.ViewModels _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); }); } - + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) + { + for (int i = 0; i < singleChannels.Count; i++) + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity + singleChannels[i].AddQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo); + } + //singleChannels.ForEach(async it => + //{ + // await _portUtil.WriteChannelInfoMethod(2, (it.Quantity + it.AddQuantity).ToString(), it.DrawerNo, it.ColNo); + // await Task.Delay(200); + // await _portUtil.ShowContentMethod(it.DrawerNo, it.ColNo); + //}); + } AlertMsg alertMsg = new AlertMsg { diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs index 76bc928..ad99d86 100644 --- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs @@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { if (!_isFinishClick) { @@ -249,7 +249,7 @@ namespace DM_Weight.ViewModels //保存账册 SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 2, Department = ConfigurationManager.AppSettings["department"].ToString(), InvoiceNo = InvoiceId, @@ -267,7 +267,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.ManuNo == it.ManuNo) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Day != null) @@ -281,7 +281,7 @@ namespace DM_Weight.ViewModels //生成日结存时可能没有该库位的绑定信息,需要写入日结存 int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 3, ManuNo = it.ManuNo, EffDate = it.EffDate, @@ -303,7 +303,7 @@ namespace DM_Weight.ViewModels AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable() .Where(ab => ab.MachineId.Equals(it.MachineId)) .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == Convert.ToInt32(it.DrugId)) + .Where(ab => ab.DrugId == it.DrugId) .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First(); if (accountBookG2Total != null) @@ -316,7 +316,7 @@ namespace DM_Weight.ViewModels //生成总结存时可能没有该库位的绑定信息,需要写入总结存 int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { - DrugId = Convert.ToInt32(it.DrugId), + DrugId = it.DrugId, Type = 4, YQuantity = 0, ManuStock = it.TakeQuantity, @@ -346,7 +346,16 @@ namespace DM_Weight.ViewModels _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); }); } - + if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 35) + { + for (int i = 0; i < singleChannels.Count; i++) + { + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, (singleChannels[i].Quantity - singleChannels[i].TakeQuantity).ToString(), singleChannels[i].DrawerNo, singleChannels[i].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(singleChannels[i].DrawerNo, singleChannels[i].ColNo); + } + } AlertMsg alertMsg = new AlertMsg { Message = "操作完成,库存已更新",