diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs new file mode 100644 index 00000000..b5f8082b --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs @@ -0,0 +1,58 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 工单追溯一级列表输出类 + /// + public class PrdMoFromOneListOutput + { + /// + /// 工单id + /// + public string id { get; set; } + + public string mo_code { get; set; } + + public string material_id { get; set; } + + public string material_code { get; set; } + + public string material_name { get; set; } + + public string? material_standard { get; set; } + + public string? act_start_date { get; set; } + + public string? act_end_date { get; set; } + + } + + /// + /// 工单追溯二级列表输出类 + /// + public class PrdMoFromTwoListOutput + { + /// + /// 任务单id + /// + public string id { get; set; } + + public string mo_task_code { get; set; } + + public string material_id { get; set; } + + public string material_code { get; set; } + + public string material_name { get; set; } + + public string? material_standard { get; set; } + + public string? act_start_date { get; set; } + + public string? act_end_date { get; set; } + + public string? workline_name { get; set; } + + public string? mbom_version { get; set; } + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromQueryInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromQueryInput.cs new file mode 100644 index 00000000..ece9e52f --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromQueryInput.cs @@ -0,0 +1,21 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class PrdMoFromQueryInput + { + /// + /// 当前页码:pageIndex. + /// + public int currentPage { get; set; } = 1; + + /// + /// 每页行数. + /// + public int pageSize { get; set; } = 50; + + public string? mo_code { get; set; } + + public string? mo_task_code { get; set; } + + public string? batch { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 6c2d1c49..114b4484 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -5,6 +5,7 @@ using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; @@ -356,6 +357,92 @@ namespace Tnb.ProductionMgr + #endregion + + #region 工单追溯相关 + + /// + /// 工单追溯一级列表 + /// + /// + /// + [HttpPost] + public async Task PrdMoFromOneList(PrdMoFromQueryInput input) + { + List ids = new List(); + List ids1 = new List(); + List ids2 = new List(); + if (!string.IsNullOrEmpty(input.mo_task_code)) + { + ids1 = await _db.Queryable().Where(x => x.mo_task_code.Contains(x.mo_task_code)).Select(x => x.mo_id).ToListAsync(); + ids = ids1; + } + if (!string.IsNullOrEmpty(input.batch)) + { + ids2 = await _db.Queryable() + .LeftJoin((a,b)=>a.mo_task_id==b.id) + .Where((a,b) => a.batch.Contains(input.batch)).Select((a,b) => b.mo_id).ToListAsync(); + ids = ids2; + } + + if (!string.IsNullOrEmpty(input.mo_task_code) && !string.IsNullOrEmpty(input.batch)) + { + ids = ids1.Intersect(ids2).ToList(); + } + + var result = await _db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .WhereIF(!string.IsNullOrEmpty(input.mo_code),(a,b)=>a.mo_code.Contains(input.mo_code)) + .WhereIF(ids!=null && ids.Count>0,(a,b)=>ids.Contains(a.id)) + .Select((a, b) => + new PrdMoFromOneListOutput + { + id = a.id, + mo_code = a.mo_code, + material_id = a.material_id, + material_code = b.code, + material_name = b.name, + material_standard = b.material_standard, + act_start_date = a.act_start_date==null ? "" : a.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss"), + act_end_date = a.act_end_date==null ? "" : a.act_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); + } + + /// + /// 工单追溯二级列表 + /// + /// + /// + [HttpPost] + public async Task PrdMoFromTwoList(Dictionary dic) + { + string mo_id = dic.ContainsKey("mo_id") ? dic["mo_id"] : ""; + return await _db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => a.workline_id == c.Id) + .LeftJoin((a, b, c, d) => a.bom_id == d.id) + .WhereIF(!string.IsNullOrEmpty(mo_id),(a,b,c,d)=>a.mo_id==mo_id) + .Select((a, b, c, d) => + new PrdMoFromTwoListOutput + { + id = a.id, + mo_task_code = a.mo_task_code, + material_id = a.material_id, + material_code = b.code, + material_name = b.name, + material_standard = b.material_standard, + act_start_date = a.act_start_date == null + ? "" + : a.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss"), + act_end_date = a.act_end_date == null + ? "" + : a.act_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss"), + workline_name = c.FullName, + mbom_version = d.version + }).ToListAsync(); + } + #endregion } }