更新取药时库存为0则检测绑定标签并是否需要重新绑定批次、效期

This commit is contained in:
maqiao 2024-03-21 15:39:59 +08:00
parent db02d51934
commit 4f0297f4bc
7 changed files with 275 additions and 91 deletions

View File

@ -3,7 +3,7 @@
<connectionStrings>
<!-- 数据库连接字符串 -->
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
<add name="database" connectionString="server=127.0.0.1;port=3306;database=hunanxianchang_db;userid=root;password=root" />
<add name="database" connectionString="server=127.0.0.1;port=3306;database=hunanxianchang_db;userid=root;password=root;Pooling=True; ConnectionLifeTime=0" />
</connectionStrings>
<!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -26,7 +26,7 @@
<!-- 按处方还药或者按取药记录还药 1:处方2药品-->
<add key="returnDrugMode" value="1" />
<!-- 自动退出时间单位秒为0时不自动退出 -->
<add key="autoExit" value="0"/>
<add key="autoExit" value="30"/>
<!--报表数据库连接-->
<add key="gridConnectionString" value="MYSQL; Database=hunanxianchang_db; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
<!-- 查询处方是orderNo还是orderGroupNo -->

View File

@ -257,7 +257,7 @@ namespace DM_Weight
//交接班
containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
containerRegistry.RegisterSingleton<SqlSugarScope>(() => SqlSugarHelperNew.GetInstance());
//containerRegistry.RegisterSingleton<SqlSugarScope>(() => SqlSugarHelperNew.GetInstance());
//账册页面
containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();

View File

@ -18,28 +18,37 @@ namespace DM_Weight.Services
private readonly ILog logger = LogManager.GetLogger(typeof(UserService));
//public static string connStr = ConfigurationManager.AppSettings["database"].ToString();
public static string connStr = ConfigurationManager.ConnectionStrings["database"].ToString();
public UserList CheckUserByFingerPrinter(int fingerPrinterId)
public UserList CheckUserByFingerPrinter(int fingerPrinterId)
{
UserList? user = null;
using (MySqlConnection con = new MySqlConnection(connStr))
{
logger.Info($"connStr{connStr}");
try
//try
//{
// con.Open();
//}
//catch (Exception ex)
//{
// logger.Info($"Open失败{ex.ToString()}");
// if (con.State == System.Data.ConnectionState.Open)
// {
// con.Close();
// }
// Thread.Sleep(200);
// logger.Info("再次Open");
// con.Open();
//}
connOpen(con);
Thread.Sleep(100);
while(con.State != System.Data.ConnectionState.Open)
{
con.Open();
}
catch (Exception ex)
{
logger.Info($"Open失败{ex.ToString()}");
if (con.State == System.Data.ConnectionState.Open)
{
con.Close();
}
Thread.Sleep(200);
logger.Info("再次Open");
con.Open();
connOpen(con);
Thread.Sleep(100);
}
logger.Info("数据库连接已打开");
string sql = @"select ul.id as id,ul.User_name as userName,r.id,r.role_name,r.permissions,r.machine_id from user_list ul
INNER JOIN role r on ul.machine_role_id=r.id where ul.Id=@ID and ul.machine_id=@machine_id and r.machine_id=@machine_id;";
@ -65,11 +74,32 @@ namespace DM_Weight.Services
role.Permissions = JsonConvert.DeserializeObject<List<PremissionDm>>(reader["permissions"] is DBNull ? "" : reader.GetString("permissions")); // JsonConvert.SerializeObject(reader.GetString("permissions")).ToList();
user.Role = role;
}
reader.Close();
logger.Info($"sql{sql}");
return user;
}
}
private Task connOpen(MySqlConnection con)
{
return Task.Run(() =>
{
if (con.State == System.Data.ConnectionState.Open)
{
con.Close();
}
try
{
con.Open();
}
catch (Exception ex)
{
logger.Info($"Open失败{ex.Message}");
}
});
}
}
}

View File

