|
|
@ -15,51 +15,72 @@ public class InspectJobEventHandler : |
|
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<InspectJob>> |
|
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<InspectJob>>> |
|
|
|
, ILocalEventHandler<SfsCompletedEntityEventData<InspectJob>> |
|
|
|
, ILocalEventHandler<SfsUpdateEntitySummaryDetailEventData<InspectJob>> |
|
|
|
, ILocalEventHandler<SfsUpdateEntitySummaryDetailEventData<InspectJob>> |
|
|
|
{ |
|
|
|
private readonly IInspectNoteAppService _inspectNoteAppService; |
|
|
|
|
|
|
|
public InspectJobEventHandler( |
|
|
|
IInspectNoteAppService inspectNoteAppService |
|
|
|
) |
|
|
|
) |
|
|
|
{ |
|
|
|
_inspectNoteAppService = inspectNoteAppService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 质检任务 完成后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(SfsCompletedEntityEventData<InspectJob> eventData) |
|
|
|
{ |
|
|
|
var entity = eventData.Entity; |
|
|
|
var inspectNote = BuildInspectNote(entity); |
|
|
|
await _inspectNoteAppService.CreateAsync(inspectNote).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建 质检任务后
|
|
|
|
/// 质检任务创建后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<InspectJob> eventData) |
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<InspectJob>> eventData) |
|
|
|
{ |
|
|
|
var entity = eventData.Entity; |
|
|
|
var inspectNote = BuildInspectNote(entity); |
|
|
|
await _inspectNoteAppService.CreateAsync(inspectNote).ConfigureAwait(false); |
|
|
|
//await CompleteExemptInspectJobAsync(new List<InspectJob> { entity });
|
|
|
|
var entities = eventData.Entity; |
|
|
|
|
|
|
|
foreach (var entity in entities) |
|
|
|
{ |
|
|
|
await CreateInspectNoteAsync(entity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建 质检任务后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<InspectJob>> eventData) |
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<InspectJob> eventData) |
|
|
|
{ |
|
|
|
_ = eventData.Entity; |
|
|
|
var entity = eventData.Entity; |
|
|
|
await CreateInspectNoteAsync(entity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
//await CompleteExemptInspectJobAsync(entities);
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
#region 私有
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建质检记录
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<InspectNoteEditInput> CreateInspectNoteAsync(InspectJob entity) |
|
|
|
{ |
|
|
|
var input = ObjectMapper.Map<InspectJob, InspectNoteEditInput>(entity); |
|
|
|
await _inspectNoteAppService.CreateAsync(input).ConfigureAwait(false); |
|
|
|
return input; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 汇总 详情被修改后
|
|
|
|
/// 汇总 详情被修改后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData">Event data</param>
|
|
|
|
[UnitOfWork] |
|
|
@ -75,7 +96,8 @@ public class InspectJobEventHandler : |
|
|
|
{ |
|
|
|
var noteCreateInput = new InspectNoteEditInput(); |
|
|
|
|
|
|
|
var noteSummaryDetailInput = ObjectMapper.Map<InspectJobSummaryDetail, InspectNoteSummaryDetailInput>(jobSummaryDetail); |
|
|
|
var noteSummaryDetailInput = |
|
|
|
ObjectMapper.Map<InspectJobSummaryDetail, InspectNoteSummaryDetailInput>(jobSummaryDetail); |
|
|
|
|
|
|
|
noteCreateInput.SummaryDetails.Add(noteSummaryDetailInput); |
|
|
|
|
|
|
@ -92,13 +114,54 @@ public class InspectJobEventHandler : |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 构造 质检记录
|
|
|
|
/// 完成免检任务
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
/// <param name="entities"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private InspectNoteEditInput BuildInspectNote(InspectJob entity) |
|
|
|
private async Task CompleteExemptInspectJobAsync(List<InspectJob> entities) |
|
|
|
{ |
|
|
|
var input = ObjectMapper.Map<InspectJob, InspectNoteEditInput>(entity); |
|
|
|
return input; |
|
|
|
foreach (var inspectJob in entities) |
|
|
|
{ |
|
|
|
var summaryDetail = inspectJob.SummaryDetails.FirstOrDefault(); |
|
|
|
//免检任务自动完成 并调用检验记录生成业务
|
|
|
|
if (summaryDetail?.InspectType != EnumInspectType.Exempt) |
|
|
|
{ |
|
|
|
await CompleteExemptInspectJobAsync(inspectJob, summaryDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 处理免检 物品
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="inspectJob"></param>
|
|
|
|
/// <param name="summarydDetail"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CompleteExemptInspectJobAsync(InspectJob inspectJob, InspectJobSummaryDetail summarydDetail) |
|
|
|
{ |
|
|
|
//任务状态直接完成
|
|
|
|
await inspectJob.CompleteAsync(inspectJob.CreatorId, "", Clock.Now).ConfigureAwait(false); |
|
|
|
foreach (var detail in inspectJob.Details) |
|
|
|
{ |
|
|
|
await inspectJob.SetDetail( |
|
|
|
detail.Id, |
|
|
|
detail.GoodQty, |
|
|
|
detail.FailedReason, |
|
|
|
detail.FailedQty, |
|
|
|
detail.CrackQty, |
|
|
|
detail.NotPassedQty, |
|
|
|
inspectJob.Worker, |
|
|
|
detail.SupplierBatch, |
|
|
|
detail.ArriveDate, |
|
|
|
detail.ProduceDate, |
|
|
|
detail.ExpireDate, |
|
|
|
detail.ContainerCode, |
|
|
|
detail.LocationCode, |
|
|
|
detail.Lot, |
|
|
|
detail.PackingCode, |
|
|
|
detail.ReceiveQty).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|