5 changed files with 168 additions and 54 deletions
@ -0,0 +1,88 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.EventBus; |
|||
using Volo.Abp.Uow; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Shared.Event; |
|||
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
using Win_in.Sfs.Wms.Store.Event.Transaction; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Event.Transactions; |
|||
|
|||
public class InjectionNoteEventHandler |
|||
: StoreInventoryEventHandlerBase |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<InjectionNote>> |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<List<InjectionNote>>> |
|||
, ILocalEventHandler<SfsConfirmedEntityEventData<InjectionNote>> |
|||
{ |
|||
private const EnumTransType TransType = EnumTransType.Issue; |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<InjectionNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
var route = entity.UseOnTheWayLocation |
|||
? EnumTransferRoute.SourceToOnTheWay |
|||
: EnumTransferRoute.SourceToDestination; |
|||
transferLogs.AddRange(await BuildTransferLogsAsync(entity).ConfigureAwait(false)); |
|||
|
|||
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<InjectionNote>> eventData) |
|||
{ |
|||
var entities = eventData.Entity; |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
//如果要做库存事务汇总,可以修改此处
|
|||
foreach (var issueNote in entities) |
|||
{ |
|||
transferLogs.AddRange(await BuildTransferLogsAsync(issueNote).ConfigureAwait(false)); |
|||
} |
|||
|
|||
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<InjectionNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
|
|||
var inputList = await BuildTransferLogsAsync(entity) |
|||
.ConfigureAwait(false); |
|||
await AddTransferLogsAsync(inputList).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList) |
|||
{ |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
|
|||
transferLogs.AddRange(inputList); |
|||
|
|||
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task<List<TransferLogEditInput>> BuildTransferLogsAsync(InjectionNote issueNote) |
|||
{ |
|||
var transferLogs = new List<TransferLogEditInput>(); |
|||
foreach (var detail in issueNote.Details.Where(detail => detail.HandledToQty != 0)) |
|||
{ |
|||
var transferLog = ObjectMapper.Map<InjectionNoteDetail, TransferLogEditInput>(detail); |
|||
|
|||
transferLog.TransSubType = EnumTransSubType.Issue_WIP; |
|||
transferLog.TransType = TransType; |
|||
transferLog.DocNumber = issueNote.Number; |
|||
transferLog.JobNumber = issueNote.JobNumber; |
|||
|
|||
transferLogs.Add(transferLog); |
|||
} |
|||
|
|||
await Task.CompletedTask.ConfigureAwait(false); |
|||
|
|||
return transferLogs; |
|||
} |
|||
} |
Loading…
Reference in new issue