禁止拖动页面,添加渲染标签,添加出、入库页面绑定批次 效期
This commit is contained in:
parent
4f0297f4bc
commit
2ef1c185e3
|
@ -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;Pooling=True; ConnectionLifeTime=0" />
|
||||
<add name="database" connectionString="server=127.0.0.1;port=3306;database=hunanxianchang_db;userid=root;password=root;Pooling=false; 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="30"/>
|
||||
<add key="autoExit" value="0"/>
|
||||
<!--报表数据库连接-->
|
||||
<add key="gridConnectionString" value="MYSQL; Database=hunanxianchang_db; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
|
||||
<!-- 查询处方是orderNo还是orderGroupNo -->
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2365.46" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.3.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
<PackageReference Include="Prism.Unity" Version="8.1.97" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType ==5&&(it.Quantity>0||it.AddQuantity>0))
|
||||
.GroupBy(it => it.ColNo)
|
||||
.Select(it =>
|
||||
{
|
||||
|
|
|
@ -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<ChannelStock>()
|
||||
.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);
|
||||
|
|
|
@ -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<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
|
||||
List<ChannelStock> 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<ChannelStock> 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<ChannelStock> 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<ChannelStock> 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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace DM_Weight.ViewModels
|
|||
if (!_isFinishClick)
|
||||
{
|
||||
_isFinishClick = true;
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
|
||||
List<ChannelStock> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -619,7 +619,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> 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<ChannelStock> channelStockEffDate = 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();
|
||||
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);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -386,13 +386,29 @@ 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);
|
||||
//将库位多批次的总库存数更新标签
|
||||
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
|
||||
List<ChannelStock> channels = 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)
|
||||
.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
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)
|
||||
List<ChannelStock> 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<ChannelStock> channel = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
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)
|
||||
|
@ -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<SnackbarEvent>().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<SnackbarEvent>().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<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()
|
||||
// {
|
||||
// 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<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
// 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();
|
||||
// return ret;
|
||||
// }).ToList();
|
||||
// if (singleChannels.Count > 0)
|
||||
// {
|
||||
// for (int i = 0; i < singleChannels.Count; i++)
|
||||
// {
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 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<SnackbarEvent>().Publish(alertMsg);
|
||||
// }));
|
||||
// });
|
||||
//}
|
||||
//if (!f.IsSuccess)
|
||||
//{
|
||||
// logger.Info($"抽屉取药完成,库存更新失败!");
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "抽屉取药完成,库存更新失败!",
|
||||
// Type = MsgType.ERROR,
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// RequestData();
|
||||
//}
|
||||
Status = 0;
|
||||
_isFinishClick = false;
|
||||
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
||||
|
|
|
@ -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<ChannelStock>()
|
||||
.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<ChannelStock> channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.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 = "操作完成,库存已更新",
|
||||
|
|
|
@ -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<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> 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<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);
|
||||
//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);
|
||||
|
||||
List<ChannelStock> channels = 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)
|
||||
.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
// 更新屏显库存
|
||||
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
|
||||
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
|
||||
List<ChannelStock> 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<ChannelStock>()
|
||||
// .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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
|
||||
/>
|
||||
/>-->
|
||||
<Button
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
ToolTip="渲染标签"
|
||||
|
@ -90,7 +90,7 @@
|
|||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, UpdateSourceTrigger=PropertyChanged}"
|
||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, UpdateSourceTrigger=PropertyChanged}"
|
||||
|
||||
/>-->
|
||||
/>
|
||||
<Button
|
||||
Margin="6 0 6 0"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
Topmost="False"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
Title="主窗口" Height="768" Width="1024" WindowStyle="None" WindowState="Maximized">
|
||||
<WindowChrome.WindowChrome>
|
||||
<!--<WindowChrome.WindowChrome>
|
||||
<WindowChrome CornerRadius="4" GlassFrameThickness="1" />
|
||||
</WindowChrome.WindowChrome>
|
||||
</WindowChrome.WindowChrome>-->
|
||||
|
||||
<materialDesign:DialogHost
|
||||
DialogMargin="0"
|
||||
|
|
Loading…
Reference in New Issue