From af948e482dde30727d6f96f667ff2c41026e57f3 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 5 Jul 2023 09:52:49 +0800 Subject: [PATCH] bug --- .../Dto/PrdManage/ReportRecordListOutput.cs | 31 ++++++ .../ProductionReportRecordService.cs | 101 +++++++++++++----- 2 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs new file mode 100644 index 00000000..d337b189 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs @@ -0,0 +1,31 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class ReportRecordListOutput + { + public string id { get; set; } + public string? masterial_code { get; set; } = string.Empty; + public string? masterial_name { get; set; } = string.Empty; + public string? mo_task_code { get; set; } = string.Empty; + public string? mo_task_id { get; set; } = string.Empty; + public string? mo_task_id_id { get; set; } = string.Empty; + public string? mo_task_type { get; set; } = string.Empty; + public string? plan_end_date { get; set; } = string.Empty; + public int? plan_qty { get; set; } + public int? completed_qty { get; set; } + public string? plan_start_date { get; set; } = string.Empty; + public int? reported_work_qty { get; set; } + public string? status { get; set; } = string.Empty; + + public List? tablefield107 { get; set; } = new List(); + + } + + public class ReportRecordListChildrenOutput + { + public int? reported_qty { get; set; } + + public string? create_id { get; set; } = string.Empty; + public string? create_id_id { get; set; } = string.Empty; + public string? create_time { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs index 9b7a26a3..78493934 100644 --- a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs @@ -20,7 +20,12 @@ using Tnb.ProductionMgr.Interfaces; using JNPF.Systems.Interfaces.System; using Tnb.BasicData; using JNPF.Common.Extension; +using JNPF.Common.Filter; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Tnb.ProductionMgr.Entities.Dto; namespace Tnb.ProductionMgr { @@ -51,34 +56,80 @@ namespace Tnb.ProductionMgr } + // 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) + // //{ + // // var dicMoTaskStatus = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); + // // foreach (var row in data.list) + // // { + // // var dic = row.ToDictionary(x => x.Key, x => x.Value); + // // //if (dic.ContainsKey(nameof(PrdReportRecord.status))) + // // //{ + // // // var statusCode = dic[nameof(PrdReportRecord.status)].ToString(); + // // // row[nameof(PrdReportRecord.status)] = dicMoTaskStatus[statusCode]; + // // //} + // // if (dic.ContainsKey(nameof(PrdReportRecord.mo_task_type))) + // // { + // // var moTypeId = dic[nameof(PrdReportRecord.mo_task_type)].ToString(); + // // if (moTypeId.IsNotEmptyOrNull()) + // // { + // // row[nameof(PrdReportRecord.mo_task_type)] = (await _dictionaryDataService.GetInfo(moTypeId)).FullName; + // // } + // + // // } + // // } + // //} + // return data!; + // } + 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) - //{ - // var dicMoTaskStatus = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); - // foreach (var row in data.list) - // { - // var dic = row.ToDictionary(x => x.Key, x => x.Value); - // //if (dic.ContainsKey(nameof(PrdReportRecord.status))) - // //{ - // // var statusCode = dic[nameof(PrdReportRecord.status)].ToString(); - // // row[nameof(PrdReportRecord.status)] = dicMoTaskStatus[statusCode]; - // //} - // if (dic.ContainsKey(nameof(PrdReportRecord.mo_task_type))) - // { - // var moTypeId = dic[nameof(PrdReportRecord.mo_task_type)].ToString(); - // if (moTypeId.IsNotEmptyOrNull()) - // { - // row[nameof(PrdReportRecord.mo_task_type)] = (await _dictionaryDataService.GetInfo(moTypeId)).FullName; - // } - - // } - // } - //} - return data!; + string moTaskCode = ""; + if (!string.IsNullOrEmpty(input.queryJson)) + { + Dictionary queryJson = JsonConvert.DeserializeObject>(input.queryJson); + if (queryJson.TryGetValue("mo_task_code", out var value)) + { + moTaskCode = value; + } + } + var db = _repository.AsSugarClient(); + var result = await db.Queryable() + .LeftJoin((a,b)=>a.mo_task_type==b.Id) + .LeftJoin((a,b,c)=>a.status==c.EnCode) + .LeftJoin((a,b,c,d)=>a.mo_task_id==d.id) + .WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c)=>a.mo_task_code.Contains(moTaskCode)) + .Select((a,b,c,d)=>new ReportRecordListOutput + { + id = a.id, + masterial_code = a.masterial_code, + masterial_name = a.masterial_name, + mo_task_code = a.mo_task_code, + mo_task_id = a.mo_task_code, + mo_task_id_id = a.mo_task_id, + mo_task_type = b.FullName, + plan_end_date = a.plan_end_date==null ? "" : a.plan_end_date.Value.ToString("yyyy-mm-dd"), + plan_start_date = a.plan_start_date==null ? "" : a.plan_start_date.Value.ToString("yyyy-mm-dd"), + plan_qty = d.scheduled_qty, + reported_work_qty = a.reported_work_qty, + completed_qty = SqlFunc.IsNull(d.reported_work_qty,0) + SqlFunc.IsNull(d.scrap_qty,0), + status = c.FullName, + tablefield107 = SqlFunc.Subqueryable() + .LeftJoin((x,y)=>x.create_id==y.Id) + .Where(x=>x.mo_task_code==a.mo_task_code).ToList((x,y)=>new ReportRecordListChildrenOutput + { + reported_qty = x.reported_qty, + create_id = y.RealName, + create_id_id = x.create_id, + create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm") + }) + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); } private async Task AddRecord(string id,VisualDevModelDataUpInput input)