|
@ -27,19 +27,17 @@ public class InjectionRequestEventHandler |
|
|
{ |
|
|
{ |
|
|
private readonly IInjectionJobAppService _injectionJobAppService; |
|
|
private readonly IInjectionJobAppService _injectionJobAppService; |
|
|
private readonly IProductionLineAppService _productionLineAppService; |
|
|
private readonly IProductionLineAppService _productionLineAppService; |
|
|
private readonly IInjectionRequestManager _injectionRequestManager; |
|
|
|
|
|
private readonly IProductionLineItemAppService _productionLineItemAppService; |
|
|
private readonly IProductionLineItemAppService _productionLineItemAppService; |
|
|
private readonly ILocationAppService _locationAppService; |
|
|
private readonly ILocationAppService _locationAppService; |
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
|
|
|
|
|
|
public InjectionRequestEventHandler( |
|
|
public InjectionRequestEventHandler( |
|
|
IInjectionJobAppService injectionJobAppService, IProductionLineAppService productionLineAppService, |
|
|
IInjectionJobAppService injectionJobAppService, IProductionLineAppService productionLineAppService, |
|
|
IInjectionRequestManager injectionRequestManager, ILocationAppService locationAppService, |
|
|
ILocationAppService locationAppService, |
|
|
IBalanceAppService balanceAppService, IProductionLineItemAppService productionLineItemAppService) |
|
|
IBalanceAppService balanceAppService, IProductionLineItemAppService productionLineItemAppService) |
|
|
{ |
|
|
{ |
|
|
_injectionJobAppService = injectionJobAppService; |
|
|
_injectionJobAppService = injectionJobAppService; |
|
|
_productionLineAppService = productionLineAppService; |
|
|
_productionLineAppService = productionLineAppService; |
|
|
_injectionRequestManager = injectionRequestManager; |
|
|
|
|
|
_locationAppService = locationAppService; |
|
|
_locationAppService = locationAppService; |
|
|
_balanceAppService = balanceAppService; |
|
|
_balanceAppService = balanceAppService; |
|
|
_productionLineItemAppService = productionLineItemAppService; |
|
|
_productionLineItemAppService = productionLineItemAppService; |
|
@ -77,13 +75,13 @@ public class InjectionRequestEventHandler |
|
|
switch (entity.Type) |
|
|
switch (entity.Type) |
|
|
{ |
|
|
{ |
|
|
case nameof(EnumIssueType.BoxQty): |
|
|
case nameof(EnumIssueType.BoxQty): |
|
|
injectionJobs =await CreateInjectionJobWithBoxQtyTypeAsync(entity).ConfigureAwait(false); |
|
|
injectionJobs = await CreateInjectionJobWithBoxQtyTypeAsync(entity).ConfigureAwait(false); |
|
|
break; |
|
|
break; |
|
|
case nameof(EnumIssueType.Qty): |
|
|
case nameof(EnumIssueType.Qty): |
|
|
injectionJobs = await CreateInjectionJobWithQtyTypeAsync(entity).ConfigureAwait(false); |
|
|
injectionJobs = await CreateInjectionJobWithQtyTypeAsync(entity).ConfigureAwait(false); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (injectionJobs.Any()) |
|
|
if (injectionJobs.Any()) |
|
|
{ |
|
|
{ |
|
|
await _injectionJobAppService.CreateManyAsync(injectionJobs).ConfigureAwait(false); |
|
|
await _injectionJobAppService.CreateManyAsync(injectionJobs).ConfigureAwait(false); |
|
@ -152,7 +150,8 @@ public class InjectionRequestEventHandler |
|
|
var job = jobs.FirstOrDefault(p => p.WorkGroupCode == fromLocation?.WorkGroupCode); |
|
|
var job = jobs.FirstOrDefault(p => p.WorkGroupCode == fromLocation?.WorkGroupCode); |
|
|
if (job == null || job.Details.Any(p => p.ToLocationCode != injectionRequestDetail.ToLocationCode)) |
|
|
if (job == null || job.Details.Any(p => p.ToLocationCode != injectionRequestDetail.ToLocationCode)) |
|
|
{ |
|
|
{ |
|
|
job = await BuildInjectionJobCreateInputWithQtyTypeAsync(injectionRequest, fromLocation).ConfigureAwait(false); |
|
|
job = await BuildInjectionJobCreateInputWithQtyTypeAsync(injectionRequest, fromLocation) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
jobs.Add(job); |
|
|
jobs.Add(job); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -201,7 +200,8 @@ public class InjectionRequestEventHandler |
|
|
/// <param name="injectionRequest"></param>
|
|
|
/// <param name="injectionRequest"></param>
|
|
|
/// <param name="fromLocation"></param>
|
|
|
/// <param name="fromLocation"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
private async Task<InjectionJobEditInput> BuildInjectionJobCreateInputWithQtyTypeAsync(InjectionRequest injectionRequest, |
|
|
private async Task<InjectionJobEditInput> BuildInjectionJobCreateInputWithQtyTypeAsync( |
|
|
|
|
|
InjectionRequest injectionRequest, |
|
|
LocationDTO fromLocation) |
|
|
LocationDTO fromLocation) |
|
|
{ |
|
|
{ |
|
|
InjectionJobEditInput job; |
|
|
InjectionJobEditInput job; |
|
@ -266,8 +266,10 @@ public class InjectionRequestEventHandler |
|
|
foreach (var recommend in recommendList) |
|
|
foreach (var recommend in recommendList) |
|
|
{ |
|
|
{ |
|
|
//拿走需求量
|
|
|
//拿走需求量
|
|
|
var detail = await BuildInjectionJobDetailWithQtyTypeAsync(injectionRequestDetail, recommend, toLocationGroupCode) |
|
|
var detail = |
|
|
.ConfigureAwait(false); |
|
|
await BuildInjectionJobDetailWithQtyTypeAsync(injectionRequestDetail, recommend, |
|
|
|
|
|
toLocationGroupCode) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
if (injectionRequest.UseOnTheWayLocation) |
|
|
if (injectionRequest.UseOnTheWayLocation) |
|
|
{ |
|
|
{ |
|
|
//获取在途库
|
|
|
//获取在途库
|
|
@ -347,6 +349,7 @@ public class InjectionRequestEventHandler |
|
|
(InjectionRequest injectionRequest) |
|
|
(InjectionRequest injectionRequest) |
|
|
{ |
|
|
{ |
|
|
var inputJobs = new List<InjectionJobEditInput>(); |
|
|
var inputJobs = new List<InjectionJobEditInput>(); |
|
|
|
|
|
var inputExpectOutEditInput = new ExpectOutEditInput(); |
|
|
//已用的库存的箱码集合
|
|
|
//已用的库存的箱码集合
|
|
|
var useBalanceList = new List<string>(); |
|
|
var useBalanceList = new List<string>(); |
|
|
|
|
|
|
|
@ -369,9 +372,9 @@ public class InjectionRequestEventHandler |
|
|
throw new UserFriendlyException($"库位【{inputDetailTemplate.ToLocationCode}】没有对应的【生产线】"); |
|
|
throw new UserFriendlyException($"库位【{inputDetailTemplate.ToLocationCode}】没有对应的【生产线】"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var productLineCodeAndItemCode = (await _productionLineItemAppService |
|
|
var productLineCodeAndItemCode = await _productionLineItemAppService |
|
|
.GetByProductLineCodeAndItemCodeAsync(productionLineDto.Code, inputDetailTemplate.ItemCode) |
|
|
.GetByProductLineCodeAndItemCodeAsync(productionLineDto.Code, inputDetailTemplate.ItemCode) |
|
|
.ConfigureAwait(false)); |
|
|
.ConfigureAwait(false); |
|
|
if (productLineCodeAndItemCode == null) |
|
|
if (productLineCodeAndItemCode == null) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException( |
|
|
throw new UserFriendlyException( |
|
@ -387,16 +390,15 @@ public class InjectionRequestEventHandler |
|
|
Locations = JsonSerializer.Deserialize<List<string>>(productLineCodeAndItemCode |
|
|
Locations = JsonSerializer.Deserialize<List<string>>(productLineCodeAndItemCode |
|
|
.RawLocationCodeListJson) |
|
|
.RawLocationCodeListJson) |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
//所有可用库存
|
|
|
|
|
|
var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); |
|
|
var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); |
|
|
usableList=usableList.Where(p => !useBalanceList.Contains(p.PackingCode)).ToList(); |
|
|
usableList = usableList.Where(p => !useBalanceList.Contains(p.PackingCode)).ToList(); |
|
|
var firstUsable = usableList.First(); |
|
|
|
|
|
useBalanceList.Add(firstUsable.PackingCode); |
|
|
|
|
|
usableList.Remove(firstUsable); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < sumBoxQty; i++) |
|
|
for (var i = 0; i < sumBoxQty; i++) |
|
|
{ |
|
|
{ |
|
|
|
|
|
var firstUsable = usableList.First(); |
|
|
|
|
|
useBalanceList.Add(firstUsable.PackingCode); |
|
|
|
|
|
usableList.Remove(firstUsable); |
|
|
|
|
|
|
|
|
var injectionJobEditInput = |
|
|
var injectionJobEditInput = |
|
|
await BuildInjectionJobCreateInputWithBoxQtyTypeAsync(injectionRequest, inputDetailTemplate, |
|
|
await BuildInjectionJobCreateInputWithBoxQtyTypeAsync(injectionRequest, inputDetailTemplate, |
|
|
firstUsable) |
|
|
firstUsable) |
|
@ -416,8 +418,9 @@ public class InjectionRequestEventHandler |
|
|
/// <param name="injectionRequestDetail"></param>
|
|
|
/// <param name="injectionRequestDetail"></param>
|
|
|
/// <param name="balanceDtos"></param>
|
|
|
/// <param name="balanceDtos"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
private async Task<InjectionJobEditInput> BuildInjectionJobCreateInputWithBoxQtyTypeAsync(InjectionRequest injectionRequest, |
|
|
private async Task<InjectionJobEditInput> BuildInjectionJobCreateInputWithBoxQtyTypeAsync( |
|
|
InjectionRequestDetail injectionRequestDetail,BalanceDTO balanceDtos) |
|
|
InjectionRequest injectionRequest, |
|
|
|
|
|
InjectionRequestDetail injectionRequestDetail, BalanceDTO balanceDtos) |
|
|
{ |
|
|
{ |
|
|
InjectionJobEditInput job; |
|
|
InjectionJobEditInput job; |
|
|
job = ObjectMapper.Map<InjectionRequest, InjectionJobEditInput>(injectionRequest); |
|
|
job = ObjectMapper.Map<InjectionRequest, InjectionJobEditInput>(injectionRequest); |
|
@ -429,7 +432,8 @@ public class InjectionRequestEventHandler |
|
|
job.Worker = injectionRequest.Worker; |
|
|
job.Worker = injectionRequest.Worker; |
|
|
job.InjectionRequestNumber = injectionRequest.Number; |
|
|
job.InjectionRequestNumber = injectionRequest.Number; |
|
|
|
|
|
|
|
|
job.Details.Add(await BuildInjectionJobDetailWithBoxQtyTypeAsync(injectionRequestDetail, balanceDtos).ConfigureAwait(false)); |
|
|
job.Details.Add(await BuildInjectionJobDetailWithBoxQtyTypeAsync(injectionRequestDetail, balanceDtos) |
|
|
|
|
|
.ConfigureAwait(false)); |
|
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
|
|
|
|
@ -446,8 +450,6 @@ public class InjectionRequestEventHandler |
|
|
private async Task<InjectionJobDetailInput> BuildInjectionJobDetailWithBoxQtyTypeAsync( |
|
|
private async Task<InjectionJobDetailInput> BuildInjectionJobDetailWithBoxQtyTypeAsync( |
|
|
InjectionRequestDetail injectionRequestDetail, BalanceDTO balance) |
|
|
InjectionRequestDetail injectionRequestDetail, BalanceDTO balance) |
|
|
{ |
|
|
{ |
|
|
//ProductionLineDTO prodLine = await _productionLineAppService.GetByLocationGroupCodeAsync(toLocationGroupCode).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
var detail = ObjectMapper.Map<BalanceDTO, InjectionJobDetailInput>(balance); |
|
|
var detail = ObjectMapper.Map<BalanceDTO, InjectionJobDetailInput>(balance); |
|
|
detail.RequestLocationCode = injectionRequestDetail.ToLocationCode; |
|
|
detail.RequestLocationCode = injectionRequestDetail.ToLocationCode; |
|
|
detail.WorkStation = injectionRequestDetail.WorkStation; |
|
|
detail.WorkStation = injectionRequestDetail.WorkStation; |
|
@ -475,8 +477,8 @@ public class InjectionRequestEventHandler |
|
|
detail.ToLocationErpCode = injectionRequestDetail.ToLocationErpCode; |
|
|
detail.ToLocationErpCode = injectionRequestDetail.ToLocationErpCode; |
|
|
detail.ToLocationArea = injectionRequestDetail.ToLocationArea; |
|
|
detail.ToLocationArea = injectionRequestDetail.ToLocationArea; |
|
|
detail.ToWarehouseCode = injectionRequestDetail.ToWarehouseCode; |
|
|
detail.ToWarehouseCode = injectionRequestDetail.ToWarehouseCode; |
|
|
|
|
|
detail.ToLocationGroup= injectionRequestDetail.ToLocationGroup; |
|
|
|
|
|
|
|
|
//detail.ProdLine = prodLine == null ? toLocationGroupCode : prodLine.Code;
|
|
|
|
|
|
detail.ProdLine = injectionRequestDetail.ToLocationCode; |
|
|
detail.ProdLine = injectionRequestDetail.ToLocationCode; |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
return detail; |
|
|
return detail; |
|
|