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); }