@ -490,7 +490,6 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5)
.GroupBy(it => new
{
@ -500,18 +499,64 @@ namespace DM_Weight.ViewModels
{
var ret = it.First();
ret.CheckQuantity = it.Sum(itx => itx.CheckQuantity);
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
ret.Quantity = it.Sum(itx => itx.Quantity);
return ret;
}).ToList();
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
}).OrderBy(it => it.EffDate).ToList();
if (singleChannels != null && singleChannels.Count > 0)
{
singleChannels.ForEach(it =>
for (int i = 0; i < singleChannels.Count; i++)
{
// 将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
});
List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
//.Where(cs=>cs.Quantity>0)
.OrderBy(cs => cs.EffDate)
.ToList();
//.Sum(it => it.Quantity);
if (singleChannels[i].Quantity != singleChannels[i].CheckQuantity)
{
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(channel[0].DrawerNo, channel[0].ColNo, channel.Sum(c => c.Quantity));
Thread.Sleep(500);
}
//如果最近效期的批次库存为0则重新绑定批次效期标签为库存不为0的近效期的标签
if (channel[0].Quantity == 0)
{
ChannelStock cs = channel.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
if (cs != null)
{
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
}
}
else
{
//判断盘点前数量是否是0盘点前数量为0的可能已经把标签绑定的批次效期替换了所以要更新回来
int beForeQuantity = record.Where(it => it.DrawerNo == channel[0].DrawerNo && it.ColNo == channel[0].ColNo && it.ManuNo == channel[0].ManuNo && it.EffDate == channel[0].EffDate).Select(s => s.Quantity).Min();
if (beForeQuantity == 0)
{
_portUtil.WriteChannelInfo(6, channel[0].EffDate == null ? "" : channel[0].EffDate, channel[0].DrawerNo, channel[0].ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, channel[0].ManuNo, channel[0].DrawerNo, channel[0].ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(channel[0].DrawerNo, channel[0].ColNo);
}
}
}
}
//singleChannels.ForEach(it =>
//{
// // 将库位多批次的总库存数更新标签
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
//});
logger.Info("已完成-更新标签");
AlertMsg alertMsg = new AlertMsg
{

View File

@ -21,6 +21,7 @@ using DM_Weight.util;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using System.Windows.Controls;
using System.Threading.Channels;
namespace DM_Weight.ViewModels
{
@ -35,11 +36,11 @@ namespace DM_Weight.ViewModels
get => _channelStocks;
set => SetProperty(ref _channelStocks, value);
}
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
@ -93,7 +94,7 @@ namespace DM_Weight.ViewModels
break;
}
}
}
private int _status;
@ -129,7 +130,7 @@ namespace DM_Weight.ViewModels
}, (DrawerNo) => Status == 0
);
}
public DelegateCommand OpenDrawer
{
@ -144,7 +145,7 @@ namespace DM_Weight.ViewModels
// group t by new { t.ColNo, t.BoardType }
// into grp
// select new { grp.Key.ColNo, grp.Key.BoardType, quantity = grp.Sum(t => t.Quantity) }).ToList();
List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
_portUtil.WindowName = "DrawerTakeDrugWindow";
@ -206,7 +207,7 @@ namespace DM_Weight.ViewModels
ColNo = it.ColNo,
DrugId = it.DrugId,
ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ?DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture):null,
EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
@ -224,12 +225,19 @@ namespace DM_Weight.ViewModels
}
return true;
});
if (f.Data)
if (f.Data)
{
logger.Info("更新屏显库存singleChannels");
// 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
List<ChannelStock> singleChannels = new List<ChannelStock>();
for (int i = 0; i < ChannelStocks.Count; i++)
{
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(ChannelStocks[i]);
singleChannels.Add(copy);
}
singleChannels = singleChannels.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
@ -237,7 +245,7 @@ namespace DM_Weight.ViewModels
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
return ret;
}).ToList();
}).OrderBy(it => it.Quantity).ToList();
singleChannels = singleChannels.Where(it => it.TakeQuantity > 0).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
@ -248,6 +256,44 @@ namespace DM_Weight.ViewModels
{
_portUtil.WriteQuantityAsync(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
Thread.Sleep(500);
//string varCS = from cs in ChannelStocks orderby cs.EffDate group cs by cs.ColNo into g orderby g.Key select g.;
List<ChannelStock> groupCS = ChannelStocks
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
return ret;
}).ToList();
if (groupCS != null)
{
for (int i = 0; i < groupCS.Count; i++)
{
//全部取出
if (groupCS[i].Quantity == groupCS[i].TakeQuantity)
{
//查询该库位下非0的近效期及批次重新绑定
//更新绑定的效期、批次
ChannelStock newBind= SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == groupCS[i].MachineId)
.Where(cs => cs.DrawerNo == groupCS[i].DrawerNo)
.Where(cs => cs.ColNo == groupCS[i].ColNo)
.Where(cs=>cs.Quantity>0)
.OrderBy(cs => cs.EffDate)
.First();
_portUtil.WriteChannelInfo(6, newBind.EffDate == null ? "" : newBind.EffDate, newBind.DrawerNo, newBind.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, newBind.ManuNo, newBind.DrawerNo, newBind.ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(newBind.DrawerNo, newBind.ColNo);
}
}
}
}
logger.Info("更新屏显库存singleChannels_完成");
RequestData();
@ -282,7 +328,7 @@ namespace DM_Weight.ViewModels
}
}
});
}
@ -330,6 +376,7 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.Quantity > 0)
.OrderBy(cs => cs.ColNo)
.OrderBy(cs => cs.EffDate)
.ToList();
ChannelStocks = queryData;
}

View File

