复制master分支代码
This commit is contained in:
parent
b11a8a479c
commit
d4c42203d2
|
@ -11,6 +11,7 @@ using Prism.Regions;
|
|||
using Prism.Services.Dialogs;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Configuration;
|
||||
|
@ -18,6 +19,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -288,7 +290,7 @@ namespace DM_Weight.ViewModels
|
|||
List<ChannelStock> iChannelStock = new List<ChannelStock>();
|
||||
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";
|
||||
|
||||
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();
|
||||
//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();
|
||||
if (stockList == null || stockList.Count<=0)
|
||||
if (stockList == null || stockList.Count <= 0)
|
||||
{
|
||||
if (manuNoList == null || manuNoList.Count <= 0)
|
||||
{
|
||||
|
@ -341,8 +343,8 @@ namespace DM_Weight.ViewModels
|
|||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
continue;
|
||||
}
|
||||
//没有库存写入一条数据
|
||||
ChannelStock stock = new ChannelStock();
|
||||
//没有库存写入一条数据
|
||||
stock.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
|
||||
stock.DrawerNo = channelLst.DrawerNo;
|
||||
stock.BoardType = channelLst.BoardType;
|
||||
|
@ -355,13 +357,16 @@ namespace DM_Weight.ViewModels
|
|||
stockList.Add(stock);
|
||||
}
|
||||
//stock.AddQuantity = invoicesManuNo[j].quantity;
|
||||
stockList.GroupBy(it =>it.ManuNo)
|
||||
.Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.AddQuantity = invoicesManuNo[j].quantity;
|
||||
return ret;
|
||||
}).ToList();
|
||||
//stockList.ForEach(s => s.AddQuantity = invoicesManuNo[j].quantity);
|
||||
stockList.GroupBy(x => x.ManuNo)
|
||||
.Select(it =>
|
||||
{
|
||||
var ret = it.First();
|
||||
ret.AddQuantity = invoicesManuNo[j].quantity;
|
||||
return ret;
|
||||
})
|
||||
.ToList();
|
||||
|
||||
if (channelLst.channelStocks == null)
|
||||
{
|
||||
channelLst.channelStocks = new List<ChannelStock>();
|
||||
|
@ -435,7 +440,7 @@ namespace DM_Weight.ViewModels
|
|||
List<ChannelStock> singleChannels = new List<ChannelStock>();
|
||||
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 = singleChannels.GroupBy(it => new
|
||||
|
@ -458,15 +463,21 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
|
||||
{
|
||||
//List<ChannelStock> ChannelLst = channelStocks.Where(it => it.BoardType != 1)
|
||||
// .GroupBy(it => it.ColNo)
|
||||
// .Select(it =>
|
||||
// {
|
||||
// var ret = it.First();
|
||||
// ret.Quantity = it.Sum(itx => itx.Quantity);
|
||||
// ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
|
||||
// return ret;
|
||||
// }).ToList();
|
||||
List<ChannelStock> ChannelLst = new List<ChannelStock>();
|
||||
for (int i = 0; i < channelStocks.Count; i++)
|
||||
{
|
||||
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(channelStocks[i]);
|
||||
singleChannels.Add(copy);
|
||||
}
|
||||
ChannelLst = ChannelLst.Where(it => it.BoardType != 1)
|
||||
.GroupBy(it => it.ColNo)
|
||||
.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 =>
|
||||
{
|
||||
|
@ -537,7 +548,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
//查询现有库位中是否有库存为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();
|
||||
if (recordHistory!=null&& recordHistory.Id!=null)
|
||||
if (recordHistory != null && recordHistory.Id != null)
|
||||
{
|
||||
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(item => new ChannelStock()
|
||||
{
|
||||
|
@ -599,7 +610,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
//根据ChannelLsts中的库位,删除该库位库存为0的记录
|
||||
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;
|
||||
|
@ -625,7 +636,7 @@ namespace DM_Weight.ViewModels
|
|||
if (singleChannels[i].BoardType == 5)
|
||||
{
|
||||
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.ColNo == singleChannels[i].ColNo)
|
||||
.OrderBy(cs => cs.EffDate).ToList();
|
||||
|
|
Loading…
Reference in New Issue