From f144b21a09cddf6243c37c222da4c030600066e7 Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Fri, 23 Aug 2024 08:36:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8D=AF=E7=9B=92=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E7=B1=BB=E5=9E=8B=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=89=93?= =?UTF-8?q?=E5=BC=80=E8=8D=AF=E7=9B=92=E5=8F=8A=E6=97=A0=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/App.config | 2 +- DM_Weight/Converter/BoardTypeConverter.cs | 13 ++ DM_Weight/Port/PortUtil.cs | 133 +++++++++++------- .../ViewModels/ApplyInStockWindowViewModel.cs | 35 ++++- .../BindingChannelDialogViewModel.cs | 36 +++++ .../BindingChannelNewDialogViewModel.cs | 10 ++ .../ViewModels/CheckStockWindowViewModel.cs | 20 ++- .../DrawerAddDrugWindowViewModel.cs | 34 ++++- .../DrawerTakeDrugWindowViewModel.cs | 30 ++++ .../ViewModels/InvoiceAddDialogViewModel.cs | 10 ++ .../ViewModels/InvoiceTakeDialogViewModel.cs | 12 +- .../ViewModels/OrderReturnDialogViewModel.cs | 12 +- .../ViewModels/OrderTakeDialogViewModel.cs | 14 +- .../ViewModels/ReturnDrugDialogViewModel.cs | 8 +- .../ViewModels/SelfAddDialogViewModel.cs | 17 ++- .../ViewModels/SelfTakeDialogViewModel.cs | 12 +- 16 files changed, 332 insertions(+), 66 deletions(-) diff --git a/DM_Weight/App.config b/DM_Weight/App.config index ee262d3..beedc98 100644 --- a/DM_Weight/App.config +++ b/DM_Weight/App.config @@ -54,7 +54,7 @@ - + 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/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index 6602d94..f73b344 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -85,7 +85,7 @@ namespace DM_Weight.Port // 是否正在操作中 public bool Operate { get; set; } - + //冰箱是否正在操作中 public bool FridgeOperate { get; set; } @@ -264,6 +264,12 @@ namespace DM_Weight.Port // 药盒指示灯使能 await BoxLockLightOn(); } + // 药盒 + if (BoardType == 35) + { + // 药盒带屏幕 + await OpenBox(); + } if (BoardType == 6) { // 药盒指示灯使能 @@ -663,23 +669,23 @@ namespace DM_Weight.Port byte[] buffer = new byte[length]; // try // { - int _length = 0; - DateTime start = DateTime.Now; - DateTime end = DateTime.Now; - while (_length != length && end.Subtract(start).TotalMilliseconds < timeout) - { - _length = serialPort.BytesToRead; - end = DateTime.Now; - } - if (_length != length) - { - throw new TimeoutException($"串口【{serialPort.PortName}】交互超时"); - } - serialPort.Read(buffer, 0, length); + int _length = 0; + DateTime start = DateTime.Now; + DateTime end = DateTime.Now; + while (_length != length && end.Subtract(start).TotalMilliseconds < timeout) + { + _length = serialPort.BytesToRead; + end = DateTime.Now; + } + if (_length != length) + { + throw new TimeoutException($"串口【{serialPort.PortName}】交互超时"); + } + serialPort.Read(buffer, 0, length); // } // catch (Exception ex) // { - // logger.Error($"GetBufferByPort:{ex.Message}"); + // logger.Error($"GetBufferByPort:{ex.Message}"); // } return buffer; } @@ -970,16 +976,23 @@ namespace DM_Weight.Port /// /// /// - public async Task OpenBox(int ColNo) + public async Task OpenBox() { - int[] iNum = new int[] { 3, 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}; - canBusSerial.Write(buffer, 0, 8); - await Task.Delay(TimeSpan.FromMilliseconds(20)); + 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); + } + } /// /// 查询药盒状态 @@ -990,7 +1003,7 @@ namespace DM_Weight.Port { 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 }; + byte[] buffer = new byte[] { 0xaa, (byte)channel, 2, 0, 0, 0, 0, 0xee }; canBusSerial.Write(buffer, 0, 8); return await GetBufferByPort(canBusSerial, 8); } @@ -1084,7 +1097,7 @@ namespace DM_Weight.Port { canBusSerial.DiscardInBuffer(); - int channel = Convert.ToInt32((drawerNo * 10 + colNo).ToString(),16); + int channel = Convert.ToInt32((drawerNo * 10 + colNo).ToString(), 16); byte[] buffer = new byte[] { 0xaa, (byte)channel, 6, 0, 0, 0, 0, 0xee }; buffer[3] = (byte)(quantity >> 8); buffer[4] = (byte)(quantity & 0xff); @@ -1133,55 +1146,67 @@ namespace DM_Weight.Port #region 标签显示屏 //清屏 - public void ClearContentMethod(int drawerNo,int colNo) + 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 = iNum[colNo2]; - byte[] buffer = new byte[] { 0xaa,(byte)channel,0x09,(byte)bColNo ,0xee}; + //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 void ShowContentMethod(int drawerNo, int colNo) + public async Task ShowContentMethod(int drawerNo, int colNo) { - var channel = drawerNo * 10 + Math.Ceiling((decimal)colNo % 3); - byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xee}; - canBusSerial.Write(buffer,0,8); + 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 void WriteChannelInfoMethod(int type,string content,int drawerNo,int colNo) + 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)); - content = content.Substring(0, 10); - int channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16); + 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]; if (contentBuf.Length % 2 != 0) + 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)colNo2, (byte)type, 0, 0, 0, 0xee }; + byte[] buffer = new byte[] { 0xaa, (byte)channel, (byte)bColNo, (byte)type, 0, 0, 0, 0xee }; canBusSerial.Write(buffer, 0, 8); - await Task.Delay(20); + 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); - await Task.Delay(20); + logger.Info($"写标签指令:{Convert.ToHexString(buffer)}"); + await Task.Delay(30); } buffer[4] = 2; buffer[5] = 0; buffer[6] = 0; canBusSerial.Write(buffer, 0, 8); - await Task.Delay(20); + logger.Info($"结束写标签指令:{Convert.ToHexString(buffer)}"); + await Task.Delay(30); } catch (Exception ex) @@ -1221,7 +1246,7 @@ namespace DM_Weight.Port logger.Info($"操作发生异常:ex:{ex.Message}"); return null; } - + } // 回收箱状态查询 public async Task CheckRecoverStatus() @@ -1382,7 +1407,7 @@ namespace DM_Weight.Port }); logger.Info($"操作发生异常:ex:{ex.Message},方法名:ClearCount;参数:{DrawerNo},{ColNo}"); } - + } public async void SetNumCount(int DrawerNo, int ColNo, int Quantity) @@ -1413,7 +1438,7 @@ namespace DM_Weight.Port }); logger.Info($"操作发生异常:ex:{ex.Message},方法名:SetNumCount;参数:{DrawerNo},{ColNo},{Quantity}"); } - + } #endregion /// @@ -1463,7 +1488,7 @@ namespace DM_Weight.Port { try { - fridgeSerial.DiscardInBuffer(); + fridgeSerial.DiscardInBuffer(); byte bAddress; if (iIndex == 1) { @@ -1502,7 +1527,7 @@ namespace DM_Weight.Port { try { - fridgeSerial.DiscardInBuffer(); + fridgeSerial.DiscardInBuffer(); byte bAddress; if (iIndex == 1) { @@ -1578,7 +1603,7 @@ namespace DM_Weight.Port /// 冰箱温度设定最小 /// /// - public async Task FridgeMinSetting(float min,int iIndex) + public async Task FridgeMinSetting(float min, int iIndex) { try { @@ -1617,7 +1642,7 @@ namespace DM_Weight.Port /// 冰箱温度设定最大 /// /// - public async Task FridgeMaxSetting(float max,int iIndex) + public async Task FridgeMaxSetting(float max, int iIndex) { try { @@ -1662,9 +1687,9 @@ namespace DM_Weight.Port { fridgeSerial.DiscardInBuffer(); byte bAddress; - if (iIndex == 1 ) + if (iIndex == 1) { - bAddress=0x01; + bAddress = 0x01; } else { @@ -1710,7 +1735,7 @@ namespace DM_Weight.Port /// 设置冰箱温度 /// /// - public async Task SetFridgeTemperature(float temperature,int iIndex) + public async Task SetFridgeTemperature(float temperature, int iIndex) { int tpt = (int)temperature * 10; byte Temperature = (byte)(tpt & 0xff); diff --git a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs index a2d8969..11f7c67 100644 --- a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs +++ b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs @@ -534,7 +534,7 @@ namespace DM_Weight.ViewModels private bool _isFinishClick = false; public DelegateCommand TakeFinish { get => new DelegateCommand(TakeFinishAction); } - private void TakeFinishAction() + private async void TakeFinishAction() { if (!_isFinishClick) { @@ -771,8 +771,41 @@ namespace DM_Weight.ViewModels //} } } + List singleChannelsBoxSmart = record.Where(it => it.BoardType == 35) + .GroupBy(it => new { it.DrawerNo, 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(); + if (singleChannelsBoxSmart != null && singleChannelsBoxSmart.Count > 0) + { + for (int i = 0; i < singleChannelsBoxSmart.Count; i++) + { + List channelStockEffDate = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.MachineId == singleChannelsBoxSmart[i].MachineId) + .Where(cs => cs.DrawerNo == singleChannelsBoxSmart[i].DrawerNo) + .Where(cs => cs.ColNo == singleChannelsBoxSmart[i].ColNo) + .Where(cs => cs.Quantity > 0) + .OrderBy(cs => cs.EffDate).ToList(); + int totalQuantity = channelStockEffDate.Sum(it => it.Quantity); + //将库位多批次的总库存数更新标签 + + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(2, totalQuantity.ToString(), channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(5, channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); + await Task.Delay(200); + await _portUtil.WriteChannelInfoMethod(6, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); + await Task.Delay(200); + await _portUtil.ShowContentMethod(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo); + } + } AlertMsg alertMsg = new AlertMsg diff --git a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs index 957f4fa..7fef8ee 100644 --- a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs @@ -248,6 +248,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 @@ -306,6 +321,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(); @@ -347,6 +377,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/BindingChannelNewDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs index 98ede1d..bf54314 100644 --- a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs +++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs @@ -290,6 +290,10 @@ namespace DM_Weight.ViewModels //await Task.Delay(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } + if(item.BoardType==35) + { + _portUtil.ClearContentMethod(item.DrawerNo,item.ColNo); + } //_screenUtil.SetStockInfo(item, 1); } @@ -365,6 +369,12 @@ namespace DM_Weight.ViewModels //Thread.Sleep(200); _portUtil.ShowContent(item.DrawerNo, item.ColNo); } + + if (item.BoardType == 35) + { + _portUtil.WindowName = "BindingChannelDialog"; + _portUtil.ClearContentMethod(item.DrawerNo,item.ColNo); + } } diff --git a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs index 2e46b39..63bd5bd 100644 --- a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs @@ -141,7 +141,7 @@ namespace DM_Weight.ViewModels // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { _isFinishClick = true; List record = ChannelStocks.FindAll(it => it.Quantity != it.CheckQuantity).ToList(); @@ -206,7 +206,23 @@ namespace DM_Weight.ViewModels _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++) + { + 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/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs index 90263bd..0273ead 100644 --- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs @@ -135,7 +135,7 @@ namespace DM_Weight.ViewModels _portUtil.WindowName = "DrawerAddDrugWindow"; _portUtil.Operate = true; _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1; - _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray(); + _portUtil.ColNos = singleChannels.Where(it=>it.AddQuantity>0).Select(it => it.ColNo).ToArray(); _portUtil.DrawerNo = DrawerNo; _portUtil.Start(); @@ -154,7 +154,7 @@ namespace DM_Weight.ViewModels // 完成按钮 public DelegateCommand TakeFinish { - get => new DelegateCommand(() => + get => new DelegateCommand(async() => { if (!_isFinishClick) { @@ -296,6 +296,36 @@ 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(it => + { + _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 50b9dee..ed47f23 100644 --- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs @@ -301,6 +301,36 @@ 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(it => + { + _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..a629242 100644 --- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs @@ -378,6 +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 cb0a1be..b179401 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) { @@ -442,6 +442,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..2f6b6bc 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) { @@ -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 e290581..742d7b8 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) { @@ -460,6 +460,18 @@ 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 de3da3e..d82c41e 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(); @@ -364,6 +364,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 { diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs index 7a4770a..db5309b 100644 --- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs +++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs @@ -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 dce4974..d769f64 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) { @@ -344,6 +344,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 {