From ab238d4f3c2ac111528f2ef8573160de9492deb8 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Sun, 25 Jun 2023 15:18:51 +0800 Subject: [PATCH] =?UTF-8?q?bug,=E7=94=9F=E4=BA=A7bom=E5=B7=A5=E5=BA=8F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=92=E5=BA=8F=E5=92=8C=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E4=B8=80=E9=81=93=E5=B7=A5=E5=BA=8F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BasicData/Tnb.BasicData/BasMbomService.cs | 3 +++ .../Entity/PrdMoTask.cs | 6 ++++++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 17 ++++++++++++++++- .../Tnb.ProductionMgr/PrdPackReportService.cs | 11 ++++++++--- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs index 7c441b64..4eae1f35 100644 --- a/BasicData/Tnb.BasicData/BasMbomService.cs +++ b/BasicData/Tnb.BasicData/BasMbomService.cs @@ -282,6 +282,7 @@ namespace Tnb.BasicData if (mbomSaveDataInput != null && mbomSaveDataInput.processes != null) { + int index = 0; foreach (var process in mbomSaveDataInput.processes) { string mbomProcessId = SnowflakeIdHelper.NextId(); @@ -296,6 +297,8 @@ namespace Tnb.BasicData byproduct_status = process.byproduct_status, production_method = process.production_method, route_detail_id = process.route_detail_id, + ordinal = ++index, + is_last = index==mbomSaveDataInput.processes.Count ? 1 : 0, }); diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs index 16772015..097e9df0 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -182,4 +182,10 @@ public partial class PrdMoTask : BaseEntity /// 生产bom工序id /// public string? mbom_process_id { get; set; } + + /// + /// 最后一道工序完成数量 + /// + public int? last_process_complete_qty { get; set; } + } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 643340d9..bd1fb462 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1263,7 +1263,22 @@ namespace Tnb.ProductionMgr .SetColumns(x => x.reported_work_qty == x.reported_work_qty + input.reported_qty) .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync(); } - + var mbomProcess = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mbom_process_id); + if (mbomProcess.is_last==1 && prdMoTask != null && !string.IsNullOrEmpty(prdMoTask.parent_id)) + { + var parentMoTask = await db.Queryable().SingleAsync(x => x.id == prdMoTask.parent_id); + if (parentMoTask?.last_process_complete_qty == null) + { + await db.Updateable() + .SetColumns(x => x.last_process_complete_qty == input.reported_qty) + .Where(x => x.id == prdMoTask.parent_id).ExecuteCommandAsync(); + }else if (parentMoTask?.last_process_complete_qty != null) + { + await db.Updateable() + .SetColumns(x => x.last_process_complete_qty == x.last_process_complete_qty + input.reported_qty) + .Where(x => x.id == prdMoTask.parent_id).ExecuteCommandAsync(); + } + } var master = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id); if (master != null) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index c884c791..488d0645 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -70,7 +70,7 @@ namespace Tnb.ProductionMgr plan_end_date = a.estimated_end_date, plan_qty = c.plan_qty, // complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty), - complete_qty = a.reported_work_qty+a.scrap_qty, + complete_qty = a.last_process_complete_qty, mo_task_status = a.mo_task_status, }) @@ -116,8 +116,12 @@ namespace Tnb.ProductionMgr private async Task GetChild(string parentId, List nodes, Dictionary dic) { - var items = await _db.Queryable().LeftJoin((a, b) => a.process_id == b.id).LeftJoin((a, b, c) => a.mo_id == c.id) + var items = await _db.Queryable() + .LeftJoin((a, b) => a.process_id == b.id) + .LeftJoin((a, b, c) => a.mo_id == c.id) + .LeftJoin((a,b,c,d)=>a.mbom_process_id==d.id) .Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled") + .OrderBy((a,b,c,d)=>d.ordinal) .Select((a, b, c) => new PrdMoTask { id = a.id, @@ -129,7 +133,8 @@ namespace Tnb.ProductionMgr plan_start_date = a.estimated_start_date, plan_end_date = a.estimated_end_date, plan_qty = c.plan_qty, - complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty), + //complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty), + complete_qty = a.reported_work_qty+a.scrap_qty, mo_task_status = a.mo_task_status, }).ToListAsync();