From 22514ee2235884917b719ff68874832d90b311b4 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Thu, 18 Apr 2024 15:11:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9B=98=E7=82=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Properties/launchSettings.json | 8 +++ .../Enums/Store/EnumInventoryMode.cs | 28 +++++++++ .../Jobs/CountJobs/DTOs/CountJobDTO.cs | 6 ++ .../Jobs/CountJobs/ICountJobAppService.cs | 3 + .../CountJobs/Inputs/CountJobEditInput.cs | 6 ++ .../Notes/CountNotes/DTOs/CountNoteDTO.cs | 5 +- .../Plans/CountPlans/DTOs/CountPlanDTO.cs | 6 ++ .../Plans/CountPlans/ICountPlanAppService.cs | 1 + .../CountPlans/Inputs/CountPlanEditInput.cs | 6 ++ .../CountPlans/Inputs/CountPlanImportInput.cs | 6 ++ .../Jobs/CountJobs/CountJobAppService.cs | 26 ++++++++ .../CountJobs/CountJobAutoMapperProfile.cs | 3 +- .../CountNotes/CountNoteAutoMapperProfile.cs | 14 +---- .../Plans/CountPlans/CountPlanAppService.cs | 10 +++ .../Jobs/CountJobs/CountJob.cs | 14 ++++- .../Jobs/CountJobs/CountJobDependentDetail.cs | 4 ++ .../Jobs/CountJobs/CountJobDetail.cs | 11 +++- .../Jobs/CountJobs/CountJobManager.cs | 60 ++++++++++++++++-- .../Jobs/CountJobs/ICountJobManager.cs | 2 +- .../Notes/CountNotes/CountNote.cs | 9 +++ .../CountNotes/CountNoteDependentDetail.cs | 58 ++++++++++++++++++ .../Notes/CountNotes/CountNoteDetail.cs | 61 ------------------- .../Notes/CountNotes/CountNoteManager.cs | 49 +++++++++++++-- .../Plans/CountPlans/CountPlan.cs | 9 +++ .../Plans/CountPlans/CountPlanManager.cs | 18 +++++- .../Plans/CountPlans/ICountPlanManager.cs | 2 +- ...ountJobDbContextModelCreatingExtensions.cs | 1 + ...untNoteDbContextModelCreatingExtensions.cs | 34 ++++++++--- .../StoreEntityFrameworkCoreModule.cs | 2 +- .../Jobs/CountJobAutoMapperProfile.cs | 16 +++++ .../Plans/CountPlanAutoMapperProfile.cs | 3 + .../Jobs/CountJobEventHandler.cs | 11 ++++ .../Requests/CountPlanEventHandler.cs | 19 ++++-- 33 files changed, 402 insertions(+), 109 deletions(-) create mode 100644 be/DataExchange/Iac/Win_in.Sfs.Wms.DataExchange.Iac.QadAgent/Properties/launchSettings.json create mode 100644 be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/EnumInventoryMode.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDependentDetail.cs diff --git a/be/DataExchange/Iac/Win_in.Sfs.Wms.DataExchange.Iac.QadAgent/Properties/launchSettings.json b/be/DataExchange/Iac/Win_in.Sfs.Wms.DataExchange.Iac.QadAgent/Properties/launchSettings.json new file mode 100644 index 000000000..33504c948 --- /dev/null +++ b/be/DataExchange/Iac/Win_in.Sfs.Wms.DataExchange.Iac.QadAgent/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "WSL": { + "commandName": "WSL2", + "distributionName": "" + } + } +} \ No newline at end of file diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/EnumInventoryMode.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/EnumInventoryMode.cs new file mode 100644 index 000000000..0f331efe8 --- /dev/null +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/EnumInventoryMode.cs @@ -0,0 +1,28 @@ + +using System.ComponentModel.DataAnnotations; +namespace Win_in.Sfs.Shared.Domain.Shared; + +/// +/// 盘点模式 +/// +public enum EnumInventoryMode +{ + /// + /// 未定义 + /// + [Display(Name = "未定义")] + None = 0, + + /// + /// 箱码 + /// + [Display(Name = "箱码")] + ByPackingCode = 1, + + /// + /// 无箱码 + /// + [Display(Name = "无箱码")] + ByErpItemCode = 2, + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDTO.cs index 5f10bc2ce..8be6d99fb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/DTOs/CountJobDTO.cs @@ -30,6 +30,12 @@ public class CountJobDTO : SfsJobDTOBase [Display(Name = "盘点方式")] public EnumCountMethod CountMethod { get; set; } + /// + /// 盘点模式 + /// + [Display(Name = "盘点模式")] + public EnumInventoryMode InventoryMode { get; set; } + /// /// 类型 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/ICountJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/ICountJobAppService.cs index 4a3fde10b..38a914daa 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/ICountJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/ICountJobAppService.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Win_in.Sfs.Wms.Store.Domain; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -12,4 +13,6 @@ public interface ICountJobAppService Task CancelByCountPlanAsync(string countPlanNumber); Task CloseByCountPlanAsync(string countPlanNumber); + Task> GetCountJobDependentDetailByPlanNumber(string countPlanNumber,int inventoryStage); + Task> ResetStatusByNumberAsync(List numbers); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobEditInput.cs index 5181ee4da..2b35969a4 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/CountJobs/Inputs/CountJobEditInput.cs @@ -8,6 +8,12 @@ namespace Win_in.Sfs.Wms.Store.Application.Contracts; public class CountJobEditInput : SfsJobCreateUpdateInputBase, ISfsJobCreateInput { #region Base + /// + /// 盘点模式 + /// + [Display(Name = "盘点模式")] + public EnumInventoryMode InventoryMode { get; set; } + /// /// 盘点方式 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CountNotes/DTOs/CountNoteDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CountNotes/DTOs/CountNoteDTO.cs index b116aabf2..932c3e3fb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CountNotes/DTOs/CountNoteDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CountNotes/DTOs/CountNoteDTO.cs @@ -16,7 +16,10 @@ public class CountNoteDTO : SfsStoreDTOBase, IHasNumber /// [Display(Name = "盘点计划单号")] public string CountPlanNumber { get; set; } - + /// + /// 盘点任务单号 + /// + public string CountJobNumber { get; set; } /// /// 类型 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/DTOs/CountPlanDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/DTOs/CountPlanDTO.cs index 3b1534210..0e26ee1eb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/DTOs/CountPlanDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/DTOs/CountPlanDTO.cs @@ -58,6 +58,12 @@ public class CountPlanDTO : SfsStoreRequestDTOBase [Display(Name = "盘点方式")] public EnumCountMethod CountMethod { get; set; } + /// + /// 盘点模式 + /// + [Display(Name = "盘点模式")] + public EnumInventoryMode InventoryMode { get; set; } + /// /// 盘点的零件集合 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/ICountPlanAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/ICountPlanAppService.cs index c9a84848d..0d397e79f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/ICountPlanAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/ICountPlanAppService.cs @@ -32,4 +32,5 @@ public interface ICountPlanAppService Task ChangeStageAsync(Guid id, EnumCountStage stage); Task ChangeStageAsync(Guid id, List detailIdList, EnumCountStage stage); + Task ResetStatusByNumberAsync(string number); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanEditInput.cs index a54e9efe3..3de261d6d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanEditInput.cs @@ -58,6 +58,12 @@ public class CountPlanEditInput : SfsStoreRequestCreateOrUpdateInputBase, IHasNu [Display(Name = "盘点方式")] public EnumCountMethod CountMethod { get; set; } + + /// + /// 盘点模式 + /// + [Display(Name = "盘点模式")] + public EnumInventoryMode InventoryMode { get; set; } /// /// 类型 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanImportInput.cs index 3802dce2d..aee4debde 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanImportInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/CountPlans/Inputs/CountPlanImportInput.cs @@ -51,4 +51,10 @@ public class CountPlanImportInput : SfsStoreImportInputBase [Required(ErrorMessage = "{0}是必填项")] public EnumCountMethod CountMethod { get; set; } + + /// + /// 盘点模式 + /// + [Display(Name = "盘点模式")] + public EnumInventoryMode InventoryMode { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs index f2b69f2c0..22d302bc3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAppService.cs @@ -52,6 +52,20 @@ public class CountJobAppService return dtoList; } + /// + /// 根据选择的任务号码重置盘点任务 + /// + /// + /// + [HttpPost("reset-status-by-number")] + + public virtual async Task> ResetStatusByNumberAsync(List numbers) + { + var entityList= await _countJobManager.ResetStatusByNumberAsync(numbers).ConfigureAwait(false); + var dtoList = ObjectMapper.Map, List>(entityList); + return dtoList; + } + public override async Task CompleteAsync(Guid id, CountJobDTO dto) { var input = new CountJobCheckInput @@ -98,7 +112,19 @@ public class CountJobAppService } } } + [HttpPost("get-countjob-dependent-detail-by-plannumber")] + public virtual async Task> GetCountJobDependentDetailByPlanNumber(string countPlanNumber, int inventoryStage) + { + var entities = await _repository.GetListAsync(p => p.JobStatus == EnumJobStatus.Done && p.CountPlanNumber == countPlanNumber && p.InventoryStage == inventoryStage, true).ConfigureAwait(false); + for (int i = entities.Count - 1; i >= 0; i--) + { + var entitie = entities[i]; + entitie.DepDetails.RemoveAll(r => r.InventoryStage != inventoryStage); + entitie.Details.RemoveAll(r => r.InventoryStage != inventoryStage); + } + return entities; + } //[HttpPost("handle-count-job-async")] //public virtual async Task HandleCountJobAsync(Guid guid, CountJobDTO dto) //{ diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs index df81e992b..20da66f9f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/CountJobs/CountJobAutoMapperProfile.cs @@ -77,7 +77,8 @@ public partial class StoreApplicationAutoMapperProfile : Profile CreateMap() ; - + CreateMap() + .ReverseMap(); CreateMap() .IgnoreAuditedObjectProperties() .Ignore(x => x.MasterID) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAutoMapperProfile.cs index fb83ae1ac..b5e81aef6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CountNotes/CountNoteAutoMapperProfile.cs @@ -45,26 +45,16 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.Number); CreateMap() - .ForMember(x => x.FirstCountQty, y => y.MapFrom(t => t.FirstCountQty)) - .ForMember(x => x.FirstCountTime, y => y.MapFrom(t => DateTime.Now)) + .ForMember(x => x.DetailStatus, y => y.MapFrom(t => EnumCountStatus.New)) .ForMember(x => x.FinalCountQty, y => y.MapFrom(t => t.FirstCountQty)) - .Ignore(x => x.FirstCountOperator) - .Ignore(x => x.FirstCountDescription) + .Ignore(x => x.LocationArea) .Ignore(x => x.LocationGroup) .Ignore(x => x.LocationErpCode) .Ignore(x => x.WarehouseCode) .Ignore(x => x.Uom) .Ignore(x => x.CountLabel) - .Ignore(x => x.RepeatCountQty) - .Ignore(x => x.RepeatCountTime) - .Ignore(x => x.RepeatCountOperator) - .Ignore(x => x.RepeatCountDescription) - .Ignore(x => x.AuditCountQty) - .Ignore(x => x.AuditCountTime) - .Ignore(x => x.AuditCountOperator) - .Ignore(x => x.AuditCountDescription) .Ignore(x => x.Stage) .Ignore(x => x.Adjusted) .Ignore(X => X.StdPackQty) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/CountPlans/CountPlanAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/CountPlans/CountPlanAppService.cs index bba258161..2f2f67939 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/CountPlans/CountPlanAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/CountPlans/CountPlanAppService.cs @@ -131,6 +131,16 @@ public class CountPlanAppService : await _countPlanManager.CompleteAsync(id, type).ConfigureAwait(false); } + // + // 更新计划状态 + // + // + // + [HttpPost("reset-by-number")] + public virtual async Task ResetStatusByNumberAsync(string number) + { + await _countPlanManager.ResetStatusByNumberAsync(number).ConfigureAwait(false); + } [HttpPost("check-status")] public virtual async Task CheckStatusAsync(string number) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs index a008e92f2..dd89bb9a8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJob.cs @@ -26,11 +26,22 @@ public class CountJob : SfsJobAggregateRootBase [IgnoreUpdate] public EnumCountStage CountStage { get; set; } + /// + /// 盘点次数 + /// + public int InventoryStage { get; set; } + + /// /// 盘点方式 /// public EnumCountMethod CountMethod { get; set; } + /// + /// 盘点模式 + /// + public EnumInventoryMode InventoryMode { get; set; } + /// /// 类型 /// @@ -65,7 +76,6 @@ public class CountJob : SfsJobAggregateRootBase /// /// 任务从表明细(记录每次扫得明细) /// - [IgnoreUpdate] public List DepDetails { get; set; } = new List(); /// @@ -86,7 +96,7 @@ public class CountJob : SfsJobAggregateRootBase detail.ExpireDate = expireDate; detail.LocationCode = locationCode; - detail.CountQty = qty; + detail.CountQty = detail.CountQty+qty; detail.CountTime = time; detail.CountOperator = oper; detail.CountDescription = desc; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs index 1d79ddb41..2e83fcba1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDependentDetail.cs @@ -7,6 +7,10 @@ namespace Win_in.Sfs.Wms.Store.Domain; public class CountJobDependentDetail : SfsJobDetailEntityBase, IHasCountResult, IHasInventoryQty { + /// + /// 盘点次数 + /// + public int InventoryStage { get; set; } /// /// 盘点标签 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDetail.cs index ea2bfdc3c..9ed5558e1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDetail.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobDetail.cs @@ -6,7 +6,10 @@ namespace Win_in.Sfs.Wms.Store.Domain; public class CountJobDetail : SfsJobDetailEntityBase, IHasCountResult, IHasInventoryQty { - + /// + /// 盘点计划单号 + /// + public string CountPlanNumber { get; set; } /// /// 盘点标签 /// @@ -17,6 +20,12 @@ public class CountJobDetail : SfsJobDetailEntityBase, IHasCountResult, IHasInven /// public decimal InventoryQty { get; set; } + /// + /// 盘点次数 + /// + public int InventoryStage { get; set; } + + /// /// 计量单位 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs index af22b75b6..3bebda3a9 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/CountJobManager.cs @@ -9,6 +9,7 @@ using Volo.Abp.Users; using Volo.Abp.Validation; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Inventory.Application.Contracts; namespace Win_in.Sfs.Wms.Store.Domain; @@ -16,17 +17,48 @@ namespace Win_in.Sfs.Wms.Store.Domain; public class CountJobManager : SfsJobManagerBase, ICountJobManager { private readonly IBalanceAppService _balanceAppService; - + private readonly ICountJobRepository _repository; + private readonly ICountNoteRepository _noteRepository; public CountJobManager( - ICountJobRepository repository, - IBalanceAppService balanceAppService + ICountJobRepository repository, + IBalanceAppService balanceAppService, + ICountNoteRepository noteRepository ) : base(repository) { + _noteRepository = noteRepository; _balanceAppService = balanceAppService; - + _repository = repository; + } + /// + /// 根据选择的任务号码重置盘点任务 + /// + /// + /// + /// + public virtual async Task> ResetStatusByNumberAsync(List numbers) + { + var joblist = await _repository.GetListAsync(r => numbers.Contains(r.Number)).ConfigureAwait(false); + var planNumbers = joblist.Select(r => r.CountPlanNumber).Distinct(); + if (planNumbers.Count() > 1) + { + throw new UserFriendlyException($"所选任务属于多个盘点计划,无法重盘!"); + } + foreach (var job in joblist) + { + var note = await _noteRepository.FindAsync(r => r.CountJobNumber == job.Number).ConfigureAwait(false); + if (note != null && note.Adjusted == true) + { + throw new UserFriendlyException($"任务号 【{job.Number}】生成的记录【{note.Number}】已经进行了调整,无法重盘"); + } + job.JobStatus = EnumJobStatus.Open; + } + await _repository.UpdateManyAsync(joblist).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsSubmittedEntityEventData>(joblist), false).ConfigureAwait(false); + return joblist; } + /// /// 执行任务 /// @@ -41,7 +73,15 @@ public class CountJobManager : SfsJobManagerBase, ICou //entity.ConcurrencyStamp = input.ConcurrencyStamp; await SetDetailsAsync(input, entity).ConfigureAwait(false); - return await base.CompleteAsync(entity, user).ConfigureAwait(false); + // return await base.CompleteAsync(entity, user).ConfigureAwait(false); + + + entity.CompleteUserId = user.Id; + entity.CompleteUserName = user.Name; + entity.CompleteTime = Clock.Now; + await PublishCompletedAsync(entity).ConfigureAwait(false); + + return await _repository.UpdateAsync(entity).ConfigureAwait(false); } /// @@ -96,11 +136,19 @@ public class CountJobManager : SfsJobManagerBase, ICou } else { - await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, detail.CountQty, detail.CountTime, detail.CountOperator, detail.CountDescription) .ConfigureAwait(false); } } + + foreach (var depDetail in input.DepDetails) + { + var jobDepDetail = ObjectMapper.Map(depDetail); + var number = entity.Number; + jobDepDetail.SetIdAndNumber(GuidGenerator, entity.Id, number); + jobDepDetail.CountLabel = GuidGenerator.Create().ToString(); + entity.DepDetails.Add(jobDepDetail); + } } public override void CheckDetails(CountJob entity, AbpValidationResult result) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs index ce077b05b..19b46538a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/CountJobs/ICountJobManager.cs @@ -12,5 +12,5 @@ public interface ICountJobManager : IJobManager Task UpdateManyAsync(IList countJobs); Task> CreateWithConditionAsync(CountPlan entity, List partCondition, List locCondition, List statusList); - + Task> ResetStatusByNumberAsync(List numbers); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNote.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNote.cs index 78d106363..3b311f1c5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNote.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNote.cs @@ -17,6 +17,11 @@ public class CountNote : SfsStoreAggregateRootBase /// public string CountPlanNumber { get; set; } + /// + /// 盘点任务单号 + /// + public string CountJobNumber { get; set; } + /// /// 类型 /// @@ -56,6 +61,10 @@ public class CountNote : SfsStoreAggregateRootBase /// 明细列表 /// public override List Details { get; set; } = new List(); + /// + /// 记录从表明细(记录每次扫得明细) + /// + public List DepDetails { get; set; } = new List(); public virtual async Task GenerateAdjustRequestAsync() { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDependentDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDependentDetail.cs new file mode 100644 index 000000000..49086859e --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDependentDetail.cs @@ -0,0 +1,58 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Wms.Store.Domain; + +public class CountNoteDependentDetail : SfsStoreDetailWithLotPackingLocationStatusEntityBase, IHasCountResult, IHasInventoryQty +{ + + /// + /// 盘点标签 + /// + public string CountLabel { get; set; } + + /// + /// 库存数量 + /// + public decimal InventoryQty { get; set; } + + /// + /// 计量单位 + /// + [Display(Name = "计量单位")] + public string Uom { get; set; } + + /// + /// 库存库位 + /// + public string InventoryLocationCode { get; set; } + + /// + /// 盘点数量(每次扫得数量) + /// + public decimal CountQty { get; set; } + + /// + /// 盘点时间 + /// + public DateTime? CountTime { get; set; } + + /// + /// 盘点操作员 + /// + public string CountOperator { get; set; } + + /// + /// 盘点描述 + /// + public string CountDescription { get; set; } + /// + /// 标包数量 + /// + [Display(Name = "标包数量")] + [Column(TypeName = "decimal(18,6)")] + public decimal StdPackQty { get; set; } + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDetail.cs index 18f1bf30a..5341f29c4 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDetail.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteDetail.cs @@ -10,7 +10,6 @@ namespace Win_in.Sfs.Wms.Store.Domain; /// 盘点计划明细 /// public class CountNoteDetail : SfsStoreDetailWithLotPackingLocationStatusEntityBase -, IHasCountDetail , IHasStdPack { /// @@ -34,66 +33,6 @@ public class CountNoteDetail : SfsStoreDetailWithLotPackingLocationStatusEntityB /// public decimal InventoryQty { get; set; } - /// - /// 初盘数量 - /// - public decimal FirstCountQty { get; set; } - - /// - /// 初盘时间 - /// - public DateTime? FirstCountTime { get; set; } - - /// - /// 初盘操作员 - /// - public string FirstCountOperator { get; set; } - - /// - /// 初盘描述 - /// - public string FirstCountDescription { get; set; } - - /// - /// 重盘数量 - /// - public decimal RepeatCountQty { get; set; } - - /// - /// 重盘时间 - /// - public DateTime? RepeatCountTime { get; set; } - - /// - /// 重盘操作员 - /// - public string RepeatCountOperator { get; set; } - - /// - /// 重盘描述 - /// - public string RepeatCountDescription { get; set; } - - /// - /// 监盘数量 - /// - public decimal AuditCountQty { get; set; } - - /// - /// 监盘时间 - /// - public DateTime? AuditCountTime { get; set; } - - /// - /// 监盘操作员 - /// - public string AuditCountOperator { get; set; } - - /// - /// 监盘描述 - /// - public string AuditCountDescription { get; set; } - /// /// 最终盘点数量 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteManager.cs index 630fbefd9..67fbd3e37 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CountNotes/CountNoteManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.Uow; using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Domain; @@ -26,6 +27,48 @@ public class CountNoteManager : SfsStoreManagerBase, _repository = repository; _countPlanRepository = countPlanRepository; } + /// + /// 创建 + /// + /// + /// + [UnitOfWork] + public override async Task CreateAsync(CountNote entity) + { + + entity.SetIdAndNumberWithDetails(GuidGenerator, await GenerateNumberAsync(typeof(CountNote).Name, entity.ActiveDate).ConfigureAwait(false)); + + foreach (var item in entity.DepDetails) + { + item.SetIdAndNumber(GuidGenerator,entity.Id,entity.Number); + } + + await PublishCreatedAsync(entity).ConfigureAwait(false); + await Repository.InsertAsync(entity).ConfigureAwait(false); + return entity; + } + /// + /// 批量创建 + /// + /// + /// + [UnitOfWork] + public override async Task> CreateManyAsync(List entities) + { + List deleteItems = new List(); + foreach (var entity in entities) + { + var deleteentity=await Repository.GetAsync(r=>r.CountJobNumber== entity.CountJobNumber).ConfigureAwait(false); + deleteItems.Add(deleteentity); + entity.SetIdAndNumberWithDetails(GuidGenerator, await GenerateNumberAsync(typeof(CountNote).Name, entity.ActiveDate).ConfigureAwait(false)); + + } + //先删除之前得记录 + await Repository.DeleteManyAsync(deleteItems).ConfigureAwait(false); + await Repository.InsertManyAsync(entities).ConfigureAwait(false); + await PublishCreatedAsync(entities).ConfigureAwait(false); + return entities; + } /// /// 开始调整库存 @@ -157,11 +200,7 @@ public class CountNoteManager : SfsStoreManagerBase, detail.ExpireDate = detail.ProduceDate.AddDays(validateDays); detail.CountLabel = Guid.NewGuid().ToString(); - detail.FirstCountQty = detail.FirstCountQty; - detail.FirstCountTime = DateTime.Now; - detail.FirstCountOperator = note.Worker; - - detail.FinalCountQty = detail.FirstCountQty; + detail.FinalCountQty = detail.FinalCountQty; detail.DetailStatus = EnumCountStatus.New; detail.Stage = EnumCountStage.First; detail.Adjusted = false; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlan.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlan.cs index 64c844162..186624026 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlan.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlan.cs @@ -24,6 +24,11 @@ public class CountPlan : SfsStoreRequestAggregateRootBase /// public EnumCountStage Stage { get; set; } + /// + /// 盘点次数 + /// + public int InventoryStage { get; set; } + /// /// 盘点执行形式 /// @@ -33,6 +38,10 @@ public class CountPlan : SfsStoreRequestAggregateRootBase /// 盘点方式 /// public EnumCountMethod CountMethod { get; set; } + /// + /// 盘点模式 + /// + public EnumInventoryMode InventoryMode { get; set; } /// /// 描述 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs index 846c509cc..3306c2ad6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs @@ -284,7 +284,21 @@ public class CountPlanManager : SfsStoreRequestManagerBase + /// 根据plannumber更新主表状态和子表状态 + /// + /// + /// + public virtual async Task ResetStatusByNumberAsync(string number) + { + var entity = await Repository.GetAsync(r=>r.Number==number).ConfigureAwait(false); + entity.RequestStatus = EnumRequestStatus.Handling; + entity.Details.ForEach(p=> + { + p.DetailStatus = EnumCountStatus.New; + + }); + } /// /// job执行后更新计划 /// @@ -334,7 +348,7 @@ public class CountPlanManager : SfsStoreRequestManagerBase /// Task CompleteByJobAsync(CountPlan entity); - + Task ResetStatusByNumberAsync(string number); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Jobs/CountJobs/CountJobDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Jobs/CountJobs/CountJobDbContextModelCreatingExtensions.cs index 1a6333d90..3b6215a2e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Jobs/CountJobs/CountJobDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Jobs/CountJobs/CountJobDbContextModelCreatingExtensions.cs @@ -42,6 +42,7 @@ public static class CountJobDbContextModelCreatingExtensions b.ConfigureByConvention(); //Configure Sfs base properties b.ConfigureSfsBase(); + //Configure Job base properties b.ConfigureJobDetail(); //Properties diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CountNotes/CountNoteDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CountNotes/CountNoteDbContextModelCreatingExtensions.cs index cec442d3d..815422f44 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CountNotes/CountNoteDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CountNotes/CountNoteDbContextModelCreatingExtensions.cs @@ -27,6 +27,7 @@ public static class CountNoteDbContextModelCreatingExtensions //Relations b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); + b.HasMany(q => q.DepDetails).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); //Indexes b.HasIndex(q => new { q.Number }).IsUnique(); @@ -47,15 +48,6 @@ public static class CountNoteDbContextModelCreatingExtensions //Properties b.Property(q => q.CountPlanNumber).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.CountLabel).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.FirstCountQty).HasPrecision(18, 6); - b.Property(q => q.FirstCountOperator).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.FirstCountDescription).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.RepeatCountQty).HasPrecision(18, 6); - b.Property(q => q.RepeatCountOperator).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.RepeatCountDescription).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.AuditCountQty).HasPrecision(18, 6); - b.Property(q => q.AuditCountOperator).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.AuditCountDescription).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.FinalCountQty).HasPrecision(18, 6); b.Property(q => q.DetailStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); b.Property(q => q.Stage).HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); @@ -65,5 +57,29 @@ public static class CountNoteDbContextModelCreatingExtensions //Indexes b.HasIndex(q => new { q.Number, q.CountLabel }).IsUnique(); }); + + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(options.TablePrefix + nameof(CountNoteDependentDetail), options.Schema); + //Configure ABP properties + b.ConfigureByConvention(); + //Configure Sfs base properties + b.ConfigureSfsStoreBase(); + //Configure Sfs store detail properties + b.ConfigureSfsStoreDetailBase(); + b.ConfigureStoreDetailWithLotPackingLocationStatus(); + //Properties + b.Property(q => q.CountLabel).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.InventoryLocationCode).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.CountOperator).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.CountDescription).HasMaxLength(SfsPropertyConst.CodeLength); + + //Relations + //None + + //Indexes + //b.HasIndex(q => new { q.PackingCode }).IsUnique(); + }); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs index 3a820eef5..4c2612673 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs @@ -296,7 +296,7 @@ public class StoreEntityFrameworkCoreModule : AbpModule options.Entity(orderOptions => orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details)); options.Entity(orderOptions => - orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details)); + orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details).Include(o => o.DepDetails)); options.Entity(orderOptions => orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details) .Include(o => o.SummaryDetails)); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/CountJobAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/CountJobAutoMapperProfile.cs index 7ee5dda80..85a6bb112 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/CountJobAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/CountJobAutoMapperProfile.cs @@ -1,5 +1,6 @@ using AutoMapper; using Volo.Abp.AutoMapper; +using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; @@ -106,6 +107,8 @@ public partial class StoreEventAutoMapperProfile : Profile // .ForMember(x => x.Item, y => y.MapFrom(d => new Item(d.ItemName, d.ItemDesc1, d.ItemDesc2))) // .ForMember(x => x.Batch, y => y.MapFrom(d => new Batch(d.SupplierBatch, d.ArriveDate, d.ProduceDate, d.ExpireDate))) .ForMember(x => x.InventoryLocationCode, y => y.MapFrom(d => d.LocationCode)) + .ForMember(x => x.CountPlanNumber, y => y.MapFrom(d => d.Number)) + .Ignore(x=>x.InventoryStage) .Ignore(x => x.MasterID) .Ignore(x => x.Number) .Ignore(x => x.Id) @@ -116,5 +119,18 @@ public partial class StoreEventAutoMapperProfile : Profile .Ignore(x => x.CountDescription) ; + CreateMap() + .ForMember(x => x.Stage, y => y.MapFrom(d => d.CountStage)) + .ForMember(x => x.BeginTime, y => y.MapFrom(d => d.CreationTime)) + .ForMember(x => x.EndTime, y => y.MapFrom(d => d.CompleteTime)) + .ForMember(x => x.CountJobNumber, y => y.MapFrom(d => d.Number)) + .Ignore(x => x.Adjusted) + .Ignore(x => x.ActiveDate); + CreateMap() + .ForMember(x => x.FinalCountQty, y => y.MapFrom(d => d.CountQty)) + .ForMember(x => x.DetailStatus, y => y.MapFrom(d => EnumCountStatus.New)) + .Ignore(x => x.Stage) + .Ignore(x => x.Adjusted); + CreateMap(); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Plans/CountPlanAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Plans/CountPlanAutoMapperProfile.cs index bfd07f21d..cf0e69b5c 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Plans/CountPlanAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Plans/CountPlanAutoMapperProfile.cs @@ -53,12 +53,15 @@ public partial class StoreEventAutoMapperProfile : Profile CreateMap() .ForMember(x => x.CountPlanNumber, y => y.MapFrom(d => d.Number)) .Ignore(x => x.Adjusted) + .Ignore(x=>x.DepDetails) + .Ignore(x=>x.CountJobNumber) ; CreateMap() .ForMember(x => x.CountPlanNumber, y => y.MapFrom(d => d.Number)) .Ignore(x => x.Adjusted) ; + CreateMap(); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/CountJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/CountJobEventHandler.cs index 4d426ce79..6560175aa 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/CountJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/CountJobEventHandler.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.EventBus; @@ -13,6 +14,7 @@ namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; public class CountJobEventHandler : StoreEventHandlerBase , ILocalEventHandler> + ,ILocalEventHandler>> { private readonly ICountPlanAppService _countPlanAppService; private readonly ICountNoteAppService _countNoteAppService; @@ -42,6 +44,15 @@ public class CountJobEventHandler : } } + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsSubmittedEntityEventData> eventData) + { + var entity = eventData.Entity.First(); + if (!string.IsNullOrEmpty(entity.CountPlanNumber)) + { + await _countPlanAppService.ResetStatusByNumberAsync(entity.CountPlanNumber).ConfigureAwait(false); + } + } private async Task BuildCountPlanJobUpdateDTO(CountJob entity) { var countPlanUpdateInput = ObjectMapper.Map(entity); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountPlanEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountPlanEventHandler.cs index 53547826f..cba7ab568 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountPlanEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/CountPlanEventHandler.cs @@ -106,13 +106,18 @@ public class CountPlanEventHandler var entity = eventData.Entity; await ThawEqualBalancesAsync(entity).ConfigureAwait(false); + var jobs= await _countJobAppService.GetCountJobDependentDetailByPlanNumber(entity.Number,entity.InventoryStage).ConfigureAwait(false); //创建盘点记录 - var countNote = BuildCountNote(entity); - - if (countNote.Details.Count > 0) + List notes = new List(); + foreach (var job in jobs) + { + var countNote = ObjectMapper.Map(job); + notes.Add(countNote); + } + if (notes.Count > 0) { - await _countNoteManager.CreateAsync(countNote).ConfigureAwait(false); + await _countNoteManager.CreateManyAsync(notes).ConfigureAwait(false); } await _countJobAppService.CloseByCountPlanAsync(entity.Number).ConfigureAwait(false); @@ -126,16 +131,18 @@ public class CountPlanEventHandler /// /// /// - private CountNote BuildCountNote(CountPlan countPlan) + private CountNote BuildCountNote(CountPlan countPlan,List depDetail) { var countNote = ObjectMapper.Map(countPlan); countNote.Details = new List(); + foreach (var countPlanDetail in countPlan.Details.Where(p => p.DetailStatus == EnumCountStatus.Completed)) { var countNoteDetail = ObjectMapper.Map(countPlanDetail); countNote.Details.Add(countNoteDetail); } - + var depDetails = ObjectMapper.Map, List>(depDetail); + countNote.DepDetails.AddRange(depDetails); return countNote; }