@ -37,7 +37,7 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
IDialogService _dialogService;
//private SqlSugarScope SqlSugarHelper.Db;
public OrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
{
@ -171,11 +171,11 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
.Includes<DrugInfo>(od => od.DrugInfo)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
.Where(od => od.OrderNo == OrderInfo.OrderNo)
.ToList();
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
.Includes<DrugInfo>(od => od.DrugInfo)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
.Where(od => od.OrderNo == OrderInfo.OrderNo)
.ToList();
List<ChannelStock> channelStocks = new List<ChannelStock>();
List<string> msg = new List<string>();
@ -194,7 +194,7 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.DrugId == orderDetail.DrugId)
.OrderBy(cs => cs.EffDate)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs=> cs.ManuNo)
.OrderBy(cs => cs.ManuNo)
.ToList();
int total = HasQChannels.Sum(it => it.Quantity);
int TakeQ = orderDetail.Quantity;
@ -230,7 +230,7 @@ namespace DM_Weight.ViewModels
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("msgInfo", msg);
DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
}
else
{
@ -279,17 +279,17 @@ namespace DM_Weight.ViewModels
singleChannels.Add(copy);
}
singleChannels = singleChannels
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(it => it.Quantity);
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
return ret;
})
.ToList()
.FindAll(it => it.BoardType != 1);
singleChannels = singleChannels
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(it => it.Quantity);
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
return ret;
})
.ToList()
.FindAll(it => it.BoardType != 1);
// 发送取药数量
singleChannels.ForEach(it =>
@ -331,12 +331,14 @@ namespace DM_Weight.ViewModels
string InvoiceId = OrderInfo.OrderNo;
var f = SqlSugarHelper.Db.UseTran(() =>
{
logger.Info($"更新OrderInfo:{InvoiceId}");
SqlSugarHelper.Db.Updateable(new OrderInfo()
{
DmStatus = 1,
OrderNo = OrderInfo.OrderNo
}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
SqlSugarHelper.Db.Insertable(new OrderFinish()
{
OrderNo = OrderInfo.OrderNo,
@ -345,10 +347,12 @@ namespace DM_Weight.ViewModels
State = 1,
Operator = HomeWindowViewModel.Operator?.Nickname,
});
logger.Info("进入record循环");
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
logger.Info($"更新ChannelStock:{it.Id}");
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
@ -357,13 +361,14 @@ namespace DM_Weight.ViewModels
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
logger.Info($"保存MachineRecord:{it.ManuNo}");
// 保存数据 出库记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
@ -391,46 +396,76 @@ namespace DM_Weight.ViewModels
{
// 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
Task.Factory.StartNew(() =>
{
//List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
// .GroupBy(it =>new {it.DrawerNo, it.ColNo })
// .Select(it =>
// {
// var ret = it.First();
// ret.Quantity = it.Sum(itx => itx.Quantity);
// ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
// ret.EffDate = it.Min(it => it.EffDate);
// ret.ManuNo = it.OrderBy(it => it.ManuNo).Select(it => it.ManuNo).First().ToString();
// return ret;
// })
// .Where(it=>it.Quantity> 0)
// .OrderBy(it => it.EffDate)
// .ToList();
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.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 ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//{
//singleChannels.ForEach(it =>
//{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
//});
//}
if(singleChannels.Count > 0)
{
for (int i = 0; i < singleChannels.Count; i++)
if (singleChannels.Count > 0)
{
if (singleChannels[i].BoardType == 5)
for (int i = 0; i < singleChannels.Count; i++)
{
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
if (singleChannels[i].BoardType == 5)
{
List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
//.Where(cs=>cs.Quantity>0)
.OrderBy(cs => cs.EffDate)
.ToList();
//.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(channel[0].DrawerNo, channel[0].ColNo, channel.Sum(c => c.Quantity));
Thread.Sleep(500);
//如果最近效期的批次库存为0则重新绑定批次效期标签为库存不为0的近效期的标签
if (channel[0].Quantity == 0)
{
ChannelStock cs = channel.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
if (cs != null)
{
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
}
}
}
}
}
}
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存已更新",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存已更新",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}));
});
}
if(!f.IsSuccess)
if (!f.IsSuccess)
{
AlertMsg alertMsg = new AlertMsg
{
@ -438,6 +473,7 @@ namespace DM_Weight.ViewModels
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
RequestData();
}
Status = 0;
_isFinishClick = false;

View File

@ -299,13 +299,39 @@ namespace DM_Weight.ViewModels
{
if (singleChannels[i].BoardType == 5)
{
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.Sum(it => it.Quantity);
//int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
// .Where(cs => cs.MachineId == singleChannels[i].MachineId)
// .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
// .Where(cs => cs.ColNo == singleChannels[i].ColNo)
// .Sum(it => it.Quantity);
////将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
//.Where(cs=>cs.Quantity>0)
.OrderBy(cs => cs.EffDate)
.ToList();
//.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
_portUtil.WriteQuantity(channel[0].DrawerNo, channel[0].ColNo, channel.Sum(c => c.Quantity));
Thread.Sleep(500);
//如果最近效期的批次库存为0则重新绑定批次效期标签为库存不为0的近效期的标签
if (channel[0].Quantity == 0)
{
ChannelStock cs = channel.Where(cs => cs.Quantity > 0).OrderBy(it => it.EffDate).FirstOrDefault();
if (cs != null)
{
_portUtil.WriteChannelInfo(6, cs.EffDate == null ? "" : cs.EffDate, cs.DrawerNo, cs.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, cs.ManuNo, cs.DrawerNo, cs.ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
}
}
}
}
}