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 0d397e79f..a7d4db6dc 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 @@ -33,4 +33,5 @@ public interface ICountPlanAppService Task ChangeStageAsync(Guid id, List detailIdList, EnumCountStage stage); Task ResetStatusByNumberAsync(string number); + Task NewResetStatusByNumberAsync(string number, List locationCodes); } 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 5bad74a89..b3cf850a3 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 @@ -146,6 +146,19 @@ public class CountPlanAppService : { await _countPlanManager.ResetStatusByNumberAsync(number).ConfigureAwait(false); } + // + // 更新计划状态 + // + // + // + [HttpPost("new-reset-by-number")] + public virtual async Task NewResetStatusByNumberAsync(string number,ListlocationCodes) + { + await _countPlanManager.ResetStatusByNumberAsync1(number, locationCodes).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/Plans/CountPlans/CountPlanManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs index 55709757f..02eb3e7db 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 @@ -313,6 +313,58 @@ public class CountPlanManager : SfsStoreRequestManagerBase + /// 根据plannumber更新主表状态和子表状态 + /// + /// + /// + public virtual async Task ResetStatusByNumberAsync1(string number,List locationCodes) + { + var entity = await Repository.GetAsync(r => r.Number == number).ConfigureAwait(false); + entity.RequestStatus = EnumRequestStatus.Handling; + entity.InventoryStage++; + + switch (entity.CountMethod) + { + case EnumCountMethod.ByLocation: + { + //按库位拆分成多个盘点任务 + entity.Details.Where(r=> locationCodes.Contains(r.LocationCode)).ToList().ForEach(p => + { + p.FirstCountQty = 0; + p.FinalCountQty = 0; + p.DetailStatus = EnumCountStatus.New; + }); + break; + } + case EnumCountMethod.ByItem: + { + //按物品生成多个盘点任务 + entity.Details.ForEach(p => + { + p.FirstCountQty = 0; + p.FinalCountQty = 0; + p.DetailStatus = EnumCountStatus.New; + }); + break; + } + case EnumCountMethod.ByLocationAndItem: + { + //按物品和库位生成多个盘点任务 + entity.Details.ForEach(p => + { + p.FirstCountQty = 0; + p.FinalCountQty = 0; + p.DetailStatus = EnumCountStatus.New; + }); + break; + } + case EnumCountMethod.None: + default: + throw new UserFriendlyException($"盘点任务生成失败;原因:盘点方式错误,将执行回滚操作!"); + } + } /// /// job执行后更新计划 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/ICountPlanManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/ICountPlanManager.cs index 6e311701e..f293ec629 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/ICountPlanManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/ICountPlanManager.cs @@ -22,4 +22,5 @@ public interface ICountPlanManager : ISfsStoreRequestManager Task CompleteByJobAsync(CountPlan entity); Task ResetStatusByNumberAsync(string number); + Task ResetStatusByNumberAsync1(string number, List locationCodes); } 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 7f26533c3..7e7233104 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 @@ -50,7 +50,10 @@ public class CountJobEventHandler : var entity = eventData.Entity.First(); if (!string.IsNullOrEmpty(entity.CountPlanNumber)) { - await _countPlanAppService.ResetStatusByNumberAsync(entity.CountPlanNumber).ConfigureAwait(false); + // await _countPlanAppService.ResetStatusByNumberAsync(entity.CountPlanNumber).ConfigureAwait(false); + var locationCodes = eventData.Entity.SelectMany(r => r.Details).Select(p => p.LocationCode).Distinct().ToList(); + await _countPlanAppService.NewResetStatusByNumberAsync(entity.CountPlanNumber, locationCodes).ConfigureAwait(false); + } } private async Task BuildCountPlanJobUpdateDTO(CountJob entity)