修正
This commit is contained in:
parent
1a32d1c774
commit
42870e62cf
@ -335,6 +335,8 @@ namespace ZR.Service.MES.dev
|
||||
// All_device_type = new List<DeviceType> { line };
|
||||
//}
|
||||
All_device_type = FindAllLeafNodes(devicetype_id);
|
||||
DeviceType final_parent = FindFinalParentNode(devicetype_id);
|
||||
Workshop = final_parent.Name;
|
||||
List<LineDetail> LineDetailList = new List<LineDetail>();
|
||||
// 2 获取每个线下的所有设备
|
||||
if (All_device_type.Count > 0)
|
||||
@ -476,6 +478,31 @@ namespace ZR.Service.MES.dev
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于在父子节点对象中,根据输入的节点 ID 找到最终的父节点:
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
public DeviceType FindFinalParentNode(int nodeId)
|
||||
{
|
||||
DeviceType currentNode = Context.Queryable<DeviceType>().Where(n => n.Id == nodeId).First();
|
||||
|
||||
if (currentNode == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
DeviceType parentNode = Context.Queryable<DeviceType>().Where(n => n.Id == currentNode.ParentId).First();
|
||||
|
||||
while (parentNode != null)
|
||||
{
|
||||
currentNode = parentNode;
|
||||
parentNode = Context.Queryable<DeviceType>().Where(n => n.Id == currentNode.ParentId).First();
|
||||
}
|
||||
|
||||
return currentNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user