交接柜补药按药品分组

This commit is contained in:
maqiao 2024-12-02 10:34:36 +08:00
parent 32bc9f5ffb
commit 5e567836e4
2 changed files with 18 additions and 13 deletions

View File

@ -358,20 +358,16 @@ namespace DM_Weight.ViewModels
{
for (int j = 0; j < jiaojieStock.Count; j++)
{
List<ChannelStock> stockManuList = jiaojieStock.Where(cs => cs.ManuNo == it.ManuNo).ToList();
if (stockManuList == null||stockManuList.Count<=0)
List<ChannelStock> searchStock = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.DrawerNo == jiaojieStock[j].DrawerNo && cs.DrugId == jiaojieStock[j].DrugId && cs.DrugId == it.DrugId && cs.ManuNo == it.ManuNo)
.ToList();
//List<ChannelStock> stockManuList = jiaojieStock.Where(cs => cs.ManuNo == it.ManuNo).ToList();
if (searchStock == null || searchStock.Count <= 0)
{
jiaojieStock[j].ManuNo= it.ManuNo;
if (jiaojieStock[j].Quantity <= 0)
{
SqlSugarHelper.Db.Updateable(jiaojieStock[j]).ExecuteCommand();
}
else
{
jiaojieStock[j].ManuNo= it.ManuNo;
jiaojieStock[j].Chnguid = Guid.NewGuid().ToString();
SqlSugarHelper.Db.Insertable(jiaojieStock).ExecuteCommand();
}
SqlSugarHelper.Db.Deleteable<ChannelStock>().Where(cs=>cs.DrawerNo== jiaojieStock[j].DrawerNo&&cs.DrugId== jiaojieStock[j].DrugId&&cs.ManuNo==null).ExecuteCommand();
jiaojieStock[j].ManuNo = it.ManuNo;
jiaojieStock[j].Id = Guid.NewGuid().ToString();
SqlSugarHelper.Db.Insertable(jiaojieStock).ExecuteCommand();
}
}
}

View File

@ -8,6 +8,7 @@ using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -76,6 +77,14 @@ namespace DM_Weight.ViewModels
.OrderBy(cs => cs.Chnguid)
.OrderBy(cs => cs.DrawerNo)
.ToList();
ChannelStocks = ChannelStocks.GroupBy(it => new { it.DrawerNo, it.DrugId })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
return ret;
})
.ToList();
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);