From 7dcb35b4552222bdb6da8b22acd6726d61215c6c Mon Sep 17 00:00:00 2001 From: "DEVICE8\\12494" Date: Thu, 25 May 2023 22:51:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=8F=90=E6=8A=A5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/PrdManage/PrdMoTaskOutput.cs | 8 + .../Dto/PrdManage/PrdMotreeOutput.cs | 4 + .../Entity/PrdMoTask.cs | 5 +- .../Entity/PrdMoTask.part.cs | 39 ++++ .../Entity/PrdMoTaskDefect.cs | 2 + .../Entity/PrdMoTaskDefectRecord.cs | 4 + .../Entity/PrdReportRecord.cs | 9 +- .../IProductionReportRecordService.cs | 12 ++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 185 +++++------------- .../Tnb.ProductionMgr/PrdTaskManageService.cs | 72 +++++++ .../ProductionReportRecordService.cs | 72 +++++++ 11 files changed, 272 insertions(+), 140 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs index 0eb46fc1..c0a9d030 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs @@ -75,6 +75,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 预计完工时间 /// public DateTime? estimated_end_date { get; set; } + /// + /// 工序编码 + /// + public string process_code { get; set; } + /// + /// 工序名称 + /// + public string process_name { get; set;} } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs index 166af51e..141c0095 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs @@ -33,6 +33,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 物料名称 /// public string material_name { get; set; } + /// + /// 物料规格型号 + /// + public string material_standard { get; set; } /// /// 工单类型:1-正常工单、2-返工工单、3-试制工单 diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs index e53d8c16..663cdb9d 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -168,5 +168,8 @@ public partial class PrdMoTask : BaseEntity /// 工序任务量 /// public int? process_task_qty { get; set; } - + /// + /// 工序id + /// + public string process_id { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs index 33fa02c4..4fef7dff 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs @@ -31,5 +31,44 @@ namespace Tnb.ProductionMgr.Entities /// [SugarColumn(IsIgnore = true)] public int? mold_cavity_qty { get; set; } + + /// + /// 任务计划数 + /// + [SugarColumn(IsIgnore = true)] + public int? icmo_qty { get; set; } + /// + /// 已报工数量 + /// + [SugarColumn(IsIgnore = true)] + public int? reported_work_qty { get; set; } + /// + /// 提报数 + /// + [SugarColumn(IsIgnore = true)] + public int? reported_qty { get; set; } + /// + /// 生产数量 + /// + [SugarColumn(IsIgnore = true)] + public int? prd_qty { get; set; } + /// + /// 设备编码 + /// + [SugarColumn(IsIgnore = true)] + public string eqp_code { get; set; } + /// + /// 物料编码 + [SugarColumn(IsIgnore = true)] + public string material_code { get; set; } + /// + /// 物料名称 + [SugarColumn(IsIgnore = true)] + public string material_name { get; set; } + /// + /// 物料属性 + /// + [SugarColumn(IsIgnore = true)] + public string material_property { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs index d5d476f6..89a77326 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs @@ -53,4 +53,6 @@ public partial class PrdMoTaskDefect : BaseEntity /// public int scrap_qty { get; set; } + public int mo_task_type { get; set; } + } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs index 254eea97..eaa4c58c 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs @@ -78,5 +78,9 @@ public partial class PrdMoTaskDefectRecord : BaseEntity /// 任务单编号 /// public string? mo_task_code { get; set; } + /// + /// 任务类型 + /// + public int mo_task_type { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs index 4113a839..ba5bdc0b 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs @@ -53,5 +53,12 @@ public partial class PrdReportRecord : BaseEntity /// 任务单号 /// public string? mo_task_code { get; set; } - + /// + /// 任务单状态 + /// + public string status { get; set; } + /// + /// 任务类型 + /// + public int mo_task_type { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs new file mode 100644 index 00000000..b02102ed --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Interfaces +{ + public interface IProductionReportRecordService + { + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index e685cf04..b552c4bf 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -111,7 +111,7 @@ namespace Tnb.ProductionMgr .Where((a, b, c) => a.material_id == materialId) .Select((a, b, c) => new Tnb.ProductionMgr.Entities.Dto.MoldListOutput { - mold_id = a.id, + mold_id = b.id, mold_code = b.mold_code, mold_name = b.mold_name, mold_type_code = b.mold_type_code, @@ -217,71 +217,6 @@ namespace Tnb.ProductionMgr return data; } /// - /// 根据任务单号获取提报记录明细 - /// - /// 任务单号 - /// - /// returns: - ///
{ - ///
icmo_qty:任务计划数量 - ///
reported_work_qty:已报工数量 - ///
reported_qty:报工数量 - ///
prd_qty:生产数量 - ///
} - ///
- [HttpGet("{mo_task_code}")] - public async Task GetPrdReportByIcmoCode(string mo_task_code) - { - var db = _repository.AsSugarClient(); - var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == mo_task_code); - var eqpCode = ""; - var moldCode = ""; - var materialCode = ""; - var materialName = ""; - var materialProp = ""; - if (prdTask != null) - { - var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id); - var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id); - var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id); - eqpCode = eqp != null ? eqp.code : ""; - moldCode = mold != null ? mold.mold_code : ""; - materialCode = material != null ? material.code : ""; - materialName = material != null ? material.name : ""; - materialProp = material != null ? material.material_property : ""; - } - - var res = await db.Queryable().Where(it => it.mo_task_code == mo_task_code) - .Select(it => new PrdReportOutput - { - icmo_qty = it.icmo_qty, - reported_work_qty = it.reported_work_qty, - eqp_code = eqpCode, - mold_code = moldCode, - material_code = materialCode, - material_name = materialName, - prd_qty = it.prd_qty, - scrap_qty = SqlFunc.Subqueryable().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(x => x.scrap_qty), - }) - .Mapper(it => - { - it.icmo_qty = it.icmo_qty ?? (db.Queryable().First(it => it.icmo_code == mo_task_code)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable().First(it => it.icmo_code == mo_task_code).scheduled_qty); - it.reported_work_qty = it.reported_work_qty ?? 0; - //it.reported_qty = it.reported_qty ?? 0; - it.prd_qty = it.prd_qty ?? 0; - it.scrap_qty = it.scrap_qty ?? 0; - }) - .FirstAsync(); - res ??= new PrdReportOutput - { - icmo_qty = db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty, - reported_work_qty = 0, - prd_qty = 0, - scrap_qty = 0, - }; - return res; - } - /// /// 获取自检报废批次记录 /// /// 任务单Id @@ -343,7 +278,6 @@ namespace Tnb.ProductionMgr [HttpGet("{moId}")] public async Task GetPrdTaskInfoByMoId(string moId, int schedType = 1) { - List result = new(); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); if (schedType == 1) @@ -369,6 +303,8 @@ namespace Tnb.ProductionMgr estimated_end_date = a.estimated_end_date, plan_qty = b.plan_qty, complete_qty = a.complete_qty, + process_code = SqlFunc.Subqueryable().Where(it => it.id == a.process_id).Select(it => it.process_code), + process_name = SqlFunc.Subqueryable().Where(it => it.id == a.process_id).Select(it => it.process_name), }) .Mapper(it => { @@ -381,7 +317,7 @@ namespace Tnb.ProductionMgr result = await _db.Queryable().LeftJoin((a, b) => a.mo_id == b.id) .LeftJoin((a, b, c) => a.material_id == c.id) .LeftJoin((a, b, c, d) => a.workline_id == d.Id) - .Where((a, b, c, d) => a.mo_id == moId && string.IsNullOrEmpty(a.parent_id)) + .Where((a, b, c, d) => b.id == moId || b.parent_id == moId) .Select((a, b, c, d) => new PrdMoTaskOutput { mo_task_code = a.mo_task_code, @@ -505,8 +441,12 @@ namespace Tnb.ProductionMgr node.material_id_id = materialId; node.material_code = material?.code; node.material_name = material?.name; + node.material_standard = material?.material_standard; } + // + var scheldQtyCol = nameof(PrdMo.scheduled_qty); + node.scheduled_qty = _db.Queryable().Where(it => it.mo_id == dic["id"].ToString()).Sum(it => it.scheduled_qty)?.ToString(); var queryObj = new { parent_id = node.id }; input.superQueryJson = ""; input.queryJson = queryObj.ToJsonString(); @@ -527,7 +467,9 @@ namespace Tnb.ProductionMgr subNode.material_id_id = materialId; subNode.material_code = material?.code; subNode.material_name = material?.name; + subNode.material_standard = material?.material_standard; } + node.scheduled_qty = _db.Queryable().Where(it => it.mo_id == dic["id"].ToString()).Sum(it => it.scheduled_qty)?.ToString(); childNodes.Add(subNode); } trees.AddRange(childNodes); @@ -696,6 +638,7 @@ namespace Tnb.ProductionMgr moTask.id = SnowflakeIdHelper.NextId(); moTask.create_id = _userManager.UserId; moTask.bom_id = input.bom_id; + moTask.workroute_id = (await _db.Queryable().FirstAsync(it => it.id == input.bom_id))?.route_id; moTask.workline_id = input.workline_id; moTask.create_time = DateTime.Now; moTask.schedule_type = 2; @@ -726,7 +669,7 @@ namespace Tnb.ProductionMgr } row = await _db.Insertable(moTask).ExecuteCommandAsync(); var material_h = await _db.Queryable().FirstAsync(it => it.id == moTask.material_id); - //添加生产任务操作记录日志s + //添加生产任务操作记录日志 var taskLog = new PrdTaskLog(); taskLog.id = SnowflakeIdHelper.NextId(); taskLog.mo_code = (await _db.Queryable().FirstAsync(it => it.id == input.mo_id))?.mo_code!; @@ -775,43 +718,41 @@ namespace Tnb.ProductionMgr } } } - //根据生产bomId 拆解生产子任务 - var outputList = new List(); var subTaskList = await _db.Queryable() - .LeftJoin((a, b) => a.id == b.mbom_id) - .LeftJoin((a, b, c) => a.route_id == c.id) - .LeftJoin((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id) - .LeftJoin((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id) - .Where((a, b, c, d, e) => a.id == input.bom_id && d.ordinal < SqlFunc.Subqueryable().Where(it => it.route_id == a.route_id).OrderByDesc(it => it.ordinal).Select(it => it.ordinal)) - .Select((a, b, c, d, e) => new SubBomListOutput - { - version = a.version, - unit_id = a.unit_id, - route_id = c.id, - route_name = c.name, - process_id = b.process_id, - material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id), - num = e.num, - ordinal = d.ordinal, - }) - .Mapper(it => it.output_qty = it.num.ParseToInt()) - .ToListAsync(); - + .LeftJoin((a, b) => a.id == b.mbom_id) + .LeftJoin((a, b, c) => a.route_id == c.id) + .LeftJoin((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id) + .LeftJoin((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id) + .Where((a, b, c, d, e) => a.id == input.bom_id) + .Select((a, b, c, d, e) => new SubBomListOutput + { + version = a.version, + unit_id = a.unit_id, + route_id = c.id, + process_id = b.process_id, + material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id), + num = e.num, + ordinal = d.ordinal, + }) + .Mapper(it => it.output_qty = it.num.ParseToInt()) + .ToListAsync(); if (subTaskList?.Count > 0) { List subMoTasks = new(); foreach (var item in subTaskList) { PrdMoTask subMoTask = new(); - subMoTask.schedule_type = 2; - subMoTask.mo_task_status = DictConst.ToBeScheduledEncode; - subMoTask.parent_id = moTask.id; subMoTask.mo_id = input.mo_id; - //subMoTask.bom_id = input.bom_id; + subMoTask.material_id = item.material_id; + subMoTask.schedule_type = 2; + subMoTask.parent_id = moTask.id; + subMoTask.bom_id = input.bom_id; + subMoTask.process_id = item.process_id; + subMoTask.mo_task_status = DictConst.ToBeScheduledEncode; + subMoTask.workroute_id = item.route_id; subMoTask.workline_id = input.workline_id; subMoTask.material_id = item.material_id; - subMoTask.workroute_id = item.route_id; - subMoTask.scheduled_qty = item.output_qty * moTask.scheduled_qty; + subMoTask.scheduled_qty = input.scheduled_qty; subMoTask.process_task_qty = item.output_qty * moTask.scheduled_qty; subMoTask.estimated_start_date = input.estimated_start_date; subMoTask.estimated_end_date = input.estimated_end_date; @@ -830,45 +771,6 @@ namespace Tnb.ProductionMgr } row = await _db.Insertable(subMoTasks).ExecuteCommandAsync(); } - #region 注释代码 - //var bom = await _db.Queryable().FirstAsync(it => it.id == input.bom_id); - //if (bom != null && bom.route_id.IsNotEmptyOrNull()) - //{ - // var mbomProcesses = await _db.Queryable().Where(it => it.mbom_id == bom.id).ToListAsync(); - // var routes = await _db.Queryable().Where(it => it.route_id == bom.route_id).ToListAsync(); - // if (routes?.Count > 0) - // { - // var processIds = routes.Select(x => x.process_id).ToList(); - // if (processIds?.Count > 0) - // { - // var bomOutputs = await _db.Queryable().Where(it => processIds.Contains(it.process_id)).ToListAsync(); - // if (bomOutputs?.Count > 0) - // { - // List subMoTasks = new(); - // foreach (var item in bomOutputs) - // { - // var material = await _db.Queryable().FirstAsync(it => it.id == item.material_id); - // PrdMoTask subMoTask = new(); - // subMoTask.id = SnowflakeIdHelper.NextId(); - // subMoTask.schedule_type = 2; - // subMoTask.parent_id = moTask.id; - // subMoTask.bom_id = input.bom_id; - // subMoTask.mo_task_status = DictConst.ToBeScheduledEncode; - // subMoTask.workline_id = input.workline_id; - // subMoTask.material_id = item.material_id; - // subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty; - // subMoTask.estimated_start_date = input.estimated_start_date; - // subMoTask.estimated_end_date = input.estimated_end_date; - // subMoTask.create_id = _userManager.UserId; - // subMoTask.create_time = DateTime.Now; - // subMoTasks.Add(subMoTask); - // } - // } - // } - // } - //} - #endregion - await _db.Ado.CommitTranAsync(); } catch (Exception ex) @@ -1088,7 +990,13 @@ namespace Tnb.ProductionMgr var record = prdTask.Adapt(); if (prdTask != null) { + var material = (await db.Queryable().FirstAsync(it => it.id == prdTask.material_id)); record.id = SnowflakeIdHelper.NextId(); + record.masterial_code = material?.code; + record.masterial_name = material?.name; + record.plan_start_date = prdTask.estimated_start_date; + record.plan_end_date = prdTask.estimated_end_date; + record.plan_qty = prdTask.plan_qty; record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id))?.code; record.completed_qty = input.reported_qty; row = await db.Insertable(record).ExecuteCommandAsync(); @@ -1202,11 +1110,12 @@ namespace Tnb.ProductionMgr if (outMaterials?.Count > 0) { - var mids = await _db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync(); - var ids = outMaterials.Select(x => x.material_id).Except(mids).ToList(); + //var mids = await _db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync(); + var ids = outMaterials.Select(x => x.material_id).ToList(); + await _db.Deleteable().Where(it => it.parent_id == input.mo_id).ExecuteCommandAsync(); if (ids?.Count > 0) { - var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt()); + var dicOutMaterialNum = outMaterials.DistinctBy(x => x.material_id).ToDictionary(x => x.material_id, x => x.num.ParseToInt()); List subMoList = new(); var outputMaterials = await _db.Queryable().Where(it => ids.Contains(it.id)).ToListAsync(); foreach (var om in outputMaterials) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index f654c1eb..62830b07 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -21,6 +21,8 @@ using Tnb.ProductionMgr.Interfaces; using Aspose.Cells.Drawing; using Microsoft.AspNetCore.Mvc; using DbModels; +using JNPF.Common.Extension; +using Tnb.ProductionMgr.Entities.Dto.PrdManage; namespace Tnb.ProductionMgr { @@ -60,6 +62,12 @@ namespace Tnb.ProductionMgr var data = await _runService.GetListResult(templateEntity, input); if (data?.list?.Count > 0) { + var statusField = "mo_task_status"; + var scheduledTypeField = nameof(PrdMoTask.schedule_type); + data.list = data.list.Where(it => it.ContainsKey(statusField) && + it[statusField].IsNotEmptyOrNull() && it[statusField].ToString() != "待下发" && + it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1 + ).ToList(); foreach (var row in data.list) { var dic = row.ToDictionary(x => x.Key, x => x.Value); @@ -98,6 +106,70 @@ namespace Tnb.ProductionMgr } return data!; } + /// + /// 根据任务单号获取提报记录明细 + /// + /// 任务单号 + /// + /// returns: + ///
{ + ///
icmo_qty:任务计划数量 + ///
reported_work_qty:已报工数量 + ///
reported_qty:报工数量 + ///
prd_qty:生产数量 + ///
} + ///
+ [HttpGet] + public async Task GetPrdReportByIcmoCode([FromRoute] string mo_task_code) + { + var db = _repository.AsSugarClient(); + var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == mo_task_code); + var eqpCode = ""; + var moldCode = ""; + var materialCode = ""; + var materialName = ""; + var materialProp = ""; + if (prdTask != null) + { + var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id); + var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id); + var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id); + eqpCode = eqp != null ? eqp.code : ""; + moldCode = mold != null ? mold.mold_code : ""; + materialCode = material != null ? material.code : ""; + materialName = material != null ? material.name : ""; + materialProp = material != null ? material.material_property : ""; + + } + var res = await db.Queryable().Where(it => it.mo_task_code == mo_task_code) + .Select(it => new PrdReportOutput + { + icmo_qty = it.icmo_qty, + reported_work_qty = it.reported_work_qty, + reported_qty = it.reported_qty, + prd_qty = it.prd_qty, + scrap_qty = SqlFunc.Subqueryable().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(pmtd => pmtd.scrap_qty), + }) + .Mapper(it => + { + it.icmo_qty = it.icmo_qty ?? (db.Queryable().First(it => it.icmo_code == mo_task_code)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable().First(it => it.icmo_code == mo_task_code).scheduled_qty); + it.reported_work_qty = it.reported_work_qty ?? 0; + it.reported_qty = it.reported_qty ?? 0; + it.prd_qty = it.prd_qty ?? 0; + it.scrap_qty = it.scrap_qty ?? 0; + }) + .FirstAsync(); + prdTask.eqp_code = eqpCode; + prdTask.mold_code = moldCode; + prdTask.material_code = materialCode; + prdTask.material_name = materialName; + prdTask.icmo_qty = res?.icmo_qty; + prdTask.reported_work_qty = res?.reported_work_qty ?? 0; + prdTask.reported_qty = res?.reported_qty ?? 0; + prdTask.prd_qty = res?.prd_qty ?? 0; + + return prdTask; + } //public async Task GetPrdMoTaskList() //{ diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs new file mode 100644 index 00000000..d63b715d --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Interfaces; + +namespace Tnb.ProductionMgr +{ + /// + /// 生产提报记录 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class ProductionReportRecordService : IOverideVisualDevService, IProductionReportRecordService, IDynamicApiController, ITransient + { + private const string ModuleId = "25568191969061"; + private readonly ISqlSugarRepository _repository; + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public ProductionReportRecordService(ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + OverideFuncs.GetListAsync = GetList; + } + + + private async Task GetList(VisualDevModelListQueryInput input) + { + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + var data = await _runService.GetListResult(templateEntity, input); + if (data?.list?.Count > 0) + { + foreach (var row in data.list) + { + var dic = row.ToDictionary(x => x.Key, x => x.Value); + var pkName = "material_id_id"; + if (dic.ContainsKey(pkName)) + { + var materialId = dic[pkName]?.ToString(); + var material = await _db.Queryable().FirstAsync(it => it.id == materialId); + //if (material != null) + //{ + // row.Add("material_name", material.name); + // row.Add($"material_attribute", material.attribute); + + //} + } + } + } + return data!; + } + } +}