优化故障树展示,根据与门/或门更新父节点状态

This commit is contained in:
zhanghan11 2024-04-11 15:53:28 +08:00
parent 95d5934a96
commit 111978d720
6 changed files with 84 additions and 26 deletions

View File

@ -28,7 +28,7 @@ public class IpcFaultTreeConfig extends TreeEntity
/** 规则id */
@Excel(name = "规则id")
private Long alarmRuleConfigId;
private String alarmRuleConfigId;
/** 规则描述 */
@Excel(name = "规则描述")
@ -156,11 +156,11 @@ public class IpcFaultTreeConfig extends TreeEntity
return delFlag;
}
public Long getAlarmRuleConfigId() {
public String getAlarmRuleConfigId() {
return alarmRuleConfigId;
}
public void setAlarmRuleConfigId(Long alarmRuleConfigId) {
public void setAlarmRuleConfigId(String alarmRuleConfigId) {
this.alarmRuleConfigId = alarmRuleConfigId;
}

View File

@ -73,5 +73,5 @@ public interface IpcFaultTreeConfigMapper
/**
* 查询故障树查询
*/
public List<IpcFaultTreeShow> getFaultTreeShow(String partKey);
public List<IpcFaultTreeConfig> getFaultTreeShow(String partKey);
}

View File

@ -74,5 +74,5 @@ public interface IIpcFaultTreeConfigService
/**
* 查询故障树查询
*/
public List<IpcFaultTreeShow> getFaultTreeShow(String partKey);
public List<IpcFaultTreeConfig> getFaultTreeShow(String partKey);
}

View File

@ -120,7 +120,7 @@ public class IpcFaultTreeConfigServiceImpl implements IIpcFaultTreeConfigService
* 查询故障树
*/
@Override
public List<IpcFaultTreeShow> getFaultTreeShow(String partKey){
public List<IpcFaultTreeConfig> getFaultTreeShow(String partKey){
return ipcFaultTreeConfigMapper.getFaultTreeShow(partKey);
}
}

View File

@ -185,26 +185,31 @@
<result property="nodeShapeType" column="node_shape_type"/>
<result property="nodeFontColor" column="nodeFontColor"/>
</resultMap>
<select id="getFaultTreeShow" parameterType="string" resultMap="IpcFaultTreeShowResult">
<select id="getFaultTreeShow" parameterType="string" resultMap="IpcFaultTreeConfigResult">
SELECT a.node_id,
a.parent_id,
a.ancestors,
a.node_name label,
a.node_name,
a.order_num,
a.part_key,
a.icon_cls,
a.node_shape_type,
a.alarm_rule_config_description content,
a.icon_cls nodeDesc,
a.node_default_color,
a.node_alarm_color,
a.is_leaf,
a.status,
a.del_flag,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.alarm_rule_config_id,
a.alarm_rule_config_description,
CASE
WHEN b.num > 0 AND c.type='in_running' THEN
a.node_alarm_color
ELSE a.node_default_color
END nodeBorderColor,
CASE
WHEN b.num > 0 AND c.type='in_running' THEN
a.node_alarm_color
ELSE a.node_default_color
END nodeFontColor
'1'
ELSE '0'
END is_alarm
FROM (SELECT * FROM ipc_fault_tree_config WHERE STATUS = '0' AND part_key = #{partKey}) a
LEFT JOIN (SELECT rule_config_id, count(0) num
FROM `ipc_alarm_record`

View File

@ -22,7 +22,7 @@
>
<div
class="component-wrapper "
style="margin-left:3%;"
style="margin:0 3%;"
>
<vue-okr-tree
:loading="loading"
@ -66,11 +66,10 @@ export default {
getList() {
this.loading = true;
getFaultTreeShow(this.part).then((response) => {
this.treeData = this.handleTree(
response.data,
"nodeId",
"parentId"
)[0].children;
const nodes = this.handleTree(response.data, "nodeId", "parentId");
this.updateParentStatusBasedOnLogic(nodes);
console.log(nodes);
this.treeData = nodes[0].children;
this.loading = false;
});
},
@ -87,8 +86,8 @@ export default {
});
},
renderContent(h, node) {
console.log("h", h);
console.log("node", node);
// console.log("h", h);
// console.log("node", node);
let des = node.data.nodeDsc;
let iconCls = node.data.iconCls;
if (iconCls) {
@ -111,6 +110,60 @@ export default {
return <div class="org-chart-node-btn-text"></div>;
}
},
//
//
//
yumen(children) {
return children.every((child) => child.isAlarm === "1");
},
//
huomen(children) {
return children.some((child) => child.isAlarm === "1");
},
//
feimen(children) {
return children.every((child) => child.isAlarm === "0");
},
//
biaojuemen(children, threshold) {
const activeCount = children.filter(
(child) => child.isAlarm === "1"
).length;
const totalCount = children.length;
return activeCount / totalCount >= threshold;
},
//
updateParentStatusBasedOnLogic(nodes) {
nodes.forEach((node) => {
//
if (node.children && node.children.length > 0) {
this.updateParentStatusBasedOnLogic(node.children);
}
// icon_cls
if (node.children && node.children.length > 0) {
// 使
//
if (node.isAlarm === "0") {
switch (node.iconCls) {
case "icon-yumen":
node.isAlarm = this.yumen(node.children) ? "1" : "0";
break;
case "icon-huomen":
node.isAlarm = this.huomen(node.children) ? "1" : "0";
break;
default:
break;
}
}
}
node.label = node.nodeName;
node.nodeBorderColor =
node.isAlarm === "1" ? node.nodeAlarmColor : node.nodeDefaultColor;
node.nodeFontColor =
node.isAlarm === "1" ? node.nodeAlarmColor : node.nodeDefaultColor;
});
},
},
};
</script>