|
@ -1,6 +1,5 @@ |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Text; |
|
|
|
|
|
using System.Text.Json; |
|
|
using System.Text.Json; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using AutoMapper; |
|
|
using AutoMapper; |
|
@ -15,7 +14,6 @@ using Win_in.Sfs.Shared.Event; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
|
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; |
|
|
namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; |
|
|
|
|
|
|
|
@ -33,13 +31,11 @@ public class AssembleIssueRequestEventHandler |
|
|
private readonly ILocationAppService _locationAppService; |
|
|
private readonly ILocationAppService _locationAppService; |
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
private IMapper _mapper; |
|
|
private IMapper _mapper; |
|
|
//private readonly IAssembleIssueRequestManager _assembleIssueRequestManager;
|
|
|
|
|
|
|
|
|
|
|
|
public AssembleIssueRequestEventHandler( |
|
|
public AssembleIssueRequestEventHandler( |
|
|
IAssembleIssueJobAppService assembleIssueJobAppService, IProductionLineAppService productionLineAppService, |
|
|
IAssembleIssueJobAppService assembleIssueJobAppService, IProductionLineAppService productionLineAppService, |
|
|
ILocationAppService locationAppService, |
|
|
ILocationAppService locationAppService, |
|
|
IBalanceAppService balanceAppService, IProductionLineItemAppService productionLineItemAppService |
|
|
IBalanceAppService balanceAppService, IProductionLineItemAppService productionLineItemAppService |
|
|
//, IAssembleIssueRequestManager assembleIssueRequestManager
|
|
|
|
|
|
) |
|
|
) |
|
|
{ |
|
|
{ |
|
|
_assembleIssueJobAppService = assembleIssueJobAppService; |
|
|
_assembleIssueJobAppService = assembleIssueJobAppService; |
|
@ -47,7 +43,6 @@ public class AssembleIssueRequestEventHandler |
|
|
_locationAppService = locationAppService; |
|
|
_locationAppService = locationAppService; |
|
|
_balanceAppService = balanceAppService; |
|
|
_balanceAppService = balanceAppService; |
|
|
_productionLineItemAppService = productionLineItemAppService; |
|
|
_productionLineItemAppService = productionLineItemAppService; |
|
|
//_assembleIssueRequestManager = assembleIssueRequestManager;
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
@ -67,8 +62,6 @@ public class AssembleIssueRequestEventHandler |
|
|
/// <param name="eventData">Event data</param>
|
|
|
/// <param name="eventData">Event data</param>
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<AssembleIssueRequest>> eventData) |
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<AssembleIssueRequest>> eventData) |
|
|
{ |
|
|
{ |
|
|
var entity = eventData.Entity; |
|
|
|
|
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -102,7 +95,7 @@ public class AssembleIssueRequestEventHandler |
|
|
public virtual async Task HandleEventAsync(SfsCompletedEntityEventData<AssembleIssueRequest> eventData) |
|
|
public virtual async Task HandleEventAsync(SfsCompletedEntityEventData<AssembleIssueRequest> eventData) |
|
|
{ |
|
|
{ |
|
|
_ = eventData.Entity; |
|
|
_ = eventData.Entity; |
|
|
// await _assembleIssueJobAppService.CompleteByAssembleIssueRequestAsync(entity.Number);
|
|
|
// await _AssembleIssueJobAppService.CompleteByAssembleIssueRequestAsync(entity.Number);
|
|
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
} |
|
|
} |
|
@ -179,8 +172,8 @@ public class AssembleIssueRequestEventHandler |
|
|
|
|
|
|
|
|
if (assembleIssueJobDetailInputs.Any()) |
|
|
if (assembleIssueJobDetailInputs.Any()) |
|
|
{ |
|
|
{ |
|
|
var assembleIssueJobEditInput = new AssembleIssueJobEditInput(); |
|
|
var assembleIssueJobEditInput = await BuildAssembleIssueJobCreateInputWithQtyTypeAsync( |
|
|
assembleIssueJobEditInput = await BuildAssembleIssueJobCreateInputWithQtyTypeAsync(assembleIssueRequest, |
|
|
assembleIssueRequest, |
|
|
assembleIssueRequestDetails.First()).ConfigureAwait(false); |
|
|
assembleIssueRequestDetails.First()).ConfigureAwait(false); |
|
|
assembleIssueJobEditInput.Details = assembleIssueJobDetailInputs; |
|
|
assembleIssueJobEditInput.Details = assembleIssueJobDetailInputs; |
|
|
jobs.Add(assembleIssueJobEditInput); |
|
|
jobs.Add(assembleIssueJobEditInput); |
|
@ -212,7 +205,6 @@ public class AssembleIssueRequestEventHandler |
|
|
return job; |
|
|
return job; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 构造注塑任务明细-按数量
|
|
|
/// 构造注塑任务明细-按数量
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -339,22 +331,19 @@ public class AssembleIssueRequestEventHandler |
|
|
{ |
|
|
{ |
|
|
var inputJobs = new List<AssembleIssueJobEditInput>(); |
|
|
var inputJobs = new List<AssembleIssueJobEditInput>(); |
|
|
|
|
|
|
|
|
var jobs = await _assembleIssueJobAppService.GetByRequestNumberAsync(assembleIssueRequest.Number).ConfigureAwait(false); |
|
|
var jobs = await _assembleIssueJobAppService.GetByRequestNumberAsync(assembleIssueRequest.Number) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
//已用的库存的集合
|
|
|
|
|
|
useBalanceList = useBalanceList; |
|
|
|
|
|
|
|
|
|
|
|
foreach (var detail in assembleIssueRequestDetailList) |
|
|
foreach (var detail in assembleIssueRequestDetailList) |
|
|
{ |
|
|
{ |
|
|
//当前零件的集合
|
|
|
//当前零件的集合
|
|
|
var inputDetails = assembleIssueRequestDetailList; |
|
|
var inputDetails = assembleIssueRequestDetailList; |
|
|
//获取请求下 这个零件和这个库位一个需要多少箱
|
|
|
//获取请求下 这个零件和这个库位一个需要多少箱
|
|
|
var sumBoxQty = inputDetails.Sum(p => p.BoxQty -jobs.Count); |
|
|
var sumBoxQty = inputDetails.Sum(p => p.BoxQty - jobs.Count); |
|
|
//获取生产线
|
|
|
//获取生产线
|
|
|
var productionLineDto = await _productionLineAppService |
|
|
var productionLineDto = await _productionLineAppService |
|
|
.GetByLocationCodeAsync(inputDetails.First().ToLocationCode).ConfigureAwait(false); |
|
|
.GetByLocationCodeAsync(inputDetails.First().ToLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var productLineCodeAndItemCode = await _productionLineItemAppService |
|
|
var productLineCodeAndItemCode = await _productionLineItemAppService |
|
|
.GetByProductLineCodeAndItemCodeAsync(productionLineDto.Code, detail.ItemCode) |
|
|
.GetByProductLineCodeAndItemCodeAsync(productionLineDto.Code, detail.ItemCode) |
|
|
.ConfigureAwait(false); |
|
|
.ConfigureAwait(false); |
|
@ -366,7 +355,8 @@ public class AssembleIssueRequestEventHandler |
|
|
|
|
|
|
|
|
//可用库存
|
|
|
//可用库存
|
|
|
var usableList = recommendbalanceDtos; |
|
|
var usableList = recommendbalanceDtos; |
|
|
usableList = usableList.Where(p => !useBalanceList.Select(p => p.PackingCode).Contains(p.PackingCode)) |
|
|
usableList = usableList.Where(p => |
|
|
|
|
|
!useBalanceList.Select(balanceDto => balanceDto.PackingCode).Contains(p.PackingCode)) |
|
|
.ToList(); |
|
|
.ToList(); |
|
|
if (usableList.Any()) |
|
|
if (usableList.Any()) |
|
|
{ |
|
|
{ |
|
@ -375,7 +365,7 @@ public class AssembleIssueRequestEventHandler |
|
|
if (usableList.Any()) |
|
|
if (usableList.Any()) |
|
|
{ |
|
|
{ |
|
|
var firstUsable = usableList.First(); |
|
|
var firstUsable = usableList.First(); |
|
|
useBalanceList.Add((BalanceDTO)firstUsable); |
|
|
useBalanceList.Add(firstUsable); |
|
|
usableList.Remove(firstUsable); |
|
|
usableList.Remove(firstUsable); |
|
|
|
|
|
|
|
|
var assembleIssueJobEditInput = |
|
|
var assembleIssueJobEditInput = |
|
@ -429,7 +419,6 @@ public class AssembleIssueRequestEventHandler |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="assembleIssueRequestDetail"></param>
|
|
|
/// <param name="assembleIssueRequestDetail"></param>
|
|
|
/// <param name="balance"></param>
|
|
|
/// <param name="balance"></param>
|
|
|
/// <param name="toLocationGroupCode"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
private async Task<AssembleIssueJobDetailInput> BuildAssembleIssueJobDetailWithBoxQtyTypeAsync( |
|
|
private async Task<AssembleIssueJobDetailInput> BuildAssembleIssueJobDetailWithBoxQtyTypeAsync( |
|
|
AssembleIssueRequestDetail assembleIssueRequestDetail, BalanceDTO balance) |
|
|
AssembleIssueRequestDetail assembleIssueRequestDetail, BalanceDTO balance) |
|
@ -594,8 +583,6 @@ public class AssembleIssueRequestEventHandler |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
usableList = temp; |
|
|
|
|
|
|
|
|
|
|
|
assembleIssueJobEditInputs.AddRange( |
|
|
assembleIssueJobEditInputs.AddRange( |
|
|
await CreateAssembleIssueJobWithQtyTypeAsync(assembleIssueRequest, |
|
|
await CreateAssembleIssueJobWithQtyTypeAsync(assembleIssueRequest, |
|
|
new List<AssembleIssueRequestDetail> { assembleIssueRequestDetail }, temp, |
|
|
new List<AssembleIssueRequestDetail> { assembleIssueRequestDetail }, temp, |
|
@ -608,7 +595,8 @@ public class AssembleIssueRequestEventHandler |
|
|
if (assembleIssueJobEditInputs.Count > 0) //有库存 可以创建任务
|
|
|
if (assembleIssueJobEditInputs.Count > 0) //有库存 可以创建任务
|
|
|
{ |
|
|
{ |
|
|
//新增任务
|
|
|
//新增任务
|
|
|
var addAssembleIssueJobDtos = await _assembleIssueJobAppService.CreateManyAsync(assembleIssueJobEditInputs) |
|
|
var addAssembleIssueJobDtos = await _assembleIssueJobAppService |
|
|
|
|
|
.CreateManyAsync(assembleIssueJobEditInputs) |
|
|
.ConfigureAwait(false); |
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
await UpdateAssembleIssueRequestDetailQtyAsync(assembleIssueRequest, addAssembleIssueJobDtos) |
|
|
await UpdateAssembleIssueRequestDetailQtyAsync(assembleIssueRequest, addAssembleIssueJobDtos) |
|
@ -665,18 +653,15 @@ public class AssembleIssueRequestEventHandler |
|
|
requestDetail.ReceivedQty = allReceivedQty; |
|
|
requestDetail.ReceivedQty = allReceivedQty; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//await _assembleIssueRequestManager.UpdateAsync(assembleIssueRequest).ConfigureAwait(false);
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 排序规则 1.批次正序 2.底层 3.到货日期正序 4.数量倒序(整箱优先) 5.库位正序 6.箱码正序
|
|
|
/// 排序规则 1.批次正序 2.底层 3.到货日期正序 4.数量倒序(整箱优先) 5.库位正序 6.箱码正序
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="balances"></param>
|
|
|
/// <param name="balances"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public async Task<List<SortBalance>> SortByFifoAsync(List<BalanceDTO> balances) |
|
|
public async Task<List<SortBalance>> SortByFifoAsync(List<BalanceDTO> balances) |
|
|
{ |
|
|
{ |
|
|
var sortBalances = new List<SortBalance>(); |
|
|
|
|
|
var config = new MapperConfiguration(cfg => |
|
|
var config = new MapperConfiguration(cfg => |
|
|
{ |
|
|
{ |
|
|
cfg.CreateMap<BalanceDTO, SortBalance>() |
|
|
cfg.CreateMap<BalanceDTO, SortBalance>() |
|
@ -687,15 +672,16 @@ public class AssembleIssueRequestEventHandler |
|
|
var resultBalances = _mapper.Map<List<BalanceDTO>, List<SortBalance>>(balances); |
|
|
var resultBalances = _mapper.Map<List<BalanceDTO>, List<SortBalance>>(balances); |
|
|
foreach (var resultBalance in resultBalances) |
|
|
foreach (var resultBalance in resultBalances) |
|
|
{ |
|
|
{ |
|
|
var locationDto = await _locationAppService.GetByCodeAsync(resultBalance.LocationCode).ConfigureAwait(false); |
|
|
var locationDto = |
|
|
|
|
|
await _locationAppService.GetByCodeAsync(resultBalance.LocationCode).ConfigureAwait(false); |
|
|
resultBalance.LocationRow = locationDto.RowCode; |
|
|
resultBalance.LocationRow = locationDto.RowCode; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
resultBalances |
|
|
resultBalances = resultBalances |
|
|
.OrderBy(p => p.Lot) |
|
|
.OrderBy(p => p.Lot) |
|
|
.ThenBy(p => p.LocationRow) |
|
|
.ThenBy(p => p.LocationRow) |
|
|
.ThenBy(p => p.PutInTime) |
|
|
.ThenBy(p => p.PutInTime) |
|
|
.ThenBy(p => p.Qty)//2023-9-14 苑静雯 从小数开始发料
|
|
|
.ThenBy(p => p.Qty) //2023-9-14 苑静雯 从小数开始发料
|
|
|
.ThenBy(p => p.LocationCode) |
|
|
.ThenBy(p => p.LocationCode) |
|
|
.ThenBy(p => p.PackingCode) |
|
|
.ThenBy(p => p.PackingCode) |
|
|
.ToList(); |
|
|
.ToList(); |
|
@ -703,4 +689,3 @@ public class AssembleIssueRequestEventHandler |
|
|
return resultBalances; |
|
|
return resultBalances; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|