修改核对麻醉单时修改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")]
public DateTime? EffDate { get; set; }
/// <summary>
/// 出库入库类型(1入库2出库31还药32还空瓶,21药箱移出移入69药箱替换)
/// 出库入库类型(1入库2出库31还药32还空瓶,21药箱移出移入,69药箱替换55绑定药品操作绑定、解绑、修改基数)
///</summary>
[SugarColumn(ColumnName = "type")]
public int Type { get; set; }

View File

@ -66,8 +66,18 @@ namespace DM_Weight.ViewModels
{
if (value != null)
{
DrugInfo = DrugInfos.Where(di => di.DrugId == value.Drug.DrugId).First();
BaseQuantity = value.BaseQuantity.ToString();
try
{
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();
}
SetProperty(ref _channelList, value);
@ -264,7 +274,7 @@ namespace DM_Weight.ViewModels
SnackbarMessageQueue.Enqueue("药品基数请输入正确的整数");
return;
}
if (_ChannelList != null)
if (_ChannelLists != null)
{
int iNum = _ChannelLists.Where(cs => cs.DrugId == DrugInfo.DrugId.ToString()).Count();
if (iNum > 0)
@ -289,11 +299,12 @@ namespace DM_Weight.ViewModels
{
Id = chnguid,
DrawerNo = (DrawerNo + 1),
ColNo=(colNoCount+1),
ColNo = (colNoCount + 1),
DrugId = DrugInfo.DrugId,
BaseQuantity = baseQuantity,
MachineId = "DM5",
DrawerType=1
DrawerType = 1,
State = 0
}).ExecuteCommand();
SqlSugarHelper.Db.Insertable(new ChannelStock()
{
@ -365,7 +376,7 @@ namespace DM_Weight.ViewModels
}
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"));
SnackbarMessageQueue.Enqueue("药品还有库存不能操作解绑");
@ -450,19 +461,31 @@ namespace DM_Weight.ViewModels
{
_ChannelList.channelStocks[0].NeedNum = 0;
}
int oldBaseQty = _ChannelList.BaseQuantity;
_ChannelList.BaseQuantity = baseQty;
//_ChannelList.channelStocks[0].BaseQuantity = baseQty;
//int iUpdate = SqlSugarHelper.Db.Updateable<ChannelStock>(_ChannelList.channelStocks[0]).ExecuteCommand();
_ChannelList.channelStocks.ForEach(cs=>cs.BaseQuantity= baseQty);
int iBaseUpdate= SqlSugarHelper.Db.Updateable(_ChannelList.channelStocks).UpdateColumns(cs => cs.BaseQuantity).ExecuteCommand();
_ChannelList.channelStocks.ForEach(cs => cs.BaseQuantity = baseQty);
int iBaseUpdate = SqlSugarHelper.Db.Updateable(_ChannelList.channelStocks).UpdateColumns(cs => new { cs.BaseQuantity, cs.NeedNum }).ExecuteCommand();
//更新ChannelList表中的BaseQuantity
int iUpdateChannelList = SqlSugarHelper.Db.Updateable<ChannelList>()
.SetColumns(it => new ChannelList() { BaseQuantity = baseQty })
.Where(it => it.Id == _ChannelList.Id).ExecuteCommand();
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"));
SnackbarMessageQueue.Enqueue("保存修改完成!");
RequestData();

View File

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

View File

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