From ee2e9ffc3dd7ce60a2cd62a26e6e1e988632e88e Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 24 Jul 2023 11:24:08 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=8C=E6=88=90=E6=A0=A1?=
=?UTF-8?q?=E9=AA=8C=EF=BC=8C=E8=87=AA=E6=A3=80=E6=8A=A5=E5=BA=9F=E8=AE=B0?=
=?UTF-8?q?=E5=BD=95=E6=B7=BB=E5=8A=A0=E6=8A=A5=E5=BA=9F=E4=BA=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/PrdManage/PrdMoTaskDefectOutput.cs | 2 ++
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 21 ++++++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskDefectOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskDefectOutput.cs
index dc76daba..e345f950 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskDefectOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskDefectOutput.cs
@@ -27,6 +27,8 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
public string? batch { get; set; }
public string? create_time { get; set; }
+
+ public string? create_name { get; set; }
///
/// 报废数量
///
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 37c14d22..0d2f713d 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -245,13 +245,15 @@ namespace Tnb.ProductionMgr
}
output.mo_task_code = (await db.Queryable().FirstAsync(it => it.id == moTaskId))?.mo_task_code;
var defects = await db.Queryable().Where(it => it.mo_task_id == moTaskId).ToListAsync();
+ var users = await db.Queryable().ToListAsync();
if (defects?.Count > 0)
{
- output.batchItems = defects.GroupBy(g => new { g.batch }).Select(t => new BatchItem
+ output.batchItems = defects.GroupBy(g => new { g.batch,g.create_id }).Select(t => new BatchItem
{
scrap_qty = t.Sum(d => d.defective_item_qty),
batch = t.Key.batch,
create_time = t.Key.batch.ParseToDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
+ create_name = users.First(x=>x.Id==t.Key.create_id)?.RealName ?? "",
categoryItems = t.GroupBy(g => g.defective_cagetory_id).Select(c => new CategoryItem
{
name = _dicDefect[c.Key]?.ToString(),
@@ -263,6 +265,7 @@ namespace Tnb.ProductionMgr
}).ToList(),
}).ToList(),
}).ToList();
+
}
return output;
}
@@ -1015,11 +1018,19 @@ namespace Tnb.ProductionMgr
{
if (list?.Count > 0)
{
- var schedQtySum = list.Sum(x => x.scheduled_qty);
- var planQtySum = list.Sum(x => x.plan_qty);
- if (schedQtySum < planQtySum)
+ // var schedQtySum = list.Sum(x => x.scheduled_qty);
+ // var planQtySum = list.Sum(x => x.plan_qty);
+ // if (schedQtySum < planQtySum)
+ // {
+ // throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
+ // }
+
+ int reportedWorkQty = list.Sum(x => x.reported_work_qty) ?? 0;
+ int scrapQty = list.Sum(x => x.scrap_qty) ?? 0;
+ int scheduledQty = list.Sum(x => x.scheduled_qty) ?? 0;
+ if (scheduledQty >= reportedWorkQty+scrapQty)
{
- throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
+ throw new AppFriendlyException("已完成数量大于等于任务单数量,才可完成", 500);
}
}
}