优化故障树展示,根据与门/或门更新父节点状态
This commit is contained in:
parent
95d5934a96
commit
111978d720
@ -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;
|
||||
}
|
||||
|
||||
|
@ -73,5 +73,5 @@ public interface IpcFaultTreeConfigMapper
|
||||
/**
|
||||
* 查询故障树查询
|
||||
*/
|
||||
public List<IpcFaultTreeShow> getFaultTreeShow(String partKey);
|
||||
public List<IpcFaultTreeConfig> getFaultTreeShow(String partKey);
|
||||
}
|
||||
|
@ -74,5 +74,5 @@ public interface IIpcFaultTreeConfigService
|
||||
/**
|
||||
* 查询故障树查询
|
||||
*/
|
||||
public List<IpcFaultTreeShow> getFaultTreeShow(String partKey);
|
||||
public List<IpcFaultTreeConfig> getFaultTreeShow(String partKey);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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`
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user