From 596f483d63a2d59b970195c1e894d515b08d5364 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 18 Oct 2023 18:17:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E6=A3=80=E6=8F=90=E6=8A=A5=E4=B9=9F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=A2=84=E8=AE=A1=E7=BB=93=E6=9D=9F=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 341c9405..3c57b8fa 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1510,7 +1510,7 @@ namespace Tnb.ProductionMgr if (toolMolds != null && toolMolds?.mold_cavity > 0 && processStandardsH != null && processStandardsH?.moulding_cycle > 0) { - decimal? addTime = ((prdMoTask.scheduled_qty-input.reported_qty) * processStandardsH?.moulding_cycle - 1) / toolMolds.mold_cavity + 1; + decimal? addTime = ((prdMoTask.scheduled_qty-input.reported_qty-(prdMoTask.scrap_qty??0)) * processStandardsH?.moulding_cycle - 1) / toolMolds.mold_cavity + 1; if (prdMoTask.act_start_date != null && addTime != null && addTime > 0) { DateTime cal_plan_end_date = prdMoTask.act_start_date.Value.AddSeconds((double)addTime); @@ -1572,7 +1572,7 @@ namespace Tnb.ProductionMgr .Where((a,b)=>a.process_id==prdMoTask.process_id).Select((a,b)=>b).ToListAsync(); decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x); - decimal? addTime = (prdMoTask.scheduled_qty-input.reported_qty) * max; + decimal? addTime = (prdMoTask.scheduled_qty-input.reported_qty-(prdMoTask.scrap_qty??0)) * max; if (prdMoTask.act_start_date != null && addTime != null && addTime > 0) { DateTime cal_plan_end_date = prdMoTask.act_start_date.Value.AddSeconds((double)addTime); @@ -1792,6 +1792,44 @@ namespace Tnb.ProductionMgr await db.Updateable(reportMaster).ExecuteCommandAsync(); } + if (prdMoTask.schedule_type == 1) + { + PerProcessStandardsH processStandardsH = await db.Queryable() + .Where(x => x.equip_id == prdMoTask.eqp_id && x.molds_id == prdMoTask.mold_id && + x.output_material_id == prdMoTask.material_id && x.enabled == 1) + .OrderByDescending(x => x.create_time).FirstAsync(); + + ToolMolds toolMolds = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mold_id); + if (toolMolds != null && toolMolds?.mold_cavity > 0 && processStandardsH != null && + processStandardsH?.moulding_cycle > 0) + { + decimal? addTime = ((prdMoTask.scheduled_qty-prdMoTask.reported_work_qty-input.scrap_qty) * processStandardsH?.moulding_cycle - 1) / toolMolds.mold_cavity + 1; + if (prdMoTask.act_start_date != null && addTime != null && addTime > 0) + { + DateTime cal_plan_end_date = prdMoTask.act_start_date.Value.AddSeconds((double)addTime); + await db.Updateable() + .SetColumns(x => x.plan_end_date == cal_plan_end_date) + .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync(); + } + } + } + else + { + var list = await db.Queryable() + .LeftJoin((a,b)=>a.process_id==b.process_id && b.enabled==1) + .Where((a,b)=>a.process_id==prdMoTask.process_id).Select((a,b)=>b).ToListAsync(); + + decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x); + decimal? addTime = (prdMoTask.scheduled_qty-prdMoTask.reported_work_qty-input.scrap_qty) * max; + if (prdMoTask.act_start_date != null && addTime != null && addTime > 0) + { + DateTime cal_plan_end_date = prdMoTask.act_start_date.Value.AddSeconds((double)addTime); + await db.Updateable() + .SetColumns(x => x.plan_end_date == cal_plan_end_date) + .Where(x => x.id == input.mo_task_id).ExecuteCommandAsync(); + } + } + }); return result.IsSuccess; }