diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs index 878b02ee0..1ccb8b4f3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs @@ -2,14 +2,17 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json; using System.Threading.Tasks; +using AutoMapper; using Castle.Components.DictionaryAdapter; using Volo.Abp; +using Volo.Abp.AutoMapper; using Volo.Abp.EventBus; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; 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; @@ -28,6 +31,7 @@ public class KittingIssueRequestEventHandler private readonly IProductionLineItemAppService _productionLineItemAppService; private readonly ILocationAppService _locationAppService; private readonly IBalanceAppService _balanceAppService; + private IMapper _mapper; //private readonly IKittingIssueRequestManager _kittingIssueRequestManager; public KittingIssueRequestEventHandler( @@ -329,7 +333,7 @@ public class KittingIssueRequestEventHandler ( KittingIssueRequest kittingIssueRequest, List kittingIssueRequestDetailList, - List recommendbalanceDtos, + List recommendbalanceDtos, List useBalanceList) { var inputJobs = new List(); @@ -368,7 +372,7 @@ public class KittingIssueRequestEventHandler if (usableList.Any()) { var firstUsable = usableList.First(); - useBalanceList.Add(firstUsable); + useBalanceList.Add((BalanceDTO)firstUsable); usableList.Remove(firstUsable); var kittingIssueJobEditInput = @@ -533,6 +537,7 @@ public class KittingIssueRequestEventHandler IsPackingCode = true }; var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); + var sortByFifoAsync=await SortByFifoAsync(usableList).ConfigureAwait(false); //因为是按箱叫料 先把值赋值给箱数量上 kittingIssueRequestDetail.BoxQty = kittingIssueRequestDetail.Qty; @@ -543,7 +548,7 @@ public class KittingIssueRequestEventHandler kittingIssueJobEditInputs.AddRange( await CreateKittingIssueJobWithBoxQtyTypeAsync(kittingIssueRequest, new EditableList { kittingIssueRequestDetail }, - usableList, + sortByFifoAsync, useBalanceList).ConfigureAwait(false)); } } @@ -660,4 +665,43 @@ public class KittingIssueRequestEventHandler //await _kittingIssueRequestManager.UpdateAsync(kittingIssueRequest).ConfigureAwait(false); } + + /// + /// 排序规则 1.批次正序 2.底层 3.到货日期正序 4.数量倒序(整箱优先) 5.库位正序 6.箱码正序 + /// + /// + /// + public async Task> SortByFifoAsync(List balances) + { + var sortBalances = new List(); + var config = new MapperConfiguration(cfg => + { + cfg.CreateMap() + .Ignore(x => x.LocationRow); + }); + _mapper = new Mapper(config); + + var resultBalances = _mapper.Map, List>(balances); + foreach (var resultBalance in resultBalances) + { + var locationDto=await _locationAppService.GetByCodeAsync(resultBalance.LocationCode).ConfigureAwait(false); + resultBalance.LocationRow = locationDto.RowCode; + } + + resultBalances + .OrderBy(p => p.Lot) + .OrderBy(p=>p.LocationRow) + .ThenBy(p => p.PutInTime) + .ThenBy(p => p.Qty)//2023-9-14 苑静雯 从小数开始发料 + .ThenBy(p => p.LocationCode) + .ThenBy(p => p.PackingCode) + .ToList(); + + return resultBalances; + } +} + +public class SortBalance: BalanceDTO +{ + public int LocationRow { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs index 545e6961f..6f9c964f1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs @@ -82,10 +82,10 @@ public class UnplannedIssueRequestEventHandler public virtual async Task HandleEventAsync(SfsHandledEntityEventData eventData) { var entity = eventData.Entity; - if (entity.UnplannedIssueType == Shared.Domain.Shared.Enums.Store.EnumUnplannedIssueType.Wip&&!string.IsNullOrEmpty(entity.OANumber)) - { - entity.RequestStatus = EnumRequestStatus.Completed; - } + //if (entity.UnplannedIssueType == Shared.Domain.Shared.Enums.Store.EnumUnplannedIssueType.Wip&&!string.IsNullOrEmpty(entity.OANumber)) + //{ + // entity.RequestStatus = EnumRequestStatus.Completed; + //} if (entity.DirectCreateNote) { var note = await BuildUnplannedIssueNoteCreateInputAsync(entity).ConfigureAwait(false);