From d011be343ff87d35a1aad29b41abcf93c4860d77 Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Tue, 14 May 2024 15:11:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E5=BA=93=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Jobs/IssueJobController.cs | 2 +- .../Locations/ILocationAppService.cs | 1 + .../Locations/LocationAppService.cs | 10 ++ .../IssueJobs/IIssueJobAppService.cs | 2 +- .../ITransferLibJobAppService.cs | 6 +- .../ITransferLibRequestAppService.cs | 1 + .../Jobs/IssueJobs/IssueJobAppService.cs | 2 +- .../KittingIssueJobAppService.cs | 7 +- .../TransferLibJobAppService.cs | 119 ++++++++++++++---- .../TransferLibRequestAppService.cs | 77 +++++++++++- .../Jobs/KittingIssueJobEventHandler.cs | 32 ++++- .../KittingIssueRequestEventHandler.cs | 2 +- 12 files changed, 219 insertions(+), 42 deletions(-) diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobController.cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobController.cs index 2efe34c7d..3826740d3 100644 --- a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobController.cs +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobController.cs @@ -240,7 +240,7 @@ public class IssueJobController : AbpController [HttpGet("check-job-exist")] public virtual async Task> CheckJobExistByItemCodeAndLocationCode(string itemCode, string locationCode) { - return await _issueJobAppService.CheckJobExistByItemCodeAndLocationCode(itemCode, locationCode).ConfigureAwait(false); + return await _issueJobAppService.CheckJobExistByItemCodeAndLocationCodeAsync(itemCode, locationCode).ConfigureAwait(false); } /// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs index fdfb1d4cf..669965707 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Locations/ILocationAppService.cs @@ -32,4 +32,5 @@ public interface ILocationAppService Task> GetListByTypesAndErpCodeAsync(List types, string erpCode); Task> GetListByTypesAndErpCodeAsync(List types, string erpCode,string locCode); Task> GetListByErpLocationCodes(List ErpLocationCodes); + Task GetFirstRowOneAsync(); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs index 1ad9ec748..1625440b5 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Locations/LocationAppService.cs @@ -1,12 +1,14 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Caching; using Volo.Abp.Domain.Repositories; +using Volo.Abp.ObjectMapping; using Volo.Abp.Validation; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain; @@ -220,6 +222,14 @@ public class LocationAppService return ObjectMapper.Map, List>(list); } + [HttpGet("get-first-row-one")] + public virtual async Task GetFirstRowOneAsync() + { + var first = await _repository.GetListAsync(p => p.RowCode == 1).ConfigureAwait(false); + + return ObjectMapper.Map(first.FirstOrDefault()); + } + protected override async Task ValidateImportModelAsync(LocationImportInput importInput, List validationRresult) { await base.ValidateImportModelAsync(importInput, validationRresult).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/IIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/IIssueJobAppService.cs index 306f0df4e..d496a4530 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/IIssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/IssueJobs/IIssueJobAppService.cs @@ -8,7 +8,7 @@ namespace Win_in.Sfs.Wms.Store.Application.Contracts; public interface IIssueJobAppService : ISfsJobAppServiceBase { - Task> CheckJobExistByItemCodeAndLocationCode(string itemCode, string locationCode); + Task> CheckJobExistByItemCodeAndLocationCodeAsync(string itemCode, string locationCode); Task CancelByMaterialRequestAsync(string materialNumber); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/TransferLibJobs/ITransferLibJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/TransferLibJobs/ITransferLibJobAppService.cs index d98931e79..b023b698b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/TransferLibJobs/ITransferLibJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/TransferLibJobs/ITransferLibJobAppService.cs @@ -1,7 +1,11 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + namespace Win_in.Sfs.Wms.Store.Application.Contracts; public interface ITransferLibJobAppService : ISfsJobAppServiceBase { - + Task> GetByRequestNumberAsync(string requestNumber); + Task CompleteByRequestAsync(string requestNumber); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferLibRequests/ITransferLibRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferLibRequests/ITransferLibRequestAppService.cs index c42656894..ead41f7fc 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferLibRequests/ITransferLibRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferLibRequests/ITransferLibRequestAppService.cs @@ -17,4 +17,5 @@ public interface ITransferLibRequestAppService Task> GetListForCustomAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, CancellationToken cancellationToken = default); + Task CompleteByJobAsync(string requestNumber); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/IssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/IssueJobAppService.cs index f1e5d8d17..d3ee9c10d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/IssueJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/IssueJobAppService.cs @@ -43,7 +43,7 @@ public class IssueJobAppService /// [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.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs index 1be488c64..d808124fa 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 @@ -108,9 +108,10 @@ public class KittingIssueJobAppService if (kittingJob.JobStatus == EnumJobStatus.Open || kittingJob.JobStatus == EnumJobStatus.Partial || kittingJob.JobStatus == EnumJobStatus.Wait) { - throw new UserFriendlyException($"任务状态不是{kittingJob.JobStatus == EnumJobStatus.Open}、" + - $"{kittingJob.JobStatus == EnumJobStatus.Partial}、" + - $"{kittingJob.JobStatus == EnumJobStatus.Wait}"); + throw new UserFriendlyException($"任务状态不是" + + $"{EnumJobStatus.Open.GetDisplayName()}、" + + $"{EnumJobStatus.Partial.GetDisplayName()}、" + + $"{EnumJobStatus.Wait.GetDisplayName()}"); } await _expectOutAppService.RemoveByNumberAsync(kittingJob.Number).ConfigureAwait(false); 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 37689d407..7bb954fcf 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 @@ -1,12 +1,13 @@ using System; -using System.Reflection; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; using Volo.Abp; using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Shared.Domain.Shared; +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,23 +17,30 @@ namespace Win_in.Sfs.Wms.Store.Application; [Authorize] [Route($"{StoreConsts.RootPath}transfer-lib-job")] - public class TransferLibJobAppService - : SfsJobAppServiceBase, - ITransferLibJobAppService + : SfsJobAppServiceBase, + ITransferLibJobAppService { private readonly IServiceProvider _serviceProvider; private readonly ILocationAppService _locationAppService; + private readonly IExpectOutAppService _expectOutAppService; + + protected ITransferLibRequestAppService TransferLibRequestAppService => + LazyServiceProvider.LazyGetRequiredService(); public TransferLibJobAppService( - ITransferLibJobRepository repository, ITransferLibJobManager TransferLibJobManager, IServiceProvider serviceProvider, ILocationAppService locationAppService) : base(repository, TransferLibJobManager) + ITransferLibJobRepository repository, ITransferLibJobManager TransferLibJobManager, + IServiceProvider serviceProvider, ILocationAppService locationAppService, IExpectOutAppService expectOutAppService) : base(repository, + TransferLibJobManager) { _serviceProvider = serviceProvider; _locationAppService = locationAppService; + _expectOutAppService = expectOutAppService; } /// - /// 新移库完成任务 + /// 新移库完成任务 /// /// /// @@ -41,32 +49,36 @@ public class TransferLibJobAppService [UnitOfWork] public override async Task CompleteAsync(Guid id, TransferLibJobDTO dto) { - string methodPrefix = "TransferLibJobAppService.CompleteAsync - "; + var methodPrefix = "TransferLibJobAppService.CompleteAsync - "; if (dto.CallServerName.IsNullOrEmpty()) { throw new UserFriendlyException($"{methodPrefix}CallServerName 不能为空"); } + if (dto.CallBusinessType.IsNullOrEmpty()) { throw new UserFriendlyException($"{methodPrefix}CallBusinessType 不能为空"); } + if (dto.CallRequestNumber.IsNullOrEmpty()) { throw new UserFriendlyException($"{methodPrefix}CallRequestNumber 不能为空"); } + if (dto.CallJobNumber.IsNullOrEmpty()) { throw new UserFriendlyException($"{methodPrefix}CallJobNumber 不能为空"); } #region 校验 + foreach (var detailObj in dto.Details) { if (detailObj.IsPackingCodeFrom) { if (detailObj.RecommendFromPackingCode != detailObj.HandledFromPackingCode) { - throw new UserFriendlyException($"触发校验:推荐From箱码必须等于实际From箱码"); + throw new UserFriendlyException("触发校验:推荐From箱码必须等于实际From箱码"); } } @@ -74,7 +86,7 @@ public class TransferLibJobAppService { if (detailObj.RecommendToPackingCode != detailObj.HandledToPackingCode) { - throw new UserFriendlyException($"触发校验:推荐To箱码必须等于实际To箱码"); + throw new UserFriendlyException("触发校验:推荐To箱码必须等于实际To箱码"); } } @@ -82,7 +94,7 @@ public class TransferLibJobAppService { if (detailObj.RecommendFromLot != detailObj.HandledFromLot) { - throw new UserFriendlyException($"触发校验:推荐From批次必须等于实际From批次"); + throw new UserFriendlyException("触发校验:推荐From批次必须等于实际From批次"); } } @@ -90,9 +102,10 @@ public class TransferLibJobAppService { if (detailObj.RecommendToLot != detailObj.HandledToLot) { - throw new UserFriendlyException($"触发校验:推荐To批次必须等于实际To批次"); + throw new UserFriendlyException("触发校验:推荐To批次必须等于实际To批次"); } } + //if (detailObj.IsItemCodeFrom) //if (detailObj.IsItemCodeTo) //if (detailObj.IsStatusFrom) @@ -101,7 +114,7 @@ public class TransferLibJobAppService { if (detailObj.RecommendFromLocationCode != detailObj.HandledFromLocationCode) { - throw new UserFriendlyException($"触发校验:推荐From库位必须等于实际From库位"); + throw new UserFriendlyException("触发校验:推荐From库位必须等于实际From库位"); } } @@ -109,7 +122,7 @@ public class TransferLibJobAppService { if (detailObj.RecommendToLocationCode != detailObj.HandledToLocationCode) { - throw new UserFriendlyException($"触发校验:推荐To库位必须等于实际To库位"); + throw new UserFriendlyException("触发校验:推荐To库位必须等于实际To库位"); } } @@ -117,7 +130,7 @@ public class TransferLibJobAppService { if (detailObj.RecommendFromLocationGroup != detailObj.HandledFromLocationGroup) { - throw new UserFriendlyException($"触发校验:推荐From库位组必须等于实际From库位组"); + throw new UserFriendlyException("触发校验:推荐From库位组必须等于实际From库位组"); } } @@ -125,14 +138,15 @@ public class TransferLibJobAppService { if (detailObj.RecommendToLocationGroup != detailObj.HandledToLocationGroup) { - throw new UserFriendlyException($"触发校验:推荐To库位组必须等于实际To库位组"); + throw new UserFriendlyException("触发校验:推荐To库位组必须等于实际To库位组"); } } + if (detailObj.IsLocationAreaFrom) { if (detailObj.RecommendFromLocationArea != detailObj.HandledFromLocationArea) { - throw new UserFriendlyException($"触发校验:推荐From库区必须等于实际From库区"); + throw new UserFriendlyException("触发校验:推荐From库区必须等于实际From库区"); } } @@ -140,14 +154,15 @@ public class TransferLibJobAppService { if (detailObj.RecommendToLocationArea != detailObj.HandledToLocationArea) { - throw new UserFriendlyException($"触发校验:推荐To库区必须等于实际To库区"); + throw new UserFriendlyException("触发校验:推荐To库区必须等于实际To库区"); } } + if (detailObj.IsLocationErpCodeFrom) { if (detailObj.RecommendFromLocationErpCode != detailObj.HandledFromLocationErpCode) { - throw new UserFriendlyException($"触发校验:推荐From ERP库区必须等于实际From ERP库区"); + throw new UserFriendlyException("触发校验:推荐From ERP库区必须等于实际From ERP库区"); } } @@ -155,24 +170,27 @@ public class TransferLibJobAppService { if (detailObj.RecommendToLocationErpCode != detailObj.HandledToLocationErpCode) { - throw new UserFriendlyException($"触发校验:推荐To ERP库区必须等于实际To ERP库区"); + throw new UserFriendlyException("触发校验:推荐To ERP库区必须等于实际To ERP库区"); } } + if (detailObj.IsQtyFrom) { if (detailObj.RecommendFromQty != detailObj.HandledFromQty) { - throw new UserFriendlyException($"触发校验:推荐From数量必须等于实际From数量"); + throw new UserFriendlyException("触发校验:推荐From数量必须等于实际From数量"); } } + if (detailObj.IsQtyTo) { if (detailObj.RecommendToQty != detailObj.HandledToQty) { - throw new UserFriendlyException($"触发校验:推荐To数量必须等于实际To数量"); + throw new UserFriendlyException("触发校验:推荐To数量必须等于实际To数量"); } } } + #endregion foreach (var detail in dto.Details) @@ -180,8 +198,10 @@ public class TransferLibJobAppService detail.HandledFromContainerCode = string.Empty; detail.HandledToContainerCode = string.Empty; - var fromLocationDto=await _locationAppService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); - var toLocationDto=await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); + var fromLocationDto = await _locationAppService.GetByCodeAsync(detail.HandledFromLocationCode) + .ConfigureAwait(false); + var toLocationDto = + await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); detail.HandledFromLocationArea = fromLocationDto.AreaCode; detail.HandledFromLocationCode = fromLocationDto.Code; @@ -190,7 +210,7 @@ public class TransferLibJobAppService detail.HandledFromWarehouseCode = fromLocationDto.WarehouseCode; detail.HandledToLocationArea = toLocationDto.AreaCode; - detail.HandledToLocationCode = toLocationDto.Code ; + detail.HandledToLocationCode = toLocationDto.Code; detail.HandledToLocationErpCode = toLocationDto.ErpLocationCode; detail.HandledToLocationGroup = toLocationDto.LocationGroupCode; detail.HandledToWarehouseCode = toLocationDto.WarehouseCode; @@ -199,23 +219,68 @@ public class TransferLibJobAppService var ret = await base.CompleteAsync(id, dto).ConfigureAwait(false); if (ret != null) { - Type ty = Type.GetType(dto.CallServerName); + var ty = Type.GetType(dto.CallServerName); if (ty == null) { throw new UserFriendlyException($"{methodPrefix}没有找到类型为{dto.CallServerName}的对象"); } + var instance = _serviceProvider.GetService(ty); if (instance == null) { throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象创建失败"); } - ITransferLibCallback transferLibCallback = (ITransferLibCallback)instance; + + var transferLibCallback = (ITransferLibCallback)instance; if (transferLibCallback == null) { throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象没有实现ITransferLibCallback接口"); } + await transferLibCallback.DoTransferLibCallbackAsync(dto).ConfigureAwait(false); } + + await TransferLibRequestAppService.CompleteByJobAsync(dto.RequestNumber).ConfigureAwait(false); + return ret; } + + [HttpPost("get-by-request/{requestNumber}")] + [UnitOfWork] + public async Task> GetByRequestNumberAsync(string requestNumber) + { + var list = await _repository.GetListAsync(p => p.RequestNumber == requestNumber).ConfigureAwait(false); + + return ObjectMapper.Map, List>(list); + } + + public override async Task CancelAcceptAsync(Guid id) + { + var job = await _repository.FindAsync(p => p.Id == id).ConfigureAwait(false); + + if (job.JobStatus == EnumJobStatus.Open || job.JobStatus == EnumJobStatus.Partial || + job.JobStatus == EnumJobStatus.Doing || job.JobStatus == EnumJobStatus.Wait) + { + await _repository.UpdateAsync(job).ConfigureAwait(false); + } + + await _expectOutAppService.RemoveByNumberAsync(job.Number).ConfigureAwait(false); + } + + [HttpPost("complete-by-request/{requestNumber}")] + [UnitOfWork] + public async Task CompleteByRequestAsync(string requestNumber) + { + var list = await _repository.GetListAsync(p => p.RequestNumber == requestNumber).ConfigureAwait(false); + + foreach (var job in list) + { + if (job.JobStatus == EnumJobStatus.Open || job.JobStatus == EnumJobStatus.Partial || + job.JobStatus == EnumJobStatus.Doing || job.JobStatus == EnumJobStatus.Wait) + { + await _repository.UpdateAsync(job).ConfigureAwait(false); + await _expectOutAppService.RemoveByNumberAsync(job.Number).ConfigureAwait(false); + } + } + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferLibRequests/TransferLibRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferLibRequests/TransferLibRequestAppService.cs index 4ca739917..64501eb3e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferLibRequests/TransferLibRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferLibRequests/TransferLibRequestAppService.cs @@ -4,11 +4,13 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading; using System.Threading.Tasks; +using DocumentFormat.OpenXml.Office2010.Excel; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.ObjectMapping; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; @@ -17,6 +19,8 @@ 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 static ClosedXML.Excel.XLPredefinedFormat; +using Filter = Win_in.Sfs.Shared.Domain.Filter; namespace Win_in.Sfs.Wms.Store.Application; @@ -39,16 +43,18 @@ public class TransferLibRequestAppService : SfsStoreRequestAppServiceBase private readonly ITransferLibRequestManager _transferLibRequestManager; private readonly IBalanceAppService _balanceAppService; private readonly ILocationAppService _locationAppService; + private readonly ITransferLibJobAppService _transferLibJobAppService; public TransferLibRequestAppService( ITransferLibRequestRepository repository, ITransferLibRequestManager transferLibRequestManager, IBalanceAppService balanceAppService, - ILocationAppService locationAppService) : base(repository, transferLibRequestManager) + ILocationAppService locationAppService, ITransferLibJobAppService transferLibJobAppService) : base(repository, transferLibRequestManager) { _transferLibRequestManager = transferLibRequestManager; _balanceAppService = balanceAppService; _locationAppService = locationAppService; + _transferLibJobAppService = transferLibJobAppService; } #region 东阳使用 @@ -307,6 +313,75 @@ public class TransferLibRequestAppService : SfsStoreRequestAppServiceBase #endregion + public override async Task CancelAsync(Guid id) + { + var request = await _repository.GetAsync(id).ConfigureAwait(false); + + var list = await _transferLibJobAppService.GetByRequestNumberAsync(request.Number).ConfigureAwait(false); + if (list.Any()) + { + foreach (var kittingIssueJobDto in list) + { + if (kittingIssueJobDto.JobStatus == EnumJobStatus.Open || + kittingIssueJobDto.JobStatus == EnumJobStatus.Partial || + kittingIssueJobDto.JobStatus == EnumJobStatus.Doing || + kittingIssueJobDto.JobStatus == EnumJobStatus.Wait) + { + await _transferLibJobAppService.CancelAsync(kittingIssueJobDto.Id).ConfigureAwait(false); + } + } + } + + if (request.RequestStatus == EnumRequestStatus.Partial || request.RequestStatus == EnumRequestStatus.Handling || + request.RequestStatus == EnumRequestStatus.New) + { + request.RequestStatus = EnumRequestStatus.Cancelled; + await _repository.UpdateAsync(request).ConfigureAwait(false); + } + else + { + throw new UserFriendlyException($"【{request.RequestStatus.GetDisplayName()}】状态不允许取消"); + } + + return ObjectMapper.Map(request); + } + + public override async Task CompleteAsync(Guid id) + { + var request = await _repository.FindAsync(p => p.Id == id).ConfigureAwait(false); + + if (request.RequestStatus == EnumRequestStatus.Partial || request.RequestStatus == EnumRequestStatus.Handling || + request.RequestStatus == EnumRequestStatus.New) + { + request.RequestStatus = EnumRequestStatus.Completed; + await _repository.UpdateAsync(request).ConfigureAwait(false); + } + else + { + throw new UserFriendlyException($"【{request.RequestStatus.GetDisplayName()}】状态不允许取消"); + } + + await _transferLibJobAppService.CompleteByRequestAsync(request.Number).ConfigureAwait(false); + + return ObjectMapper.Map(request); + } + + [HttpPost("Complete-By-Job")] + public async Task CompleteByJobAsync(string requestNumber) + { + var request = await _repository.FindAsync(p => p.Number == requestNumber).ConfigureAwait(false); + + if (request.RequestStatus == EnumRequestStatus.Partial || request.RequestStatus == EnumRequestStatus.Handling || + request.RequestStatus == EnumRequestStatus.New) + { + request.RequestStatus = EnumRequestStatus.Completed; + await _repository.UpdateAsync(request).ConfigureAwait(false); + } + else + { + throw new UserFriendlyException($"【{request.RequestStatus.GetDisplayName()}】状态不允许取消"); + } + } /// /// 【创建】库移请求 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 ae77c1b59..27d345225 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 @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Castle.Components.DictionaryAdapter; +using Volo.Abp; using Volo.Abp.EventBus; using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; @@ -128,6 +129,25 @@ 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); + + var locationDtoRowOne = new LocationDTO(); + if (locationListSort.Any()) + { + locationDtoRowOne = locationListSort.FirstOrDefault(); + } + else + { + locationDtoRowOne = await _locationAppService.GetFirstRowOneAsync().ConfigureAwait(false); + if (locationDtoRowOne == null) + { + throw new UserFriendlyException("没有找到1层的库位"); + } + } + + if (locationDto.Type == EnumLocationType.RAW) { if (!await IsMinRowAsync(kittingIssueJob).ConfigureAwait(false)) @@ -154,7 +174,7 @@ public class KittingIssueJobEventHandler : detailInput.RecommendFromQty = detail.RecommendFromQty; detailInput.RecommendFromLot = detail.RecommendFromLot; - detailInput.RecommendFromPackingCode = detailInput.RecommendFromPackingCode; + detailInput.RecommendFromPackingCode = detail.RecommendFromPackingCode; detailInput.RecommendToLot = detail.RecommendToLot; detailInput.RecommendFromArriveDate = detail.RecommendFromArriveDate; @@ -178,11 +198,11 @@ public class KittingIssueJobEventHandler : detailInput.RecommendToProduceDate = detail.RecommendToProduceDate; detailInput.RecommendToSupplierBatch = detail.RecommendToSupplierBatch; - detailInput.RecommendToLocationCode = detail.RecommendToLocationCode; - detailInput.RecommendToLocationGroup = detail.RecommendToLocationGroup; - detailInput.RecommendToLocationArea = detail.RecommendToLocationArea; - detailInput.RecommendToLocationErpCode = detail.RecommendToLocationErpCode; - detailInput.RecommendToWarehouseCode = detail.RecommendToWarehouseCode; + detailInput.RecommendToLocationCode = locationDtoRowOne.Code; + detailInput.RecommendToLocationGroup = locationDtoRowOne.LocationGroupCode; + detailInput.RecommendToLocationArea = locationDtoRowOne.AreaCode; + detailInput.RecommendToLocationErpCode = locationDtoRowOne.ErpLocationCode; + detailInput.RecommendToWarehouseCode = locationDtoRowOne.WarehouseCode; input.Details = new EditableList() { detailInput }; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs index 17528e307..bc7cb02fb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs @@ -688,7 +688,7 @@ public class KittingIssueRequestEventHandler resultBalance.LocationRow = locationDto.RowCode; } - resultBalances + resultBalances=resultBalances .OrderBy(p => p.Lot) .ThenBy(p=>p.LocationRow) .ThenBy(p => p.PutInTime)