|
|
@ -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<CountJob, CountJobDetail>, ICou |
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
public virtual async Task<List<CountJob>> ResetStatusByNumberAsync(List<string> 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<CountJob, CountJobDetail>, 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<CountJobDetail> newDetails = new List<CountJobDetail>(); |
|
|
|
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<List<CountJob>>(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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 执行任务
|
|
|
|