diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b53f0461..b73e6164 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1642,6 +1642,14 @@ namespace Tnb.ProductionMgr Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : ""; + List worklineIds = new List(); + List equipIds = new List(); + if (!string.IsNullOrEmpty(eqpId)) + { + worklineIds = await db.Queryable().Where(x => x.ParentId == eqpId && x.Category==DictConst.RegionCategoryWorklineCode && x.DeleteMark==null).Select(x=>x.Id).ToListAsync(); + equipIds = await db.Queryable().Where(x => x.equip_type_id == eqpId).Select(x => x.id).ToListAsync(); + } + var result = await db.Queryable() .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus) @@ -1651,7 +1659,9 @@ namespace Tnb.ProductionMgr .LeftJoin((a,b,c,d,e,f,g)=>a.workline_id==g.Id) .LeftJoin((a,b,c,d,e,f,g,h)=>a.eqp_id==h.id) .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) - .WhereIF(!string.IsNullOrEmpty(eqpId), (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count<=0 && worklineIds.Count<=0, (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .WhereIF(worklineIds.Count>0,(a, b, c, d)=>worklineIds.Contains(a.workline_id)) + .WhereIF(equipIds.Count>0,(a, b, c, d)=>equipIds.Contains(a.eqp_id)) .Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput { id = a.id,