那么我现在要给这个部门树下加上所对应的巡检岗位,下面代码是加上巡检岗位的方法,请帮我修正一下 private void AddEquipTypeToNode(JzTreeNode item) { ObjectModel InspectionPostCls = ObjectHelper.GetObjectModel("巡检岗位类"); RelationModel postsAndInspection = ObjectHelper.GetRelationModel("部门信息与巡检岗位关系类"); string where = $"attr_{InspectionPostCls.GetAttr("SUB_REL_ID").RelateSelect.EscapeAttrID}='{item.id}'" + $" and {JzDefBasic.IsValid}=1"; List<ObjectModel> InspectionPostClsList = _baseBLL.GetObjListByWhere(InspectionPostCls, where); _baseBLL.GetTableBDataByObjA(postsAndInspection.ClassID, item.id); item.children = new List<JzTreeNode>(); foreach (var obj in InspectionPostClsList) { JzTreeNode node = new JzTreeNode(); node.id = obj.ObjectID; node.parentId = item.id; node.label = obj.GetAttrValue("MC"); item.children.Add(node); } }
时间: 2024-02-14 16:13:18 浏览: 167
根据代码,应该将 `AddEquipTypeToNode` 方法作为 `GetRoute` 方法中 `foreach` 循环的一部分,以便在遍历部门树时逐个添加巡检岗位信息。此外,还需要修改 `AddEquipTypeToNode` 方法的参数,将部门节点的 `id` 作为参数传入,以便查找该部门所对应的巡检岗位。
修改后的 `GetRoute` 方法代码如下:
```csharp
internal object GetRoute(ActionParaModel para)
{
var groupId = para.InputParas["groupId"].ToString();
ObjectModel xtCls = ObjectHelper.GetObjectModel("部门信息类");
string where = $"attr_{xtCls.GetAttr(JzDefAttribute.SubRelID).RelateSelect.EscapeAttrID}='{groupId}' and {JzDefBasic.IsValid}=1";
List<ObjectModel> xtList = _baseBLL.GetObjListByWhere(xtCls, where);
List<JzTreeNode> nodesList = new List<JzTreeNode>();
foreach (var xt in xtList)
{
JzTreeNode node = new JzTreeNode();
node.id = xt.ObjectID;
node.parentId = "0";
node.label = xt.GetAttrValue("BMMC");
AddEquipTypeToNode(node.id, node); // 添加巡检岗位信息
nodesList.Add(node);
}
return nodesList;
}
private void AddEquipTypeToNode(string deptId, JzTreeNode item)
{
ObjectModel InspectionPostCls = ObjectHelper.GetObjectModel("巡检岗位类");
RelationModel postsAndInspection = ObjectHelper.GetRelationModel("部门信息与巡检岗位关系类");
string where = $"attr_{postsAndInspection.GetAttr("OBJA_ID").RelateSelect.EscapeAttrID}='{deptId}' and {JzDefBasic.IsValid}=1";
List<ObjectModel> InspectionPostClsList = _baseBLL.GetObjListByWhere(InspectionPostCls, where);
item.children = new List<JzTreeNode>();
foreach (var obj in InspectionPostClsList)
{
JzTreeNode node = new JzTreeNode();
node.id = obj.ObjectID;
node.parentId = item.id;
node.label = obj.GetAttrValue("MC");
item.children.Add(node);
}
}
```
需要注意的是,以上代码仅为参考,具体实现还需要根据业务逻辑进行调整。
阅读全文