diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs index c51ac8a27..c65c7656b 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs @@ -5,6 +5,7 @@ using System.Text.Json; using System.Threading.Tasks; using Volo.Abp.ObjectMapping; using Win_in.Sfs.Auth.Application.Contracts; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.DataExchange.Domain; using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; @@ -21,6 +22,7 @@ public class ItemTransformNoteConverter : IOutgoingConverter private readonly ISupplierAsnAppService _supplierAsnAppService; private readonly IDepartmentAppService _departmentAppService; private readonly IObjectMapper _objectMapper; + private readonly ILocationAppService _locationAppService; public ItemTransformNoteConverter( IOutgoingFromWmsManager outgoingFromWmsManager @@ -28,6 +30,7 @@ public class ItemTransformNoteConverter : IOutgoingConverter , ISupplierAsnAppService supplierAsnAppService , IDepartmentAppService departmentAppService , IObjectMapper objectMapper + , ILocationAppService locationAppService ) { _outgoingFromWmsManager = outgoingFromWmsManager; @@ -35,6 +38,7 @@ public class ItemTransformNoteConverter : IOutgoingConverter _supplierAsnAppService = supplierAsnAppService; _departmentAppService = departmentAppService; _objectMapper = objectMapper; + _locationAppService = locationAppService; } public virtual async Task> ConvertAsync() @@ -102,6 +106,8 @@ public class ItemTransformNoteConverter : IOutgoingConverter private CountAdjust BuildIssue(ItemTransformNoteExchangeDto exchangeCountAdjust, string departmentCode) { var detail = exchangeCountAdjust.Detail; + + // _locationAppService.GetListByCodesAndTypesAsync var counta = new CountAdjust() { mesout_asd_refc = "MES", diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/UnplannedIssueRequests/UnplannedIssueRequestForDongyangAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/UnplannedIssueRequests/UnplannedIssueRequestForDongyangAppService.cs index 8d459cc10..48db37e3f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/UnplannedIssueRequests/UnplannedIssueRequestForDongyangAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/UnplannedIssueRequests/UnplannedIssueRequestForDongyangAppService.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Volo.Abp; using Volo.Abp.Data; using Volo.Abp.Users; @@ -50,6 +51,7 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA //[Authorize(UnplannedIssueRequestPermissions.Create)] public override async Task CreateByOAAsync(UnplannedIssueRequestEditInput input) { + Logger.LogInformation($"DeptNmae【{input.DeptName}】,DeptCode【{input.DeptCode}】"); var entity = ObjectMapper.Map(input); foreach (var item in entity.Details) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/UnplannedIssueRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/UnplannedIssueRequestAutoMapperProfile.cs index 9061cf543..8c555e4ee 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/UnplannedIssueRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/UnplannedIssueRequestAutoMapperProfile.cs @@ -7,6 +7,7 @@ using Win_in.Sfs.Wms.Store.Domain; namespace Win_in.Sfs.Wms.Store.Event; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Inventory.Application.Contracts; public partial class StoreEventAutoMapperProfile : Profile { @@ -66,5 +67,11 @@ public partial class StoreEventAutoMapperProfile : Profile .Ignore(x => x.ReasonCode) .IgnoreIHasRecommendAndHandledFrom(); + CreateMap() + .ForMember(x => x.JobNumber, y => y.MapFrom(d => d.Number)) + .Ignore(x => x.Worker) + .Ignore(x => x.SerialNumber) + .Ignore(x => x.ExtraProperties); + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreInventoryEventHandlerBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreInventoryEventHandlerBase.cs index 3976683a1..1fae8d066 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreInventoryEventHandlerBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Bases/StoreInventoryEventHandlerBase.cs @@ -9,5 +9,5 @@ public abstract class StoreInventoryEventHandlerBase : StoreEventHandlerBase protected ITransferLogAppService TransferLogAppService => LazyServiceProvider.LazyGetRequiredService(); protected ITransactionAppService TransactionAppService => LazyServiceProvider.LazyGetRequiredService(); - + protected IExpectOutAppService ExpectOutAppService => LazyServiceProvider.LazyGetRequiredService(); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs index a4d5dae11..545e6961f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/UnplannedIssueRequestEventHandler.cs @@ -1,18 +1,27 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Volo.Abp.Domain.Entities; using Volo.Abp.EventBus; +using Volo.Abp.ObjectMapping; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; using Win_in.Sfs.Shared.Event; +using Win_in.Sfs.Wms.Inventory.Application.Contracts; +using Win_in.Sfs.Wms.Inventory.Domain; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; +using Win_in.Sfs.Wms.Store.Event.Inventories; namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; public class UnplannedIssueRequestEventHandler - : StoreEventHandlerBase + : StoreExpectInOutEventHandlerBase , ILocalEventHandler> , ILocalEventHandler>> , ILocalEventHandler> + , ILocalEventHandler> + , ILocalEventHandler> + , ILocalEventHandler> { private readonly IUnplannedIssueJobAppService _unplannedIssueJobApp; private readonly IUnplannedIssueNoteAppService _unplannedIssueNoteAppService; @@ -35,6 +44,10 @@ public class UnplannedIssueRequestEventHandler public async Task HandleEventAsync(SfsCreatedEntityEventData eventData) { var entity = eventData.Entity; + if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) + { + await AddExpectOutsAsync(entity).ConfigureAwait(false); + } //if (entity.AutoSubmit) //{ // await _unplannedIssueRequestManager.SubmitAsync(entity).ConfigureAwait(false); @@ -53,6 +66,10 @@ public class UnplannedIssueRequestEventHandler if (entity.AutoSubmit) { await _unplannedIssueRequestManager.SubmitAsync(entity).ConfigureAwait(false); + if(entity.UnplannedIssueType== EnumUnplannedIssueType.Raw) + { + await AddExpectOutsAsync(entity).ConfigureAwait(false); + } } } } @@ -80,9 +97,53 @@ public class UnplannedIssueRequestEventHandler await _unplannedIssueJobApp.CreateAsync(job).ConfigureAwait(false); } } + public virtual async Task HandleEventAsync(SfsRefusedEntityEventData eventData) + { + var entity = eventData.Entity; + if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) + { + await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); + } + } + public virtual async Task HandleEventAsync(SfsAbortedEntityEventData eventData) + { + var entity = eventData.Entity; + if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) + { + await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); + } + } + public virtual async Task HandleEventAsync(SfsCancelledEntityEventData eventData) + { + var entity = eventData.Entity; + if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) + { + await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); + } + } + + #region 私有 + private async Task AddExpectOutsAsync(UnplannedIssueRequest entitie) + { + var expectOuts = new List(); + var entityExpectOuts = BuildExpectOutInventoryAsync(entitie); + expectOuts.AddRange(entityExpectOuts); + await ExpectOutAppService.AddManyAsync(expectOuts).ConfigureAwait(false); + } + + private List BuildExpectOutInventoryAsync(UnplannedIssueRequest request) + { + var inputs = ObjectMapper.Map, List>(request.Details); + foreach (var input in inputs) + { + input.JobNumber = request.Number; + input.Worker = request.Worker; + } + return inputs; + } private async Task BuildUnplannedIssueNoteCreateInputAsync( UnplannedIssueRequest entity) { @@ -120,6 +181,8 @@ public class UnplannedIssueRequestEventHandler return createInput; } + + /* 改用AutoMapper实现 private void SetUnplannedIssueJobDetails(UnplannedIssueJobCreateInput createInput, List details) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/UnplannedIssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/UnplannedIssueNoteEventHandler.cs index 47834440e..a1da37d65 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/UnplannedIssueNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/UnplannedIssueNoteEventHandler.cs @@ -1,12 +1,15 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Volo.Abp.Domain.Entities; using Volo.Abp.EventBus; using Volo.Abp.Uow; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; 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.Event.Inventories; using Win_in.Sfs.Wms.Store.Event.Transaction; namespace Win_in.Sfs.Wms.Store.Event.Transactions; @@ -35,6 +38,10 @@ public class UnplannedIssueNoteEventHandler if (!string.IsNullOrEmpty(entity.UnplannedIssueRequestNumber)) { await _unplannedIssueRequestApp.CompleteByNumberAsync(entity.UnplannedIssueRequestNumber).ConfigureAwait(false); + if (entity.UnplannedIssueType == EnumUnplannedIssueType.Raw) + { + await ExpectOutAppService.RemoveAsync(entity.UnplannedIssueRequestNumber).ConfigureAwait(false); + } } } @@ -53,11 +60,11 @@ public class UnplannedIssueNoteEventHandler { var entities = eventData.Entity; await AddTransactionsAsync(entities).ConfigureAwait(false); + await RemoveExpectOut(entities).ConfigureAwait(false); } private async Task AddTransactionsAsync(List unplannedIssueNotes) { - var inboundTransactions = new List(); //如果要做库存事务汇总,可以修改此处 @@ -69,6 +76,17 @@ public class UnplannedIssueNoteEventHandler await TransactionAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); } + private async Task RemoveExpectOut(List unplannedIssueNotes) + { + foreach (var unplannedIssueNote in unplannedIssueNotes) + { + if (unplannedIssueNote.UnplannedIssueType == EnumUnplannedIssueType.Raw) + { + await ExpectOutAppService.RemoveAsync(unplannedIssueNote.UnplannedIssueRequestNumber).ConfigureAwait(false); + } + } + } + private List BuildTransactions(UnplannedIssueNote unplannedIssueNote) { var transactions = new List();