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 51fbb63ad..a5036fb9b 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 @@ -310,24 +310,27 @@ public class CountJobManager : SfsJobManagerBase, ICou //var oldDepDetail = entity.DepDetails.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == depDetail.LocationCode && r.InventoryStage == entity.InventoryStage && r.Lot == depDetail.Lot); var oldDepDetail = entity.DepDetails.FirstOrDefault(r => r.Id == new Guid(depDetail.Id.ToString())); if (depDetail.IsDelete) - { - countCount = -oldDepDetail.CountQty; - entity.DepDetails.Remove(oldDepDetail); - - //移除的扫描记录盘点数量与计划中盘点数量一致,移除计划中的物料 - var planDB = await _planRepository.FindAsync(r => r.Number == input.CountPlanNumber).ConfigureAwait(false); - if (planDB != null) + { + if(oldDepDetail != null) { - var planDetailDB = planDB.Details.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == depDetail.LocationCode && r.Lot == depDetail.Lot && r.Status == depDetail.Status); - if (planDetailDB != null) + countCount = -oldDepDetail.CountQty; + entity.DepDetails.Remove(oldDepDetail); + + //移除的扫描记录盘点数量与计划中盘点数量一致,移除计划中的物料 + var planDB = await _planRepository.FindAsync(r => r.Number == input.CountPlanNumber).ConfigureAwait(false); + if (planDB != null) { - if(planDetailDB.FinalCountQty == oldDepDetail.CountQty) + var planDetailDB = planDB.Details.FirstOrDefault(r => r.ItemCode == depDetail.ItemCode && r.PackingCode == depDetail.PackingCode && r.LocationCode == depDetail.LocationCode && r.Lot == depDetail.Lot && r.Status == depDetail.Status); + if (planDetailDB != null) { - planDB.Details.Remove(planDetailDB); - await _planRepository.UpdateAsync(planDB).ConfigureAwait(false); + if (planDetailDB.FinalCountQty == oldDepDetail.CountQty) + { + planDB.Details.Remove(planDetailDB); + await _planRepository.UpdateAsync(planDB).ConfigureAwait(false); + } } } - } + } } else { @@ -335,6 +338,7 @@ public class CountJobManager : SfsJobManagerBase, ICou { countCount = depDetail.CountQty - oldDepDetail.CountQty; oldDepDetail.CountQty = depDetail.CountQty; + oldDepDetail.CountDescription = depDetail.CountDescription; } else { @@ -358,14 +362,16 @@ public class CountJobManager : SfsJobManagerBase, ICou jobDetail.ProduceDate = DateTime.Now; jobDetail.ExpireDate = DateTime.Parse("9999-12-31 23:59:59.9999999"); jobDetail.InventoryQty = 0; - var detailNumber = await GetNumber().ConfigureAwait(false); - jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber); + + //var detailNumber = await GetNumber().ConfigureAwait(false); + jobDetail.CountPlanNumber = input.CountPlanNumber; + jobDetail.SetIdAndNumber(GuidGenerator, entity.Id, depDetail.Number); jobDetail.CountLabel = GuidGenerator.Create().ToString(); entity.Details.Add(jobDetail); } else { - await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, detail.CountDescription) + await entity.SetDetail(detail.Id, detail.SupplierBatch, detail.ArriveDate, detail.ProduceDate, detail.ExpireDate, detail.LocationCode, countCount, detail.CountTime, detail.CountOperator, depDetail.CountDescription) .ConfigureAwait(false); } }