diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs index fe17be14f..d29cb989b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs @@ -17,6 +17,7 @@ using Win_in.Sfs.Wms.Store.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application; using System.Linq; +using Volo.Abp.ObjectMapping; using Win_in.Sfs.Basedata.Application; using Win_in.Sfs.Basedata.Application.Contracts; @@ -65,45 +66,76 @@ public class PutawayNoteAppService : //[Authorize(PutawayNotePermissions.Create)] public override async Task CreateAsync(PutawayNoteEditInput input) { - foreach (var detail in input.Details) + var inputSplits = new List(); + var resultPutawayNote=new List(); + + //先获取所有的箱码 + var selectPackingCode=input.Details.Select(p => p.ToPackingCode); + var splitPackingRecList = await _splitPackingRecAppService.GetListByToPackingCode(selectPackingCode.ToList()).ConfigureAwait(false); + //按照不同的条件分组 + var group= splitPackingRecList.GroupBy(p => new { + p.SupplierCode,p.AsnNumber,p.PoNumber + }); + foreach (var groupWhere in group) { - var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(input.Number, input.SupplierCode, detail.ItemCode).ConfigureAwait(false); - if (isClosed) + var tempEditInput = new PutawayNoteEditInput(); + tempEditInput.Details = new List(); + tempEditInput.SupplierCode = groupWhere.First().SupplierCode; + tempEditInput.AsnNumber = groupWhere.First().AsnNumber; + tempEditInput.InspectNumber = string.Empty; + tempEditInput.JobNumber = string.Empty; + tempEditInput.ProductReceiptNumber = string.Empty; + tempEditInput.PurchaseReceiptRequestNumber = string.Empty; + tempEditInput.Type = EnumPutawayType.PurchasePutaway; + foreach (var packingCode in groupWhere) { - throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!"); + var detailInput=input.Details.First(p => p.ToPackingCode == packingCode.ToPackingCode); + tempEditInput.Details.Add(detailInput); } - var item = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); - if (!item.CanMake) + inputSplits.Add(tempEditInput); + } + + foreach (var inputSplit in inputSplits) + { + foreach (var detail in inputSplit.Details) { - var isprice = await _purchasePriceSheetAppService.CheckPurPriceAsync(input.SupplierCode, detail.ItemCode).ConfigureAwait(false); - if (isprice) + var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(inputSplit.Number, inputSplit.SupplierCode, detail.ItemCode).ConfigureAwait(false); + if (isClosed) { - throw new UserFriendlyException($"供应商【{input.SupplierCode}】物品名称【{detail.ItemCode}】无采购价格无法执行采购上架!"); + throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!"); } - } - var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false); + var item = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + if (!item.CanMake) + { + var isprice = await _purchasePriceSheetAppService.CheckPurPriceAsync(inputSplit.SupplierCode, detail.ItemCode).ConfigureAwait(false); + if (isprice) + { + throw new UserFriendlyException($"供应商【{inputSplit.SupplierCode}】物品名称【{detail.ItemCode}】无采购价格无法执行采购上架!"); + } + } + var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false); - if (erpLocationItem == null) - { - throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息"); - } - var purchasereDetail = await _purchaseReceiptNoteAppService - .GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false); - if (purchasereDetail != null) - { - var inspectJobDto = await _inspectJobAppService - .GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false); - if (inspectJobDto.JobStatus != EnumJobStatus.Done) + if (erpLocationItem == null) { - throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检"); + throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息"); + } + var purchasereDetail = await _purchaseReceiptNoteAppService + .GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false); + if (purchasereDetail != null) + { + var inspectJobDto = await _inspectJobAppService + .GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false); + if (inspectJobDto.JobStatus != EnumJobStatus.Done) + { + throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检"); + } } } + var entity = ObjectMapper.Map(inputSplit); + resultPutawayNote.Add( await _putawayNoteManager.CreateByPurchaseAsync(entity).ConfigureAwait(false)); } - var entity = ObjectMapper.Map(input); - var result = await _putawayNoteManager.CreateByPurchaseAsync(entity).ConfigureAwait(false); - - var dto = ObjectMapper.Map(result); + var dto = ObjectMapper.Map(resultPutawayNote.First()); return dto; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs index 809db3d71..547dbdb05 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs @@ -232,7 +232,7 @@ ISupplierItemAppService supplierItemAppService) : base(repository) { if (result.All(p => p.Code != itemCode)) { - throw new UserFriendlyException($"供应商代码【{itemCode}】不存在"); + throw new UserFriendlyException($"ERP料号代码【{itemCode}】不存在"); } }