From d0665180c7990f7aca5c48cde91a7e15f81e19fb Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Thu, 11 Apr 2024 08:46:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=B3=A8=E5=A1=91?= =?UTF-8?q?=E5=8F=91=E6=96=99=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enums/Job/EnumJobStatus.cs | 8 +- .../InjectionJobs/DTOs/InjectionJobDTO.cs | 1 - .../InjectionJobs/IInjectionJobAppService.cs | 3 +- .../InjectionJobs/InjectionJobAppService.cs | 12 +- .../InjectionRequestManager.cs | 2 +- .../Jobs/InjectionJobEventHandler.cs | 175 ++++++++++++++---- .../Requests/InjectionRequestEventHandler.cs | 50 ++--- .../settings/appsettings.Development.json | 4 +- 8 files changed, 183 insertions(+), 72 deletions(-) diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Job/EnumJobStatus.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Job/EnumJobStatus.cs index a2de366d0..619e84684 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Job/EnumJobStatus.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Job/EnumJobStatus.cs @@ -45,5 +45,11 @@ public enum EnumJobStatus /// 作废 /// [Display(Name = "作废")] - Cancelled = 9 + Cancelled = 9, + + /// + /// 等待 + /// + [Display(Name = "等待")] + Wait=30, } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/DTOs/InjectionJobDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/DTOs/InjectionJobDTO.cs index bde149b68..3851df4e1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/DTOs/InjectionJobDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/DTOs/InjectionJobDTO.cs @@ -42,5 +42,4 @@ public class InjectionJobDTO : SfsJobDTOBase /// [Display(Name = "使用在途库")] public bool UseOnTheWayLocation { get; set; } - } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/IInjectionJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/IInjectionJobAppService.cs index a238cf57b..a5681c7ac 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/IInjectionJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/IInjectionJobAppService.cs @@ -8,7 +8,7 @@ namespace Win_in.Sfs.Wms.Store.Application.Contracts; public interface IInjectionJobAppService : ISfsJobAppServiceBase { - Task> CheckJobExistByItemCodeAndLocationCode(string itemCode, string locationCode); + Task> CheckJobExistByItemCodeAndLocationCodeAsync(string itemCode, string locationCode); Task CancelByMaterialRequestAsync(string injectionNumber); @@ -22,5 +22,4 @@ public interface IInjectionJobAppService /// /// Task SaveDetail_SplitPackingAsync(SplitPacking_UpdateJobDetailInput input); - } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs index a8ff9b2bd..9e75a94a8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionJobs/InjectionJobAppService.cs @@ -33,6 +33,16 @@ public class InjectionJobAppService _injectionJobManager = injectionJobManager; } + public override Task> CreateManyAsync(List inputs) + { + return base.CreateManyAsync(inputs); + } + + public override Task CreateAsync(InjectionJobEditInput input) + { + return base.CreateAsync(input); + } + /// /// 根据物品和库位 检查是否存在发料任务 /// @@ -42,7 +52,7 @@ public class InjectionJobAppService /// [Authorize] [HttpGet("check-job-exist")] - public virtual async Task> CheckJobExistByItemCodeAndLocationCode(string itemCode, + public virtual async Task> CheckJobExistByItemCodeAndLocationCodeAsync(string itemCode, string locationCode) { var entities = await _repository.GetListAsync(c => diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/InjectionRequests/InjectionRequestManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/InjectionRequests/InjectionRequestManager.cs index 014b4d81a..cff1683fa 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/InjectionRequests/InjectionRequestManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/MaterialRequests/InjectionRequests/InjectionRequestManager.cs @@ -34,7 +34,7 @@ public class InjectionRequestManager /// /// public virtual async Task CreateByNumberAsync(InjectionRequest entity) - { + { var number = string.IsNullOrEmpty(entity.Number) ? await GenerateNumberAsync(nameof(InjectionRequest), entity.ActiveDate).ConfigureAwait(false) : entity.Number; 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 9499c8fa1..97ced430f 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 @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -6,7 +5,9 @@ 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.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.Domain.Shared; @@ -16,16 +17,26 @@ namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; public class InjectionJobEventHandler : StoreEventHandlerBase , ILocalEventHandler> + , 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, ILocationAppService locationAppService) + public InjectionJobEventHandler(IInjectionNoteAppService injectionNoteAppService, + IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService, + ILocationAppService locationAppService, ITransferLibRequestAppService transferLibRequestAppService) { _injectionNoteAppService = injectionNoteAppService; + _balanceAppService = balanceAppService; + _expectOutAppService = expectOutAppService; _locationAppService = locationAppService; + _transferLibRequestAppService = transferLibRequestAppService; } /// @@ -41,8 +52,92 @@ public class InjectionJobEventHandler : await _injectionNoteAppService.CreateAsync(injectionNote).ConfigureAwait(false); } + /// + /// 创建后 + /// + /// + /// + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + + await CreateExpectOutAsync(entity).ConfigureAwait(false); + } + + /// + /// 批量创建后 + /// + /// + /// + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entitys = eventData.Entity; + + foreach (var entity in entitys) + { + await CreateExpectOutAsync(entity).ConfigureAwait(false); + } + } + #region 私有 + /// + /// 创建预计出 + /// + /// + /// + private async Task CreateExpectOutAsync(InjectionJob entity) + { + var expectOutEditInputs = new List(); + foreach (var detail in entity.Details) + { + var balanceDto = await _balanceAppService + .GetRealQtyByPackingCodeAndItemCodeAndLocationCodeAndStatusAsync(detail.RecommendPackingCode, + detail.ItemCode, detail.RecommendFromLocationCode, EnumInventoryStatus.OK).ConfigureAwait(false); + + var inputoExpectOutEditInput = new ExpectOutEditInput(); + inputoExpectOutEditInput.JobNumber = entity.Number; + inputoExpectOutEditInput.ItemCode = detail.ItemCode; + inputoExpectOutEditInput.Qty = balanceDto.Qty; + inputoExpectOutEditInput.LocationCode = balanceDto.LocationCode; + inputoExpectOutEditInput.ArriveDate = balanceDto.ArriveDate; + inputoExpectOutEditInput.ContainerCode = balanceDto.ContainerCode; + inputoExpectOutEditInput.ExpireDate = balanceDto.ExpireDate; + inputoExpectOutEditInput.ItemDesc1 = balanceDto.ItemDesc1; + inputoExpectOutEditInput.ItemDesc2 = balanceDto.ItemDesc2; + inputoExpectOutEditInput.ItemName = balanceDto.ItemName; + inputoExpectOutEditInput.LocationArea = balanceDto.LocationArea; + inputoExpectOutEditInput.LocationGroup = balanceDto.LocationGroup; + inputoExpectOutEditInput.LocationErpCode = balanceDto.LocationErpCode; + inputoExpectOutEditInput.PackingCode = balanceDto.PackingCode; + inputoExpectOutEditInput.Lot = balanceDto.Lot; + inputoExpectOutEditInput.ProduceDate = balanceDto.ProduceDate; + inputoExpectOutEditInput.Status = balanceDto.Status; + inputoExpectOutEditInput.Uom = balanceDto.Uom; + inputoExpectOutEditInput.SupplierBatch = balanceDto.SupplierBatch; + inputoExpectOutEditInput.WarehouseCode= balanceDto.WarehouseCode; + + expectOutEditInputs.Add(inputoExpectOutEditInput); + } + + await _expectOutAppService.AddManyAsync(expectOutEditInputs).ConfigureAwait(false); + } + + /// + /// 根据是否在 第一层 来创建 是否生成库移任务 + /// + /// + private async Task CreateTransferLib(InjectionJob injectionJob) + { + var input= new TransferLibRequestEditInput(); + //input.CallBusinessType = nameof(type); + input.CallJobNumber = injectionJob.Number; + input.CallRequestNumber = injectionJob.InjectionRequestNumber; + //input.CallServerName= + + //_transferLibRequestAppService.CreateAsync(); + } + /// /// 创建补料记录实体 /// @@ -80,49 +175,49 @@ public class InjectionJobEventHandler : switch (locationType) { case EnumLocationType.WIP: + { + //用开关控制 发料到线边后去除箱码和托码 ??? + if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToWip.IsRemovePackingCode) + .ConfigureAwait(false)) { - //用开关控制 发料到线边后去除箱码和托码 ??? - if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToWip.IsRemovePackingCode) - .ConfigureAwait(false)) - { - injectionNoteDetail.ToPackingCode = ""; - } - - if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToWip.IsRemoveContainerCode) - .ConfigureAwait(false)) - { - injectionNoteDetail.ToContainerCode = ""; - } - - if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToWip.IsRemoveLot).ConfigureAwait(false)) - { - injectionNoteDetail.ToLot = ""; - } - - break; + injectionNoteDetail.ToPackingCode = ""; } + + if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToWip.IsRemoveContainerCode) + .ConfigureAwait(false)) + { + injectionNoteDetail.ToContainerCode = ""; + } + + if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToWip.IsRemoveLot).ConfigureAwait(false)) + { + injectionNoteDetail.ToLot = ""; + } + + break; + } case EnumLocationType.SEMI: + { + //用开关控制 发料到后去除箱码和托码 ??? + if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToSemi.IsRemovePackingCode) + .ConfigureAwait(false)) + { + injectionNoteDetail.ToPackingCode = ""; + } + + if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToSemi.IsRemoveContainerCode) + .ConfigureAwait(false)) + { + injectionNoteDetail.ToContainerCode = ""; + } + + if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToSemi.IsRemoveLot).ConfigureAwait(false)) { - //用开关控制 发料到后去除箱码和托码 ??? - if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToSemi.IsRemovePackingCode) - .ConfigureAwait(false)) - { - injectionNoteDetail.ToPackingCode = ""; - } - - if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToSemi.IsRemoveContainerCode) - .ConfigureAwait(false)) - { - injectionNoteDetail.ToContainerCode = ""; - } - - if (await SettingManager.IsTrueAsync(StoreSettings.Issue.ToSemi.IsRemoveLot).ConfigureAwait(false)) - { - injectionNoteDetail.ToLot = ""; - } - - break; + injectionNoteDetail.ToLot = ""; } + + break; + } } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/InjectionRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/InjectionRequestEventHandler.cs index d8263b67c..6d18713cc 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/InjectionRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/InjectionRequestEventHandler.cs @@ -27,19 +27,17 @@ public class InjectionRequestEventHandler { private readonly IInjectionJobAppService _injectionJobAppService; private readonly IProductionLineAppService _productionLineAppService; - private readonly IInjectionRequestManager _injectionRequestManager; private readonly IProductionLineItemAppService _productionLineItemAppService; private readonly ILocationAppService _locationAppService; private readonly IBalanceAppService _balanceAppService; public InjectionRequestEventHandler( IInjectionJobAppService injectionJobAppService, IProductionLineAppService productionLineAppService, - IInjectionRequestManager injectionRequestManager, ILocationAppService locationAppService, + ILocationAppService locationAppService, IBalanceAppService balanceAppService, IProductionLineItemAppService productionLineItemAppService) { _injectionJobAppService = injectionJobAppService; _productionLineAppService = productionLineAppService; - _injectionRequestManager = injectionRequestManager; _locationAppService = locationAppService; _balanceAppService = balanceAppService; _productionLineItemAppService = productionLineItemAppService; @@ -77,13 +75,13 @@ public class InjectionRequestEventHandler switch (entity.Type) { case nameof(EnumIssueType.BoxQty): - injectionJobs =await CreateInjectionJobWithBoxQtyTypeAsync(entity).ConfigureAwait(false); + injectionJobs = await CreateInjectionJobWithBoxQtyTypeAsync(entity).ConfigureAwait(false); break; case nameof(EnumIssueType.Qty): injectionJobs = await CreateInjectionJobWithQtyTypeAsync(entity).ConfigureAwait(false); break; } - + if (injectionJobs.Any()) { await _injectionJobAppService.CreateManyAsync(injectionJobs).ConfigureAwait(false); @@ -152,7 +150,8 @@ public class InjectionRequestEventHandler var job = jobs.FirstOrDefault(p => p.WorkGroupCode == fromLocation?.WorkGroupCode); if (job == null || job.Details.Any(p => p.ToLocationCode != injectionRequestDetail.ToLocationCode)) { - job = await BuildInjectionJobCreateInputWithQtyTypeAsync(injectionRequest, fromLocation).ConfigureAwait(false); + job = await BuildInjectionJobCreateInputWithQtyTypeAsync(injectionRequest, fromLocation) + .ConfigureAwait(false); jobs.Add(job); } @@ -201,7 +200,8 @@ public class InjectionRequestEventHandler /// /// /// - private async Task BuildInjectionJobCreateInputWithQtyTypeAsync(InjectionRequest injectionRequest, + private async Task BuildInjectionJobCreateInputWithQtyTypeAsync( + InjectionRequest injectionRequest, LocationDTO fromLocation) { InjectionJobEditInput job; @@ -266,8 +266,10 @@ public class InjectionRequestEventHandler foreach (var recommend in recommendList) { //拿走需求量 - var detail = await BuildInjectionJobDetailWithQtyTypeAsync(injectionRequestDetail, recommend, toLocationGroupCode) - .ConfigureAwait(false); + var detail = + await BuildInjectionJobDetailWithQtyTypeAsync(injectionRequestDetail, recommend, + toLocationGroupCode) + .ConfigureAwait(false); if (injectionRequest.UseOnTheWayLocation) { //获取在途库 @@ -347,6 +349,7 @@ public class InjectionRequestEventHandler (InjectionRequest injectionRequest) { var inputJobs = new List(); + var inputExpectOutEditInput = new ExpectOutEditInput(); //已用的库存的箱码集合 var useBalanceList = new List(); @@ -369,9 +372,9 @@ public class InjectionRequestEventHandler throw new UserFriendlyException($"库位【{inputDetailTemplate.ToLocationCode}】没有对应的【生产线】"); } - var productLineCodeAndItemCode = (await _productionLineItemAppService + var productLineCodeAndItemCode = await _productionLineItemAppService .GetByProductLineCodeAndItemCodeAsync(productionLineDto.Code, inputDetailTemplate.ItemCode) - .ConfigureAwait(false)); + .ConfigureAwait(false); if (productLineCodeAndItemCode == null) { throw new UserFriendlyException( @@ -387,16 +390,15 @@ public class InjectionRequestEventHandler Locations = JsonSerializer.Deserialize>(productLineCodeAndItemCode .RawLocationCodeListJson) }; - - //所有可用库存 var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); - usableList=usableList.Where(p => !useBalanceList.Contains(p.PackingCode)).ToList(); - var firstUsable = usableList.First(); - useBalanceList.Add(firstUsable.PackingCode); - usableList.Remove(firstUsable); + usableList = usableList.Where(p => !useBalanceList.Contains(p.PackingCode)).ToList(); - for (int i = 0; i < sumBoxQty; i++) + for (var i = 0; i < sumBoxQty; i++) { + var firstUsable = usableList.First(); + useBalanceList.Add(firstUsable.PackingCode); + usableList.Remove(firstUsable); + var injectionJobEditInput = await BuildInjectionJobCreateInputWithBoxQtyTypeAsync(injectionRequest, inputDetailTemplate, firstUsable) @@ -416,8 +418,9 @@ public class InjectionRequestEventHandler /// /// /// - private async Task BuildInjectionJobCreateInputWithBoxQtyTypeAsync(InjectionRequest injectionRequest, - InjectionRequestDetail injectionRequestDetail,BalanceDTO balanceDtos) + private async Task BuildInjectionJobCreateInputWithBoxQtyTypeAsync( + InjectionRequest injectionRequest, + InjectionRequestDetail injectionRequestDetail, BalanceDTO balanceDtos) { InjectionJobEditInput job; job = ObjectMapper.Map(injectionRequest); @@ -429,7 +432,8 @@ public class InjectionRequestEventHandler job.Worker = injectionRequest.Worker; job.InjectionRequestNumber = injectionRequest.Number; - job.Details.Add(await BuildInjectionJobDetailWithBoxQtyTypeAsync(injectionRequestDetail, balanceDtos).ConfigureAwait(false)); + job.Details.Add(await BuildInjectionJobDetailWithBoxQtyTypeAsync(injectionRequestDetail, balanceDtos) + .ConfigureAwait(false)); await Task.CompletedTask.ConfigureAwait(false); @@ -446,8 +450,6 @@ public class InjectionRequestEventHandler private async Task BuildInjectionJobDetailWithBoxQtyTypeAsync( InjectionRequestDetail injectionRequestDetail, BalanceDTO balance) { - //ProductionLineDTO prodLine = await _productionLineAppService.GetByLocationGroupCodeAsync(toLocationGroupCode).ConfigureAwait(false); - var detail = ObjectMapper.Map(balance); detail.RequestLocationCode = injectionRequestDetail.ToLocationCode; detail.WorkStation = injectionRequestDetail.WorkStation; @@ -475,8 +477,8 @@ public class InjectionRequestEventHandler detail.ToLocationErpCode = injectionRequestDetail.ToLocationErpCode; detail.ToLocationArea = injectionRequestDetail.ToLocationArea; detail.ToWarehouseCode = injectionRequestDetail.ToWarehouseCode; + detail.ToLocationGroup= injectionRequestDetail.ToLocationGroup; - //detail.ProdLine = prodLine == null ? toLocationGroupCode : prodLine.Code; detail.ProdLine = injectionRequestDetail.ToLocationCode; await Task.CompletedTask.ConfigureAwait(false); return detail; diff --git a/build/src/docker/publish/conf/settings/appsettings.Development.json b/build/src/docker/publish/conf/settings/appsettings.Development.json index d575183e9..a8e489fe5 100644 --- a/build/src/docker/publish/conf/settings/appsettings.Development.json +++ b/build/src/docker/publish/conf/settings/appsettings.Development.json @@ -114,8 +114,8 @@ "BaseUrl": "http://dev.ccwin-in.com:60083/" }, "BaseData": { - //"BaseUrl": "http://localhost:59094/" - "BaseUrl": "http://dev.ccwin-in.com:60084/" + "BaseUrl": "http://localhost:59094/" + //"BaseUrl": "http://dev.ccwin-in.com:60084/" }, "Default": { "BaseUrl": "http://dev.ccwin-in.com:60083/"