diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index d77872ee..a1ae4e79 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -774,22 +774,41 @@ namespace Tnb.ProductionMgr //根据工单号获取当前工单包含的已排产数 var schedQty = _db.Queryable().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty); + // if (mo != null) + // {//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产 + // if (schedQty.HasValue && schedQty.Value >= mo.plan_qty) + // { + // mo.mo_status = DictConst.AlreadyId; + // await _db.Updateable(mo).ExecuteCommandAsync(); + // } + // else + // { + // if (schedQty.HasValue) + // { + // mo.scheduled_qty += schedQty.Value; + // await _db.Updateable(mo).ExecuteCommandAsync(); + // } + // } + // } + if (mo != null) - {//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产 - if (schedQty.HasValue && schedQty.Value >= mo.plan_qty) + { + if (mo.scheduled_qty == null) { - mo.mo_status = DictConst.AlreadyId; - await _db.Updateable(mo).ExecuteCommandAsync(); + await _db.Updateable() + .SetColumns(x => x.mo_status == DictConst.AlreadyId) + .SetColumns(x => x.scheduled_qty == input.scheduled_qty) + .Where(x=>x.id==mo.id) + .ExecuteCommandAsync(); } else { - if (schedQty.HasValue) - { - mo.scheduled_qty += schedQty.Value; - await _db.Updateable(mo).ExecuteCommandAsync(); - } + await _db.Updateable().SetColumns(x => x.scheduled_qty == x.scheduled_qty + input.scheduled_qty) + .Where(x=>x.id==mo.id) + .ExecuteCommandAsync(); } } + var subTaskList = await _db.Queryable() .LeftJoin((a, b) => a.id == b.mbom_id) .LeftJoin((a, b, c) => a.route_id == c.id)