修改药品基数时如果新基数大于原则需要补药数量为新基数减去原基数

This commit is contained in:
maqiao 2025-03-22 14:58:53 +08:00
parent af620ae141
commit 1d27a080fa
1 changed files with 15 additions and 9 deletions

View File

@ -126,11 +126,11 @@ namespace DM_Weight.ViewModels
//.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase) //.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase)
.Includes(cs => cs.DrugInfo) .Includes(cs => cs.DrugInfo)
.Where(cs => cs.MachineId.Equals("DM5")) .Where(cs => cs.MachineId.Equals("DM5"))
.Where(cs => cs.DrawerNo == DrawerNo+1).ToList(); .Where(cs => cs.DrawerNo == DrawerNo + 1).ToList();
if (list != null && list.Count > 0) if (list != null && list.Count > 0)
{ {
Channels=list.GroupBy(cs =>cs.DrugId).Select(cs => Channels = list.GroupBy(cs => cs.DrugId).Select(cs =>
{ {
var ret = cs.First(); var ret = cs.First();
ret.Quantity = cs.Sum(itx => itx.Quantity); ret.Quantity = cs.Sum(itx => itx.Quantity);
@ -215,23 +215,23 @@ namespace DM_Weight.ViewModels
} }
var f = SqlSugarHelper.Db.UseTran(() => var f = SqlSugarHelper.Db.UseTran(() =>
{ {
string chnguid = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.MachineId == ConfigurationManager.AppSettings["machineId"].ToString() && cs.DrawerNo == DrawerNo+1).Select(cs => cs.Id).First(); string chnguid = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.MachineId == ConfigurationManager.AppSettings["machineId"].ToString() && cs.DrawerNo == DrawerNo + 1).Select(cs => cs.Id).First();
SqlSugarHelper.Db.Insertable(new ChannelStock() SqlSugarHelper.Db.Insertable(new ChannelStock()
{ {
Chnguid = chnguid, Chnguid = chnguid,
DrawerNo = DrawerNo+ 1, DrawerNo = DrawerNo + 1,
DrugId = DrugInfo.DrugId.ToString(), DrugId = DrugInfo.DrugId.ToString(),
BaseQuantity = baseQuantity, BaseQuantity = baseQuantity,
Id = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(),
MachineId = "DM5", MachineId = "DM5",
AddToJJNum=0, AddToJJNum = 0,
NeedNum=baseQuantity NeedNum = baseQuantity
}).ExecuteCommand(); }).ExecuteCommand();
// 保存数据 入库记录 // 保存数据 入库记录
SqlSugarHelper.Db.Insertable(new MachineRecord() SqlSugarHelper.Db.Insertable(new MachineRecord()
{ {
MachineId = "DM5", MachineId = "DM5",
DrawerNo = DrawerNo+1, DrawerNo = DrawerNo + 1,
DrugId = DrugInfo.DrugId.ToString(), DrugId = DrugInfo.DrugId.ToString(),
Operator = HomeWindowViewModel.Operator?.Id, Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now, OperationTime = DateTime.Now,
@ -350,8 +350,14 @@ namespace DM_Weight.ViewModels
int baseQty = 0; int baseQty = 0;
if (int.TryParse(BaseQuantity, out baseQty)) if (int.TryParse(BaseQuantity, out baseQty))
{ {
Channel.BaseQuantity = Convert.ToInt32(baseQty); logger.Info($"修改药品基数{Channel.BaseQuantity}改为{baseQty}");
int iUpdate= SqlSugarHelper.Db.Updateable<ChannelStock>(Channel).ExecuteCommand(); if (baseQty > Channel.BaseQuantity)
{
//基数变大,需要补药
Channel.NeedNum = baseQty - Channel.BaseQuantity;
}
Channel.BaseQuantity = baseQty;
int iUpdate = SqlSugarHelper.Db.Updateable<ChannelStock>(Channel).ExecuteCommand();
if (iUpdate > 0) if (iUpdate > 0)
{ {