From acf1d9f94af702366356158228cb1a3afaaa2145 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 26 Jul 2023 10:03:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=A1=91=E4=BB=BB=E5=8A=A1=E5=8D=95?= =?UTF-8?q?=E4=BB=A5pps=E5=BC=80=E5=A4=B4=20=E6=B3=A8=E5=A1=91=E6=8C=A4?= =?UTF-8?q?=E5=87=BA=E6=8E=92=E4=BA=A7=E5=B7=B2=E6=8E=92=E4=BA=A7=E6=95=B0?= =?UTF-8?q?=E9=87=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 67 ++++++++++++------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index e17fb054..227988a8 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -658,32 +658,34 @@ namespace Tnb.ProductionMgr { if (input.schedule_type.Value == 1) //注塑、基础排产 { + var mo = await db.Queryable().FirstAsync(it => it.id == input.mo_id); var moTask = input.Adapt(); moTask.id = SnowflakeIdHelper.NextId(); moTask.create_id = _userManager.UserId; moTask.create_time = DateTime.Now; moTask.mo_task_status = DictConst.ToBeScheduledEncode; moTask.scheduled_qty = input.scheduled_qty; - - var mo = await db.Queryable().FirstAsync(it => it.id == input.mo_id); - var moCode = mo?.mo_code; - var taskCode = await db.Queryable().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)).OrderByDescending(it => it.mo_task_code).Select(it => it.mo_task_code).FirstAsync(); moTask.unit_id = mo.unit_id; - if (taskCode.IsNullOrEmpty()) - { - moTask.mo_task_code = $"{moCode}-01"; - } - else - { - var pos = taskCode.IndexOf("-", StringComparison.Ordinal); - if (pos > -1) - { - var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt(); - var code = taskCode.AsSpan().Slice(0, pos).ToString(); - var n = (num + 1).ToString().PadLeft(2, '0'); - moTask.mo_task_code = $"{code}-{n}"; - } - } + + var moCode = mo?.mo_code; + var taskCode = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.PRDMOTASK_CODE); + moTask.mo_task_code = taskCode; + // var taskCode = await db.Queryable().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)).OrderByDescending(it => it.mo_task_code).Select(it => it.mo_task_code).FirstAsync(); + // if (taskCode.IsNullOrEmpty()) + // { + // moTask.mo_task_code = $"{moCode}-01"; + // } + // else + // { + // var pos = taskCode.IndexOf("-", StringComparison.Ordinal); + // if (pos > -1) + // { + // var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt(); + // var code = taskCode.AsSpan().Slice(0, pos).ToString(); + // var n = (num + 1).ToString().PadLeft(2, '0'); + // moTask.mo_task_code = $"{code}-{n}"; + // } + // } try { await db.Ado.BeginTranAsync(); @@ -702,16 +704,31 @@ namespace Tnb.ProductionMgr if (mo != null) {//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产 - if (schedQty.HasValue && schedQty.Value >= mo.plan_qty) + // if (schedQty.HasValue && schedQty.Value >= mo.plan_qty) + // { + // mo.mo_status = DictConst.AlreadyId; + // } + // else + // { + // if (schedQty.HasValue) + // mo.scheduled_qty = schedQty.Value; + // } + // row = await db.Updateable(mo).ExecuteCommandAsync(); + + if (mo.scheduled_qty == null) { - mo.mo_status = DictConst.AlreadyId; + 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().SetColumns(x => x.scheduled_qty == x.scheduled_qty + input.scheduled_qty) + .Where(x=>x.id==mo.id) + .ExecuteCommandAsync(); } - row = await db.Updateable(mo).ExecuteCommandAsync(); } var material = await db.Queryable().FirstAsync(it => it.id == moTask.material_id); @@ -789,7 +806,7 @@ namespace Tnb.ProductionMgr moTask.estimated_end_date = input.estimated_end_date; moTask.scheduled_qty = input.scheduled_qty; var mo = await _db.Queryable().FirstAsync(it => it.id == input.mo_id); - moTask.unit_id = mo.unit_id; + // moTask.unit_id = mo.unit_id; var moCode = mo?.mo_code; // var taskCode = await _db.Queryable().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)) // .OrderByDescending(it => it.mo_task_code)