From a2d7f522ec9524b7af8c3e793aae4348870e37f6 Mon Sep 17 00:00:00 2001 From: tongfei <244188119@qq.com> Date: Fri, 8 Dec 2023 15:12:17 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml | 9 +++++++++ .../IInventoryDetailsRepositories.cs | 9 +++++++++ .../Services/InventoryInOutDetailsService.cs | 16 ++++++++++++---- .../InventoryDetailsRepositories.cs | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index e4bb7017..085f8b09 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -2192,6 +2192,15 @@ + + + 列表-根据物料和仓库 + + + + + + 物料收发明细-仓储接口 diff --git a/src/WMS.Web.Domain/Infrastructure/IInventoryDetailsRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IInventoryDetailsRepositories.cs index 13029553..278bc4af 100644 --- a/src/WMS.Web.Domain/Infrastructure/IInventoryDetailsRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IInventoryDetailsRepositories.cs @@ -45,5 +45,14 @@ namespace WMS.Web.Domain.Infrastructure /// /// Task> GetListBy(List materialIds, List stockCodes, List subStockIds, List orgCodes); + + /// + /// 列表-根据物料和仓库 + /// + /// + /// + /// + /// + Task> GetListBy(List materialIds, List stockCodes, List orgCodes); } } diff --git a/src/WMS.Web.Domain/Services/InventoryInOutDetailsService.cs b/src/WMS.Web.Domain/Services/InventoryInOutDetailsService.cs index 7895dac2..5ade8e5c 100644 --- a/src/WMS.Web.Domain/Services/InventoryInOutDetailsService.cs +++ b/src/WMS.Web.Domain/Services/InventoryInOutDetailsService.cs @@ -53,8 +53,17 @@ namespace WMS.Web.Domain.Services var orgCodes = dtos.Select(x => x.OrgCode).ToList(); var materialIds = dtos.Select(x => x.MaterialId).ToList(); var stockCodes = dtos.GroupBy(x => x.StockCode).Select(x => x.Key).ToList(); - var subStockIds = dtos.GroupBy(x => x.SubStockId).Select(x => x.Key).ToList(); - var inventoryDetails=await _inventoryDetailsRepositories.GetListBy(materialIds, stockCodes, subStockIds, orgCodes); + var inventoryDetails=await _inventoryDetailsRepositories.GetListBy(materialIds, stockCodes, orgCodes); + + //还要汇总出:只对仓库的库存合集,不要仓位 + var inventoryDetailsTotal = inventoryDetails.GroupBy(x => new { x.OrgCode, x.MaterialId, x.StockCode }) + .Select(x => new + { + OrgCode = x.Key.OrgCode, + MaterialId = x.Key.MaterialId, + StockCode = x.Key.StockCode, + Qty = x.Sum(t => t.Qty) + }).ToList(); //1.创建要新增的对象 var add_entitys = new List(); @@ -63,10 +72,9 @@ namespace WMS.Web.Domain.Services foreach (var dto in dtos) { //2.1当前的即时库存明细 - var currentDetail= inventoryDetails.Where(x => + var currentDetail= inventoryDetailsTotal.Where(x => x.MaterialId == dto.MaterialId && x.StockCode == dto.StockCode && - x.SubStockId == dto.SubStockId && x.OrgCode==dto.OrgCode).FirstOrDefault(); //2.2组装物料收发明细实体 diff --git a/src/WMS.Web.Repositories/InventoryDetailsRepositories.cs b/src/WMS.Web.Repositories/InventoryDetailsRepositories.cs index 274a9929..14346580 100644 --- a/src/WMS.Web.Repositories/InventoryDetailsRepositories.cs +++ b/src/WMS.Web.Repositories/InventoryDetailsRepositories.cs @@ -194,5 +194,20 @@ namespace WMS.Web.Repositories orgCodes.Contains(x.OrgCode) && subStockIds.Contains(x.SubStockId) ).ToListAsync(); } + + /// + /// 列表-根据物料和仓库和仓位 + /// + /// + /// + /// + /// + /// + public async Task> GetListBy(List materialIds, List stockCodes,List orgCodes) + { + return await _context.InventoryDetails.Where(x => materialIds.Contains(x.MaterialId) && + stockCodes.Contains(x.StockCode) && + orgCodes.Contains(x.OrgCode)).ToListAsync(); + } } }