diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/IssueJobs/InjectionJobs/InjectionJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/IssueJobs/InjectionJobs/InjectionJobManager.cs index 4ef7158a4..349e5d32e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/IssueJobs/InjectionJobs/InjectionJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/IssueJobs/InjectionJobs/InjectionJobManager.cs @@ -33,33 +33,37 @@ public class InjectionJobManager : SfsJobManagerBase q.RequestType).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.InjectionRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.JobType).HasConversion(); + b.Property(q => q.JobStatus).HasConversion(); //Relations b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); //Indexes @@ -46,8 +48,10 @@ public static class InjectionJobDbContextModelCreatingExtensions b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.OnTheWayLocationCode).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.PositionCode).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.RecommendType).HasMaxLength(SfsPropertyConst.CodeLength); - + b.Property(q => q.OnTheWayLocationCode).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.PositionCode).HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(false); + b.Property(q => q.RecommendType).HasMaxLength(SfsPropertyConst.CodeLength).HasConversion(); + b.Property(q => q.Status).IsRequired().HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); //Relations //None diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/InjectionNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/InjectionNoteAutoMapperProfile.cs index 81a60e3a6..815c19d23 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/InjectionNoteAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/InjectionNoteAutoMapperProfile.cs @@ -9,7 +9,43 @@ public partial class StoreEventAutoMapperProfile : Profile { private void InjectionNoteAutoMapperProfile() { - - } + CreateMap() + .Ignore(x => x.DocNumber) + .Ignore(x => x.JobNumber) + .Ignore(x => x.Worker) + .Ignore(x => x.TransType) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.TransSubType) + + .ForMember(x => x.Qty, y => y.MapFrom(t => t.HandledToQty)) + .ForMember(x => x.SupplierBatch, y => y.MapFrom(t => t.HandledFromSupplierBatch)) + .ForMember(x => x.ArriveDate, y => y.MapFrom(t => t.HandledFromArriveDate)) + .ForMember(x => x.ProduceDate, y => y.MapFrom(t => t.HandledFromProduceDate)) + .ForMember(x => x.ExpireDate, y => y.MapFrom(t => t.HandledFromExpireDate)) + + .ForMember(x => x.FromPackingCode, y => y.MapFrom(t => t.HandledFromPackingCode)) + .ForMember(x => x.FromContainerCode, y => y.MapFrom(t => t.HandledFromContainerCode)) + + .ForMember(x => x.FromLot, y => y.MapFrom(t => t.HandledFromLot)) + .ForMember(x => x.FromStatus, y => y.MapFrom(t => t.Status)) + .ForMember(x => x.FromLocationCode, y => y.MapFrom(t => t.HandledFromLocationCode)) + .ForMember(x => x.FromLocationGroup, y => y.MapFrom(t => t.HandledFromLocationGroup)) + .ForMember(x => x.FromLocationArea, y => y.MapFrom(t => t.HandledFromLocationArea)) + .ForMember(x => x.FromLocationErpCode, y => y.MapFrom(t => t.HandledFromLocationErpCode)) + .ForMember(x => x.FromWarehouseCode, y => y.MapFrom(t => t.HandledFromWarehouseCode)) + + .ForMember(x => x.ToLot, y => y.MapFrom(t => t.HandledToLot)) + .ForMember(x => x.ToStatus, y => y.MapFrom(t => t.Status)) + .ForMember(x => x.ToPackingCode, y => y.MapFrom(t => t.HandledToPackingCode)) + .ForMember(x => x.ToContainerCode, y => y.MapFrom(t => t.HandledToContainerCode)) + + .ForMember(x => x.ToLocationCode, y => y.MapFrom(t => t.HandledToLocationCode)) + .ForMember(x => x.ToLocationGroup, y => y.MapFrom(t => t.HandledToLocationGroup)) + .ForMember(x => x.ToLocationArea, y => y.MapFrom(t => t.HandledToLocationArea)) + .ForMember(x => x.ToLocationErpCode, y => y.MapFrom(t => t.HandledToLocationErpCode)) + .ForMember(x => x.ToWarehouseCode, y => y.MapFrom(t => t.HandledToWarehouseCode)) + + ; + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InjectionJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InjectionJobEventHandler.cs index 95d41bb11..2654ce94a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InjectionJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InjectionJobEventHandler.cs @@ -9,7 +9,6 @@ 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; namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; @@ -19,20 +18,16 @@ public class InjectionJobEventHandler : , ILocalEventHandler> , ILocalEventHandler>> { - private const EnumTransType TransType = EnumTransType.Issue; - private readonly IInjectionNoteAppService _injectionNoteAppService; - private readonly IBalanceAppService _balanceAppService; private readonly IExpectOutAppService _expectOutAppService; private readonly ILocationAppService _locationAppService; private readonly ITransferLibRequestAppService _transferLibRequestAppService; public InjectionJobEventHandler(IInjectionNoteAppService injectionNoteAppService, - IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService, + IExpectOutAppService expectOutAppService, ILocationAppService locationAppService, ITransferLibRequestAppService transferLibRequestAppService) { _injectionNoteAppService = injectionNoteAppService; - _balanceAppService = balanceAppService; _expectOutAppService = expectOutAppService; _locationAppService = locationAppService; _transferLibRequestAppService = transferLibRequestAppService; @@ -99,7 +94,7 @@ public class InjectionJobEventHandler : inputoExpectOutEditInput.ItemCode = detail.ItemCode; inputoExpectOutEditInput.Qty = detail.RecommendFromQty; inputoExpectOutEditInput.LocationCode = detail.RecommendFromLocationCode; - inputoExpectOutEditInput.ArriveDate =detail.RecommendFromArriveDate; + inputoExpectOutEditInput.ArriveDate = detail.RecommendFromArriveDate; inputoExpectOutEditInput.ContainerCode = detail.RecommendFromContainerCode; inputoExpectOutEditInput.ExpireDate = detail.RecommendFromExpireDate; inputoExpectOutEditInput.ItemDesc1 = detail.ItemDesc1; @@ -199,22 +194,9 @@ public class InjectionJobEventHandler : private async Task BuildInjectionNoteAsync(InjectionJob entity) { var injectionNoteCreateInput = ObjectMapper.Map(entity); - //injectionNoteCreateInput.JobNumber = entity.Number; - //var locationCodes = injectionNoteCreateInput.Details.Select(p => p.ToLocationCode).Distinct().ToList(); - //var locations = await _locationAppService.GetByCodesAsync(locationCodes).ConfigureAwait(false); - - //injectionNoteCreateInput.Details.RemoveAll(p => p.Qty == 0); - - //foreach (var detail in injectionNoteCreateInput.Details) - //{ - // var location = locations.First(p => p.Code == detail.ToLocationCode); - // await RemovePackingCodeAndContainerCodeAndLotAsync(detail, location.Type).ConfigureAwait(false); //去箱 去托 去批 - - // detail.ToLocationArea = location.AreaCode; - // detail.ToLocationGroup = location.LocationGroupCode; - // detail.ToLocationErpCode = location.ErpLocationCode; - // detail.ToWarehouseCode = location.WarehouseCode; - //} + injectionNoteCreateInput.JobNumber = entity.Number; + + await Task.CompletedTask.ConfigureAwait(false); return injectionNoteCreateInput; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/InjectionNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/InjectionNoteEventHandler.cs new file mode 100644 index 000000000..7298a982f --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/InjectionNoteEventHandler.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; +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.Domain; +using Win_in.Sfs.Wms.Store.Event.Transaction; + +namespace Win_in.Sfs.Wms.Store.Event.Transactions; + +public class InjectionNoteEventHandler + : StoreInventoryEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> + , ILocalEventHandler> +{ + private const EnumTransType TransType = EnumTransType.Issue; + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + var transferLogs = new List(); + var route = entity.UseOnTheWayLocation + ? EnumTransferRoute.SourceToOnTheWay + : EnumTransferRoute.SourceToDestination; + transferLogs.AddRange(await BuildTransferLogsAsync(entity).ConfigureAwait(false)); + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + var transferLogs = new List(); + //如果要做库存事务汇总,可以修改此处 + foreach (var issueNote in entities) + { + transferLogs.AddRange(await BuildTransferLogsAsync(issueNote).ConfigureAwait(false)); + } + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData eventData) + { + var entity = eventData.Entity; + + var inputList = await BuildTransferLogsAsync(entity) + .ConfigureAwait(false); + await AddTransferLogsAsync(inputList).ConfigureAwait(false); + } + + private async Task AddTransferLogsAsync(List inputList) + { + var transferLogs = new List(); + + transferLogs.AddRange(inputList); + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + + private async Task> BuildTransferLogsAsync(InjectionNote issueNote) + { + var transferLogs = new List(); + foreach (var detail in issueNote.Details.Where(detail => detail.HandledToQty != 0)) + { + var transferLog = ObjectMapper.Map(detail); + + transferLog.TransSubType = EnumTransSubType.Issue_WIP; + transferLog.TransType = TransType; + transferLog.DocNumber = issueNote.Number; + transferLog.JobNumber = issueNote.JobNumber; + + transferLogs.Add(transferLog); + } + + await Task.CompletedTask.ConfigureAwait(false); + + return transferLogs; + } +}