From 2ef1c185e36171943dbd2125064349e3ccfd1231 Mon Sep 17 00:00:00 2001
From: maqiao <625215135@qq.com>
Date: Tue, 26 Mar 2024 10:59:21 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E6=8B=96=E5=8A=A8=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=B8=B2=E6=9F=93=E6=A0=87?=
=?UTF-8?q?=E7=AD=BE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=87=BA=E3=80=81=E5=85=A5?=
=?UTF-8?q?=E5=BA=93=E9=A1=B5=E9=9D=A2=E7=BB=91=E5=AE=9A=E6=89=B9=E6=AC=A1?=
=?UTF-8?q?=20=E6=95=88=E6=9C=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DM_Weight/App.config | 4 +-
DM_Weight/DM_Weight.csproj | 1 +
DM_Weight/Models/ChannelStock.cs | 8 +
DM_Weight/Services/UserService.cs | 2 +-
.../ViewModels/AddDrugControlViewModel.cs | 2 +-
.../BindingChannelNewDialogViewModel.cs | 9 +-
.../DrawerAddDrugWindowViewModel.cs | 48 +++--
.../DrawerTakeDrugWindowViewModel.cs | 16 +-
.../ViewModels/InvoiceInNewWindowViewModel.cs | 9 +-
.../ViewModels/OrderReturnDialogViewModel.cs | 30 ++-
.../ViewModels/OrderTakeDialogViewModel.cs | 203 ++++++++++++++----
.../ViewModels/ReturnDrugDialogViewModel.cs | 33 ++-
.../ViewModels/SelfAddDialogViewModel.cs | 47 +++-
.../ViewModels/SelfTakeDialogViewModel.cs | 5 +-
.../Views/Dialog/BindingChannelNewDialog.xaml | 4 +-
DM_Weight/Views/MainWindow.xaml | 4 +-
16 files changed, 327 insertions(+), 98 deletions(-)
diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 3667ffb..7cba26c 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -3,7 +3,7 @@
-
+
-
+
diff --git a/DM_Weight/DM_Weight.csproj b/DM_Weight/DM_Weight.csproj
index 79dd253..0a29539 100644
--- a/DM_Weight/DM_Weight.csproj
+++ b/DM_Weight/DM_Weight.csproj
@@ -71,6 +71,7 @@
+
diff --git a/DM_Weight/Models/ChannelStock.cs b/DM_Weight/Models/ChannelStock.cs
index 2a6a89b..1c3f38e 100644
--- a/DM_Weight/Models/ChannelStock.cs
+++ b/DM_Weight/Models/ChannelStock.cs
@@ -112,6 +112,10 @@ namespace DM_Weight.Models
get => _addQuantity;
set
{
+ if (value < 0)
+ {
+ throw new ArgumentException("加药数量不能小于0");
+ }
SetProperty(ref _addQuantity, value);
}
}
@@ -128,6 +132,10 @@ namespace DM_Weight.Models
{
throw new ArgumentException("取药数量不能大于库存");
}
+ if(value< 0)
+ {
+ throw new ArgumentException("取药数量不能小于0");
+ }
SetProperty(ref _takeQuantity, value);
}
}
diff --git a/DM_Weight/Services/UserService.cs b/DM_Weight/Services/UserService.cs
index c8eb756..c4bd4fa 100644
--- a/DM_Weight/Services/UserService.cs
+++ b/DM_Weight/Services/UserService.cs
@@ -44,7 +44,7 @@ namespace DM_Weight.Services
Thread.Sleep(100);
while(con.State != System.Data.ConnectionState.Open)
{
- logger.Info("再次Open");
+ logger.Info($"再次Open:{con.State}");
connOpen(con);
Thread.Sleep(100);
}
diff --git a/DM_Weight/ViewModels/AddDrugControlViewModel.cs b/DM_Weight/ViewModels/AddDrugControlViewModel.cs
index 2bec9cc..d0c1ca9 100644
--- a/DM_Weight/ViewModels/AddDrugControlViewModel.cs
+++ b/DM_Weight/ViewModels/AddDrugControlViewModel.cs
@@ -342,7 +342,7 @@ namespace DM_Weight.ViewModels
}
// 更新屏显库存
//List singleChannels = record.FindAll(it => it.BoardType != 1);
- List singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
+ List singleChannels = ChannelStocks.Where(it => it.BoardType ==5&&(it.Quantity>0||it.AddQuantity>0))
.GroupBy(it => it.ColNo)
.Select(it =>
{
diff --git a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
index c0af7f4..343ed9d 100644
--- a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
+++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
@@ -469,7 +469,6 @@ namespace DM_Weight.ViewModels
}
});
}
-
public DelegateCommand RemoveBinding
{
get => new DelegateCommand(async () =>
@@ -554,6 +553,14 @@ namespace DM_Weight.ViewModels
Thread.Sleep(200);
_portUtil.WriteChannelInfo(8, drugSelected.Manufactory == null ? "" : drugSelected.Manufactory.Length > 10 ? drugSelected.Manufactory.Substring(0, 10) : drugSelected.Manufactory, item.DrawerNo, item.ColNo);
Thread.Sleep(200);
+ //查询该库存下库存不为0的近效期的批次效期
+ ChannelStock channelStock = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId == item.MachineId && cs.DrawerNo == item.DrawerNo && cs.ColNo == item.ColNo && cs.Quantity > 0)
+ .OrderBy(cs => cs.EffDate).First();
+ _portUtil.WriteChannelInfo(6, channelStock.EffDate == null ? "" : channelStock.EffDate, item.DrawerNo, item.ColNo);
+ Thread.Sleep(200);
+ _portUtil.WriteChannelInfo(5, channelStock.ManuNo == null ? "" : channelStock.ManuNo, item.DrawerNo, item.ColNo);
+ Thread.Sleep(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteQuantity(item.DrawerNo, item.ColNo, item.totalCount);
diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
index 24789af..ce87a3d 100644
--- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
@@ -17,6 +17,7 @@ using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using System.Collections.ObjectModel;
+using System.Threading;
namespace DM_Weight.ViewModels
{
@@ -186,7 +187,7 @@ namespace DM_Weight.ViewModels
if (!_isFinishClick)
{
_isFinishClick = true;
- List record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
+ List record = ChannelStocks.FindAll(it => it.AddQuantity > 0).ToList();
if (record.Count > 0)
{
//string InvoiceId = "DRAWER_" + CurrentTimeMillis();
@@ -241,21 +242,44 @@ 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(it => it.Quantity);
- ret.AddQuantity = it.Sum(it => it.AddQuantity);
- return ret;
- }).ToList();
- singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList();
- if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
+ //List singleChannels = ChannelStocks.Where(it => it.BoardType == 5 && (it.Quantity > 0 || it.AddQuantity > 0))
+ // .GroupBy(it => it.ColNo)
+ // .Select(it =>
+ // {
+ // var ret = it.First();
+ // ret.Quantity = it.Sum(it => it.Quantity);
+ // ret.AddQuantity = it.Sum(it => it.AddQuantity);
+ // return ret;
+ // })
+ // .OrderBy(it => it.EffDate).ToList();
+
+ List singleChannels = ChannelStocks.Where(it => it.BoardType == 5 && (it.Quantity > 0 || it.AddQuantity > 0))
+ .GroupBy(it => it.ColNo)
+ .Select(it =>
+ {
+ var ret = it.First();
+ ret.Quantity = it.Sum(itx => itx.Quantity);
+ ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
+ ret.EffDate = it.Min(it => it.EffDate);
+ ret.ManuNo = it.OrderBy(it => it.ManuNo).Select(it => it.ManuNo).First().ToString();
+ return ret;
+ })
+ .OrderBy(it => it.EffDate)
+ .ToList();
+
+ //singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList();
+ if (singleChannels.Count > 0)
{
//将库位多批次的总库存数更新标签
singleChannels.ForEach(it =>
{
+ _portUtil.WriteChannelInfo(6, it.EffDate == null ? "" : it.EffDate, it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
+ _portUtil.WriteChannelInfo(5, it.ManuNo, it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
+ _portUtil.ShowContent(it.DrawerNo, it.ColNo);
+
+ Thread.Sleep(500);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
}
diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
index 99f99fd..6d23c6a 100644
--- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
@@ -168,7 +168,7 @@ namespace DM_Weight.ViewModels
if (!_isFinishClick)
{
_isFinishClick = true;
- List record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
+ List record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
if (record.Count > 0)
{
@@ -284,12 +284,14 @@ namespace DM_Weight.ViewModels
.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);
-
+ if (newBind != null)
+ {
+ _portUtil.WriteChannelInfo(6, newBind.EffDate == null ? "" : newBind.EffDate, newBind.DrawerNo , newBind.ColNo);
+ Thread.Sleep(200);
+ _portUtil.WriteChannelInfo(5, newBind.ManuNo == null ? "" : newBind.ManuNo, newBind.DrawerNo, newBind.ColNo);
+ Thread.Sleep(200);
+ _portUtil.ShowContent(newBind.DrawerNo, newBind.ColNo);
+ }
}
}
diff --git a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs
index f6fe068..b7706fc 100644
--- a/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs
@@ -619,7 +619,7 @@ namespace DM_Weight.ViewModels
{
// 更新屏显库存
//List singleChannels = record.FindAll(it => it.BoardType != 1);
- List singleChannels = record.Where(it => it.BoardType != 1)
+ List singleChannels = record.Where(it => it.BoardType == 5)
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
@@ -633,12 +633,13 @@ namespace DM_Weight.ViewModels
{
for (int i = 0; i < singleChannels.Count; i++)
{
- if (singleChannels[i].BoardType == 5)
- {
+ //if (singleChannels[i].BoardType == 5)
+ //{
List channelStockEffDate = 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();
int totalQuantity = channelStockEffDate.Sum(it => it.Quantity);
@@ -650,7 +651,7 @@ namespace DM_Weight.ViewModels
_portUtil.WriteChannelInfo(5, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
- }
+ //}
}
}
diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
index 79fc581..54df2e3 100644
--- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
@@ -386,13 +386,29 @@ 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);
- //将库位多批次的总库存数更新标签
- _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
+ List channels = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId == singleChannels[i].MachineId)
+ .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
+ .Where(cs => cs.ColNo == singleChannels[i].ColNo)
+ .OrderBy(cs => cs.EffDate).ToList();
+ if (channels != null && channels.Count > 0)
+ {
+ if (channels[0].Quantity == 0)
+ {
+ //近效期的数量是0,则查该抽屉库位下库存不是0的,有则绑定
+ ChannelStock cs = channels.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);
+ }
+ }
+ //将库位多批次的总库存数更新标签
+ _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, channels.Sum(cs => cs.Quantity));
+ }
}
}
}
diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
index 917350e..358ec18 100644
--- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
@@ -329,24 +329,16 @@ namespace DM_Weight.ViewModels
if (record.Count > 0)
{
string InvoiceId = OrderInfo.OrderNo;
- var f = SqlSugarHelper.Db.UseTran(() =>
+ try
{
+ SqlSugarHelper.Db.BeginTran();
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,
- PatientId = OrderInfo.PatientId,
- Pharmacy = OrderInfo.Pharmacy,
- State = 1,
- Operator = HomeWindowViewModel.Operator?.Nickname,
- });
+
logger.Info("进入record循环");
for (int i = 0; i < record.Count; i++)
{
@@ -389,45 +381,29 @@ namespace DM_Weight.ViewModels
SupplierDept = ConfigurationManager.AppSettings["receiveDept"].ToString(),
ReceiveDept = OrderInfo.DeptName
}).ExecuteCommand();
+ logger.Info("结束循环");
}
- return true;
- });
- if (f.Data)
- {
+
+ SqlSugarHelper.Db.CommitTran();
+
+ logger.Info("事务已提交");
// 更新屏显库存
//List singleChannels = record.FindAll(it => it.BoardType != 1);
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)
+ List singleChannels = record.Where(it => it.BoardType == 5)
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
return ret;
}).ToList();
+ logger.Info("查询数据并写标签");
if (singleChannels.Count > 0)
{
for (int i = 0; i < singleChannels.Count; i++)
{
- if (singleChannels[i].BoardType == 5)
- {
- List channel = SqlSugarHelper.Db.Queryable()
+ 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)
@@ -451,11 +427,11 @@ namespace DM_Weight.ViewModels
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
}
}
- }
}
}
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
+ logger.Info($"抽屉取药完成,库存已更新");
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存已更新",
@@ -464,17 +440,168 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent().Publish(alertMsg);
}));
});
+
}
- if (!f.IsSuccess)
+ catch (Exception ex)
{
+ SqlSugarHelper.Db.RollbackTran();
+ logger.Info($"抽屉取药完成,库存更新失败!{ex.Message}");
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存更新失败!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent().Publish(alertMsg);
- RequestData();
}
+
+ //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,
+ // // PatientId = OrderInfo.PatientId,
+ // // Pharmacy = OrderInfo.Pharmacy,
+ // // 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()
+ // {
+ // Quantity = it.Quantity - it.TakeQuantity,
+ // ManuNo = it.ManuNo,
+ // 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()
+ // {
+ // MachineId = it.MachineId,
+ // DrawerNo = it.DrawerNo,
+ // 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,
+ // Operator = HomeWindowViewModel.Operator?.Id,
+ // Reviewer = HomeWindowViewModel.Reviewer?.Id,
+ // OperationTime = DateTime.Now,
+ // Quantity = it.TakeQuantity,
+ // Type = 2,
+ // InvoiceId = InvoiceId,
+ // StockQuantity = nowChannels.Sum(it => it.Quantity),
+ // ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
+ // SupplierDept = ConfigurationManager.AppSettings["receiveDept"].ToString(),
+ // ReceiveDept = OrderInfo.DeptName
+ // }).ExecuteCommand();
+ // }
+ // return true;
+ //});
+ //if (f.Data)
+ //{
+ // // 更新屏显库存
+ // //List singleChannels = record.FindAll(it => it.BoardType != 1);
+ // 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();
+ // return ret;
+ // }).ToList();
+ // if (singleChannels.Count > 0)
+ // {
+ // for (int i = 0; i < singleChannels.Count; i++)
+ // {
+ // 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);
+ // }
+ // }
+ // }
+ // }
+ // }
+ // System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+ // {
+ // logger.Info($"抽屉取药完成,库存已更新");
+ // AlertMsg alertMsg = new AlertMsg
+ // {
+ // Message = "抽屉取药完成,库存已更新",
+ // Type = MsgType.SUCCESS,
+ // };
+ // _eventAggregator.GetEvent().Publish(alertMsg);
+ // }));
+ // });
+ //}
+ //if (!f.IsSuccess)
+ //{
+ // logger.Info($"抽屉取药完成,库存更新失败!");
+ // AlertMsg alertMsg = new AlertMsg
+ // {
+ // Message = "抽屉取药完成,库存更新失败!",
+ // Type = MsgType.ERROR,
+ // };
+ // _eventAggregator.GetEvent().Publish(alertMsg);
+ // RequestData();
+ //}
Status = 0;
_isFinishClick = false;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
index 86d2aef..2921c41 100644
--- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
@@ -17,6 +17,7 @@ using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using SqlSugar;
+using System.Threading;
namespace DM_Weight.ViewModels
{
@@ -279,16 +280,30 @@ namespace DM_Weight.ViewModels
// 更新屏显库存
if (ChannelStock.BoardType == 5)
{
- //_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
- int totalQuantity = SqlSugarHelper.Db.Queryable()
- .Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
- .Where(cs => cs.DrawerNo == ChannelStock.DrawerNo)
- .Where(cs => cs.ColNo == ChannelStock.ColNo)
- .Sum(it => it.Quantity);
-
- _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, totalQuantity);
+ List channels = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId == ChannelStock.MachineId)
+ .Where(cs => cs.DrawerNo == ChannelStock.DrawerNo)
+ .Where(cs => cs.ColNo == ChannelStock.ColNo)
+ .OrderBy(cs => cs.EffDate).ToList();
+ if (channels != null && channels.Count > 0)
+ {
+ if (channels[0].Quantity == 0)
+ {
+ //近效期的数量是0,则查该抽屉库位下库存不是0的,有则绑定
+ ChannelStock cs = channels.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);
+ }
+ }
+ //将库位多批次的总库存数更新标签
+ _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, channels.Sum(cs => cs.Quantity));
+ }
}
-
AlertMsg alertMsg = new AlertMsg
{
Message = "操作完成,库存已更新",
diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
index fe60ce0..5cacc09 100644
--- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
@@ -21,6 +21,7 @@ using System.Threading;
using SqlSugar;
using System.Configuration;
using System.Collections;
+using System.Threading.Channels;
namespace DM_Weight.ViewModels
{
@@ -316,7 +317,7 @@ namespace DM_Weight.ViewModels
{
// 更新屏显库存
//List singleChannels = record.FindAll(it => it.BoardType != 1);
- List singleChannels = record.Where(it => it.BoardType != 1)
+ List singleChannels = record.Where(it => it.BoardType == 5)
.GroupBy(it => new { it.DrawerNo,it.ColNo })
.Select(it =>
{
@@ -341,13 +342,43 @@ 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);
- //将库位多批次的总库存数更新标签
- _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
+ //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);
+
+ List channels = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId == singleChannels[i].MachineId)
+ .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
+ .Where(cs => cs.ColNo == singleChannels[i].ColNo)
+ .OrderBy(cs => cs.EffDate).ToList();
+ if (channels != null && channels.Count > 0)
+ {
+ if (channels[0].Quantity==0)
+ {
+ //近效期的数量是0,则查该抽屉库位下库存不是0的,有则绑定
+ ChannelStock cs = channels.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
+ {
+ _portUtil.WriteChannelInfo(6, channels[0].EffDate == null ? "" : channels[0].EffDate, channels[0].DrawerNo, channels[0].ColNo);
+ Thread.Sleep(200);
+ _portUtil.WriteChannelInfo(5, channels[0].ManuNo, channels[0].DrawerNo, channels[0].ColNo);
+ Thread.Sleep(200);
+ _portUtil.ShowContent(channels[0].DrawerNo, channels[0].ColNo);
+ }
+ //将库位多批次的总库存数更新标签
+ _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, channels.Sum(cs => cs.Quantity));
+ }
}
}
}
diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
index 0a71a30..d2ef8ef 100644
--- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
@@ -274,7 +274,7 @@ namespace DM_Weight.ViewModels
{
// 更新屏显库存
//List singleChannels = record.FindAll(it => it.BoardType != 1);
- List singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
+ List singleChannels = ChannelStocks.Where(it => it.BoardType == 5)
.GroupBy(it =>new { it.DrawerNo, it.ColNo })
.Select(it =>
{
@@ -297,8 +297,6 @@ namespace DM_Weight.ViewModels
{
for (int i = 0; i < singleChannels.Count; i++)
{
- if (singleChannels[i].BoardType == 5)
- {
//int totalQuantity = SqlSugarHelper.Db.Queryable()
// .Where(cs => cs.MachineId == singleChannels[i].MachineId)
// .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
@@ -332,7 +330,6 @@ namespace DM_Weight.ViewModels
_portUtil.ShowContent(cs.DrawerNo, cs.ColNo);
}
}
- }
}
}
diff --git a/DM_Weight/Views/Dialog/BindingChannelNewDialog.xaml b/DM_Weight/Views/Dialog/BindingChannelNewDialog.xaml
index 41f83b3..a19e096 100644
--- a/DM_Weight/Views/Dialog/BindingChannelNewDialog.xaml
+++ b/DM_Weight/Views/Dialog/BindingChannelNewDialog.xaml
@@ -81,7 +81,7 @@
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
- />
+ />-->
-->
+ />