添加药盒标签类型,添加打开药盒及无按钮标签

This commit is contained in:
maqiao 2024-08-23 08:36:41 +08:00
parent 43d372ebe0
commit f144b21a09
16 changed files with 332 additions and 66 deletions

View File

@ -54,7 +54,7 @@
<!-- 抽屉串口的串口号 --> <!-- 抽屉串口的串口号 -->
<add key="DrawerPortPath" value="COM1" /> <add key="DrawerPortPath" value="COM1" />
<!-- can总线串口的串口号 --> <!-- can总线串口的串口号 -->
<add key="CanBusPortPath" value="COM3" /> <add key="CanBusPortPath" value="COM17" />
<!-- 条码枪串口的串口号 --> <!-- 条码枪串口的串口号 -->
<add key="ScanCodePortPath" value="COM8" /> <add key="ScanCodePortPath" value="COM8" />

View File

@ -55,6 +55,19 @@ namespace DM_Weight.Converter
{ {
return "外置回收"; return "外置回收";
} }
case 35:
if (DrawerType == 1)
{
return "管控药盒带屏幕";
}
else if (DrawerType == 2)
{
return "药盒带屏幕回收(内置)";
}
else
{
return "外置回收";
}
case 4: case 4:
if (DrawerType == 1) if (DrawerType == 1)
{ {

View File

@ -264,6 +264,12 @@ namespace DM_Weight.Port
// 药盒指示灯使能 // 药盒指示灯使能
await BoxLockLightOn(); await BoxLockLightOn();
} }
// 药盒
if (BoardType == 35)
{
// 药盒带屏幕
await OpenBox();
}
if (BoardType == 6) if (BoardType == 6)
{ {
// 药盒指示灯使能 // 药盒指示灯使能
@ -663,23 +669,23 @@ namespace DM_Weight.Port
byte[] buffer = new byte[length]; byte[] buffer = new byte[length];
// try // try
// { // {
int _length = 0; int _length = 0;
DateTime start = DateTime.Now; DateTime start = DateTime.Now;
DateTime end = DateTime.Now; DateTime end = DateTime.Now;
while (_length != length && end.Subtract(start).TotalMilliseconds < timeout) while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
{ {
_length = serialPort.BytesToRead; _length = serialPort.BytesToRead;
end = DateTime.Now; end = DateTime.Now;
} }
if (_length != length) if (_length != length)
{ {
throw new TimeoutException($"串口【{serialPort.PortName}】交互超时"); throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
} }
serialPort.Read(buffer, 0, length); serialPort.Read(buffer, 0, length);
// } // }
// catch (Exception ex) // catch (Exception ex)
// { // {
// logger.Error($"GetBufferByPort{ex.Message}"); // logger.Error($"GetBufferByPort{ex.Message}");
// } // }
return buffer; return buffer;
} }
@ -970,16 +976,23 @@ namespace DM_Weight.Port
/// </summary> /// </summary>
/// <param name="ColNo"></param> /// <param name="ColNo"></param>
/// <returns></returns> /// <returns></returns>
public async Task OpenBox(int ColNo) public async Task OpenBox()
{ {
int[] iNum = new int[] { 3, 2, 1 }; for (int i = 0; i < ColNos.Length; i++)
var colNo2 = ColNo % 3 > 0 ? (ColNo % 3) - 1 : 2; {
var bColNo = iNum[colNo2]; int ColNo = ColNos[i];
decimal decolNO = (decimal)ColNo; int[] iNum = new int[] { 4, 2, 1 };
var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16); var colNo2 = ColNo % 3 > 0 ? (ColNo % 3) - 1 : 2;
byte[] buffer = new byte[] { 0xaa, (byte)channel, 5,(byte)bColNo, 0x00,0x00,0x00,0xee}; var bColNo = iNum[colNo2];
canBusSerial.Write(buffer, 0, 8); decimal decolNO = (decimal)ColNo;
await Task.Delay(TimeSpan.FromMilliseconds(20)); 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);
}
} }
/// <summary> /// <summary>
/// 查询药盒状态 /// 查询药盒状态
@ -990,7 +1003,7 @@ namespace DM_Weight.Port
{ {
decimal deColNo = (decimal)ColNo; decimal deColNo = (decimal)ColNo;
var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(deColNo / 3)).ToString(), 16); 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); canBusSerial.Write(buffer, 0, 8);
return await GetBufferByPort(canBusSerial, 8); return await GetBufferByPort(canBusSerial, 8);
} }
@ -1084,7 +1097,7 @@ namespace DM_Weight.Port
{ {
canBusSerial.DiscardInBuffer(); 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 }; byte[] buffer = new byte[] { 0xaa, (byte)channel, 6, 0, 0, 0, 0, 0xee };
buffer[3] = (byte)(quantity >> 8); buffer[3] = (byte)(quantity >> 8);
buffer[4] = (byte)(quantity & 0xff); buffer[4] = (byte)(quantity & 0xff);
@ -1133,55 +1146,67 @@ namespace DM_Weight.Port
#region #region
//清屏 //清屏
public void ClearContentMethod(int drawerNo,int colNo) public void ClearContentMethod(int drawerNo, int colNo)
{ {
decimal deColNo = colNo; decimal deColNo = colNo;
var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3); //var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3);
int[] iNum =new int[] { 3, 2, 1 }; int[] iNum = new int[] { 3, 2, 1 };
var colNo2 = colNo%3>0?(colNo%3)-1:2; var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
var bColNo = iNum[colNo2]; var bColNo = Convert.ToInt32((iNum[colNo2]+10).ToString(),16);
byte[] buffer = new byte[] { 0xaa,(byte)channel,0x09,(byte)bColNo ,0xee}; //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); 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); 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}; byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xee };
canBusSerial.Write(buffer,0,8); 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 try
{ {
canBusSerial.DiscardInBuffer(); canBusSerial.DiscardInBuffer();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content)); byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content));
content = content.Substring(0, 10); if (content.Length > 10)
int channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16); {
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 }; int[] iNum = new int[] { 3, 2, 1 };
var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2; 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); 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); canBusSerial.Write(buffer, 0, 8);
await Task.Delay(20); logger.Info($"开始写标签指令:{Convert.ToHexString(buffer)}");
await Task.Delay(30);
buffer[4] = 1; buffer[4] = 1;
for (int i = 0; i < contentBuf.Length; i += 2) for (int i = 0; i < contentBuf.Length; i += 2)
{ {
buffer[5] = contentBuf[i]; buffer[5] = contentBuf[i];
buffer[6] = contentBuf[i + 1]; buffer[6] = contentBuf[i + 1];
canBusSerial.Write(buffer, 0, 8); canBusSerial.Write(buffer, 0, 8);
await Task.Delay(20); logger.Info($"写标签指令:{Convert.ToHexString(buffer)}");
await Task.Delay(30);
} }
buffer[4] = 2; buffer[4] = 2;
buffer[5] = 0; buffer[5] = 0;
buffer[6] = 0; buffer[6] = 0;
canBusSerial.Write(buffer, 0, 8); canBusSerial.Write(buffer, 0, 8);
await Task.Delay(20); logger.Info($"结束写标签指令:{Convert.ToHexString(buffer)}");
await Task.Delay(30);
} }
catch (Exception ex) catch (Exception ex)
@ -1578,7 +1603,7 @@ namespace DM_Weight.Port
/// 冰箱温度设定最小 /// 冰箱温度设定最小
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task FridgeMinSetting(float min,int iIndex) public async Task FridgeMinSetting(float min, int iIndex)
{ {
try try
{ {
@ -1617,7 +1642,7 @@ namespace DM_Weight.Port
/// 冰箱温度设定最大 /// 冰箱温度设定最大
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task FridgeMaxSetting(float max,int iIndex) public async Task FridgeMaxSetting(float max, int iIndex)
{ {
try try
{ {
@ -1662,9 +1687,9 @@ namespace DM_Weight.Port
{ {
fridgeSerial.DiscardInBuffer(); fridgeSerial.DiscardInBuffer();
byte bAddress; byte bAddress;
if (iIndex == 1 ) if (iIndex == 1)
{ {
bAddress=0x01; bAddress = 0x01;
} }
else else
{ {
@ -1710,7 +1735,7 @@ namespace DM_Weight.Port
/// 设置冰箱温度 /// 设置冰箱温度
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<float> SetFridgeTemperature(float temperature,int iIndex) public async Task<float> SetFridgeTemperature(float temperature, int iIndex)
{ {
int tpt = (int)temperature * 10; int tpt = (int)temperature * 10;
byte Temperature = (byte)(tpt & 0xff); byte Temperature = (byte)(tpt & 0xff);

View File

@ -534,7 +534,7 @@ namespace DM_Weight.ViewModels
private bool _isFinishClick = false; private bool _isFinishClick = false;
public DelegateCommand TakeFinish { get => new DelegateCommand(TakeFinishAction); } public DelegateCommand TakeFinish { get => new DelegateCommand(TakeFinishAction); }
private void TakeFinishAction() private async void TakeFinishAction()
{ {
if (!_isFinishClick) if (!_isFinishClick)
{ {
@ -771,8 +771,41 @@ namespace DM_Weight.ViewModels
//} //}
} }
} }
List<ChannelStock> 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<ChannelStock> channelStockEffDate = SqlSugarHelper.Db.Queryable<ChannelStock>()
.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 AlertMsg alertMsg = new AlertMsg

View File

@ -248,6 +248,21 @@ namespace DM_Weight.ViewModels
_portUtil.ShowContent(item.DrawerNo, item.ColNo); _portUtil.ShowContent(item.DrawerNo, item.ColNo);
} }
//_screenUtil.SetStockInfo(item, 1); //_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 else
@ -306,6 +321,21 @@ namespace DM_Weight.ViewModels
await Task.Delay(200); await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo); _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); //_screenUtil.SetStockInfo(item, 1);
}); });
GetChannelsByDrawerNo(); GetChannelsByDrawerNo();
@ -347,6 +377,12 @@ namespace DM_Weight.ViewModels
await Task.Delay(200); await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo); _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); //_screenUtil.SetStockInfo(item, 1);
}); });

