diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 57d10080..d0fc4e9f 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Mvc; using Senparc.Weixin.Work.AdvancedAPIs.MailList; using SqlSugar; using Tnb.BasicData; +using Tnb.BasicData.Entitys.Entity; using Tnb.EquipMgr.Entities; using Tnb.ProductionMgr.Entities; using Tnb.ProductionMgr.Entities.Dto; @@ -321,7 +322,6 @@ namespace Tnb.ProductionMgr //同组工单排产 if (entities.Count > 0) { - //var icmoEntities = entities.Adapt>(); icmoEntities = entities.Select(x => new PrdTask { id = SnowflakeIdHelper.NextId(), @@ -381,21 +381,11 @@ namespace Tnb.ProductionMgr } } - if (row > 0) { if (icmoEntities?.Count > 0 && combineMoCodes?.FirstOrDefault() is not null) { var moList = await db.Queryable().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync(); - //var icmoList = moList.Select(x => new PrdTask - //{ - // id = SnowflakeIdHelper.NextId(), - // item_id = x.item_id, - // item_code = x.item_code, - // mo_type = input.mo_type, - // plan_start_date = x.plan_start_date, - // plan_end_date = x.plan_end_date, - //}).ToList(); var combinePlanQty = icmoEntities?.Sum(x => x.plan_qty); //合并工单后的计划数量 var combineScheduledQty = icmoEntities?.Sum(x => x.scheduled_qty); //合并后的已排产数量 if (combineScheduledQty < combinePlanQty) @@ -446,8 +436,6 @@ namespace Tnb.ProductionMgr //修改工单状态为待排产,同事修改已排产数量 moStatus = DictConst.WaitProductId; icmoStatus = DictConst.ToBeScheduledEncode; - - } row = await db.Updateable().SetColumns(it => new PrdMo { @@ -547,9 +535,12 @@ namespace Tnb.ProductionMgr if (row > 0) { var prdMo = await db.Queryable().FirstAsync(it => it.id == prdTask.mo_id); - prdMo.input_qty += prdTask.scheduled_qty; - prdMo.icmo_status = DictConst.ToBeScheduledEncode; - row = await db.Updateable(prdMo).ExecuteCommandAsync(); + if (prdMo is not null) + { + prdMo.input_qty += prdTask.scheduled_qty; + prdMo.icmo_status = DictConst.ToBeScheduledEncode; + row = await db.Updateable(prdMo).ExecuteCommandAsync(); + } } return row > 0; });