diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcFaultTreeConfig.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcFaultTreeConfig.java index d527eab..9e83a33 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcFaultTreeConfig.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/domain/IpcFaultTreeConfig.java @@ -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; } diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/mapper/IpcFaultTreeConfigMapper.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/mapper/IpcFaultTreeConfigMapper.java index 12e9006..1330199 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/mapper/IpcFaultTreeConfigMapper.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/mapper/IpcFaultTreeConfigMapper.java @@ -73,5 +73,5 @@ public interface IpcFaultTreeConfigMapper /** * 查询故障树查询 */ - public List getFaultTreeShow(String partKey); + public List getFaultTreeShow(String partKey); } diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/IIpcFaultTreeConfigService.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/IIpcFaultTreeConfigService.java index 3947411..a2201dc 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/IIpcFaultTreeConfigService.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/IIpcFaultTreeConfigService.java @@ -74,5 +74,5 @@ public interface IIpcFaultTreeConfigService /** * 查询故障树查询 */ - public List getFaultTreeShow(String partKey); + public List getFaultTreeShow(String partKey); } diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcFaultTreeConfigServiceImpl.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcFaultTreeConfigServiceImpl.java index ccdb951..9f5d248 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcFaultTreeConfigServiceImpl.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/service/impl/IpcFaultTreeConfigServiceImpl.java @@ -120,7 +120,7 @@ public class IpcFaultTreeConfigServiceImpl implements IIpcFaultTreeConfigService * 查询故障树 */ @Override - public List getFaultTreeShow(String partKey){ + public List getFaultTreeShow(String partKey){ return ipcFaultTreeConfigMapper.getFaultTreeShow(partKey); } } diff --git a/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcFaultTreeConfigMapper.xml b/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcFaultTreeConfigMapper.xml index dcd229e..57a81f3 100644 --- a/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcFaultTreeConfigMapper.xml +++ b/tzipc-server/tzipc-system/src/main/resources/mapper/ipc/IpcFaultTreeConfigMapper.xml @@ -185,26 +185,31 @@ - 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` diff --git a/tzipc-ui/src/views/ipc/faultTree/faultTreeShow.vue b/tzipc-ui/src/views/ipc/faultTree/faultTreeShow.vue index d820c79..fdc29b8 100644 --- a/tzipc-ui/src/views/ipc/faultTree/faultTreeShow.vue +++ b/tzipc-ui/src/views/ipc/faultTree/faultTreeShow.vue @@ -22,7 +22,7 @@ >
{ - 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
; } }, + + // 逻辑门判断 + // 定义逻辑函数 + // 与门 + 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; + }); + }, }, };