|
@ -1,18 +1,27 @@ |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.EventBus; |
|
|
using Volo.Abp.EventBus; |
|
|
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
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.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.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
|
|
|
using Win_in.Sfs.Wms.Store.Event.Inventories; |
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; |
|
|
namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; |
|
|
|
|
|
|
|
|
public class UnplannedIssueRequestEventHandler |
|
|
public class UnplannedIssueRequestEventHandler |
|
|
: StoreEventHandlerBase |
|
|
: StoreExpectInOutEventHandlerBase |
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<UnplannedIssueRequest>> |
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<UnplannedIssueRequest>> |
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<UnplannedIssueRequest>>> |
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<UnplannedIssueRequest>>> |
|
|
, ILocalEventHandler<SfsHandledEntityEventData<UnplannedIssueRequest>> |
|
|
, ILocalEventHandler<SfsHandledEntityEventData<UnplannedIssueRequest>> |
|
|
|
|
|
, ILocalEventHandler<SfsRefusedEntityEventData<UnplannedIssueRequest>> |
|
|
|
|
|
, ILocalEventHandler<SfsAbortedEntityEventData<UnplannedIssueRequest>> |
|
|
|
|
|
, ILocalEventHandler<SfsCancelledEntityEventData<UnplannedIssueRequest>> |
|
|
{ |
|
|
{ |
|
|
private readonly IUnplannedIssueJobAppService _unplannedIssueJobApp; |
|
|
private readonly IUnplannedIssueJobAppService _unplannedIssueJobApp; |
|
|
private readonly IUnplannedIssueNoteAppService _unplannedIssueNoteAppService; |
|
|
private readonly IUnplannedIssueNoteAppService _unplannedIssueNoteAppService; |
|
@ -35,6 +44,10 @@ public class UnplannedIssueRequestEventHandler |
|
|
public async Task HandleEventAsync(SfsCreatedEntityEventData<UnplannedIssueRequest> eventData) |
|
|
public async Task HandleEventAsync(SfsCreatedEntityEventData<UnplannedIssueRequest> eventData) |
|
|
{ |
|
|
{ |
|
|
var entity = eventData.Entity; |
|
|
var entity = eventData.Entity; |
|
|
|
|
|
if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) |
|
|
|
|
|
{ |
|
|
|
|
|
await AddExpectOutsAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
//if (entity.AutoSubmit)
|
|
|
//if (entity.AutoSubmit)
|
|
|
//{
|
|
|
//{
|
|
|
// await _unplannedIssueRequestManager.SubmitAsync(entity).ConfigureAwait(false);
|
|
|
// await _unplannedIssueRequestManager.SubmitAsync(entity).ConfigureAwait(false);
|
|
@ -53,6 +66,10 @@ public class UnplannedIssueRequestEventHandler |
|
|
if (entity.AutoSubmit) |
|
|
if (entity.AutoSubmit) |
|
|
{ |
|
|
{ |
|
|
await _unplannedIssueRequestManager.SubmitAsync(entity).ConfigureAwait(false); |
|
|
await _unplannedIssueRequestManager.SubmitAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
if(entity.UnplannedIssueType== EnumUnplannedIssueType.Raw) |
|
|
|
|
|
{ |
|
|
|
|
|
await AddExpectOutsAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -80,9 +97,53 @@ public class UnplannedIssueRequestEventHandler |
|
|
await _unplannedIssueJobApp.CreateAsync(job).ConfigureAwait(false); |
|
|
await _unplannedIssueJobApp.CreateAsync(job).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
public virtual async Task HandleEventAsync(SfsRefusedEntityEventData<UnplannedIssueRequest> eventData) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = eventData.Entity; |
|
|
|
|
|
if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) |
|
|
|
|
|
{ |
|
|
|
|
|
await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
public virtual async Task HandleEventAsync(SfsAbortedEntityEventData<UnplannedIssueRequest> eventData) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = eventData.Entity; |
|
|
|
|
|
if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) |
|
|
|
|
|
{ |
|
|
|
|
|
await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<UnplannedIssueRequest> eventData) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = eventData.Entity; |
|
|
|
|
|
if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) |
|
|
|
|
|
{ |
|
|
|
|
|
await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 私有
|
|
|
#region 私有
|
|
|
|
|
|
private async Task AddExpectOutsAsync(UnplannedIssueRequest entitie) |
|
|
|
|
|
{ |
|
|
|
|
|
var expectOuts = new List<ExpectOutEditInput>(); |
|
|
|
|
|
var entityExpectOuts = BuildExpectOutInventoryAsync(entitie); |
|
|
|
|
|
expectOuts.AddRange(entityExpectOuts); |
|
|
|
|
|
|
|
|
|
|
|
await ExpectOutAppService.AddManyAsync(expectOuts).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<ExpectOutEditInput> BuildExpectOutInventoryAsync(UnplannedIssueRequest request) |
|
|
|
|
|
{ |
|
|
|
|
|
var inputs = ObjectMapper.Map<List<UnplannedIssueRequestDetail>, List<ExpectOutEditInput>>(request.Details); |
|
|
|
|
|
foreach (var input in inputs) |
|
|
|
|
|
{ |
|
|
|
|
|
input.JobNumber = request.Number; |
|
|
|
|
|
input.Worker = request.Worker; |
|
|
|
|
|
} |
|
|
|
|
|
return inputs; |
|
|
|
|
|
} |
|
|
private async Task<UnplannedIssueNoteEditInput> BuildUnplannedIssueNoteCreateInputAsync( |
|
|
private async Task<UnplannedIssueNoteEditInput> BuildUnplannedIssueNoteCreateInputAsync( |
|
|
UnplannedIssueRequest entity) |
|
|
UnplannedIssueRequest entity) |
|
|
{ |
|
|
{ |
|
@ -120,6 +181,8 @@ public class UnplannedIssueRequestEventHandler |
|
|
return createInput; |
|
|
return createInput; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 改用AutoMapper实现 |
|
|
/* 改用AutoMapper实现 |
|
|
private void SetUnplannedIssueJobDetails(UnplannedIssueJobCreateInput createInput, List<UnplannedIssueRequestDetail> details) |
|
|
private void SetUnplannedIssueJobDetails(UnplannedIssueJobCreateInput createInput, List<UnplannedIssueRequestDetail> details) |
|
|
{ |
|
|
{ |
|
|