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); } } }