diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 37d69bf..3667ffb 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -3,7 +3,7 @@
-
+
-
+
diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs
index 34a4f40..3a31637 100644
--- a/DM_Weight/App.xaml.cs
+++ b/DM_Weight/App.xaml.cs
@@ -257,7 +257,7 @@ namespace DM_Weight
//交接班
containerRegistry.RegisterForNavigation();
- containerRegistry.RegisterSingleton(() => SqlSugarHelperNew.GetInstance());
+ //containerRegistry.RegisterSingleton(() => SqlSugarHelperNew.GetInstance());
//账册页面
containerRegistry.RegisterForNavigation();
diff --git a/DM_Weight/Services/UserService.cs b/DM_Weight/Services/UserService.cs
index 17ab5a0..c8eb756 100644
--- a/DM_Weight/Services/UserService.cs
+++ b/DM_Weight/Services/UserService.cs
@@ -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>(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}");
+ }
+ });
+ }
+
+
}
}
diff --git a/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs
index f7997de..1359dd3 100644
--- a/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs
@@ -490,7 +490,6 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
- //List singleChannels = record.FindAll(it => it.BoardType != 1);
List 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 channel = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId == singleChannels[i].MachineId)
+ .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
+ .Where(cs => cs.ColNo == singleChannels[i].ColNo)
+ //.Where(cs=>cs.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
{
diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
index 3a99f38..99f99fd 100644
--- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
@@ -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 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 singleChannels = record.FindAll(it => it.BoardType != 1);
- List singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
+
+ List singleChannels = new List();
+ for (int i = 0; i < ChannelStocks.Count; i++)
+ {
+ ChannelStock copy = TransExpV2.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 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()
+ .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;
}
diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
index f1977ab..917350e 100644
--- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
@@ -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()
- .Includes(od => od.DrugInfo)
- .InnerJoin(SqlSugarHelper.Db.Queryable().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()
+ .Includes(od => od.DrugInfo)
+ .InnerJoin(SqlSugarHelper.Db.Queryable().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 channelStocks = new List();
List msg = new List();
@@ -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 nowChannels = SqlSugarHelper.Db.Queryable()
.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 singleChannels = record.FindAll(it => it.BoardType != 1);
- List singleChannels = record.Where(it => it.BoardType != 1)
- .GroupBy(it => it.ColNo)
+ Task.Factory.StartNew(() =>
+ {
+ //List 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 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()
- .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 channel = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId == singleChannels[i].MachineId)
+ .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
+ .Where(cs => cs.ColNo == singleChannels[i].ColNo)
+ //.Where(cs=>cs.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().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().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().Publish(alertMsg);
+ RequestData();
}
Status = 0;
_isFinishClick = false;
diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
index 2b7aaec..0a71a30 100644
--- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
@@ -299,13 +299,39 @@ namespace DM_Weight.ViewModels
{
if (singleChannels[i].BoardType == 5)
{
- int totalQuantity = SqlSugarHelper.Db.Queryable()
- .Where(cs => cs.MachineId == singleChannels[i].MachineId)
- .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
- .Where(cs => cs.ColNo == singleChannels[i].ColNo)
- .Sum(it => it.Quantity);
+ //int totalQuantity = SqlSugarHelper.Db.Queryable()
+ // .Where(cs => cs.MachineId == singleChannels[i].MachineId)
+ // .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
+ // .Where(cs => cs.ColNo == singleChannels[i].ColNo)
+ // .Sum(it => it.Quantity);
+ ////将库位多批次的总库存数更新标签
+ //_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
+
+
+ List channel = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId == singleChannels[i].MachineId)
+ .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
+ .Where(cs => cs.ColNo == singleChannels[i].ColNo)
+ //.Where(cs=>cs.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);
+ }
+ }
}
}
}