diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs index 57f0475b5..e98b75340 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using NetTopologySuite.Geometries; using Omu.ValueInjecter; using Volo.Abp; @@ -382,10 +383,15 @@ public class BomManager : DomainService, IBomManager public virtual async Task> GetAllItemByCode(string productCode,Guid id) { List boms = new List(); - var lst = await _repository.GetListAsync(p => p.Product == productCode).ConfigureAwait(false); + var lst = await + (await _repository.GetDbSetAsync().ConfigureAwait(false)) + .Where(p => p.Product == productCode) + .AsNoTracking() + .ToListAsync().ConfigureAwait(false); foreach (var bom in lst) { bom.Remark = id.ToString(); + bom.SetId(GuidGenerator.Create()); boms.Add(bom); var results= await GetAllItemByCode(bom.Component,bom.Id).ConfigureAwait(false); boms.AddRange(results); 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 677eecc06..85ddb2187 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 @@ -71,7 +71,6 @@ public class CountJob : SfsJobAggregateRootBase /// /// 任务明细 /// - [IgnoreUpdate] public override List Details { get; set; } = new List(); /// /// 任务从表明细(记录每次扫得明细) 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 9ed5558e1..05e66e6b7 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 @@ -1,11 +1,14 @@ using System; using System.ComponentModel.DataAnnotations; +using System.Diagnostics; +using Org.BouncyCastle.Crypto.Prng.Drbg; using Win_in.Sfs.Shared.Domain; namespace Win_in.Sfs.Wms.Store.Domain; public class CountJobDetail : SfsJobDetailEntityBase, IHasCountResult, IHasInventoryQty { + /// /// 盘点计划单号 /// 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 88e1b0935..b4971e30d 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 @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.ObjectMapping; using Volo.Abp.Users; @@ -39,7 +40,7 @@ public class CountJobManager : SfsJobManagerBase, ICou /// public virtual async Task> ResetStatusByNumberAsync(List numbers) { - var joblist = await _repository.GetListAsync(r => numbers.Contains(r.Number)).ConfigureAwait(false); + var joblist = await _repository.GetListAsync(r => numbers.Contains(r.Number), true).ConfigureAwait(false); var planNumbers = joblist.Select(r => r.CountPlanNumber).Distinct(); if (planNumbers.Count() > 1) { @@ -53,12 +54,57 @@ public class CountJobManager : SfsJobManagerBase, ICou throw new UserFriendlyException($"任务号 【{job.Number}】生成的记录【{note.Number}】已经进行了调整,无法重盘"); } job.JobStatus = EnumJobStatus.Open; + var details = job.Details.Where(r => r.InventoryStage == job.InventoryStage && r.InventoryQty != 0).ToList(); + List newDetails = new List(); + foreach (var detail in details) + { + var newDetail= BuildCountJob(detail); + newDetails.Add(newDetail); + } + job.InventoryStage++; + job.AddDetails(newDetails); } await _repository.UpdateManyAsync(joblist).ConfigureAwait(false); await LocalEventBus.PublishAsync(new SfsSubmittedEntityEventData>(joblist), false).ConfigureAwait(false); return joblist; } + private CountJobDetail BuildCountJob(CountJobDetail job) + { + CountJobDetail newDetail = new CountJobDetail(); + newDetail.SetIdAndNumber(GuidGenerator, job.Id, job.Number); + newDetail.CountPlanNumber = job.CountPlanNumber; + newDetail.CountLabel = GuidGenerator.Create().ToString(); + newDetail.InventoryQty = job.InventoryQty; + newDetail.InventoryStage = job.InventoryStage+1; + newDetail.Uom = job.Uom; + newDetail.InventoryLocationCode = job.InventoryLocationCode; + newDetail.CountQty = 0; + newDetail.CountTime = job.CountTime; + newDetail.CountOperator = job.CountOperator; + newDetail.CountDescription = job.CountDescription; + newDetail.ItemName = job.ItemName; + newDetail.ItemDesc1 = job.ItemDesc1; + newDetail.ItemDesc2 = job.ItemDesc2; + newDetail.ItemCode = job.ItemCode; + newDetail.StdPackQty = job.StdPackQty; + newDetail.Status = job.Status; + newDetail.ContainerCode = job.ContainerCode; + newDetail.PackingCode = job.PackingCode; + newDetail.Lot = job.Lot; ; + newDetail.SupplierBatch = job.SupplierBatch; + newDetail.ArriveDate = job.ArriveDate; + newDetail.ProduceDate = job.ProduceDate; + newDetail.ExpireDate = job.ExpireDate; + newDetail.LocationCode = job.LocationCode; + newDetail.LocationArea = job.LocationArea; + newDetail.LocationGroup = job.LocationGroup; + newDetail.LocationErpCode = job.LocationErpCode; + newDetail.WarehouseCode = job.WarehouseCode; + + return newDetail; + } + /// /// 执行任务 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 67fbd3e37..6443cadce 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 @@ -58,13 +58,16 @@ public class CountNoteManager : SfsStoreManagerBase, List deleteItems = new List(); foreach (var entity in entities) { - var deleteentity=await Repository.GetAsync(r=>r.CountJobNumber== entity.CountJobNumber).ConfigureAwait(false); - deleteItems.Add(deleteentity); + var deleteentity=await Repository.FindAsync(r=>r.CountJobNumber== entity.CountJobNumber).ConfigureAwait(false); + if(deleteentity!=null) deleteItems.Add(deleteentity); entity.SetIdAndNumberWithDetails(GuidGenerator, await GenerateNumberAsync(typeof(CountNote).Name, entity.ActiveDate).ConfigureAwait(false)); } //先删除之前得记录 - await Repository.DeleteManyAsync(deleteItems).ConfigureAwait(false); + if (deleteItems.Count >0) + { + await Repository.DeleteManyAsync(deleteItems).ConfigureAwait(false); + } await Repository.InsertManyAsync(entities).ConfigureAwait(false); await PublishCreatedAsync(entities).ConfigureAwait(false); return entities;