View File

@ -290,6 +290,10 @@ namespace DM_Weight.ViewModels
//await Task.Delay(200); //await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo); _portUtil.ShowContent(item.DrawerNo, item.ColNo);
} }
if(item.BoardType==35)
{
_portUtil.ClearContentMethod(item.DrawerNo,item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1); //_screenUtil.SetStockInfo(item, 1);
} }
@ -365,6 +369,12 @@ namespace DM_Weight.ViewModels
//Thread.Sleep(200); //Thread.Sleep(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo); _portUtil.ShowContent(item.DrawerNo, item.ColNo);
} }
if (item.BoardType == 35)
{
_portUtil.WindowName = "BindingChannelDialog";
_portUtil.ClearContentMethod(item.DrawerNo,item.ColNo);
}
} }

View File

@ -141,7 +141,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async() =>
{ {
_isFinishClick = true; _isFinishClick = true;
List<ChannelStock> record = ChannelStocks.FindAll(it => it.Quantity != it.CheckQuantity).ToList(); List<ChannelStock> 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); _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(); RequestData();
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {

View File

@ -135,7 +135,7 @@ namespace DM_Weight.ViewModels
_portUtil.WindowName = "DrawerAddDrugWindow"; _portUtil.WindowName = "DrawerAddDrugWindow";
_portUtil.Operate = true; _portUtil.Operate = true;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1; _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.DrawerNo = DrawerNo;
_portUtil.Start(); _portUtil.Start();
@ -154,7 +154,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async() =>
{ {
if (!_isFinishClick) if (!_isFinishClick)
{ {
@ -296,6 +296,36 @@ namespace DM_Weight.ViewModels
}); });
if (f.Data) if (f.Data)
{ {
List<ChannelStock> 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(); RequestData();
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {

View File

@ -301,6 +301,36 @@ namespace DM_Weight.ViewModels
}); });
if (f.Data) if (f.Data)
{ {
List<ChannelStock> 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(); RequestData();
AlertMsg alertMsg = new AlertMsg AlertMsg alertMsg = new AlertMsg
{ {

View File

@ -378,6 +378,16 @@ namespace DM_Weight.ViewModels
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); _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 AlertMsg alertMsg = new AlertMsg

View File

@ -288,7 +288,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async() =>
{ {
if (!_isFinishClick) if (!_isFinishClick)
{ {
@ -442,6 +442,16 @@ namespace DM_Weight.ViewModels
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); _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 AlertMsg alertMsg = new AlertMsg
{ {
Message = "调拨取药完成,库存已更新", Message = "调拨取药完成,库存已更新",

View File

@ -283,7 +283,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async() =>
{ {
if (!_isFinishClick) if (!_isFinishClick)
{ {
@ -436,6 +436,16 @@ namespace DM_Weight.ViewModels
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity); _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 AlertMsg alertMsg = new AlertMsg
{ {
Message = "处方退药完成,库存已更新", Message = "处方退药完成,库存已更新",

View File

@ -298,7 +298,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async() =>
{ {
if (!_isFinishClick) if (!_isFinishClick)
{ {
@ -460,6 +460,18 @@ namespace DM_Weight.ViewModels
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
}); });
} }
List<ChannelStock> 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 AlertMsg alertMsg = new AlertMsg
{ {
Message = "抽屉取药完成,库存已更新", Message = "抽屉取药完成,库存已更新",

View File

@ -223,7 +223,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async() =>
{ {
IsFinishClick = true; IsFinishClick = true;
string InvoiceId = "RETURN_" + CurrentTimeMillis(); string InvoiceId = "RETURN_" + CurrentTimeMillis();
@ -364,6 +364,12 @@ namespace DM_Weight.ViewModels
{ {
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity); _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 AlertMsg alertMsg = new AlertMsg
{ {

View File

@ -370,7 +370,22 @@ namespace DM_Weight.ViewModels
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); _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 AlertMsg alertMsg = new AlertMsg
{ {

View File

@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels
// 完成按钮 // 完成按钮
public DelegateCommand TakeFinish public DelegateCommand TakeFinish
{ {
get => new DelegateCommand(() => get => new DelegateCommand(async() =>
{ {
if (!_isFinishClick) if (!_isFinishClick)
{ {
@ -344,6 +344,16 @@ namespace DM_Weight.ViewModels
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); _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 AlertMsg alertMsg = new AlertMsg
{ {