From 386312b74e6c8aea060057c300ac5351bb297f15 Mon Sep 17 00:00:00 2001 From: Zheng Date: Sat, 7 Dec 2024 10:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E5=BA=93=E7=A7=BB?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransferNotes/TransferNoteAppService.cs | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs index 9788188ed..2f1b557b1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs @@ -83,6 +83,22 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase { var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); + foreach (var addTransferNote in addList) + { + foreach (var detail in addTransferNote.Details) + { + var balanceDto = await _balanceAppService.GetByItemLocationPackingAndStatusAsync(detail.FromPackingCode, + detail.ItemCode, detail.FromLocationCode, detail.FromStatus).ConfigureAwait(false); + + if (balanceDto.Qty < detail.Qty || balanceDto.Qty < 0) + { + throw new UserFriendlyException($"您申请的【ERP料号】{detail.ItemCode}【库位】{detail.FromLocationCode}【箱码】{detail.FromPackingCode}【状态】{detail.FromStatus}【数量】{detail.Qty}的库存," + + $"在实际库存中查询到【ERP料号】{balanceDto.ItemCode}【库位】{balanceDto.LocationCode}【箱码】{balanceDto.PackingCode}【状态】{balanceDto.Status}【数量】{balanceDto.Qty}" + + $"【库存不足】"); + } + } + } + foreach (var transferNote in addList) { if (transferNote.Type == EnumTransSubType.Transfer_Inside.GetDisplayName()) //储位内调拨 @@ -366,7 +382,20 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase { var entity = ObjectMapper.Map(input); - entity=await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false); + foreach (var detail in entity.Details) + { + var balanceDto = await _balanceAppService.GetByItemLocationPackingAndStatusAsync(detail.FromPackingCode, + detail.ItemCode, detail.FromLocationCode, detail.FromStatus).ConfigureAwait(false); + + if (balanceDto.Qty < detail.Qty || balanceDto.Qty < 0) + { + throw new UserFriendlyException($"您申请的【ERP料号】{detail.ItemCode}【库位】{detail.FromLocationCode}【箱码】{detail.FromPackingCode}【状态】{detail.FromStatus}【数量】{detail.Qty}的库存," + + $"在实际库存中查询到【ERP料号】{balanceDto.ItemCode}【库位】{balanceDto.LocationCode}【箱码】{balanceDto.PackingCode}【状态】{balanceDto.Status}【数量】{balanceDto.Qty}" + + $"【库存不足】"); + } + } + + entity =await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false); var dto = ObjectMapper.Map(entity); @@ -387,6 +416,19 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase foreach (var entity in entitys) { + foreach (var detail in entity.Details) + { + var balanceDto = await _balanceAppService.GetByItemLocationPackingAndStatusAsync(detail.FromPackingCode, + detail.ItemCode, detail.FromLocationCode, detail.FromStatus).ConfigureAwait(false); + + if (balanceDto.Qty < detail.Qty || balanceDto.Qty < 0) + { + throw new UserFriendlyException($"您申请的【ERP料号】{detail.ItemCode}【库位】{detail.FromLocationCode}【箱码】{detail.FromPackingCode}【状态】{detail.FromStatus}【数量】{detail.Qty}的库存," + + $"在实际库存中查询到【ERP料号】{balanceDto.ItemCode}【库位】{balanceDto.LocationCode}【箱码】{balanceDto.PackingCode}【状态】{balanceDto.Status}【数量】{balanceDto.Qty}" + + $"【库存不足】"); + } + } + resultEntity.Add(await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false)); _ = ObjectMapper.Map(entity); }