|
|
@ -17,16 +17,19 @@ public class TransferNoteEventHandler |
|
|
|
: StoreInventoryEventHandlerBase |
|
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<TransferNote>> |
|
|
|
, ILocalEventHandler<SfsConfirmedEntityEventData<TransferNote>> |
|
|
|
, ILocalEventHandler<SfsCancelledEntityEventData<TransferNote>> |
|
|
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<TransferNote>>> |
|
|
|
{ |
|
|
|
private const EnumTransType TransType = EnumTransType.Transfer; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
private readonly ITransferLogAppService _transferLogAppService; |
|
|
|
private readonly ITransferRequestAppService _transferRequestAppService; |
|
|
|
|
|
|
|
public TransferNoteEventHandler(ITransferRequestAppService transferRequestApp, ILocationAppService locationAppService, ITransferLogAppService transferLogAppService) |
|
|
|
public TransferNoteEventHandler(ITransferRequestAppService transferRequestApp, ILocationAppService locationAppService, ITransferLogAppService transferLogAppService, ITransferRequestAppService transferRequestAppService) |
|
|
|
{ |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_transferLogAppService = transferLogAppService; |
|
|
|
_transferRequestAppService = transferRequestAppService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -79,7 +82,20 @@ public class TransferNoteEventHandler |
|
|
|
var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false); |
|
|
|
await AddTransferLogsAsync(inputList).ConfigureAwait(false); |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 取消后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<TransferNote> eventData) |
|
|
|
{ |
|
|
|
var entity = eventData.Entity; |
|
|
|
|
|
|
|
var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToSource).ConfigureAwait(false); |
|
|
|
await AddTransferLogsAsync(inputList).ConfigureAwait(false); |
|
|
|
await _transferRequestAppService.CancelByRequestNumberAsync(entity.RequestNumber).ConfigureAwait(false); ; |
|
|
|
} |
|
|
|
private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList) |
|
|
|
{ |
|
|
|
var transferLogs = new List<TransferLogEditInput>(); |
|
|
@ -143,6 +159,17 @@ public class TransferNoteEventHandler |
|
|
|
transferLog.ToLocationErpCode = toLocation.ErpLocationCode; |
|
|
|
transferLog.ToLocationGroup = toLocation.LocationGroupCode; |
|
|
|
break;; |
|
|
|
case EnumTransferRoute.OnTheWayToSource: |
|
|
|
transferLog.FromLocationCode = transferOnTheWay.Code; |
|
|
|
transferLog.FromLocationArea = transferOnTheWay.AreaCode; |
|
|
|
transferLog.FromLocationErpCode = transferOnTheWay.ErpLocationCode; |
|
|
|
transferLog.FromLocationGroup = transferOnTheWay.LocationGroupCode; |
|
|
|
|
|
|
|
transferLog.ToLocationCode = fromLocation.Code; |
|
|
|
transferLog.ToLocationArea = fromLocation.AreaCode; |
|
|
|
transferLog.ToLocationErpCode = fromLocation.ErpLocationCode; |
|
|
|
transferLog.ToLocationGroup = fromLocation.LocationGroupCode; |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new ArgumentOutOfRangeException(nameof(route), route, null); |
|
|
|
} |
|
|
@ -158,6 +185,7 @@ public class TransferNoteEventHandler |
|
|
|
|
|
|
|
return transferLogs; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public enum EnumTransferRoute |
|
|
@ -176,4 +204,9 @@ public enum EnumTransferRoute |
|
|
|
/// 源>目标
|
|
|
|
/// </summary>
|
|
|
|
SourceToDestination = 3, |
|
|
|
/// <summary>
|
|
|
|
/// 在途>源库位
|
|
|
|
/// </summary>
|
|
|
|
OnTheWayToSource = 4, |
|
|
|
|
|
|
|
} |
|
|
|