复制master分支代码

This commit is contained in:
maqiao 2024-03-18 17:31:12 +08:00
parent b11a8a479c
commit d4c42203d2
1 changed files with 34 additions and 23 deletions

View File

@ -11,6 +11,7 @@ using Prism.Regions;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Configuration; using System.Configuration;
@ -18,6 +19,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Documents;
namespace DM_Weight.ViewModels namespace DM_Weight.ViewModels
{ {
@ -288,7 +290,7 @@ namespace DM_Weight.ViewModels
List<ChannelStock> iChannelStock = new List<ChannelStock>(); List<ChannelStock> iChannelStock = new List<ChannelStock>();
if (SelectedInvoice != null) if (SelectedInvoice != null)
{ {
//先查询入库单中有几种药 //先查询有几种药
string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE INVOICE_NO=@INVOICE_NO GROUP BY INVOICE_NO,DRUG_ID"; string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE INVOICE_NO=@INVOICE_NO GROUP BY INVOICE_NO,DRUG_ID";
var invoices = SqlSugarHelper.Db.SqlQueryable<InOutInvoice>(strSql) var invoices = SqlSugarHelper.Db.SqlQueryable<InOutInvoice>(strSql)
@ -328,7 +330,7 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.ManuNo == invoicesManuNo[j].DrugManuNo && cs.DrugId == invoicesManuNo[j].DrugId && cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList(); .Where(cs => cs.ManuNo == invoicesManuNo[j].DrugManuNo && cs.DrugId == invoicesManuNo[j].DrugId && cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
//stock = stockList.Count > 0 ? stockList[0] : new ChannelStock(); //stock = stockList.Count > 0 ? stockList[0] : new ChannelStock();
List<DrugManuNo> manuNoList = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.ManuNo == invoicesManuNo[j].DrugManuNo && dm.DrugId == invoicesManuNo[j].DrugId).ToList(); List<DrugManuNo> manuNoList = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.ManuNo == invoicesManuNo[j].DrugManuNo && dm.DrugId == invoicesManuNo[j].DrugId).ToList();
if (stockList == null || stockList.Count<=0) if (stockList == null || stockList.Count <= 0)
{ {
if (manuNoList == null || manuNoList.Count <= 0) if (manuNoList == null || manuNoList.Count <= 0)
{ {
@ -341,8 +343,8 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
continue; continue;
} }
//没有库存写入一条数据
ChannelStock stock = new ChannelStock(); ChannelStock stock = new ChannelStock();
//没有库存写入一条数据
stock.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"; stock.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
stock.DrawerNo = channelLst.DrawerNo; stock.DrawerNo = channelLst.DrawerNo;
stock.BoardType = channelLst.BoardType; stock.BoardType = channelLst.BoardType;
@ -355,13 +357,16 @@ namespace DM_Weight.ViewModels
stockList.Add(stock); stockList.Add(stock);
} }
//stock.AddQuantity = invoicesManuNo[j].quantity; //stock.AddQuantity = invoicesManuNo[j].quantity;
stockList.GroupBy(it =>it.ManuNo) //stockList.ForEach(s => s.AddQuantity = invoicesManuNo[j].quantity);
.Select(it => stockList.GroupBy(x => x.ManuNo)
{ .Select(it =>
var ret = it.First(); {
ret.AddQuantity = invoicesManuNo[j].quantity; var ret = it.First();
return ret; ret.AddQuantity = invoicesManuNo[j].quantity;
}).ToList(); return ret;
})
.ToList();
if (channelLst.channelStocks == null) if (channelLst.channelStocks == null)
{ {
channelLst.channelStocks = new List<ChannelStock>(); channelLst.channelStocks = new List<ChannelStock>();
@ -435,7 +440,7 @@ namespace DM_Weight.ViewModels
List<ChannelStock> singleChannels = new List<ChannelStock>(); List<ChannelStock> singleChannels = new List<ChannelStock>();
for (int i = 0; i < channelStocks.Count; i++) for (int i = 0; i < channelStocks.Count; i++)
{ {
ChannelStock copy= TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]); ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
singleChannels.Add(copy); singleChannels.Add(copy);
} }
singleChannels = singleChannels.GroupBy(it => new singleChannels = singleChannels.GroupBy(it => new
@ -458,15 +463,21 @@ namespace DM_Weight.ViewModels
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5) if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{ {
//List<ChannelStock> ChannelLst = channelStocks.Where(it => it.BoardType != 1) List<ChannelStock> ChannelLst = new List<ChannelStock>();
// .GroupBy(it => it.ColNo) for (int i = 0; i < channelStocks.Count; i++)
// .Select(it => {
// { ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
// var ret = it.First(); singleChannels.Add(copy);
// ret.Quantity = it.Sum(itx => itx.Quantity); }
// ret.AddQuantity = it.Sum(itx => itx.AddQuantity); ChannelLst = ChannelLst.Where(it => it.BoardType != 1)
// return ret; .GroupBy(it => it.ColNo)
// }).ToList(); .Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
// 发送加药数量 // 发送加药数量
singleChannels.ForEach(it => singleChannels.ForEach(it =>
{ {
@ -537,7 +548,7 @@ namespace DM_Weight.ViewModels
} }
//查询现有库位中是否有库存为0的记录如果有直接update //查询现有库位中是否有库存为0的记录如果有直接update
ChannelStock recordHistory = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity <= 0).First(); ChannelStock recordHistory = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity <= 0).First();
if (recordHistory!=null&& recordHistory.Id!=null) if (recordHistory != null && recordHistory.Id != null)
{ {
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(item => new ChannelStock() SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(item => new ChannelStock()
{ {
@ -599,7 +610,7 @@ namespace DM_Weight.ViewModels
{ {
//根据ChannelLsts中的库位删除该库位库存为0的记录 //根据ChannelLsts中的库位删除该库位库存为0的记录
SqlSugarHelper.Db.Deleteable<ChannelStock>() SqlSugarHelper.Db.Deleteable<ChannelStock>()
.Where(cs => cs.Quantity <= 0 && cs.DrawerNo == ChannelLsts[i].channelStocks[0].DrawerNo && cs.ColNo == ChannelLsts[i].channelStocks[0].ColNo).ExecuteCommand(); .Where(cs => cs.Quantity <= 0 && cs.DrugId == ChannelLsts[i].DrugId && cs.MachineId == ChannelLsts[i].MachineId).ExecuteCommand();
} }
} }
return true; return true;
@ -625,7 +636,7 @@ namespace DM_Weight.ViewModels
if (singleChannels[i].BoardType == 5) if (singleChannels[i].BoardType == 5)
{ {
List<ChannelStock> channelStockEffDate = SqlSugarHelper.Db.Queryable<ChannelStock>() List<ChannelStock> channelStockEffDate = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId==singleChannels[i].MachineId) .Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo) .Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo) .Where(cs => cs.ColNo == singleChannels[i].ColNo)
.OrderBy(cs => cs.EffDate).ToList(); .OrderBy(cs => cs.EffDate).ToList();