From ac9c6ca8effae596dfd239c886c05130034ffaa4 Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Fri, 20 Dec 2024 16:03:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E8=B0=83=E6=8B=A8=20=E5=BC=82=E5=B8=B8=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Requests/TransferRequestEventHandler.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs index 2fefa0657..3ad2cd023 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using DocumentFormat.OpenXml.Bibliography; +using Volo.Abp; using Volo.Abp.EventBus; using Volo.Abp.EventBus.Local; using Volo.Abp.SettingManagement; @@ -9,6 +10,7 @@ using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; 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.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; @@ -26,14 +28,16 @@ public class TransferRequestEventHandler private readonly ITransferNoteManager _transferNoteManager; private readonly ILocationAppService _locationAppService; private readonly ITransferRequestManager _transferRequestManager; + private readonly IBalanceAppService _balanceAppService; protected ILocalEventBus LocalEventBus => LazyServiceProvider.LazyGetRequiredService(); public TransferRequestEventHandler( - ITransferNoteManager transferNoteManager, ILocationAppService locationAppService, ITransferRequestManager transferRequestManager) + ITransferNoteManager transferNoteManager, ILocationAppService locationAppService, ITransferRequestManager transferRequestManager, IBalanceAppService balanceAppService) { _transferNoteManager = transferNoteManager; _locationAppService = locationAppService; _transferRequestManager = transferRequestManager; + _balanceAppService = balanceAppService; } @@ -53,6 +57,17 @@ public class TransferRequestEventHandler { var input = ObjectMapper.Map(entity); + foreach (var detail in input.Details) + { + var balanceDto=await _balanceAppService.GetRealQtyByPackingCodeAndItemCodeAndLocationCodeAndStatusAsync( + detail.FromPackingCode, detail.ItemCode, detail.FromLocationCode, EnumInventoryStatus.OK).ConfigureAwait(false); + + if (balanceDto.Qty < detail.Qty) + { + throw new UserFriendlyException($"{detail.ItemCode}库存不足,申请数量{detail.Qty},现有可用库存{balanceDto.Qty}"); + } + } + //获取在途库 var locationDto = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT) .ConfigureAwait(false);