|
|
@ -7,6 +7,7 @@ using Volo.Abp.Uow; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
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.Application.Contracts; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
@ -15,17 +16,21 @@ namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; |
|
|
|
|
|
|
|
public class ThirdLocationJobEventHandler : |
|
|
|
StoreEventHandlerBase |
|
|
|
, ILocalEventHandler<SfsCompletedEntityEventData<ThirdLocationJob>>,ILocalEventHandler<SfsCancelledEntityEventData<ThirdLocationJob>> |
|
|
|
, ILocalEventHandler<SfsCompletedEntityEventData<ThirdLocationJob>>,ILocalEventHandler<SfsCancelledEntityEventData<ThirdLocationJob>>, ILocalEventHandler<SfsClosedEntityEventData<ThirdLocationJob>> |
|
|
|
{ |
|
|
|
private const EnumTransType TransType = EnumTransType.Issue; |
|
|
|
|
|
|
|
private readonly IThirdLocationNoteAppService _thirdLocationNoteAppService; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
private readonly IThirdLocationRequestManager _thirdLocationRequestManager; |
|
|
|
private readonly ITransferLogAppService _transferLogAppService; |
|
|
|
|
|
|
|
public ThirdLocationJobEventHandler(IThirdLocationNoteAppService thirdLocationNoteAppService, ILocationAppService locationAppService) |
|
|
|
public ThirdLocationJobEventHandler(IThirdLocationNoteAppService thirdLocationNoteAppService, ITransferLogAppService transferLogAppService, IThirdLocationRequestManager thirdLocationRequestManager, ILocationAppService locationAppService) |
|
|
|
{ |
|
|
|
_thirdLocationNoteAppService = thirdLocationNoteAppService; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_thirdLocationRequestManager = thirdLocationRequestManager; |
|
|
|
_transferLogAppService = transferLogAppService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -104,6 +109,75 @@ public class ThirdLocationJobEventHandler : |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 关闭任务后
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventData"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(SfsClosedEntityEventData<ThirdLocationJob> eventData) |
|
|
|
{ |
|
|
|
var entity = eventData.Entity; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(entity.RequestNumber)) |
|
|
|
{ |
|
|
|
var thirdLocationRequest = await _thirdLocationRequestManager.GetByNumberAsync(entity.RequestNumber).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
var transferLogs = new List<TransferLogEditInput>(); |
|
|
|
transferLogs.AddRange(await BuildCancelTransferLogsAsync(thirdLocationRequest).ConfigureAwait(false)); |
|
|
|
|
|
|
|
await _transferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); |
|
|
|
|
|
|
|
thirdLocationRequest.RequestStatus = EnumRequestStatus.Abort; |
|
|
|
await _thirdLocationRequestManager.UpdateAsync(thirdLocationRequest).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private async Task<List<TransferLogEditInput>> BuildCancelTransferLogsAsync(ThirdLocationRequest thirdLocationRequest) |
|
|
|
{ |
|
|
|
var transferLogs = new List<TransferLogEditInput>(); |
|
|
|
foreach (var detail in thirdLocationRequest.Details.Where(detail => detail.IssuedQty-detail.ReceivedQty != 0)) |
|
|
|
{ |
|
|
|
var transferLog = ObjectMapper.Map<ThirdLocationRequestDetail, TransferLogEditInput>(detail); |
|
|
|
|
|
|
|
LocationDTO fromLocationDTO = null; |
|
|
|
LocationDTO toLocationDTO = null; |
|
|
|
|
|
|
|
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|
|
|
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
transferLog.FromLocationCode = fromLocationDTO.Code; |
|
|
|
transferLog.FromLocationArea = fromLocationDTO.AreaCode; |
|
|
|
transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode; |
|
|
|
transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode; |
|
|
|
transferLog.FromWarehouseCode = fromLocationDTO.WarehouseCode; |
|
|
|
|
|
|
|
transferLog.ToLocationCode = toLocationDTO.Code; |
|
|
|
transferLog.ToLocationArea = toLocationDTO.AreaCode; |
|
|
|
transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode; |
|
|
|
transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode; |
|
|
|
transferLog.ToWarehouseCode = toLocationDTO.WarehouseCode; |
|
|
|
transferLog.TransSubType = Enum.Parse<EnumTransSubType>(thirdLocationRequest.Type); |
|
|
|
transferLog.TransType = TransType; |
|
|
|
transferLog.DocNumber = thirdLocationRequest.Number; |
|
|
|
transferLog.JobNumber = ""; |
|
|
|
transferLog.Qty = detail.IssuedQty - detail.ReceivedQty; |
|
|
|
|
|
|
|
transferLog.FromPackingCode = ""; |
|
|
|
transferLog.FromLot = ""; |
|
|
|
transferLog.ToPackingCode = ""; |
|
|
|
transferLog.ToLot = ""; |
|
|
|
transferLog.FromStatus = EnumInventoryStatus.OK; |
|
|
|
transferLog.ToStatus = EnumInventoryStatus.OK; |
|
|
|
transferLogs.Add(transferLog); |
|
|
|
} |
|
|
|
|
|
|
|
return transferLogs; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 去除箱码 托码 批次
|
|
|
|
/// </summary>
|
|
|
|