From 7bf9e9da8ae16fd3f3079d2bd23182fbeaf0b4da Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Tue, 14 May 2024 16:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E9=A2=84=E8=AE=A1?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExpectOuts/IExpectOutAppService.cs | 1 + .../ExpectOuts/ExpectOutAppService.cs | 28 +++- .../IKittingIssueJobAppService.cs | 15 +-- .../KittingIssueJobAppService.cs | 122 +++++++++--------- .../TransferLibJobAppService.cs | 3 +- .../Jobs/KittingIssueJobEventHandler.cs | 8 +- .../Jobs/TransferLibJobEventHandler.cs | 1 - .../TransferLibNoteEventHandler.cs | 84 +++++++++--- 8 files changed, 168 insertions(+), 94 deletions(-) diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs index e5361fa7d..4993474fb 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application.Contracts/ExpectOuts/IExpectOutAppService.cs @@ -47,4 +47,5 @@ public interface IExpectOutAppService decimal qty); Task RemoveByNumberAsync(string number); + Task UpdateLocationByPackingCodeAsync(string packingCode,string locationCode); } diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs index d2aebc5ea..efbf3d6c5 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/ExpectOuts/ExpectOutAppService.cs @@ -5,7 +5,9 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Volo.Abp; +using Volo.Abp.Domain.Repositories; using Volo.Abp.ObjectMapping; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain.Shared; using Win_in.Sfs.Basedata.SplitPackings.Commons; using Win_in.Sfs.Shared.Application.Contracts; @@ -27,14 +29,15 @@ public class ExpectOutAppService , IExpectOutAppService { private readonly IExpectOutManager _expectOutManager; + private readonly ILocationAppService _locationAppService; public ExpectOutAppService( IExpectOutRepository repository, - IExpectOutManager expectOutManager - ) : base(repository) + IExpectOutManager expectOutManager, ILocationAppService locationAppService) : base(repository) { _expectOutManager = expectOutManager; + _locationAppService = locationAppService; } [HttpPost("remove")] @@ -274,4 +277,25 @@ public class ExpectOutAppService { return await _repository.GetListAsync(p => p.JobNumber == input.Number && p.PackingCode == input.FromPackingCode && p.Qty == input.FromQty && p.LocationCode == input.FromLocationCode).ConfigureAwait(false); } + + [HttpPost("Update-Location-By-PackingCode")] + public virtual async Task UpdateLocationByPackingCodeAsync(string packingCode,string locationCode) + { + var expectOut=await _repository.FindAsync(p=>p.PackingCode== packingCode).ConfigureAwait(false); + + if (expectOut != null) + { + var locationDto=await _locationAppService.GetByCodeAsync(locationCode).ConfigureAwait(false); + + expectOut.LocationCode = locationDto.Code; + expectOut.LocationArea = locationDto.AreaCode; + expectOut.LocationErpCode = locationDto.ErpLocationCode; + expectOut.WarehouseCode = locationDto.WarehouseCode; + expectOut.LocationGroup = locationDto.LocationGroupCode; + + await _repository.UpdateAsync(expectOut).ConfigureAwait(false); + } + + return ObjectMapper.Map(expectOut); + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/IKittingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/IKittingIssueJobAppService.cs index 3bf54a1b9..7e1ffddea 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/IKittingIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/IKittingIssueJobAppService.cs @@ -1,28 +1,25 @@ -using System; +using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; -using Volo.Abp.Application.Dtos; namespace Win_in.Sfs.Wms.Store.Application.Contracts; public interface IKittingIssueJobAppService - : ISfsJobAppServiceBase + : ISfsJobAppServiceBase { - Task CancelByMaterialRequestAsync(string requestNumber); - Task> GetByRequestNumberAsync(string requestNumber); /// - /// 执行任务明细 + /// 执行任务明细 /// /// - Task ExecuteDetailAsync(Guid masterId,Guid detailId, KittingIssueJobDetailDTO issueJobDetailDto); + Task ExecuteDetailAsync(Guid masterId, Guid detailId, KittingIssueJobDetailDTO issueJobDetailDto); Task CompleteAsync(Guid id); /// - /// 请求点了完成,任务全部都完成 + /// 请求点了完成,任务全部都完成 /// /// /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs index d1caafaa7..be1af1ebc 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; +using System.Text; +using System.Text.Json; using System.Threading.Tasks; using Castle.Components.DictionaryAdapter; using Microsoft.AspNetCore.Authorization; @@ -10,7 +12,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using MyNamespace; using Volo.Abp; -using Volo.Abp.ObjectMapping; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; @@ -18,12 +19,9 @@ 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; -using Win_in.Sfs.Wms.Store.Jobs.IssueJobs; using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy; using Win_in.Sfs.Wms.Store.Notes; using Win_in.Sfs.Wms.Store.Options; -using static IdentityModel.ClaimComparer; -using static Volo.Abp.Identity.Settings.IdentitySettingNames; namespace Win_in.Sfs.Wms.Store.Application; @@ -71,12 +69,12 @@ public class KittingIssueJobAppService await CheckDimensionalStorehouseAsync(input).ConfigureAwait(false); } - var kittingIssueJobDtos=await base.CreateManyAsync(inputs).ConfigureAwait(false); + var kittingIssueJobDtos = await base.CreateManyAsync(inputs).ConfigureAwait(false); foreach (var kittingIssueJobDto in kittingIssueJobDtos) { await CheckDimensionalStorehouseAsync(kittingIssueJobDto).ConfigureAwait(false); } - + return kittingIssueJobDtos; } @@ -86,7 +84,7 @@ public class KittingIssueJobAppService await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false); await CheckDimensionalStorehouseAsync(input).ConfigureAwait(false); - var kittingIssueJobDto=await base.CreateAsync(input).ConfigureAwait(false); + var kittingIssueJobDto = await base.CreateAsync(input).ConfigureAwait(false); await CheckDimensionalStorehouseAsync(kittingIssueJobDto).ConfigureAwait(false); return kittingIssueJobDto; @@ -111,7 +109,8 @@ public class KittingIssueJobAppService } await _expectOutAppService.RemoveByNumberAsync(kittingJob.Number).ConfigureAwait(false); - await _transferLibRequestAppService.CancelByCallRequestNumberAsync(kittingJob.KittingRequestNumber).ConfigureAwait(false); + await _transferLibRequestAppService.CancelByCallRequestNumberAsync(kittingJob.KittingRequestNumber) + .ConfigureAwait(false); kittingJob.JobStatus = EnumJobStatus.Cancelled; await _repository.UpdateAsync(kittingJob).ConfigureAwait(false); @@ -192,29 +191,33 @@ public class KittingIssueJobAppService var kittingIssueNoteEditInput = await BuildKittingIssueNoteAsync(kittingIssueJobDto).ConfigureAwait(false); await _kittingIssueNoteAppService.CreateAsync(kittingIssueNoteEditInput).ConfigureAwait(false); - var issueJobDetail=ObjectMapper.Map(issueJobDetailDto); - var entityDetail=kittingIssueJob.Details.Find(p => p.Id == detailId); + var issueJobDetail = ObjectMapper.Map(issueJobDetailDto); + var entityDetail = kittingIssueJob.Details.Find(p => p.Id == detailId); issueJobDetail.HandledFromQty = entityDetail.HandledFromQty; issueJobDetail.HandledToQty = entityDetail.HandledToQty; issueJobDetail.HandledToQty += issueJobDetailDto.HandledToQty; issueJobDetail.HandledFromQty += issueJobDetailDto.HandledFromQty; - kittingIssueJob.Details = new EditableList() { issueJobDetail }; + kittingIssueJob.Details = new EditableList { issueJobDetail }; if (kittingIssueJob.EnumIssueSendType == EnumIssueSendType.BoxQtyType) //按箱叫料 因为任务只有1箱 所以可以直接完成 { - await UpdateRequestAndjobStatusDoneAsync(kittingIssueJob, issueJobDetailDto, issueJobDetailDto.HandledToQty).ConfigureAwait(false); + await UpdateRequestAndjobStatusDoneAsync(kittingIssueJob, issueJobDetailDto, issueJobDetailDto.HandledToQty) + .ConfigureAwait(false); + await _expectOutAppService.RemoveByNumberAsync(kittingIssueJob.Number).ConfigureAwait(false); } else { var detail = kittingIssueJob.Details.First(p => p.Id == issueJobDetailDto.Id); if (issueJobDetail.HandledToQty >= detail.RequestQty) { - await UpdateRequestAndjobStatusDoneAsync(kittingIssueJob, issueJobDetailDto, issueJobDetailDto.HandledToQty).ConfigureAwait(false); + await UpdateRequestAndjobStatusDoneAsync(kittingIssueJob, issueJobDetailDto, + issueJobDetailDto.HandledToQty).ConfigureAwait(false); } else { - await RemoveExpectOutAsync(kittingIssueJob, issueJobDetailDto, issueJobDetailDto.HandledToQty).ConfigureAwait(false); + await RemoveExpectOutAsync(kittingIssueJob, issueJobDetailDto, issueJobDetailDto.HandledToQty) + .ConfigureAwait(false); } } @@ -222,7 +225,7 @@ public class KittingIssueJobAppService } /// - /// 完成任务 + /// 完成任务 /// /// /// @@ -235,57 +238,60 @@ public class KittingIssueJobAppService await _expectOutAppService.RemoveByNumberAsync(kittingIssueJob.Number).ConfigureAwait(false); - await KittingIssueRequestAppService.UpdateStatusCompletedAsync(kittingIssueJob.KittingRequestNumber).ConfigureAwait(false); - await _transferLibRequestAppService.CancelByCallRequestNumberAsync(kittingIssueJob.KittingRequestNumber).ConfigureAwait(false); + await KittingIssueRequestAppService.UpdateStatusCompletedAsync(kittingIssueJob.KittingRequestNumber) + .ConfigureAwait(false); + await _transferLibRequestAppService.CancelByCallRequestNumberAsync(kittingIssueJob.KittingRequestNumber) + .ConfigureAwait(false); await _repository.UpdateAsync(kittingIssueJob).ConfigureAwait(false); } /// - /// 请求点了完成,任务全部都完成 + /// 请求点了完成,任务全部都完成 /// /// /// [HttpPost("complete-by-request/{requestNumber}")] public async Task CompleteByRequestNumberAsync(string requestNumber) { - var kittingIssueJobs = await _repository.GetListAsync(p=>p.KittingRequestNumber==requestNumber).ConfigureAwait(false); + var kittingIssueJobs = await _repository.GetListAsync(p => p.KittingRequestNumber == requestNumber) + .ConfigureAwait(false); foreach (var kittingIssueJob in kittingIssueJobs) { kittingIssueJob.JobStatus = EnumJobStatus.Done; await _repository.UpdateAsync(kittingIssueJob).ConfigureAwait(false); await _expectOutAppService.RemoveByNumberAsync(kittingIssueJob.Number).ConfigureAwait(false); - await _transferLibRequestAppService.CancelByCallRequestNumberAsync(kittingIssueJob.KittingRequestNumber).ConfigureAwait(false); + await _transferLibRequestAppService.CancelByCallRequestNumberAsync(kittingIssueJob.KittingRequestNumber) + .ConfigureAwait(false); } } #region 立库 /// - /// 立体库同步 + /// 立体库同步 /// /// /// /// [HttpPost("sync-issue-job-stereo")] - public async Task SyncIssueJobStereoAsync(List input, string p_loc) { - ReusltObject ret = new ReusltObject(); + var ret = new ReusltObject(); ret.Code = "1"; ret.Message = "操作成功"; ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); try { - List IssueJobToRestoDetailDTOs = new List(); - IssueJobToRestoDTO main = new IssueJobToRestoDTO(); + var IssueJobToRestoDetailDTOs = new List(); + var main = new IssueJobToRestoDTO(); main.OperatorName = CurrentUser.UserName; foreach (var job in input) { foreach (var jobitem in job.Details) { - IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO() + IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO { Count = jobitem.HandledToQty, ProductNo = jobitem.ItemCode, @@ -295,15 +301,16 @@ public class KittingIssueJobAppService }); } } + main.Details = IssueJobToRestoDetailDTOs; var httpclient = _httpClientFactory.CreateClient(); #if DEBUG - string json = System.Text.Json.JsonSerializer.Serialize(main); - _options.Value.Address = "http://localhost:59094/";//测试地址 - _options.Value.Token = "";//测试token - _options.Value.UserName = "";//测试用户名 - _options.Value.Password = "";//测试密码 + var json = JsonSerializer.Serialize(main); + _options.Value.Address = "http://localhost:59094/"; //测试地址 + _options.Value.Token = ""; //测试token + _options.Value.UserName = ""; //测试用户名 + _options.Value.Password = ""; //测试密码 #endif if (!string.IsNullOrEmpty(_options.Value.Token)) @@ -311,14 +318,16 @@ public class KittingIssueJobAppService var token = _options.Value.Token; httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); } + if (!string.IsNullOrEmpty(_options.Value.UserName) && !string.IsNullOrEmpty(_options.Value.Password)) { var username = _options.Value.UserName; var password = _options.Value.Password; - httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{username}:{password}"))); + httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", + Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); } - IssueJobToRestoClient client = new IssueJobToRestoClient(_options.Value.Address, httpclient); + var client = new IssueJobToRestoClient(_options.Value.Address, httpclient); ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); } catch (Exception ex) @@ -330,47 +339,40 @@ public class KittingIssueJobAppService } return ret; - } [HttpPost("receive-issue-job-stereo")] public virtual async Task SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input) { - #if DEBUG - var json = System.Text.Json.JsonSerializer.Serialize(input); + var json = JsonSerializer.Serialize(input); #endif - List errors = new List(); - var ret = new ReusltObject() - { - Code = "1", - OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), - Message = "操作成功" - }; + var errors = new List(); + var ret = new ReusltObject { Code = "1", OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = "操作成功" }; try { - if (input.Jobs.Count > 0) { var jobs = input.Jobs; var numbers = jobs.Select(p => p.JobNumber); var query = _repository.WithDetails() - .Where(p => numbers.Contains(p.Number)); + .Where(p => numbers.Contains(p.Number)); var entities = query.ToList(); var dtos = ObjectMapper.Map, List>(entities); if (input.Jobs.Count == entities.Count) { errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); } + foreach (var itm in dtos) { - var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); + var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); var itmDetails = itm.Details.ToList(); - List details = new List(); + var details = new List(); foreach (var detail in first.Details) { var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.ItemCode); - KittingIssueJobDetailDTO dto = new KittingIssueJobDetailDTO(); + var dto = new KittingIssueJobDetailDTO(); dto.HandledFromLocationCode = entity.HandledFromLocationCode; dto.HandledToLocationCode = entity.HandledToLocationCode; dto.ItemCode = detail.ItemCode; @@ -381,6 +383,7 @@ public class KittingIssueJobAppService dto.Status = entity.Status; details.Add(dto); } + itm.Details = details; await CompleteAsync(itm.Id, itm).ConfigureAwait(false); } @@ -392,24 +395,23 @@ public class KittingIssueJobAppService } catch (Exception ex) { - ret = new ReusltObject() + ret = new ReusltObject { - Code = "2", - OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), - Message = ex.Message + Code = "2", OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = ex.Message }; return ret; } + if (errors.Count > 0) { - - ret = new ReusltObject() + ret = new ReusltObject { Code = "2", OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = string.Join(",", errors.ToArray()) }; } + return ret; } @@ -514,18 +516,17 @@ public class KittingIssueJobAppService if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) { //TODO 立体库 - var ret = await SyncIssueJobStereoAsync(new List { kittingIssueJobDto }, loctionDto.Code).ConfigureAwait(false); + var ret = await SyncIssueJobStereoAsync(new List { kittingIssueJobDto }, + loctionDto.Code).ConfigureAwait(false); if (ret.Code != "1") { throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}"); } } - - } /// - /// 修改当前任务状态 和 该任务的请求状态 + /// 修改当前任务状态 和 该任务的请求状态 /// /// /// @@ -533,7 +534,7 @@ public class KittingIssueJobAppService /// /// private async Task UpdateRequestAndjobStatusDoneAsync(KittingIssueJob kittingIssueJob, - KittingIssueJobDetailDTO kittingIssueJobDetailDto,decimal handledToQty) + KittingIssueJobDetailDTO kittingIssueJobDetailDto, decimal handledToQty) { if (kittingIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中 @@ -554,7 +555,8 @@ public class KittingIssueJobAppService await Task.CompletedTask.ConfigureAwait(false); } - private async Task RemoveExpectOutAsync(KittingIssueJob kittingIssueJob, KittingIssueJobDetailDTO kittingIssueJobDetailDto, + private async Task RemoveExpectOutAsync(KittingIssueJob kittingIssueJob, + KittingIssueJobDetailDTO kittingIssueJobDetailDto, decimal handledToQty) { await _expectOutAppService.RemoveByNumberAndInventoryAsync(kittingIssueJob.Number, diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs index 7bb954fcf..d67a779d7 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs @@ -31,7 +31,8 @@ public class TransferLibJobAppService public TransferLibJobAppService( ITransferLibJobRepository repository, ITransferLibJobManager TransferLibJobManager, - IServiceProvider serviceProvider, ILocationAppService locationAppService, IExpectOutAppService expectOutAppService) : base(repository, + IServiceProvider serviceProvider, ILocationAppService locationAppService, + IExpectOutAppService expectOutAppService) : base(repository, TransferLibJobManager) { _serviceProvider = serviceProvider; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/KittingIssueJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/KittingIssueJobEventHandler.cs index 27d345225..8573a076a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/KittingIssueJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/KittingIssueJobEventHandler.cs @@ -130,8 +130,8 @@ public class KittingIssueJobEventHandler : var locationDto = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode) .ConfigureAwait(false); var locationList = await _locationAppService.GetListByGroupsAsync( - new List{ detail.RecommendFromLocationGroup }).ConfigureAwait(false); - var locationListSort=locationList.OrderBy(p => p.RowCode); + new List { detail.RecommendFromLocationGroup }).ConfigureAwait(false); + var locationListSort = locationList.OrderBy(p => p.RowCode); var locationDtoRowOne = new LocationDTO(); if (locationListSort.Any()) @@ -204,7 +204,7 @@ public class KittingIssueJobEventHandler : detailInput.RecommendToLocationErpCode = locationDtoRowOne.ErpLocationCode; detailInput.RecommendToWarehouseCode = locationDtoRowOne.WarehouseCode; - input.Details = new EditableList() { detailInput }; + input.Details = new EditableList { detailInput }; await _transferLibRequestAppService.CreateAsync(input).ConfigureAwait(false); } @@ -238,7 +238,7 @@ public class KittingIssueJobEventHandler : var locationDto = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode) .ConfigureAwait(false); - if (locationDto.Type==EnumLocationType.RAW&& locationDto.RowCode == 1) + if (locationDto.Type == EnumLocationType.RAW && locationDto.RowCode == 1) { return true; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/TransferLibJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/TransferLibJobEventHandler.cs index 793bffbd6..3b1e5b52a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/TransferLibJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/TransferLibJobEventHandler.cs @@ -56,7 +56,6 @@ public class TransferLibJobEventHandler : /// 创建补料记录实体 /// /// - /// /// private TransferLibNoteEditInput BuildTransferLibNoteCreateInput(TransferLibJob entity) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferLibNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferLibNoteEventHandler.cs index dbe0024d7..92b6e6f23 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferLibNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferLibNoteEventHandler.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Castle.Components.DictionaryAdapter; 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; -using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Event.Transaction; @@ -15,22 +15,25 @@ namespace Win_in.Sfs.Wms.Store.Event.Transactions; public class TransferLibNoteEventHandler : StoreInventoryEventHandlerBase - , ILocalEventHandler> - , ILocalEventHandler> - , ILocalEventHandler>> + , ILocalEventHandler> + , ILocalEventHandler> + , ILocalEventHandler>> { private const EnumTransType TransType = EnumTransType.TransferLib; private readonly ILocationAppService _locationAppService; private readonly ITransferLogAppService _transferLogAppService; + private readonly IExpectOutAppService _expectOutAppService; - public TransferLibNoteEventHandler(ILocationAppService locationAppService, ITransferLogAppService transferLogAppService) + public TransferLibNoteEventHandler(ILocationAppService locationAppService, + ITransferLogAppService transferLogAppService, IExpectOutAppService expectOutAppService) { _locationAppService = locationAppService; _transferLogAppService = transferLogAppService; + _expectOutAppService = expectOutAppService; } /// - /// 创建 后 + /// 创建 后 /// /// /// @@ -48,7 +51,7 @@ public class TransferLibNoteEventHandler } /// - /// 批量创建 后 + /// 批量创建 后 /// /// /// @@ -67,7 +70,7 @@ public class TransferLibNoteEventHandler } /// - /// 确认 后 + /// 确认 后 /// /// /// @@ -76,7 +79,8 @@ public class TransferLibNoteEventHandler { var entity = eventData.Entity; - var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false); + var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination) + .ConfigureAwait(false); await AddTransferLogsAsync(inputList).ConfigureAwait(false); } @@ -87,11 +91,10 @@ public class TransferLibNoteEventHandler transferLogs.AddRange(inputList); await _transferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); - } /// - /// 构建正常的input + /// 构建正常的input /// /// /// @@ -104,7 +107,7 @@ public class TransferLibNoteEventHandler { //var transferLog = ObjectMapper.Map(detail); //0416修改 - TransferLogEditInput transferLog = new TransferLogEditInput(); + var transferLog = new TransferLogEditInput(); //transferLog.TransferNumber = ""; transferLog.FromPackingCode = detail.HandledFromPackingCode; transferLog.ToPackingCode = detail.HandledToPackingCode; @@ -147,9 +150,12 @@ public class TransferLibNoteEventHandler transferLog.TenantId = detail.TenantId; transferLog.Remark = detail.Remark; - var fromLocation = await _locationAppService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); - var toLocation = await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); - var transferOnTheWay = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT).ConfigureAwait(false); + var fromLocation = await _locationAppService.GetByCodeAsync(detail.HandledFromLocationCode) + .ConfigureAwait(false); + var toLocation = await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode) + .ConfigureAwait(false); + var transferOnTheWay = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT) + .ConfigureAwait(false); switch (route) { @@ -185,7 +191,8 @@ public class TransferLibNoteEventHandler transferLog.ToLocationArea = toLocation.AreaCode; transferLog.ToLocationErpCode = toLocation.ErpLocationCode; transferLog.ToLocationGroup = toLocation.LocationGroupCode; - break;; + break; + ; default: throw new ArgumentOutOfRangeException(nameof(route), route, null); } @@ -196,11 +203,54 @@ public class TransferLibNoteEventHandler transferLog.DocNumber = note.Number; transferLog.JobNumber = note.JobNumber; + if (detail.RecommendToPackingCode == detail.HandledToPackingCode) //相同把预计出的库位修改了 + { + await _expectOutAppService.UpdateLocationByPackingCodeAsync(detail.HandledToPackingCode, + detail.HandledToLocationCode).ConfigureAwait(false); + } + else //不相同创建一个新的预计出 + { + await CreateExpectOutAsync(detail).ConfigureAwait(false); + } + transferLogs.Add(transferLog); } return transferLogs; } -} + /// + /// 创建预计出 + /// + /// + /// + private async Task CreateExpectOutAsync(TransferLibNoteDetail detail) + { + var inputoExpectOutEditInput = new ExpectOutEditInput(); + inputoExpectOutEditInput.JobNumber = detail.CallRequestNumber; + inputoExpectOutEditInput.ItemCode = detail.ItemCode; + inputoExpectOutEditInput.Qty = detail.HandledFromQty; + inputoExpectOutEditInput.LocationCode = detail.HandledFromLocationCode; + inputoExpectOutEditInput.ArriveDate = detail.HandledFromArriveDate; + inputoExpectOutEditInput.ContainerCode = detail.HandledFromContainerCode; + inputoExpectOutEditInput.ExpireDate = detail.HandledFromExpireDate; + inputoExpectOutEditInput.ItemDesc1 = detail.ItemDesc1; + inputoExpectOutEditInput.ItemDesc2 = detail.ItemDesc2; + inputoExpectOutEditInput.ItemName = detail.ItemName; + inputoExpectOutEditInput.LocationArea = detail.HandledFromLocationArea; + inputoExpectOutEditInput.LocationGroup = detail.HandledFromLocationGroup; + inputoExpectOutEditInput.LocationErpCode = detail.HandledFromLocationErpCode; + inputoExpectOutEditInput.PackingCode = detail.HandledFromPackingCode; + inputoExpectOutEditInput.Lot = detail.HandledFromLot; + inputoExpectOutEditInput.ProduceDate = detail.HandledFromProduceDate; + inputoExpectOutEditInput.Status = detail.Status; + inputoExpectOutEditInput.Uom = detail.Uom; + inputoExpectOutEditInput.SupplierBatch = detail.HandledFromSupplierBatch; + inputoExpectOutEditInput.WarehouseCode = detail.HandledFromWarehouseCode; + await _expectOutAppService.AddManyAsync(new EditableList { inputoExpectOutEditInput }) + .ConfigureAwait(false); + + await Task.CompletedTask.ConfigureAwait(false); + } +}