diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/TransferLogs/TransferLogAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/TransferLogs/TransferLogAppService.cs index e30d65560..68b010434 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/TransferLogs/TransferLogAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/TransferLogs/TransferLogAppService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Wms.Inventory.Application.Contracts; @@ -23,15 +24,17 @@ public class TransferLogAppService { private readonly ITransferLogManager _transferLogManager; private readonly IInterfaceCalendarAclService _interfaceCalendarAclService; + private readonly ILocationAppService _locationAppService; public TransferLogAppService( ITransferLogRepository repository , ITransferLogManager transferLogManager , IInterfaceCalendarAclService interfaceCalendarAclService - ) : base(repository) + , ILocationAppService locationAppService) : base(repository) { _transferLogManager = transferLogManager; _interfaceCalendarAclService = interfaceCalendarAclService; + _locationAppService = locationAppService; } [HttpPost("add")] diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/IssueJobAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/IssueJobAutoMapperProfile.cs index d78170183..9075447bc 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/IssueJobAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/IssueJobAutoMapperProfile.cs @@ -56,37 +56,37 @@ public partial class StoreEventAutoMapperProfile : Profile ; CreateMap() - .MapExpectInOutFrom() + .MapExpectInOutFrom() .Ignore(x => x.Worker) .Ignore(x => x.SerialNumber) .Ignore(x => x.ExtraProperties); CreateMap() + .ForMember(x => x.RequestNumber, y => y.MapFrom(d => d.MaterialRequestNumber)) .Ignore(x => x.Confirmed) .Ignore(x => x.JobNumber) - .Ignore(x => x.RequestNumber) .Ignore(x => x.ActiveDate) ; CreateMap() - .Ignore(x => x.IssueTime) - .Ignore(x => x.FromPackingCode) - .Ignore(x => x.ToPackingCode) - .Ignore(x => x.FromContainerCode) - .Ignore(x => x.ToContainerCode) - .Ignore(x => x.FromLot) - .Ignore(x => x.ToLot) - .Ignore(x => x.SupplierBatch) - .Ignore(x => x.ArriveDate) - .Ignore(x => x.ProduceDate) - .Ignore(x => x.ExpireDate) - .Ignore(x => x.FromLocationCode) - .Ignore(x => x.FromLocationArea) - .Ignore(x => x.FromLocationGroup) - .Ignore(x => x.FromLocationErpCode) - .Ignore(x => x.FromWarehouseCode) - .Ignore(x => x.FromStatus) - .Ignore(x => x.ToStatus) - .Ignore(x => x.Qty) + .ForMember(x => x.Qty, y => y.MapFrom(d => d.HandledQty)) + .ForMember(x => x.IssueTime, y => y.MapFrom(d => DateTime.Now)) + .ForMember(x => x.FromPackingCode, y => y.MapFrom(d =>d.HandledPackingCode)) + .ForMember(x => x.ToPackingCode, y => y.MapFrom(d => d.HandledPackingCode)) + .ForMember(x => x.FromContainerCode, y => y.MapFrom(d => d.HandledContainerCode)) + .ForMember(x => x.ToContainerCode, y => y.MapFrom(d => d.HandledContainerCode)) + .ForMember(x => x.FromLot, y => y.MapFrom(d => d.HandledLot)) + .ForMember(x => x.ToLot, y => y.MapFrom(d => d.HandledLot)) + .ForMember(x => x.SupplierBatch, y => y.MapFrom(d => d.HandledSupplierBatch)) + .ForMember(x => x.ArriveDate, y => y.MapFrom(d => d.HandledArriveDate)) + .ForMember(x => x.ProduceDate, y => y.MapFrom(d => d.HandledProduceDate)) + .ForMember(x => x.ExpireDate, y => y.MapFrom(d => d.ExpiredTime)) + .ForMember(x => x.FromLocationCode, y => y.MapFrom(d => d.HandledFromLocationCode)) + .ForMember(x => x.FromLocationArea, y => y.MapFrom(d => d.HandledFromLocationArea)) + .ForMember(x => x.FromLocationGroup, y => y.MapFrom(d => d.HandledFromLocationGroup)) + .ForMember(x => x.FromLocationErpCode, y => y.MapFrom(d => d.HandledFromLocationErpCode)) + .ForMember(x => x.FromWarehouseCode, y => y.MapFrom(d => d.HandledFromWarehouseCode)) + .ForMember(x => x.FromStatus, y => y.MapFrom(d => d.Status)) + .ForMember(x => x.ToStatus, y => y.MapFrom(d => d.Status)) ; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs index 89d439cfb..845a07a72 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs @@ -187,6 +187,7 @@ public class MaterialRequestEventHandler job.WarehouseCode = fromLocation.WarehouseCode; job.ProdLine = fromLocation.LocationGroupCode; job.Worker = materialRequest.Worker; + job.MaterialRequestNumber = materialRequest.Number; return job; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs index 1ec0f954a..e77ff9309 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs @@ -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 eventData) { @@ -68,7 +76,7 @@ public class IssueNoteEventHandler private async Task AddTransferLogsAsync(List inputList) { - var transferLogs = new List(); + var transferLogs = new List(); transferLogs.AddRange(inputList); @@ -83,42 +91,48 @@ public class IssueNoteEventHandler { var transferLog = ObjectMapper.Map(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(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 = ""; + + + } + }