|
|
@ -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<KittingIssueRequestDetail> kittingIssueRequestDetailList, |
|
|
|
List<BalanceDTO> recommendbalanceDtos, |
|
|
|
List<SortBalance> recommendbalanceDtos, |
|
|
|
List<BalanceDTO> useBalanceList) |
|
|
|
{ |
|
|
|
var inputJobs = new List<KittingIssueJobEditInput>(); |
|
|
@ -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> { kittingIssueRequestDetail }, |
|
|
|
usableList, |
|
|
|
sortByFifoAsync, |
|
|
|
useBalanceList).ConfigureAwait(false)); |
|
|
|
} |
|
|
|
} |
|
|
@ -660,4 +665,43 @@ public class KittingIssueRequestEventHandler |
|
|
|
|
|
|
|
//await _kittingIssueRequestManager.UpdateAsync(kittingIssueRequest).ConfigureAwait(false);
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 排序规则 1.批次正序 2.底层 3.到货日期正序 4.数量倒序(整箱优先) 5.库位正序 6.箱码正序
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="balances"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<List<SortBalance>> SortByFifoAsync(List<BalanceDTO> balances) |
|
|
|
{ |
|
|
|
var sortBalances = new List<SortBalance>(); |
|
|
|
var config = new MapperConfiguration(cfg => |
|
|
|
{ |
|
|
|
cfg.CreateMap<BalanceDTO, SortBalance>() |
|
|
|
.Ignore(x => x.LocationRow); |
|
|
|
}); |
|
|
|
_mapper = new Mapper(config); |
|
|
|
|
|
|
|
var resultBalances = _mapper.Map<List<BalanceDTO>, List<SortBalance>>(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; } |
|
|
|
} |
|
|
|