From 06786068a2d94f7e11c140bc3b39f59346c04aea Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Fri, 14 Jun 2024 11:04:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=BD=99=E9=A2=9D=E6=8C=89?= =?UTF-8?q?=E5=BA=93=E4=BD=8D=E7=B1=BB=E5=9E=8B=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThirdLocationRequestAppService.cs | 60 +++++++++++++++---- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs index b3075b3ac..e480576c1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs @@ -22,6 +22,7 @@ using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Inventory.Application.Contracts; +using Win_in.Sfs.Wms.Inventory.Domain; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; @@ -50,6 +51,7 @@ public class ThirdLocationRequestAppService : SfsStoreRequestAppServiceBase locationCodes=new List(); + locationCodes.Add(detailInput.FromLocationCode); + List inventoryStatusList = new List(); + inventoryStatusList.Add(EnumInventoryStatus.OK); + + var fromLocationDto = await _locationAppService.GetByCodeAsync(detailInput.FromLocationCode).ConfigureAwait(false); + + List inventoryBalances; + if (fromLocationDto.Type== EnumLocationType.RAW) { - balanceSum += item.Qty; + inventoryBalances = await _balanceManager.GetUsableListAsync(detailInput.ItemCode, locationCodes, inventoryStatusList, true).ConfigureAwait(false); + } + else + { + inventoryBalances = await _balanceManager.GetUsableListAsync(detailInput.ItemCode, locationCodes, inventoryStatusList, false).ConfigureAwait(false); } - var expectOutNums= await _expectOutAppService.GetListByItemAsync(detailInput.ItemCode).ConfigureAwait(false); - decimal expectOutSum = 0; - foreach (var item in expectOutNums) + + decimal balanceSum = 0; + foreach (var item in inventoryBalances) { - expectOutSum += item.Qty; + balanceSum += item.Qty; } - decimal realityBalance = balanceSum - expectOutSum; - if (detailInput.Qty> realityBalance) + + if (detailInput.Qty > balanceSum) { - throw new UserFriendlyException($"{detailInput.ItemCode} 物品的库存为 {realityBalance} ,库存不够"); + throw new UserFriendlyException($"{detailInput.ItemCode} 物品的库存为 {balanceSum} ,库存不够"); } - + + //var balanceNums= await _balanceAppService.GetListByLocationCodeAndItemCodeAsync(detailInput.FromLocationCode, detailInput.ItemCode).ConfigureAwait(false); + //decimal balanceSum = 0; + //foreach (var item in balanceNums) + //{ + // balanceSum += item.Qty; + //} + //var expectOutNums= await _expectOutAppService.GetListByItemAsync(detailInput.ItemCode).ConfigureAwait(false); + //decimal expectOutSum = 0; + //foreach (var item in expectOutNums) + //{ + // expectOutSum += item.Qty; + //} + //decimal realityBalance = balanceSum - expectOutSum; + //if (detailInput.Qty> realityBalance) + //{ + // throw new UserFriendlyException($"{detailInput.ItemCode} 物品的库存为 {realityBalance} ,库存不够"); + //} + + detailInput.ToLocationErpCode = toLocationDto.ErpLocationCode;