修改核对麻醉单时修改channelList状态

替换药箱bug修改
This commit is contained in:
maqiao 2025-06-19 14:22:51 +08:00
parent 6b99940f50
commit 5970654ffe
4 changed files with 49 additions and 24 deletions

View File

@ -73,7 +73,7 @@ namespace DM_Weight.Models
[SugarColumn(ColumnName = "eff_date")] [SugarColumn(ColumnName = "eff_date")]
public DateTime? EffDate { get; set; } public DateTime? EffDate { get; set; }
/// <summary> /// <summary>
/// 出库入库类型(1入库2出库31还药32还空瓶,21药箱移出移入69药箱替换) /// 出库入库类型(1入库2出库31还药32还空瓶,21药箱移出移入,69药箱替换55绑定药品操作绑定、解绑、修改基数)
///</summary> ///</summary>
[SugarColumn(ColumnName = "type")] [SugarColumn(ColumnName = "type")]
public int Type { get; set; } public int Type { get; set; }

View File

@ -66,8 +66,18 @@ namespace DM_Weight.ViewModels
{ {
if (value != null) if (value != null)
{ {
DrugInfo = DrugInfos.Where(di => di.DrugId == value.Drug.DrugId).First(); try
BaseQuantity = value.BaseQuantity.ToString(); {
DrugInfo = DrugInfos.Where(di => di.DrugId == value.Drug.DrugId).First();
BaseQuantity = value.BaseQuantity.ToString();
}
catch (Exception ex)
{
RequestDrug();
DrugInfo = DrugInfos.Where(di => di.DrugId == value.Drug.DrugId).First();
BaseQuantity = value.BaseQuantity.ToString();
}
//DrugManuNo = DrugManuNos.Where(dm => dm.DrugId == value.DrugId && dm.ManuNo == value.ManuNo).First(); //DrugManuNo = DrugManuNos.Where(dm => dm.DrugId == value.DrugId && dm.ManuNo == value.ManuNo).First();
} }
SetProperty(ref _channelList, value); SetProperty(ref _channelList, value);
@ -264,7 +274,7 @@ namespace DM_Weight.ViewModels
SnackbarMessageQueue.Enqueue("药品基数请输入正确的整数"); SnackbarMessageQueue.Enqueue("药品基数请输入正确的整数");
return; return;
} }
if (_ChannelList != null) if (_ChannelLists != null)
{ {
int iNum = _ChannelLists.Where(cs => cs.DrugId == DrugInfo.DrugId.ToString()).Count(); int iNum = _ChannelLists.Where(cs => cs.DrugId == DrugInfo.DrugId.ToString()).Count();
if (iNum > 0) if (iNum > 0)
@ -289,11 +299,12 @@ namespace DM_Weight.ViewModels
{ {
Id = chnguid, Id = chnguid,
DrawerNo = (DrawerNo + 1), DrawerNo = (DrawerNo + 1),
ColNo=(colNoCount+1), ColNo = (colNoCount + 1),
DrugId = DrugInfo.DrugId, DrugId = DrugInfo.DrugId,
BaseQuantity = baseQuantity, BaseQuantity = baseQuantity,
MachineId = "DM5", MachineId = "DM5",
DrawerType=1 DrawerType = 1,
State = 0
}).ExecuteCommand(); }).ExecuteCommand();
SqlSugarHelper.Db.Insertable(new ChannelStock() SqlSugarHelper.Db.Insertable(new ChannelStock()
{ {
@ -365,7 +376,7 @@ namespace DM_Weight.ViewModels
} }
if (_ChannelList != null) if (_ChannelList != null)
{ {
if(_channelList.channelStocks.Where(cs=>cs.Quantity>0).Count() > 0) if (_channelList.channelStocks.Where(cs => cs.Quantity > 0).Count() > 0)
{ {
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c")); SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("药品还有库存不能操作解绑"); SnackbarMessageQueue.Enqueue("药品还有库存不能操作解绑");
@ -450,19 +461,31 @@ namespace DM_Weight.ViewModels
{ {
_ChannelList.channelStocks[0].NeedNum = 0; _ChannelList.channelStocks[0].NeedNum = 0;
} }
int oldBaseQty = _ChannelList.BaseQuantity;
_ChannelList.BaseQuantity = baseQty; _ChannelList.BaseQuantity = baseQty;
//_ChannelList.channelStocks[0].BaseQuantity = baseQty; //_ChannelList.channelStocks[0].BaseQuantity = baseQty;
//int iUpdate = SqlSugarHelper.Db.Updateable<ChannelStock>(_ChannelList.channelStocks[0]).ExecuteCommand(); //int iUpdate = SqlSugarHelper.Db.Updateable<ChannelStock>(_ChannelList.channelStocks[0]).ExecuteCommand();
_ChannelList.channelStocks.ForEach(cs=>cs.BaseQuantity= baseQty); _ChannelList.channelStocks.ForEach(cs => cs.BaseQuantity = baseQty);
int iBaseUpdate= SqlSugarHelper.Db.Updateable(_ChannelList.channelStocks).UpdateColumns(cs => cs.BaseQuantity).ExecuteCommand(); int iBaseUpdate = SqlSugarHelper.Db.Updateable(_ChannelList.channelStocks).UpdateColumns(cs => new { cs.BaseQuantity, cs.NeedNum }).ExecuteCommand();
//更新ChannelList表中的BaseQuantity //更新ChannelList表中的BaseQuantity
int iUpdateChannelList = SqlSugarHelper.Db.Updateable<ChannelList>() int iUpdateChannelList = SqlSugarHelper.Db.Updateable<ChannelList>()
.SetColumns(it => new ChannelList() { BaseQuantity = baseQty }) .SetColumns(it => new ChannelList() { BaseQuantity = baseQty })
.Where(it => it.Id == _ChannelList.Id).ExecuteCommand(); .Where(it => it.Id == _ChannelList.Id).ExecuteCommand();
if (iBaseUpdate > 0 && iUpdateChannelList > 0) if (iBaseUpdate > 0 && iUpdateChannelList > 0)
{ {
//保存操作记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = "DM5",
DrawerNo = _ChannelList.DrawerNo,
DrugId = _ChannelList.DrugId,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Quantity = _ChannelList.channelStocks[0].NeedNum,
Type = 55,
InvoiceId = $"修改药品基数{oldBaseQty}改为{baseQty},Quantity值为需要加药数量",
}).ExecuteCommand();
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676")); SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
SnackbarMessageQueue.Enqueue("保存修改完成!"); SnackbarMessageQueue.Enqueue("保存修改完成!");
RequestData(); RequestData();

View File

@ -171,11 +171,11 @@ namespace DM_Weight.ViewModels
AddToJJNum=0 AddToJJNum=0
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate,it.NeedNum,it.AddToJJNum }).ExecuteCommand(); }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate,it.NeedNum,it.AddToJJNum }).ExecuteCommand();
//SqlSugarHelper.Db.Updateable(new ChannelList() SqlSugarHelper.Db.Updateable(new ChannelList()
//{ {
// State=0, State = 0,
// Id=it.Chnguid Id = it.Chnguid
//}).UpdateColumns(cl => new { cl.State }).ExecuteCommand(); }).UpdateColumns(cl => new { cl.State }).ExecuteCommand();
// 保存数据 盘点记录 // 保存数据 盘点记录
SqlSugarHelper.Db.Insertable(new MachineRecord() SqlSugarHelper.Db.Insertable(new MachineRecord()

View File

@ -328,13 +328,15 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.ManuNo.Equals(currentChannelStock.ManuNo)) .Where(cs => cs.ManuNo.Equals(currentChannelStock.ManuNo))
.First(); .First();
//修改已替换的药品批次数量(现库存数-已替换总数) //修改已替换的药品批次数量(现库存数-已替换总数)
_ChannelStock.Quantity = _ChannelStock.Quantity - sumQuantity; if (_ChannelStock.Quantity > 0)
SqlSugarHelper.Db.Updateable(_ChannelStock).UpdateColumns(it => new { it.Quantity }).ExecuteCommand(); {
_ChannelStock.Quantity = _ChannelStock.Quantity - sumQuantity;
SqlSugarHelper.Db.Updateable(_ChannelStock).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
}
if (ReplaceChannelStockList != null) if (ReplaceChannelStockList != null)
{ {
//有该批次药品则更新 //有该批次药品则更新
csId = ReplaceChannelStockList.Id; //csId = ReplaceChannelStockList.Id;
ReplaceChannelStockList.Quantity = ReplaceChannelStockList.Quantity + currentChannelStock.TakeQuantity; ReplaceChannelStockList.Quantity = ReplaceChannelStockList.Quantity + currentChannelStock.TakeQuantity;
SqlSugarHelper.Db.Updateable(ReplaceChannelStockList).UpdateColumns(it => new { it.Quantity }).ExecuteCommand(); SqlSugarHelper.Db.Updateable(ReplaceChannelStockList).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
@ -348,14 +350,14 @@ namespace DM_Weight.ViewModels
DrawerNo = _ChannelStock.DrawerNo, DrawerNo = _ChannelStock.DrawerNo,
DrugId = _ChannelStock.DrugId, DrugId = _ChannelStock.DrugId,
ManuNo = currentChannelStock.ManuNo, ManuNo = currentChannelStock.ManuNo,
EffDate=currentChannelStock.EffDate, EffDate = currentChannelStock.EffDate,
Quantity = currentChannelStock.TakeQuantity, Quantity = currentChannelStock.TakeQuantity,
DrawerType = 1, DrawerType = 1,
Chnguid = _ChannelStock.Chnguid, Chnguid = _ChannelStock.Chnguid,
Id = csId, Id = csId,
}).ExecuteCommand(); }).ExecuteCommand();
} }
string csToId = Guid.NewGuid().ToString();
// 保存数据 替换药记录 // 保存数据 替换药记录
SqlSugarHelper.Db.Insertable(new MoveChannelStock() SqlSugarHelper.Db.Insertable(new MoveChannelStock()
{ {
@ -394,13 +396,13 @@ namespace DM_Weight.ViewModels
SqlSugarHelper.Db.Insertable(new ChannelStock() SqlSugarHelper.Db.Insertable(new ChannelStock()
{ {
MachineId = _ChannelStock.MachineId, MachineId = _ChannelStock.MachineId,
DrawerNo = _ChannelStock.DrawerNo, DrawerNo = currentChannelStock.DrawerNo,
DrugId = _ChannelStock.DrugId, DrugId = _ChannelStock.DrugId,
ManuNo = _ChannelStock.ManuNo, ManuNo = _ChannelStock.ManuNo,
Quantity = currentChannelStock.TakeQuantity, Quantity = currentChannelStock.TakeQuantity,
DrawerType = 1, DrawerType = 1,
Chnguid = currentChannelStock.Chnguid, Chnguid = currentChannelStock.Chnguid,
Id = csId, Id = csToId,
}).ExecuteCommand(); }).ExecuteCommand();
} }
} }