diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index f14fefef..b8cd6297 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -27,6 +27,22 @@ public static class DictConst /// 备品备件类型 /// public const string SparePartsType = "SparePartsType"; + /// + /// 注塑工单 + /// + public const string PrdMoTypeZS = "25572555259157"; + /// + /// 挤出工单 + /// + public const string PrdMoTypeJC = "25019172714005"; + /// + /// 组装工单 + /// + public const string PrdMoTypeZZ = "25019181615125"; + /// + /// 包装工单 + /// + public const string PrdMoTypeBZ = "25019191681045"; #endregion diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs index b5f8082b..85dcfc0c 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs @@ -52,7 +52,34 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public string? workline_name { get; set; } + public string? workshop_name { get; set; } + public string? mbom_version { get; set; } + + public string station_name { get; set; } + + public string equip_code { get; set; } + + } + + /// + /// 工单追溯二级列表输出类 + /// + public class PrdMoFromManListOutput + { + // /// + // /// 提报id + // /// + // public string id { get; set; } + // + // public string workgroup_name { get; set; } + + public string employee_name { get; set; } + public string work_time { get; set; } + + public DateTime? start_time { get; set; } + public DateTime? end_time { get; set; } + } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 114b4484..4c817ed4 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -418,29 +418,101 @@ namespace Tnb.ProductionMgr 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(); + string mo_task_code = dic.ContainsKey("mo_task_code") ? dic["mo_task_code"] : ""; + string batch = dic.ContainsKey("batch") ? dic["batch"] : ""; + List ids = new List(); + if (!string.IsNullOrEmpty(batch)) + { + ids = await _db.Queryable().Where(x => x.batch.Contains(batch)).Select(x=>x.mo_task_id).ToListAsync(); + } + + PrdMo prdMo = await _repository.GetSingleAsync(x => x.id == mo_id); + if (prdMo.mo_type is DictConst.PrdMoTypeZS or DictConst.PrdMoTypeJC) + { + return await _db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a,b,c)=>a.eqp_id==c.ObjectId && c.ObjectType=="Eqp") + .LeftJoin((a,b,c,d)=>c.OrganizeId==d.Id) + .LeftJoin((a,b,c,d,e)=>d.OrganizeIdTree.Contains(e.Id) && e.Category==DictConst.RegionCategoryWorkshopCode) + .LeftJoin((a,b,c,d,e,f)=>a.eqp_id==f.id) + .WhereIF(!string.IsNullOrEmpty(mo_id),(a,b,c,d)=>a.mo_id==mo_id) + .WhereIF(!string.IsNullOrEmpty(mo_task_code),(a,b,c,d)=>a.mo_task_code==mo_task_code) + .WhereIF(ids!=null && ids.Count>0,(a,b,c,d)=>ids.Contains(a.id)) + .Select((a, b, c, d,e,f) => + 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"), + workshop_name = e.FullName, + station_name = d.FullName, + equip_code = f.code + }).ToListAsync(); + } + else + { + 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) + .WhereIF(!string.IsNullOrEmpty(mo_task_code),(a,b,c,d)=>a.mo_task_code==mo_task_code) + .WhereIF(ids!=null && ids.Count>0,(a,b,c,d)=>ids.Contains(a.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(); + } + + } + + /// + /// 工单追溯人列表 + /// + /// + /// + [HttpPost] + public async Task PrdMoFromManList(Dictionary dic) + { + string mo_task_id = dic.ContainsKey("mo_task_id") ? dic["mo_task_id"] : ""; + string batch = dic.ContainsKey("batch") ? dic["batch"] : ""; + List ids = new List(); + if (!string.IsNullOrEmpty(batch)) + { + ids = await _db.Queryable().Where(x => x.batch.Contains(batch)).Select(x=>x.mo_task_id).ToListAsync(); + } + + return await _db.Queryable() + .LeftJoin((a, b) => a.create_id == b.Id) + .WhereIF(!string.IsNullOrEmpty(mo_task_id), (a, b) => a.mo_task_id == mo_task_id) + .WhereIF(ids!=null && ids.Count>0,(a,b)=>ids.Contains(a.mo_task_id)) + .GroupBy((a,b)=>new {a.create_id,employee_name = b.RealName}) + .Select((a, b) => new PrdMoFromManListOutput() + { + // id = a.id, + employee_name = b.RealName, + start_time = SqlFunc.AggregateMin(a.create_time), + end_time = SqlFunc.AggregateMax(a.create_time) + }).Mapper(x => + { + x.work_time = (x.start_time == null ? "" : x.start_time.Value.ToString("yyyy-MM-dd HH:mm:ss")) + "~" + (x.end_time == null ? "" : x.end_time.Value.ToString("yyyy-MM-dd HH:mm:ss")); + }) + .ToListAsync(); } #endregion