更新取药时库存为0则检测绑定标签并是否需要重新绑定批次、效期
This commit is contained in:
parent
db02d51934
commit
4f0297f4bc
|
@ -3,7 +3,7 @@
|
||||||
<connectionStrings>
|
<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;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>
|
</connectionStrings>
|
||||||
<!--<runtime>
|
<!--<runtime>
|
||||||
--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
|
--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<!-- 按处方还药或者按取药记录还药 1:处方2:药品-->
|
<!-- 按处方还药或者按取药记录还药 1:处方2:药品-->
|
||||||
<add key="returnDrugMode" value="1" />
|
<add key="returnDrugMode" value="1" />
|
||||||
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
<!-- 自动退出时间,单位秒,为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;"/>
|
<add key="gridConnectionString" value="MYSQL; Database=hunanxianchang_db; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
|
||||||
<!-- 查询处方是orderNo还是orderGroupNo -->
|
<!-- 查询处方是orderNo还是orderGroupNo -->
|
||||||
|
|
|
@ -257,7 +257,7 @@ namespace DM_Weight
|
||||||
//交接班
|
//交接班
|
||||||
containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
|
containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
|
||||||
|
|
||||||
containerRegistry.RegisterSingleton<SqlSugarScope>(() => SqlSugarHelperNew.GetInstance());
|
//containerRegistry.RegisterSingleton<SqlSugarScope>(() => SqlSugarHelperNew.GetInstance());
|
||||||
|
|
||||||
//账册页面
|
//账册页面
|
||||||
containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
|
containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
|
||||||
|
|
|
@ -18,28 +18,37 @@ namespace DM_Weight.Services
|
||||||
private readonly ILog logger = LogManager.GetLogger(typeof(UserService));
|
private readonly ILog logger = LogManager.GetLogger(typeof(UserService));
|
||||||
//public static string connStr = ConfigurationManager.AppSettings["database"].ToString();
|
//public static string connStr = ConfigurationManager.AppSettings["database"].ToString();
|
||||||
public static string connStr = ConfigurationManager.ConnectionStrings["database"].ToString();
|
public static string connStr = ConfigurationManager.ConnectionStrings["database"].ToString();
|
||||||
public UserList CheckUserByFingerPrinter(int fingerPrinterId)
|
public UserList CheckUserByFingerPrinter(int fingerPrinterId)
|
||||||
{
|
{
|
||||||
UserList? user = null;
|
UserList? user = null;
|
||||||
|
|
||||||
using (MySqlConnection con = new MySqlConnection(connStr))
|
using (MySqlConnection con = new MySqlConnection(connStr))
|
||||||
{
|
{
|
||||||
logger.Info($"connStr:{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");
|
logger.Info("再次Open");
|
||||||
con.Open();
|
connOpen(con);
|
||||||
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("数据库连接已打开");
|
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
|
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;";
|
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();
|
role.Permissions = JsonConvert.DeserializeObject<List<PremissionDm>>(reader["permissions"] is DBNull ? "" : reader.GetString("permissions")); // JsonConvert.SerializeObject(reader.GetString("permissions")).ToList();
|
||||||
user.Role = role;
|
user.Role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
reader.Close();
|
||||||
logger.Info($"sql:{sql}");
|
logger.Info($"sql:{sql}");
|
||||||
return user;
|
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}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,6 @@ namespace DM_Weight.ViewModels
|
||||||
if (f.Data)
|
if (f.Data)
|
||||||
{
|
{
|
||||||
// 更新屏显库存
|
// 更新屏显库存
|
||||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
|
||||||
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5)
|
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType == 5)
|
||||||
.GroupBy(it => new
|
.GroupBy(it => new
|
||||||
{
|
{
|
||||||
|
@ -500,18 +499,64 @@ namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
var ret = it.First();
|
var ret = it.First();
|
||||||
ret.CheckQuantity = it.Sum(itx => itx.CheckQuantity);
|
ret.CheckQuantity = it.Sum(itx => itx.CheckQuantity);
|
||||||
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||||
return ret;
|
return ret;
|
||||||
}).ToList();
|
}).OrderBy(it => it.EffDate).ToList();
|
||||||
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
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("已完成-更新标签");
|
logger.Info("已完成-更新标签");
|
||||||
AlertMsg alertMsg = new AlertMsg
|
AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@ using DM_Weight.util;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Threading.Channels;
|
||||||
|
|
||||||
namespace DM_Weight.ViewModels
|
namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -35,11 +36,11 @@ namespace DM_Weight.ViewModels
|
||||||
get => _channelStocks;
|
get => _channelStocks;
|
||||||
set => SetProperty(ref _channelStocks, value);
|
set => SetProperty(ref _channelStocks, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly DateTime Jan1st1970 = new DateTime
|
private static readonly DateTime Jan1st1970 = new DateTime
|
||||||
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private PortUtil _portUtil;
|
private PortUtil _portUtil;
|
||||||
IEventAggregator _eventAggregator;
|
IEventAggregator _eventAggregator;
|
||||||
|
@ -93,7 +94,7 @@ namespace DM_Weight.ViewModels
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _status;
|
private int _status;
|
||||||
|
@ -129,7 +130,7 @@ namespace DM_Weight.ViewModels
|
||||||
}, (DrawerNo) => Status == 0
|
}, (DrawerNo) => Status == 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DelegateCommand OpenDrawer
|
public DelegateCommand OpenDrawer
|
||||||
{
|
{
|
||||||
|
@ -144,7 +145,7 @@ namespace DM_Weight.ViewModels
|
||||||
// group t by new { t.ColNo, t.BoardType }
|
// group t by new { t.ColNo, t.BoardType }
|
||||||
// into grp
|
// into grp
|
||||||
// select new { grp.Key.ColNo, grp.Key.BoardType, quantity = grp.Sum(t => t.Quantity) }).ToList();
|
// select new { grp.Key.ColNo, grp.Key.BoardType, quantity = grp.Sum(t => t.Quantity) }).ToList();
|
||||||
|
|
||||||
List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
|
List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
|
||||||
|
|
||||||
_portUtil.WindowName = "DrawerTakeDrugWindow";
|
_portUtil.WindowName = "DrawerTakeDrugWindow";
|
||||||
|
@ -206,7 +207,7 @@ namespace DM_Weight.ViewModels
|
||||||
ColNo = it.ColNo,
|
ColNo = it.ColNo,
|
||||||
DrugId = it.DrugId,
|
DrugId = it.DrugId,
|
||||||
ManuNo = it.ManuNo,
|
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,
|
Operator = HomeWindowViewModel.Operator?.Id,
|
||||||
Reviewer = HomeWindowViewModel.Reviewer?.Id,
|
Reviewer = HomeWindowViewModel.Reviewer?.Id,
|
||||||
OperationTime = DateTime.Now,
|
OperationTime = DateTime.Now,
|
||||||
|
@ -224,12 +225,19 @@ namespace DM_Weight.ViewModels
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (f.Data)
|
if (f.Data)
|
||||||
{
|
{
|
||||||
logger.Info("更新屏显库存singleChannels");
|
logger.Info("更新屏显库存singleChannels");
|
||||||
// 更新屏显库存
|
// 更新屏显库存
|
||||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
//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)
|
.GroupBy(it => it.ColNo)
|
||||||
.Select(it =>
|
.Select(it =>
|
||||||
{
|
{
|
||||||
|
@ -237,7 +245,7 @@ namespace DM_Weight.ViewModels
|
||||||
ret.Quantity = it.Sum(itx => itx.Quantity);
|
ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||||
ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
|
ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
|
||||||
return ret;
|
return ret;
|
||||||
}).ToList();
|
}).OrderBy(it => it.Quantity).ToList();
|
||||||
singleChannels = singleChannels.Where(it => it.TakeQuantity > 0).ToList();
|
singleChannels = singleChannels.Where(it => it.TakeQuantity > 0).ToList();
|
||||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
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);
|
_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_完成");
|
logger.Info("更新屏显库存singleChannels_完成");
|
||||||
RequestData();
|
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.DrawerType == 1)
|
||||||
.Where(cs => cs.Quantity > 0)
|
.Where(cs => cs.Quantity > 0)
|
||||||
.OrderBy(cs => cs.ColNo)
|
.OrderBy(cs => cs.ColNo)
|
||||||
|
.OrderBy(cs => cs.EffDate)
|
||||||
.ToList();
|
.ToList();
|
||||||
ChannelStocks = queryData;
|
ChannelStocks = queryData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace DM_Weight.ViewModels
|
||||||
|
|
||||||
private PortUtil _portUtil;
|
private PortUtil _portUtil;
|
||||||
IEventAggregator _eventAggregator;
|
IEventAggregator _eventAggregator;
|
||||||
IDialogService _dialogService;
|
IDialogService _dialogService;
|
||||||
//private SqlSugarScope SqlSugarHelper.Db;
|
//private SqlSugarScope SqlSugarHelper.Db;
|
||||||
public OrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
|
public OrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
|
||||||
{
|
{
|
||||||
|
@ -171,11 +171,11 @@ namespace DM_Weight.ViewModels
|
||||||
|
|
||||||
public void RequestData()
|
public void RequestData()
|
||||||
{
|
{
|
||||||
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
|
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
|
||||||
.Includes<DrugInfo>(od => od.DrugInfo)
|
.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)
|
.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)
|
.Where(od => od.OrderNo == OrderInfo.OrderNo)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
List<ChannelStock> channelStocks = new List<ChannelStock>();
|
List<ChannelStock> channelStocks = new List<ChannelStock>();
|
||||||
List<string> msg = new List<string>();
|
List<string> msg = new List<string>();
|
||||||
|
@ -194,7 +194,7 @@ namespace DM_Weight.ViewModels
|
||||||
.Where(cs => cs.DrugId == orderDetail.DrugId)
|
.Where(cs => cs.DrugId == orderDetail.DrugId)
|
||||||
.OrderBy(cs => cs.EffDate)
|
.OrderBy(cs => cs.EffDate)
|
||||||
.OrderBy(cs => cs.DrawerNo)
|
.OrderBy(cs => cs.DrawerNo)
|
||||||
.OrderBy(cs=> cs.ManuNo)
|
.OrderBy(cs => cs.ManuNo)
|
||||||
.ToList();
|
.ToList();
|
||||||
int total = HasQChannels.Sum(it => it.Quantity);
|
int total = HasQChannels.Sum(it => it.Quantity);
|
||||||
int TakeQ = orderDetail.Quantity;
|
int TakeQ = orderDetail.Quantity;
|
||||||
|
@ -230,7 +230,7 @@ namespace DM_Weight.ViewModels
|
||||||
DialogParameters dialogParameters = new DialogParameters();
|
DialogParameters dialogParameters = new DialogParameters();
|
||||||
dialogParameters.Add("msgInfo", msg);
|
dialogParameters.Add("msgInfo", msg);
|
||||||
DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
|
DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -279,17 +279,17 @@ namespace DM_Weight.ViewModels
|
||||||
singleChannels.Add(copy);
|
singleChannels.Add(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
singleChannels = singleChannels
|
singleChannels = singleChannels
|
||||||
.GroupBy(it => new { it.DrawerNo, it.ColNo })
|
.GroupBy(it => new { it.DrawerNo, it.ColNo })
|
||||||
.Select(it =>
|
.Select(it =>
|
||||||
{
|
{
|
||||||
var ret = it.First();
|
var ret = it.First();
|
||||||
ret.Quantity = it.Sum(it => it.Quantity);
|
ret.Quantity = it.Sum(it => it.Quantity);
|
||||||
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
|
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
|
||||||
return ret;
|
return ret;
|
||||||
})
|
})
|
||||||
.ToList()
|
.ToList()
|
||||||
.FindAll(it => it.BoardType != 1);
|
.FindAll(it => it.BoardType != 1);
|
||||||
|
|
||||||
// 发送取药数量
|
// 发送取药数量
|
||||||
singleChannels.ForEach(it =>
|
singleChannels.ForEach(it =>
|
||||||
|
@ -331,12 +331,14 @@ namespace DM_Weight.ViewModels
|
||||||
string InvoiceId = OrderInfo.OrderNo;
|
string InvoiceId = OrderInfo.OrderNo;
|
||||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||||
{
|
{
|
||||||
|
logger.Info($"更新OrderInfo:{InvoiceId}");
|
||||||
SqlSugarHelper.Db.Updateable(new OrderInfo()
|
SqlSugarHelper.Db.Updateable(new OrderInfo()
|
||||||
{
|
{
|
||||||
DmStatus = 1,
|
DmStatus = 1,
|
||||||
OrderNo = OrderInfo.OrderNo
|
OrderNo = OrderInfo.OrderNo
|
||||||
}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
|
}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
SqlSugarHelper.Db.Insertable(new OrderFinish()
|
SqlSugarHelper.Db.Insertable(new OrderFinish()
|
||||||
{
|
{
|
||||||
OrderNo = OrderInfo.OrderNo,
|
OrderNo = OrderInfo.OrderNo,
|
||||||
|
@ -345,10 +347,12 @@ namespace DM_Weight.ViewModels
|
||||||
State = 1,
|
State = 1,
|
||||||
Operator = HomeWindowViewModel.Operator?.Nickname,
|
Operator = HomeWindowViewModel.Operator?.Nickname,
|
||||||
});
|
});
|
||||||
|
logger.Info("进入record循环");
|
||||||
for (int i = 0; i < record.Count; i++)
|
for (int i = 0; i < record.Count; i++)
|
||||||
{
|
{
|
||||||
ChannelStock it = record[i];
|
ChannelStock it = record[i];
|
||||||
|
|
||||||
|
logger.Info($"更新ChannelStock:{it.Id}");
|
||||||
// 更新数据 库存信息
|
// 更新数据 库存信息
|
||||||
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||||
{
|
{
|
||||||
|
@ -357,13 +361,14 @@ namespace DM_Weight.ViewModels
|
||||||
EffDate = it.EffDate,
|
EffDate = it.EffDate,
|
||||||
Id = it.Id,
|
Id = it.Id,
|
||||||
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
|
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
|
||||||
|
|
||||||
// 获取更新完库存后的药品库存
|
// 获取更新完库存后的药品库存
|
||||||
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
.Where(cs => cs.MachineId.Equals(it.MachineId))
|
.Where(cs => cs.MachineId.Equals(it.MachineId))
|
||||||
.Where(cs => cs.DrugId.Equals(it.DrugId))
|
.Where(cs => cs.DrugId.Equals(it.DrugId))
|
||||||
.Where(cs => cs.DrawerType == 1)
|
.Where(cs => cs.DrawerType == 1)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
logger.Info($"保存MachineRecord:{it.ManuNo}");
|
||||||
// 保存数据 出库记录
|
// 保存数据 出库记录
|
||||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
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.FindAll(it => it.BoardType != 1);
|
||||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
Task.Factory.StartNew(() =>
|
||||||
.GroupBy(it => it.ColNo)
|
{
|
||||||
|
//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 =>
|
.Select(it =>
|
||||||
{
|
{
|
||||||
var ret = it.First();
|
var ret = it.First();
|
||||||
//ret.Quantity = it.Sum(itx => itx.Quantity);
|
|
||||||
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
|
||||||
return ret;
|
return ret;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
if (singleChannels.Count > 0)
|
||||||
//{
|
|
||||||
//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[i].BoardType == 5)
|
for (int i = 0; i < singleChannels.Count; i++)
|
||||||
{
|
{
|
||||||
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
if (singleChannels[i].BoardType == 5)
|
||||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
{
|
||||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
List<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||||
.Sum(it => it.Quantity);
|
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||||
//将库位多批次的总库存数更新标签
|
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
|
//.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(() =>
|
||||||
AlertMsg alertMsg = new AlertMsg
|
{
|
||||||
{
|
AlertMsg alertMsg = new AlertMsg
|
||||||
Message = "抽屉取药完成,库存已更新",
|
{
|
||||||
Type = MsgType.SUCCESS,
|
Message = "抽屉取药完成,库存已更新",
|
||||||
};
|
Type = MsgType.SUCCESS,
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if(!f.IsSuccess)
|
if (!f.IsSuccess)
|
||||||
{
|
{
|
||||||
AlertMsg alertMsg = new AlertMsg
|
AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
{
|
||||||
|
@ -438,6 +473,7 @@ namespace DM_Weight.ViewModels
|
||||||
Type = MsgType.ERROR,
|
Type = MsgType.ERROR,
|
||||||
};
|
};
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
RequestData();
|
||||||
}
|
}
|
||||||
Status = 0;
|
Status = 0;
|
||||||
_isFinishClick = false;
|
_isFinishClick = false;
|
||||||
|
|
|
@ -299,13 +299,39 @@ namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
if (singleChannels[i].BoardType == 5)
|
if (singleChannels[i].BoardType == 5)
|
||||||
{
|
{
|
||||||
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
//int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
// .Where(cs => cs.MachineId == singleChannels[i].MachineId)
|
||||||
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
// .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
|
||||||
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
// .Where(cs => cs.ColNo == singleChannels[i].ColNo)
|
||||||
.Sum(it => it.Quantity);
|
// .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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue