|
|
@ -4,6 +4,7 @@ using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.EventBus; |
|
|
|
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; |
|
|
@ -20,6 +21,13 @@ public class IssueNoteEventHandler |
|
|
|
{ |
|
|
|
private const EnumTransType TransType = EnumTransType.Issue; |
|
|
|
|
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
|
|
|
|
public IssueNoteEventHandler(ILocationAppService locationAppService) |
|
|
|
{ |
|
|
|
_locationAppService = locationAppService; |
|
|
|
} |
|
|
|
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData) |
|
|
|
{ |
|
|
@ -68,7 +76,7 @@ public class IssueNoteEventHandler |
|
|
|
|
|
|
|
private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList) |
|
|
|
{ |
|
|
|
var transferLogs = new List<TransferLogEditInput>(); |
|
|
|
var transferLogs = new List<TransferLogEditInput>(); |
|
|
|
|
|
|
|
transferLogs.AddRange(inputList); |
|
|
|
|
|
|
@ -83,42 +91,48 @@ public class IssueNoteEventHandler |
|
|
|
{ |
|
|
|
var transferLog = ObjectMapper.Map<IssueNoteDetail, TransferLogEditInput>(detail); |
|
|
|
|
|
|
|
LocationDTO fromLocationDTO = null; |
|
|
|
LocationDTO toLocationDTO = null; |
|
|
|
|
|
|
|
if (issueNote.UseOnTheWayLocation) |
|
|
|
{ |
|
|
|
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|
|
|
var location = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|
|
|
switch (route) |
|
|
|
{ |
|
|
|
case EnumTransferRoute.SourceToOnTheWay: |
|
|
|
detail.ToLocationCode = detail.OnTheWayLocationCode; |
|
|
|
detail.ToLocationErpCode = location.ErpLocationCode; |
|
|
|
detail.ToWarehouseCode = location.WarehouseCode; |
|
|
|
detail.ToLocationArea = location.AreaCode; |
|
|
|
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|
|
|
break; |
|
|
|
case EnumTransferRoute.OnTheWayToDestination: |
|
|
|
detail.FromLocationCode = detail.OnTheWayLocationCode; |
|
|
|
detail.FromLocationErpCode = location.ErpLocationCode; |
|
|
|
detail.FromWarehouseCode = location.WarehouseCode; |
|
|
|
detail.FromLocationArea = location.AreaCode; |
|
|
|
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog).ConfigureAwait(false); |
|
|
|
break; |
|
|
|
case EnumTransferRoute.SourceToDestination: |
|
|
|
default: |
|
|
|
throw new ArgumentOutOfRangeException(nameof(route), route, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (issueNote.UseOnTheWayLocation) |
|
|
|
else |
|
|
|
{ |
|
|
|
transferLog.FromLocationCode = detail.OnTheWayLocationCode; |
|
|
|
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); |
|
|
|
transferLog.FromLocationGroup = location.LocationGroupCode; |
|
|
|
transferLog.FromLocationArea = location.AreaCode; |
|
|
|
transferLog.FromLocationErpCode = location.ErpLocationCode; |
|
|
|
transferLog.FromWarehouseCode=location.WarehouseCode; |
|
|
|
fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
|
|
|
toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
transferLog.TransType = TransType; |
|
|
|
transferLog.FromLocationCode = fromLocationDTO.Code; |
|
|
|
transferLog.FromLocationArea = fromLocationDTO.AreaCode; |
|
|
|
transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode; |
|
|
|
transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode; |
|
|
|
|
|
|
|
transferLog.ToLocationCode = toLocationDTO.Code; |
|
|
|
transferLog.ToLocationArea = toLocationDTO.AreaCode; |
|
|
|
transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode; |
|
|
|
transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode; |
|
|
|
transferLog.TransSubType = Enum.Parse<EnumTransSubType>(issueNote.RequestType); |
|
|
|
transferLog.Worker = issueNote.Worker; |
|
|
|
transferLog.TransType = TransType; |
|
|
|
transferLog.DocNumber = issueNote.Number; |
|
|
|
transferLog.JobNumber = issueNote.JobNumber; |
|
|
|
|
|
|
@ -128,4 +142,17 @@ public class IssueNoteEventHandler |
|
|
|
return transferLogs; |
|
|
|
} |
|
|
|
|
|
|
|
private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogEditInput transferLogCreateInput) |
|
|
|
{ |
|
|
|
transferLogCreateInput.ToPackingCode = ""; |
|
|
|
transferLogCreateInput.ToLot = ""; |
|
|
|
transferLogCreateInput.ToContainerCode = ""; |
|
|
|
|
|
|
|
transferLogCreateInput.FromPackingCode = ""; |
|
|
|
transferLogCreateInput.FromLot = ""; |
|
|
|
transferLogCreateInput.FromContainerCode = ""; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|