|
|
@ -1,4 +1,3 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
@ -6,7 +5,9 @@ using Volo.Abp.EventBus; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
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.Store.Application.Contracts; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
@ -16,16 +17,26 @@ namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; |
|
|
|
public class InjectionJobEventHandler : |
|
|
|
StoreEventHandlerBase |
|
|
|
, ILocalEventHandler<SfsCompletedEntityEventData<InjectionJob>> |
|
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<InjectionJob>> |
|
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<InjectionJob>>> |
|
|
|
{ |
|
|
|
private const EnumTransType TransType = EnumTransType.Issue; |
|
|
|
|
|
|
|
private readonly IInjectionNoteAppService _injectionNoteAppService; |
|
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
|
private readonly IExpectOutAppService _expectOutAppService; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
private readonly ITransferLibRequestAppService _transferLibRequestAppService; |
|
|
|
|
|
|
|
public InjectionJobEventHandler(IInjectionNoteAppService injectionNoteAppService, ILocationAppService locationAppService) |
|
|
|
public InjectionJobEventHandler(IInjectionNoteAppService injectionNoteAppService, |
|
|
|
IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService, |
|
|
|
ILocationAppService locationAppService, ITransferLibRequestAppService transferLibRequestAppService) |
|
|
|
{ |
|
|
|
_injectionNoteAppService = injectionNoteAppService; |
|
|
|
_balanceAppService = balanceAppService; |
|
|
|
_expectOutAppService = expectOutAppService; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_transferLibRequestAppService = transferLibRequestAppService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -41,8 +52,138 @@ public class InjectionJobEventHandler : |
|
|
|
await _injectionNoteAppService.CreateAsync(injectionNote).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<InjectionJob> eventData) |
|
|
|
{ |
|
|
|
var entity = eventData.Entity; |
|
|
|
|
|
|
|
await CreateExpectOutAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
await CreateTransferLibAsync(entity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 批量创建后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<InjectionJob>> eventData) |
|
|
|
{ |
|
|
|
var entitys = eventData.Entity; |
|
|
|
|
|
|
|
foreach (var entity in entitys) |
|
|
|
{ |
|
|
|
await CreateExpectOutAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
await CreateTransferLibAsync(entity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 私有
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建预计出
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CreateExpectOutAsync(InjectionJob entity) |
|
|
|
{ |
|
|
|
var expectOutEditInputs = new List<ExpectOutEditInput>(); |
|
|
|
foreach (var detail in entity.Details) |
|
|
|
{ |
|
|
|
var balanceDto = await _balanceAppService |
|
|
|
.GetRealQtyByPackingCodeAndItemCodeAndLocationCodeAndStatusAsync(detail.RecommendPackingCode, |
|
|
|
detail.ItemCode, detail.RecommendFromLocationCode, EnumInventoryStatus.OK).ConfigureAwait(false); |
|
|
|
|
|
|
|
var inputoExpectOutEditInput = new ExpectOutEditInput(); |
|
|
|
inputoExpectOutEditInput.JobNumber = entity.Number; |
|
|
|
inputoExpectOutEditInput.ItemCode = detail.ItemCode; |
|
|
|
inputoExpectOutEditInput.Qty = balanceDto.Qty; |
|
|
|
inputoExpectOutEditInput.LocationCode = balanceDto.LocationCode; |
|
|
|
inputoExpectOutEditInput.ArriveDate = balanceDto.ArriveDate; |
|
|
|
inputoExpectOutEditInput.ContainerCode = balanceDto.ContainerCode; |
|
|
|
inputoExpectOutEditInput.ExpireDate = balanceDto.ExpireDate; |
|
|
|
inputoExpectOutEditInput.ItemDesc1 = balanceDto.ItemDesc1; |
|
|
|
inputoExpectOutEditInput.ItemDesc2 = balanceDto.ItemDesc2; |
|
|
|
inputoExpectOutEditInput.ItemName = balanceDto.ItemName; |
|
|
|
inputoExpectOutEditInput.LocationArea = balanceDto.LocationArea; |
|
|
|
inputoExpectOutEditInput.LocationGroup = balanceDto.LocationGroup; |
|
|
|
inputoExpectOutEditInput.LocationErpCode = balanceDto.LocationErpCode; |
|
|
|
inputoExpectOutEditInput.PackingCode = balanceDto.PackingCode; |
|
|
|
inputoExpectOutEditInput.Lot = balanceDto.Lot; |
|
|
|
inputoExpectOutEditInput.ProduceDate = balanceDto.ProduceDate; |
|
|
|
inputoExpectOutEditInput.Status = balanceDto.Status; |
|
|
|
inputoExpectOutEditInput.Uom = balanceDto.Uom; |
|
|
|
inputoExpectOutEditInput.SupplierBatch = balanceDto.SupplierBatch; |
|
|
|
inputoExpectOutEditInput.WarehouseCode= balanceDto.WarehouseCode; |
|
|
|
|
|
|
|
expectOutEditInputs.Add(inputoExpectOutEditInput); |
|
|
|
} |
|
|
|
|
|
|
|
await _expectOutAppService.AddManyAsync(expectOutEditInputs).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 根据是否在 第一层 来创建 是否生成库移任务
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CreateTransferLibAsync(InjectionJob injectionJob) |
|
|
|
{ |
|
|
|
foreach (var detail in injectionJob.Details) |
|
|
|
{ |
|
|
|
var input = new TransferLibRequestEditInput(); |
|
|
|
input.CallBusinessType = nameof(IInjectionJobAppService); |
|
|
|
input.CallJobNumber = injectionJob.Number; |
|
|
|
input.CallRequestNumber = injectionJob.InjectionRequestNumber; |
|
|
|
input.CallServerName = "Win_in.Sfs.Wms.Store.Application.InjectionJobAppService"; |
|
|
|
input.Type = "Transfer_Warehouse"; |
|
|
|
input.UseOnTheWayLocation = true; |
|
|
|
var detailInput = new TransferLibRequestDetailInput(); |
|
|
|
detailInput.CallBusinessType = nameof(IInjectionJobAppService); |
|
|
|
detailInput.CallRequestNumber = injectionJob.InjectionRequestNumber; |
|
|
|
detailInput.CallServerName = "Win_in.Sfs.Wms.Store.Application.InjectionJobAppService"; |
|
|
|
detailInput.CallJobNumber = injectionJob.Number; |
|
|
|
|
|
|
|
detailInput.JobStatus = EnumJobStatus.Open; |
|
|
|
detailInput.ItemCode=detail.ItemCode; |
|
|
|
detailInput.Qty = detail.RecommendQty; |
|
|
|
detailInput.ArriveDate = detailInput.ArriveDate; |
|
|
|
detailInput.ExpireDate=detailInput.ExpireDate; |
|
|
|
detailInput.ProduceDate = detail.RecommendProduceDate; |
|
|
|
|
|
|
|
detailInput.ToLocationCode = detail.ToLocationCode; |
|
|
|
detailInput.ToWarehouseCode=detail.ToWarehouseCode; |
|
|
|
detailInput.ToLocationErpCode=detail.ToLocationErpCode; |
|
|
|
detailInput.ToLocationGroup=detail.ToLocationGroup; |
|
|
|
detailInput.ToLocationArea= detail.ToLocationArea; |
|
|
|
|
|
|
|
detailInput.FromLocationCode = detail.RecommendFromLocationCode; |
|
|
|
detailInput.FromLocationArea = detail.RecommendFromLocationArea; |
|
|
|
detailInput.FromLocationGroup=detail.RecommendFromLocationGroup; |
|
|
|
detailInput.FromLocationErpCode= detail.RecommendFromLocationErpCode; |
|
|
|
detailInput.FromWarehouseCode= detail.RecommendFromWarehouseCode; |
|
|
|
|
|
|
|
detailInput.ToLocationCode = "YL1"; |
|
|
|
detailInput.ToLocationErpCode = "YL1"; |
|
|
|
detailInput.ToLocationGroup = "YL1"; |
|
|
|
detailInput.ToLocationArea = "YL1"; |
|
|
|
|
|
|
|
detailInput.FromLot = detail.RecommendLot; |
|
|
|
detailInput.ToLot=detail.RecommendLot; |
|
|
|
detailInput.Qty=detail.RecommendQty; |
|
|
|
detailInput.StdPackQty = detail.StdPackQty; |
|
|
|
detailInput.Uom=detail.Uom; |
|
|
|
detailInput.SupplierBatch = detail.RecommendSupplierBatch; |
|
|
|
|
|
|
|
await _transferLibRequestAppService.CreateAsync(input); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建补料记录实体
|
|
|
|
/// </summary>
|
|
|
|