diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs index 93589603..94e5d2ed 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptInput.cs @@ -59,6 +59,6 @@ namespace Tnb.ProductionMgr.Entities.Dto /// public string? mbom_process_id { get; set; } - public List>? details { get; set; } + public List>? details { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs index 85dcfc0c..89421dde 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoFromOneListOutput.cs @@ -63,7 +63,35 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage } /// - /// 工单追溯二级列表输出类 + /// 工单追溯三级列表输出类 + /// + public class PrdMoFromThreeListOutput + { + /// + /// 任务单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? workline_id { get; set; } + + public string? batch { get; set; } + + public string process_id { get; set; } + public string process_name { get; set; } + + public string station_name { get; set; } + } + + /// + /// 工单追溯人输出类 /// public class PrdMoFromManListOutput { @@ -81,5 +109,31 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public DateTime? end_time { get; set; } + } + + /// + /// 工单追溯机输出类 + /// + public class PrdMoFromEquipListOutput + { + public string equip_code { get; set; } + public string mold_code { get; set; } + + } + + /// + /// 工单追溯料输出类 + /// + public class PrdMoFromMaterialListOutput + { + public string material_code { get; set; } + public string material_name { get; set; } + public string batch { get; set; } + public string supplier_name { get; set; } + public string instock_time { get; set; } + public string feeding_time { get; set; } + public string check_conclusion { get; set; } + + } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs index 4fd65c0f..18d44caf 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs @@ -64,5 +64,21 @@ public partial class PrdMaterialReceiptD : BaseEntity /// 已投料数量 /// public decimal feeding_num { get; set; } + + /// + /// 供应商 + /// + [SugarColumn(IsIgnore = true)] + public string supplier_id { get; set; } + /// + /// 入库时间 + /// + [SugarColumn(IsIgnore = true)] + public DateTime instock_time { get; set; } + /// + /// 检验结论 + /// + [SugarColumn(IsIgnore = true)] + public string check_conclusion { get; set; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 8b634316..10b21f06 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -101,10 +101,10 @@ namespace Tnb.ProductionMgr { feeding_id = prdFeedingH.id, material_receipt_detail_id = detail?.id, - material_id = item["material_id"], + material_id = item["material_id"]?.ToString(), num = num, - batch = item["batch"], - unit_id = item["unit_id"], + batch = item["batch"]?.ToString(), + unit_id = item["unit_id"]?.ToString(), carry_id = input.carry_id, status = "0", use_num = 0, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index b42dcfaf..f442741c 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -176,15 +176,18 @@ namespace Tnb.ProductionMgr list.Add(new PrdMaterialReceiptD { material_receipt_id = prdMaterialReceiptH.id, - material_id = item["material_id"], + material_id = item["material_id"]?.ToString(), num = Convert.ToDecimal(item["num"]), - batch = item["batch"], - unit_id = item["unit_id"], + batch = item["batch"]?.ToString(), + unit_id = item["unit_id"]?.ToString(), carry_id = input.carry_id, is_all_feeding = 0, - member_carry_id = item["member_carry_id"], - member_carry_code = item["member_carry_code"], + member_carry_id = item["member_carry_id"]?.ToString(), + member_carry_code = item["member_carry_code"]?.ToString(), feeding_num = 0, + supplier_id = item["supplier_id"]?.ToString(), + instock_time = (DateTime)item["instock_time"], + check_conclusion = item["check_conclusion"]?.ToString() }); } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 4c817ed4..29bcb5d6 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -461,7 +461,7 @@ namespace Tnb.ProductionMgr .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(!string.IsNullOrEmpty(mo_task_code),(a,b,c,d)=>a.mo_task_code.Contains(mo_task_code)) .WhereIF(ids!=null && ids.Count>0,(a,b,c,d)=>ids.Contains(a.id)) .Select((a, b, c, d) => new PrdMoFromTwoListOutput @@ -481,6 +481,56 @@ namespace Tnb.ProductionMgr } + /// + /// 工单追溯三级级列表 + /// + /// + /// + [HttpPost] + public async Task PrdMoFromThreeList(Dictionary dic) + { + string mo_task_id = dic.ContainsKey("mo_task_id") ? dic["mo_task_id"] : ""; + 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(); + } + + PrdMoTask prdMoTask = await _db.Queryable().SingleAsync(x => x.id == mo_task_id); + List processStations = await _db.Queryable().Where(x=>x.process_id==prdMoTask.process_id).ToListAsync(); + List orgIds = processStations.Select(x => x.id).ToList(); + List orgs = await _db.Queryable().Where(x=>x.Category==DictConst.RegionCategoryStationCode && x.DeleteMark==null).ToListAsync(); + return await _db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a,b,c)=>a.process_id==c.id) + .WhereIF(!string.IsNullOrEmpty(mo_task_id),(a,b,c)=>a.id==mo_task_id) + .WhereIF(!string.IsNullOrEmpty(mo_task_code),(a,b,c)=>a.mo_task_code.Contains(mo_task_code)) + .WhereIF(ids!=null && ids.Count>0,(a,b,c)=>ids.Contains(a.id)) + .Select((a, b, c) => + new PrdMoFromThreeListOutput + { + id = a.id, + mo_task_code = a.mo_task_code, + material_id = a.material_id, + material_code = b.code, + workline_id = a.workline_id, + material_name = b.name, + process_id = a.process_id, + process_name = c.process_name, + }).Mapper(x => + { + List orgId1 = orgs.Where(y => y.OrganizeIdTree.Contains(x.workline_id)).Select(y=>y.Id).ToList(); + string station_id = orgIds.Intersect(orgId1)?.FirstOrDefault(); + if (!string.IsNullOrEmpty(station_id)) + { + x.station_name = orgs.FirstOrDefault(y => y.Id == station_id)?.FullName; + } + }).ToListAsync(); + + } + /// /// 工单追溯人列表 /// @@ -514,6 +564,69 @@ namespace Tnb.ProductionMgr }) .ToListAsync(); } + + /// + /// 工单追溯机列表 + /// + /// + /// + [HttpPost] + public async Task PrdMoFromEquipList(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.eqp_id == b.id) + .LeftJoin((a,b,c)=>a.mold_id==c.id) + .WhereIF(!string.IsNullOrEmpty(mo_task_id), (a, b) => a.id == mo_task_id) + .WhereIF(ids!=null && ids.Count>0,(a,b)=>ids.Contains(a.id)) + .Select((a, b,c) => new PrdMoFromEquipListOutput() + { + equip_code = b.code, + mold_code = b.code, + }).ToListAsync(); + } + + /// + /// 工单追溯料列表 + /// + /// + /// + [HttpPost] + public async Task PrdMoFromMaterialList(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.material_id == b.id) + .LeftJoin((a,b,c)=>a.material_receipt_detail_id==c.id) + .LeftJoin((a,b,c,d)=>c.supplier_id==d.id) + .LeftJoin((a,b,c,d,e)=>a.feeding_id==e.id) + .WhereIF(!string.IsNullOrEmpty(mo_task_id), (a, b,c,d,e) => e.mo_task_id == mo_task_id) + .WhereIF(ids!=null && ids.Count>0,(a,b,c,d,e)=>ids.Contains(a.id)) + .Select((a,b,c,d,e)=>new PrdMoFromMaterialListOutput() + { + material_code = b.code, + material_name = b.name, + batch = a.batch, + supplier_name = d.supplier_name, + check_conclusion = c.check_conclusion, + instock_time = c.instock_time.ToString("yyyy-MM-dd HH:mm:ss"), + feeding_time = e.create_time==null ? "" : e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), + }).ToListAsync(); + } #endregion }