故障树管理功能提交

This commit is contained in:
zhanghan11 2024-04-02 19:06:44 +08:00
parent 549a753b2e
commit cc8c54515e
17 changed files with 1980 additions and 74 deletions

View File

@ -0,0 +1,32 @@
package com.inspur.web.controller.ipc;
import com.inspur.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/ipc/dataReceive")
public class IpcDataReceiveController {
/**
* 接收PLC数据
*/
@PostMapping("/plcData")
public AjaxResult plcData(@RequestBody Map<String, List<String>> map) {
System.out.println(map.toString());
return AjaxResult.success(1);
}
/**
* 接收温振传感器数据
*/
@PostMapping("/sensorData")
public AjaxResult sensorData(@RequestBody Map<String, List<String>> map) {
System.out.println(map.toString());
return AjaxResult.success(1);
}
}

View File

@ -0,0 +1,112 @@
package com.inspur.web.controller.ipc;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspur.common.annotation.Log;
import com.inspur.common.core.controller.BaseController;
import com.inspur.common.core.domain.AjaxResult;
import com.inspur.common.enums.BusinessType;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
import com.inspur.ipc.service.IIpcFaultTreeConfigService;
import com.inspur.common.utils.poi.ExcelUtil;
/**
* 故障树配置Controller
*
* @author inspur
* @date 2024-04-02
*/
@RestController
@RequestMapping("/ipc/faultTreeConfig")
public class IpcFaultTreeConfigController extends BaseController
{
@Autowired
private IIpcFaultTreeConfigService ipcFaultTreeConfigService;
/**
* 查询故障树配置列表
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:list')")
@GetMapping("/list")
public AjaxResult list(IpcFaultTreeConfig ipcFaultTreeConfig)
{
List<IpcFaultTreeConfig> list = ipcFaultTreeConfigService.selectIpcFaultTreeConfigList(ipcFaultTreeConfig);
return AjaxResult.success(list);
}
/**
* 导出故障树配置列表
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:export')")
@Log(title = "故障树配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IpcFaultTreeConfig ipcFaultTreeConfig)
{
List<IpcFaultTreeConfig> list = ipcFaultTreeConfigService.selectIpcFaultTreeConfigList(ipcFaultTreeConfig);
ExcelUtil<IpcFaultTreeConfig> util = new ExcelUtil<IpcFaultTreeConfig>(IpcFaultTreeConfig.class);
util.exportExcel(response, list, "故障树配置数据");
}
/**
* 获取故障树配置详细信息
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:query')")
@GetMapping(value = "/{nodeId}")
public AjaxResult getInfo(@PathVariable("nodeId") Long nodeId)
{
return AjaxResult.success(ipcFaultTreeConfigService.selectIpcFaultTreeConfigByNodeId(nodeId));
}
/**
* 校验是否存在子节点
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:query')")
@GetMapping(value = "/hasChild/{nodeId}")
public AjaxResult hasChild(@PathVariable("nodeId") Long nodeId)
{
return AjaxResult.success(ipcFaultTreeConfigService.hasChild(nodeId));
}
/**
* 新增故障树配置
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:add')")
@Log(title = "故障树配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody IpcFaultTreeConfig ipcFaultTreeConfig)
{
return toAjax(ipcFaultTreeConfigService.insertIpcFaultTreeConfig(ipcFaultTreeConfig));
}
/**
* 修改故障树配置
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:edit')")
@Log(title = "故障树配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody IpcFaultTreeConfig ipcFaultTreeConfig)
{
return toAjax(ipcFaultTreeConfigService.updateIpcFaultTreeConfig(ipcFaultTreeConfig));
}
/**
* 删除故障树配置
*/
@PreAuthorize("@ss.hasPermi('ipc:faultTreeConfig:remove')")
@Log(title = "故障树配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{nodeIds}")
public AjaxResult remove(@PathVariable Long[] nodeIds)
{
return toAjax(ipcFaultTreeConfigService.deleteIpcFaultTreeConfigByNodeIds(nodeIds));
}
}

View File

@ -109,7 +109,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage","/data/show/byPart/**").anonymous() .antMatchers("/login", "/register", "/captchaImage").anonymous()
// 数据接收接口允许匿名访问
.antMatchers("/ipc/dataReceive/plcData","/ipc/dataReceive/sensorData").permitAll()
// 静态资源可匿名访问 // 静态资源可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

View File

@ -83,6 +83,12 @@ public class IpcAlarmRecord extends BaseEntity {
@Excel(name = "报警描述") @Excel(name = "报警描述")
private String alarmDetail; private String alarmDetail;
/**
* 报警规则id
*/
@Excel(name = "报警规则id")
private Long ruleConfigId;
/** /**
* 状态 0 未处理 1 已处理 * 状态 0 未处理 1 已处理
*/ */
@ -199,6 +205,14 @@ public class IpcAlarmRecord extends BaseEntity {
return alarmDetail; return alarmDetail;
} }
public Long getRuleConfigId() {
return ruleConfigId;
}
public void setRuleConfigId(Long ruleConfigId) {
this.ruleConfigId = ruleConfigId;
}
public void setAlarmStatus(String alarmStatus) { public void setAlarmStatus(String alarmStatus) {
this.alarmStatus = alarmStatus; this.alarmStatus = alarmStatus;
} }
@ -226,7 +240,7 @@ public class IpcAlarmRecord extends BaseEntity {
public IpcAlarmRecord() { public IpcAlarmRecord() {
} }
public IpcAlarmRecord(String id, String partKey, String part, String nameKey, String name, String alarmData, String unit, String alarmLevel, String referenceName, String alarmDetail) { public IpcAlarmRecord(String id, String partKey, String part, String nameKey, String name, String alarmData, String unit, String alarmLevel, String referenceName, String alarmDetail,Long ruleConfigId) {
this.id = id; this.id = id;
this.partKey = partKey; this.partKey = partKey;
this.part = part; this.part = part;
@ -237,6 +251,7 @@ public class IpcAlarmRecord extends BaseEntity {
this.alarmLevel = alarmLevel; this.alarmLevel = alarmLevel;
this.referenceName = referenceName; this.referenceName = referenceName;
this.alarmDetail = alarmDetail; this.alarmDetail = alarmDetail;
this.ruleConfigId = ruleConfigId;
} }
@Override @Override

View File

@ -51,8 +51,8 @@ public class IpcAlarmRulesConfig extends BaseEntity
@Excel(name = "规则值2(参考标准为区间时需要)") @Excel(name = "规则值2(参考标准为区间时需要)")
private BigDecimal referenceValue2; private BigDecimal referenceValue2;
/** 规则值显示 */ /** 规则描述 */
@Excel(name = "规则值显示") @Excel(name = "规则描述")
private String referenceName; private String referenceName;
/** 判断规则 */ /** 判断规则 */

View File

@ -0,0 +1,205 @@
package com.inspur.ipc.domain;
import com.inspur.common.annotation.Excel;
import com.inspur.common.core.domain.TreeEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 故障树配置对象 ipc_fault_tree_config
*
* @author inspur
* @date 2024-04-02
*/
public class IpcFaultTreeConfig extends TreeEntity
{
private static final long serialVersionUID = 1L;
/** 节点id */
private Long nodeId;
/** 部门名称 */
@Excel(name = "节点名称")
private String nodeName;
/** 所属部位 */
@Excel(name = "所属部位")
private String partKey;
/** 规则id */
@Excel(name = "规则id")
private Long alarmRuleConfigId;
/** 规则描述 */
@Excel(name = "规则描述")
private String alarmRuleConfigDescription;
/** 节点图标 */
@Excel(name = "节点图标")
private String iconCls;
/** 节点形状 */
@Excel(name = "节点形状")
private String nodeShapeType;
/** 节点默认颜色 */
@Excel(name = "节点默认颜色")
private String nodeDefaultColor;
/** 节点报警颜色 */
@Excel(name = "节点报警颜色")
private String nodeAlarmColor;
/** 是否叶子节点 */
@Excel(name = "是否叶子节点")
private String isLeaf;
/** 是否报警 */
@Excel(name = "是否报警")
private String isAlarm;
/** 节点状态0正常 1停用 */
@Excel(name = "节点状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
public void setNodeId(Long nodeId)
{
this.nodeId = nodeId;
}
public Long getNodeId()
{
return nodeId;
}
public void setNodeName(String nodeName)
{
this.nodeName = nodeName;
}
public String getNodeName()
{
return nodeName;
}
public void setPartKey(String partKey)
{
this.partKey = partKey;
}
public String getPartKey()
{
return partKey;
}
public void setIconCls(String iconCls)
{
this.iconCls = iconCls;
}
public String getIconCls()
{
return iconCls;
}
public void setNodeShapeType(String nodeShapeType)
{
this.nodeShapeType = nodeShapeType;
}
public String getNodeShapeType()
{
return nodeShapeType;
}
public void setNodeDefaultColor(String nodeDefaultColor)
{
this.nodeDefaultColor = nodeDefaultColor;
}
public String getNodeDefaultColor()
{
return nodeDefaultColor;
}
public void setNodeAlarmColor(String nodeAlarmColor)
{
this.nodeAlarmColor = nodeAlarmColor;
}
public String getNodeAlarmColor()
{
return nodeAlarmColor;
}
public void setIsAlarm(String isAlarm)
{
this.isAlarm = isAlarm;
}
public String getIsAlarm()
{
return isAlarm;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
public Long getAlarmRuleConfigId() {
return alarmRuleConfigId;
}
public void setAlarmRuleConfigId(Long alarmRuleConfigId) {
this.alarmRuleConfigId = alarmRuleConfigId;
}
public String getAlarmRuleConfigDescription() {
return alarmRuleConfigDescription;
}
public void setAlarmRuleConfigDescription(String alarmRuleConfigDescription) {
this.alarmRuleConfigDescription = alarmRuleConfigDescription;
}
public String getIsLeaf() {
return isLeaf;
}
public void setIsLeaf(String isLeaf) {
this.isLeaf = isLeaf;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("nodeId", getNodeId())
.append("parentId", getParentId())
.append("ancestors", getAncestors())
.append("nodeName", getNodeName())
.append("orderNum", getOrderNum())
.append("partKey", getPartKey())
.append("iconCls", getIconCls())
.append("nodeShapeType", getNodeShapeType())
.append("nodeDefaultColor", getNodeDefaultColor())
.append("nodeAlarmColor", getNodeAlarmColor())
.append("isAlarm", getIsAlarm())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,69 @@
package com.inspur.ipc.mapper;
import java.util.List;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
/**
* 故障树配置Mapper接口
*
* @author inspur
* @date 2024-04-02
*/
public interface IpcFaultTreeConfigMapper
{
/**
* 查询故障树配置
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public IpcFaultTreeConfig selectIpcFaultTreeConfigByNodeId(Long nodeId);
/**
* 校验是否存在子节点
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public int hasChild(Long nodeId);
/**
* 查询故障树配置列表
*
* @param ipcFaultTreeConfig 故障树配置
* @return 故障树配置集合
*/
public List<IpcFaultTreeConfig> selectIpcFaultTreeConfigList(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 新增故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int insertIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 修改故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int updateIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 删除故障树配置
*
* @param nodeId 故障树配置主键
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeId(Long nodeId);
/**
* 批量删除故障树配置
*
* @param nodeIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeIds(Long[] nodeIds);
}

View File

@ -0,0 +1,70 @@
package com.inspur.ipc.service;
import java.util.List;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
/**
* 故障树配置Service接口
*
* @author inspur
* @date 2024-04-02
*/
public interface IIpcFaultTreeConfigService
{
/**
* 查询故障树配置
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public IpcFaultTreeConfig selectIpcFaultTreeConfigByNodeId(Long nodeId);
/**
* 校验是否存在子节点
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
public boolean hasChild(Long nodeId);
/**
* 查询故障树配置列表
*
* @param ipcFaultTreeConfig 故障树配置
* @return 故障树配置集合
*/
public List<IpcFaultTreeConfig> selectIpcFaultTreeConfigList(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 新增故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int insertIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 修改故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
public int updateIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig);
/**
* 批量删除故障树配置
*
* @param nodeIds 需要删除的故障树配置主键集合
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeIds(Long[] nodeIds);
/**
* 删除故障树配置信息
*
* @param nodeId 故障树配置主键
* @return 结果
*/
public int deleteIpcFaultTreeConfigByNodeId(Long nodeId);
}

View File

@ -0,0 +1,105 @@
package com.inspur.ipc.service.impl;
import java.util.List;
import com.inspur.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.inspur.ipc.mapper.IpcFaultTreeConfigMapper;
import com.inspur.ipc.domain.IpcFaultTreeConfig;
import com.inspur.ipc.service.IIpcFaultTreeConfigService;
/**
* 故障树配置Service业务层处理
*
* @author inspur
* @date 2024-04-02
*/
@Service
public class IpcFaultTreeConfigServiceImpl implements IIpcFaultTreeConfigService
{
@Autowired
private IpcFaultTreeConfigMapper ipcFaultTreeConfigMapper;
/**
* 查询故障树配置
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
@Override
public IpcFaultTreeConfig selectIpcFaultTreeConfigByNodeId(Long nodeId)
{
return ipcFaultTreeConfigMapper.selectIpcFaultTreeConfigByNodeId(nodeId);
}
/**
* 校验是否存在子节点
*
* @param nodeId 故障树配置主键
* @return 故障树配置
*/
@Override
public boolean hasChild(Long nodeId){
return ipcFaultTreeConfigMapper.hasChild(nodeId) > 0;
}
/**
* 查询故障树配置列表
*
* @param ipcFaultTreeConfig 故障树配置
* @return 故障树配置
*/
@Override
public List<IpcFaultTreeConfig> selectIpcFaultTreeConfigList(IpcFaultTreeConfig ipcFaultTreeConfig)
{
return ipcFaultTreeConfigMapper.selectIpcFaultTreeConfigList(ipcFaultTreeConfig);
}
/**
* 新增故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
@Override
public int insertIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig)
{
ipcFaultTreeConfig.setCreateTime(DateUtils.getNowDate());
return ipcFaultTreeConfigMapper.insertIpcFaultTreeConfig(ipcFaultTreeConfig);
}
/**
* 修改故障树配置
*
* @param ipcFaultTreeConfig 故障树配置
* @return 结果
*/
@Override
public int updateIpcFaultTreeConfig(IpcFaultTreeConfig ipcFaultTreeConfig)
{
ipcFaultTreeConfig.setUpdateTime(DateUtils.getNowDate());
return ipcFaultTreeConfigMapper.updateIpcFaultTreeConfig(ipcFaultTreeConfig);
}
/**
* 批量删除故障树配置
*
* @param nodeIds 需要删除的故障树配置主键
* @return 结果
*/
@Override
public int deleteIpcFaultTreeConfigByNodeIds(Long[] nodeIds)
{
return ipcFaultTreeConfigMapper.deleteIpcFaultTreeConfigByNodeIds(nodeIds);
}
/**
* 删除故障树配置信息
*
* @param nodeId 故障树配置主键
* @return 结果
*/
@Override
public int deleteIpcFaultTreeConfigByNodeId(Long nodeId)
{
return ipcFaultTreeConfigMapper.deleteIpcFaultTreeConfigByNodeId(nodeId);
}
}

View File

@ -86,7 +86,7 @@ public class IpcUtil {
if (judgeAlarm(map.get(rulesConfig.getNameKey()), rulesConfig.getReferenceValue1(), rulesConfig.getReferenceValue2(), rulesConfig.getReferenceCon())) { if (judgeAlarm(map.get(rulesConfig.getNameKey()), rulesConfig.getReferenceValue1(), rulesConfig.getReferenceValue2(), rulesConfig.getReferenceCon())) {
// 报警数据 // 报警数据
map.put("isAlarm", 1); map.put("isAlarm", 1);
IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(),rulesConfig.getPartKey(), rulesConfig.getPart(), rulesConfig.getNameKey(), rulesConfig.getName(), String.valueOf(map.get(rulesConfig.getNameKey())), rulesConfig.getUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getAlarmDetail()); IpcAlarmRecord ipcAlarmRecord = new IpcAlarmRecord(IdUtils.fastSimpleUUID(),rulesConfig.getPartKey(), rulesConfig.getPart(), rulesConfig.getNameKey(), rulesConfig.getName(), String.valueOf(map.get(rulesConfig.getNameKey())), rulesConfig.getUnit(), rulesConfig.getAlarmLevel(), rulesConfig.getReferenceName(), rulesConfig.getAlarmDetail(),rulesConfig.getId());
returnList.add(ipcAlarmRecord); returnList.add(ipcAlarmRecord);
} else { } else {
// 正常数据 // 正常数据

View File

@ -107,11 +107,11 @@
<insert id="batchInsertIpcAlarmRecord" parameterType="com.inspur.ipc.domain.IpcAlarmRecord"> <insert id="batchInsertIpcAlarmRecord" parameterType="com.inspur.ipc.domain.IpcAlarmRecord">
insert into ipc_alarm_record insert into ipc_alarm_record
(id,part_key,part,name_key,name,alarm_data,unit,alarm_level,alarm_time,reference_name,alarm_detail,alarm_status) (id,part_key,part,name_key,name,alarm_data,unit,alarm_level,alarm_time,reference_name,alarm_detail,alarm_status,rule_config_id)
values values
<foreach item="item" collection="list" separator=","> <foreach item="item" collection="list" separator=",">
(#{item.id}, #{item.partKey}, #{item.part},#{item.nameKey},#{item.name},#{item.alarmData}, #{item.unit}, (#{item.id}, #{item.partKey}, #{item.part},#{item.nameKey},#{item.name},#{item.alarmData}, #{item.unit},
#{item.alarmLevel},sysdate(),#{item.referenceName},#{item.alarmDetail},'0') #{item.alarmLevel},sysdate(),#{item.referenceName},#{item.alarmDetail},'0',#{item.ruleConfigId})
</foreach> </foreach>
; ;
</insert> </insert>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.inspur.ipc.mapper.IpcFaultTreeConfigMapper">
<resultMap type="com.inspur.ipc.domain.IpcFaultTreeConfig" id="IpcFaultTreeConfigResult">
<result property="nodeId" column="node_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="nodeName" column="node_name" />
<result property="orderNum" column="order_num" />
<result property="partKey" column="part_key" />
<result property="iconCls" column="icon_cls" />
<result property="nodeShapeType" column="node_shape_type" />
<result property="nodeDefaultColor" column="node_default_color" />
<result property="nodeAlarmColor" column="node_alarm_color" />
<result property="isLeaf" column="is_leaf" />
<result property="isAlarm" column="is_alarm" />
<result property="alarmRuleConfigId" column="alarm_rule_config_id" />
<result property="alarmRuleConfigDescription" column="alarm_rule_config_description" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectIpcFaultTreeConfigVo">
select node_id, parent_id, ancestors, node_name, order_num, part_key, icon_cls, node_shape_type, node_default_color, node_alarm_color, is_leaf,is_alarm, status, del_flag, create_by, create_time, update_by, update_time,alarm_rule_config_id,alarm_rule_config_description from ipc_fault_tree_config
</sql>
<select id="selectIpcFaultTreeConfigList" parameterType="com.inspur.ipc.domain.IpcFaultTreeConfig" resultMap="IpcFaultTreeConfigResult">
<include refid="selectIpcFaultTreeConfigVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
<if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="partKey != null and partKey != ''"> and part_key = #{partKey}</if>
<if test="iconCls != null and iconCls != ''"> and icon_cls = #{iconCls}</if>
<if test="nodeShapeType != null and nodeShapeType != ''"> and node_shape_type = #{nodeShapeType}</if>
<if test="nodeDefaultColor != null and nodeDefaultColor != ''"> and node_default_color = #{nodeDefaultColor}</if>
<if test="nodeAlarmColor != null and nodeAlarmColor != ''"> and node_alarm_color = #{nodeAlarmColor}</if>
<if test="isAlarm != null and isAlarm != ''"> and is_alarm = #{isAlarm}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectIpcFaultTreeConfigByNodeId" parameterType="Long" resultMap="IpcFaultTreeConfigResult">
<include refid="selectIpcFaultTreeConfigVo"/>
where node_id = #{nodeId}
</select>
<select id="hasChild" parameterType="Long" resultType="int">
select count(0) from ipc_fault_tree_config where parent_id = #{nodeId}
</select>
<insert id="insertIpcFaultTreeConfig" parameterType="com.inspur.ipc.domain.IpcFaultTreeConfig" useGeneratedKeys="true" keyProperty="nodeId">
insert into ipc_fault_tree_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="ancestors != null">ancestors,</if>
<if test="nodeName != null">node_name,</if>
<if test="orderNum != null">order_num,</if>
<if test="partKey != null">part_key,</if>
<if test="iconCls != null">icon_cls,</if>
<if test="nodeShapeType != null">node_shape_type,</if>
<if test="nodeDefaultColor != null">node_default_color,</if>
<if test="nodeAlarmColor != null">node_alarm_color,</if>
<if test="isLeaf != null">is_leaf,</if>
<if test="isAlarm != null">is_alarm,</if>
<if test="status != null">status,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="alarmRuleConfigId != null">alarm_rule_config_id,</if>
<if test="alarmRuleConfigDescription != null">alarm_rule_config_description,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="nodeName != null">#{nodeName},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="partKey != null">#{partKey},</if>
<if test="iconCls != null">#{iconCls},</if>
<if test="nodeShapeType != null">#{nodeShapeType},</if>
<if test="nodeDefaultColor != null">#{nodeDefaultColor},</if>
<if test="nodeAlarmColor != null">#{nodeAlarmColor},</if>
<if test="isLeaf != null">#{isLeaf},</if>
<if test="isAlarm != null">#{isAlarm},</if>
<if test="status != null">#{status},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="alarmRuleConfigId != null">#{alarmRuleConfigId},</if>
<if test="alarmRuleConfigDescription != null">#{alarmRuleConfigDescription},</if>
</trim>
</insert>
<update id="updateIpcFaultTreeConfig" parameterType="com.inspur.ipc.domain.IpcFaultTreeConfig">
update ipc_fault_tree_config
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="nodeName != null">node_name = #{nodeName},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="partKey != null">part_key = #{partKey},</if>
<if test="iconCls != null">icon_cls = #{iconCls},</if>
<if test="nodeShapeType != null">node_shape_type = #{nodeShapeType},</if>
<if test="nodeDefaultColor != null">node_default_color = #{nodeDefaultColor},</if>
<if test="nodeAlarmColor != null">node_alarm_color = #{nodeAlarmColor},</if>
<if test="isLeaf != null">is_leaf = #{isLeaf},</if>
<if test="isAlarm != null">is_alarm = #{isAlarm},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="alarmRuleConfigId != null">alarm_rule_config_id = #{alarmRuleConfigId},</if>
<if test="alarmRuleConfigDescription != null">alarm_rule_config_description = #{alarmRuleConfigDescription},</if>
</trim>
where node_id = #{nodeId}
</update>
<delete id="deleteIpcFaultTreeConfigByNodeId" parameterType="Long">
delete from ipc_fault_tree_config where node_id = #{nodeId}
</delete>
<delete id="deleteIpcFaultTreeConfigByNodeIds" parameterType="String">
delete from ipc_fault_tree_config where node_id in
<foreach item="nodeId" collection="array" open="(" separator="," close=")">
#{nodeId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,52 @@
import request from "@/utils/request";
// 查询故障树配置列表
export function listFaultTreeConfig(query) {
return request({
url: "/ipc/faultTreeConfig/list",
method: "get",
params: query,
});
}
// 查询故障树配置详细
export function getFaultTreeConfig(nodeId) {
return request({
url: "/ipc/faultTreeConfig/" + nodeId,
method: "get",
});
}
// 查询是否有子节点
export function selectHasChild(nodeId) {
return request({
url: "/ipc/faultTreeConfig/hasChild/" + nodeId,
method: "get",
});
}
// 新增故障树配置
export function addFaultTreeConfig(data) {
return request({
url: "/ipc/faultTreeConfig",
method: "post",
data: data,
});
}
// 修改故障树配置
export function updateFaultTreeConfig(data) {
return request({
url: "/ipc/faultTreeConfig",
method: "put",
data: data,
});
}
// 删除故障树配置
export function delFaultTreeConfig(nodeId) {
return request({
url: "/ipc/faultTreeConfig/" + nodeId,
method: "delete",
});
}

View File

@ -0,0 +1,771 @@
<template>
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item
label="部门名称"
prop="nodeName"
>
<el-input
v-model="queryParams.nodeName"
placeholder="请输入部门名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item
label="节点状态"
prop="status"
>
<el-select
v-model="queryParams.status"
placeholder="请选择节点状态"
clearable
>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetQuery"
>重置</el-button>
</el-form-item>
</el-form>
<el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['ipc:faultTreeConfig:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="faultTreeConfigList"
row-key="nodeId"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column
label="部门名称"
align="center"
prop="nodeName"
show-overflow-tooltip
/>
<el-table-column
label="显示顺序"
align="center"
prop="orderNum"
width="100"
show-overflow-tooltip
/>
<!-- <el-table-column
label="所属部位"
align="center"
prop="partKey"
show-overflow-tooltip
/>-->
<el-table-column
label="节点图标"
align="center"
prop="iconCls"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_icon"
:value="scope.row.iconCls"
/>
</template>
</el-table-column>
<el-table-column
label="节点形状"
align="center"
prop="nodeShapeType"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_shape"
:value="scope.row.nodeShapeType"
/>
</template>
</el-table-column>
<el-table-column
label="节点默认颜色"
align="center"
prop="nodeDefaultColor"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_default_color"
:value="scope.row.nodeDefaultColor"
/>
</template>
</el-table-column>
<el-table-column
label="节点报警颜色"
align="center"
prop="nodeAlarmColor"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.node_alarm_color"
:value="scope.row.nodeAlarmColor"
/>
</template>
</el-table-column>
<el-table-column
label="节点状态"
align="center"
prop="status"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.sys_normal_disable"
:value="scope.row.status"
/>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['ipc:faultTreeConfig:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['ipc:faultTreeConfig:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['ipc:faultTreeConfig:remove']"
v-if="scope.row.parentId != 0"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改故障树配置对话框 -->
<el-dialog
:title="title"
:visible.sync="open"
width="800px"
append-to-body
>
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="80px"
>
<el-row>
<el-col :span="12">
<el-form-item
label="节点名称"
prop="nodeName"
>
<el-input
v-model="form.nodeName"
placeholder="请输入节点名称"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="父节点"
prop="parentId"
v-if="form.parentId != 0"
>
<treeselect
v-model="parentId"
:options="faultTreeConfigOptions"
:normalizer="normalizer"
placeholder="请选择父节点id"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="显示顺序"
prop="orderNum"
>
<el-input-number
v-model="form.orderNum"
:max=100
:min=0
placeholder="请输入显示顺序"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="所属部位"
prop="partKey"
>
<span class="color-green">
{{ labelShow(monitorPartList,form.partKey) }}
</span>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="节点图标"
prop="iconCls"
>
<el-select
v-model="form.iconCls"
placeholder="请选择节点图标"
>
<el-option
v-for="dict in dict.type.node_icon"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="节点形状"
prop="nodeShapeType"
>
<el-select
v-model="form.nodeShapeType"
placeholder="请选择节点形状"
>
<el-option
v-for="dict in dict.type.node_shape"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="节点默认颜色"
prop="nodeDefaultColor"
>
<el-select
v-model="form.nodeDefaultColor"
placeholder="请选择节点默认颜色"
>
<el-option
v-for="dict in dict.type.node_default_color"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="节点报警颜色"
prop="nodeAlarmColor"
>
<el-select
v-model="form.nodeAlarmColor"
placeholder="请选择节点报警颜色"
>
<el-option
v-for="dict in dict.type.node_alarm_color"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
label="节点状态"
prop="status"
>
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="是否叶子节点"
prop="isLeaf"
>
<el-radio-group v-model="form.isLeaf">
<el-radio
@change="validateIsLeaf"
v-for="dict in dict.type.is_leaf"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="isShowRuleConfig">
<el-col :span="12">
<el-form-item label="报警规则描述">
<span class="color-red">{{ form.alarmRuleConfigDescription }}</span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="alarmRuleConfigId">
<el-button
type="primary"
@click="selectAlarmRule"
>选择报警规则</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submitForm"
> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<RuleConfigDialog
:partKey="form.partKey"
:openRuleDia="openRuleDia"
@ruleDataReturn="ruleDataReturn"
@closeRuleDialog="closeRuleDialog"
></RuleConfigDialog>
</div>
</template>
<script>
import {
listFaultTreeConfig,
getFaultTreeConfig,
delFaultTreeConfig,
addFaultTreeConfig,
updateFaultTreeConfig,
selectHasChild,
} from "@/api/ipc/faultTreeConfig";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { getFields } from "@/api/ipc/monitorFields";
import RuleConfigDialog from "@/views/ipc/faultTree/ruleConfigDialog";
export default {
name: "FaultTreeConfig",
dicts: [
"node_default_color",
"sys_normal_disable",
"node_icon",
"node_alarm_color",
"node_shape",
"is_leaf",
],
components: {
Treeselect,
RuleConfigDialog,
},
data() {
return {
//
openRuleDia: false,
//
isShowRuleConfig: false,
//
monitorPartList: [],
//
loading: true,
//
showSearch: true,
//
faultTreeConfigList: [],
//
faultTreeConfigOptions: [],
//
faultData: [],
//
title: "",
//
open: false,
//
isExpandAll: true,
//
refreshTable: true,
//
queryParams: {
parentId: null,
ancestors: null,
nodeName: null,
orderNum: null,
partKey: null,
iconCls: null,
nodeShapeType: null,
nodeDefaultColor: null,
nodeAlarmColor: null,
isAlarm: null,
status: null,
},
//
form: {},
parentId: "0",
//
rules: {
nodeName: [
{ required: true, message: "节点名称不能为空", trigger: "blur" },
{ max: 20, message: "节点名称长度不能大于20", trigger: "blur" },
],
parentId: [
{ required: true, message: "父节点不能为空", trigger: "blur" },
],
iconCls: [
{ required: true, message: "请选择节点图标", trigger: "blur" },
],
nodeShapeType: [
{ required: true, message: "请选择节点行政", trigger: "blur" },
],
nodeDefaultColor: [
{ required: true, message: "请选择节点默认颜色", trigger: "blur" },
],
nodeAlarmColor: [
{ required: true, message: "请选择节点报警颜色", trigger: "blur" },
],
status: [
{ required: true, message: "请选择节点状态", trigger: "blur" },
],
isLeaf: [
{ required: true, message: "请选择是否子节点", trigger: "blur" },
],
alarmRuleConfigId: [
{ validator: this.validateAlarmRuleConfigId, trigger: "change" },
],
},
};
},
watch: {
parentId: {
deep: true,
handler(val) {
this.resetRule();
const node = this.faultData.find((item) => item.nodeId == val);
if (node && node.partKey) {
this.form.partKey = node.partKey;
} else {
this.form.partKey = "";
}
this.form.parentId = val;
},
},
},
created() {
this.getMonitorPartList();
this.getTreeselect();
this.getList();
},
methods: {
/** 选择报警规则 */
selectAlarmRule() {
if (this.form.partKey) {
this.openRuleDialog();
} else {
this.$modal.msgError("请先选择父节点");
}
},
/** 打开规则选择弹窗 */
openRuleDialog() {
this.openRuleDia = true;
},
/** 关闭规则选择弹窗 */
closeRuleDialog() {
this.openRuleDia = false;
},
/** 规则选择弹窗数据返回 */
ruleDataReturn(data) {
this.form.alarmRuleConfigDescription = data.referenceName;
this.form.alarmRuleConfigId = data.id;
this.closeRuleDialog();
},
/** 报警规则校验 */
validateAlarmRuleConfigId(rule, value, callback) {
if (this.form.isLeaf == "1" && !value) {
return callback(new Error("请选择报警规则配置"));
} else {
return callback();
}
},
/** 叶子节点校验 */
validateIsLeaf() {
if (this.form.isLeaf == "1") {
if (this.form.nodeId) {
selectHasChild(this.form.nodeId).then((response) => {
//
if (response.data) {
this.$modal.msgError(
"该节点下存在子节点,不允许设置为叶子节点!"
);
this.isShowRuleConfig = false;
this.resetRule();
this.form.isLeaf = "0";
} else {
this.isShowRuleConfig = true;
}
});
} else {
this.isShowRuleConfig = true;
}
} else {
this.isShowRuleConfig = false;
this.resetRule();
}
},
/** 根据value获取label */
labelShow(fieldList, fieldValue) {
const field = fieldList.find((item) => item.fieldValue == fieldValue);
return field && field.fieldLabel ? field.fieldLabel : "";
},
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
})
.catch((error) => {
console.log(error);
});
},
/** 查询故障树配置列表 */
getList() {
this.loading = true;
listFaultTreeConfig(this.queryParams).then((response) => {
this.faultTreeConfigList = this.handleTree(
response.data,
"nodeId",
"parentId"
);
this.loading = false;
});
},
/** 转换故障树配置数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.nodeId,
label: node.nodeName,
children: node.children,
};
},
/** 查询故障树配置下拉树结构 */
getTreeselect() {
listFaultTreeConfig().then((response) => {
// this.faultTreeConfigOptions = [];
// const data = { nodeId: 0, nodeName: "", children: [] };
// data.children = this.handleTree(response.data, "nodeId", "parentId");
// this.faultTreeConfigOptions.push(data);
this.faultData = response.data;
this.faultTreeConfigOptions = this.handleTree(
response.data,
"nodeId",
"parentId"
);
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.parentId = null;
this.isShowRuleConfig = false;
this.form = {
nodeId: null,
parentId: null,
ancestors: null,
nodeName: null,
orderNum: null,
partKey: null,
iconCls: null,
nodeShapeType: null,
nodeDefaultColor: null,
nodeAlarmColor: null,
isAlarm: null,
status: "0",
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
isLeaf: "0",
alarmRuleConfigId: null,
alarmRuleConfigDescription: "",
};
this.resetForm("form");
},
//
resetRule() {
this.form.alarmRuleConfigId = null;
this.form.alarmRuleConfigDescription = "";
},
/** 搜索按钮操作 */
handleQuery() {
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
this.getTreeselect();
if (row != null && row.nodeId) {
this.parentId = row.nodeId;
} else {
this.parentId = null;
}
this.open = true;
this.title = "添加故障树配置";
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.getTreeselect();
if (row != null) {
this.parentId = row.parentId;
}
getFaultTreeConfig(row.nodeId).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改故障树配置";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.nodeId != null) {
updateFaultTreeConfig(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addFaultTreeConfig(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal
.confirm('是否确认删除故障树配置编号为"' + row.nodeId + '"的数据项?')
.then(function () {
return delFaultTreeConfig(row.nodeId);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
},
};
</script>
<style scoped>
.el-input-number,
.el-select {
width: 100%;
}
.color-green {
color: green;
}
.color-red {
color: red;
}
</style>

View File

@ -0,0 +1,200 @@
<template>
<div>
<el-select
v-model="part"
placeholder="请选择监测部位"
@change="getList()"
>
<el-option
v-for="field in monitorPartList"
:key="field.fieldValue"
:label="field.fieldLabel"
:value="field.fieldValue"
/>
</el-select>
<div class="component-wrapper">
<vue-okr-tree
:data="testData"
show-collapsable
default-expand-all
:node-btn-content="renderContent"
></vue-okr-tree>
</div>
</div>
</template>
<script>
import { VueOkrTree } from "@/components/VueOkrTree/index.js";
import { getFields } from "@/api/ipc/monitorFields";
import _ from "lodash";
export default {
name: "faultTreeShow",
components: {
VueOkrTree,
},
data() {
return {
//
monitorPartList: [],
part: "",
testData: [
{
label: "xxx科技有有限公司",
content: "这是一个有活力的公司",
nodeDsc: "智",
iconCls: "icon-yumen",
nodeBorderColor: "#ddd",
children: [
{
label: "产品研发部",
content: "这是一个有活力的产品研发部",
nodeDsc: "材",
iconCls: "icon-huomen",
nodeBorderColor: "#000",
children: [
{
label: "研发-前端",
content: "这是一个有活力的研发-前端",
nodeBorderColor: "black",
nodeShapeType: "rectangle",
},
{
label: "研发-后端",
content: "这是一个有活力的研发-后端",
nodeShapeType: "trigle",
nodeBorderColor: "black",
nodeBorderColor: "red",
nodeFontColor: "#00FF00",
},
{
label: "UI 设计",
content: "这是一个有活力的UI 设计",
nodeShapeType: "trigleReverse",
nodeBorderColor: "red",
nodeFontColor: "green",
},
],
},
{
label: "销售部",
content: "这是一个有活力的销售部",
nodeDsc: "慧",
iconCls: "icon-jinmen",
nodeBorderColor: "#00FF00",
children: [
{
label: "销售一部",
content: "这是一个有活力的销售一部",
nodeBorderColor: "#FF0000",
nodeShapeType: "circle",
nodeFontColor: "red",
nodeBorderColor: "red",
children: [
{
label: "销售一部",
content: "这是一个有活力的销售一部",
nodeBorderColor: "#FF0000",
nodeShapeType: "circle",
nodeFontColor: "red",
nodeBorderColor: "red",
iconCls: "icon-jinmen",
},
],
},
{
label: "销售二部",
content: "这是一个有活力的销售二部",
nodeBorderColor: "red",
nodeShapeType: "diamond",
nodeBorderColor: "red",
},
],
},
{
label: "财务部",
content: "这是一个有活力的财务部",
nodeBorderColor: "#FF0000",
},
],
},
],
};
},
created() {
this.getMonitorPartList();
},
methods: {
/** 查询监测部位列表 */
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
this.part = this.monitorPartList[0].fieldValue;
// this.getList();
})
.catch((error) => {
console.log(error);
});
},
renderContent(h, node) {
console.log("h", h);
console.log("node", node);
let des = node.data.nodeDsc;
let iconCls = node.data.iconCls;
if (iconCls) {
return this.$createElement(
"p",
{
class: "org-chart-node-btn-text iconfont " + iconCls,
},
""
);
} else if (des) {
return this.$createElement(
"p",
{
class: "org-chart-node-btn-text",
},
des
);
} else {
return <div class="org-chart-node-btn-text"></div>;
}
},
},
};
</script>
<style>
.org-chart-node-label .org-chart-node-btn {
border-color: transparent !important;
box-shadow: none !important;
/* margin-top: 20px !important; */
}
.org-chart-node-children {
/* padding-top: 40px !important; */
}
.org-chart-node-btn-text.iconfont.icon-connect {
font-size: 18px;
padding: 0;
background: transparent;
top: -12px;
}
/**按钮文 */
.org-chart-node-btn-text {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #fff;
border-radius: 50%;
font-size: 12px;
display: flex;
align-items: center;
justify-content: center;
color: #909090;
z-index: 2;
}
</style>

View File

@ -0,0 +1,198 @@
<template>
<div class="app-container">
<el-dialog
:title="title"
:visible.sync="openRuleDia"
width="800px"
append-to-body
>
<el-table
v-loading="loading"
:data="configList"
@row-dblclick="checkSelect"
>
<el-table-column
label="规则描述"
align="center"
prop="referenceName"
show-overflow-tooltip
/>
<el-table-column
label="监测部位"
align="center"
prop="part"
show-overflow-tooltip
>
<template slot-scope="scope">
{{ labelShow(monitorPartList,scope.row.partKey) }}
</template>
</el-table-column>
<el-table-column
label="参数名称"
align="center"
prop="name"
show-overflow-tooltip
>
<template slot-scope="scope">
{{ labelShow(monitorParamsList,scope.row.nameKey) }}
</template>
</el-table-column>
<el-table-column
label="报警描述"
align="center"
prop="alarmDetail"
show-overflow-tooltip
/>
<el-table-column
label="报警等级"
align="center"
prop="alarmLevel"
show-overflow-tooltip
>
<template slot-scope="scope">
<dict-tag
:options="dict.type.alarm_level"
:value="scope.row.alarmLevel"
/>
</template>
</el-table-column>
</el-table>
<span class="color-red">双击选中规则</span>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<div
slot="footer"
class="dialog-footer"
>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listConfig } from "@/api/ipc/rulesConfig";
import { getFields } from "@/api/ipc/monitorFields";
export default {
name: "RuleConfigDialog",
dicts: ["alarm_level", "judge_rules"],
props: {
partKey: {
type: String,
default: null,
},
openRuleDia: {
type: Boolean,
default: false,
},
},
data() {
return {
//
monitorPartList: [],
monitorParamsList: [],
//
loading: true,
//
showSearch: true,
//
total: 0,
//
configList: [],
//
title: "报警规则选择",
//
queryParams: {
pageNum: 1,
pageSize: 10,
partKey: null,
},
};
},
watch: {
partKey: {
deep: true,
handler(val) {
this.getList();
},
},
},
created() {
this.getMonitorPartList();
this.getPlcMonitorParamsList();
this.getSensorMonitorParamsList();
this.getList();
},
methods: {
/** 确认选中 */
checkSelect(row, column, event) {
this.$emit("ruleDataReturn", row);
},
//
cancel() {
this.$emit("closeRuleDialog");
},
/** 根据value获取label */
labelShow(fieldList, fieldValue) {
const field = fieldList.find((item) => item.fieldValue == fieldValue);
return field && field.fieldLabel ? field.fieldLabel : "";
},
getMonitorPartList() {
getFields("monitor_part")
.then((res) => {
this.monitorPartList = res.data;
})
.catch((error) => {
console.log(error);
});
},
getPlcMonitorParamsList() {
getFields("plc_monitor_params")
.then((res) => {
this.monitorParamsList = this.monitorParamsList.concat(res.data);
})
.catch((error) => {
console.log(error);
});
},
getSensorMonitorParamsList() {
getFields("sensor_monitor_params")
.then((res) => {
this.monitorParamsList = this.monitorParamsList.concat(res.data);
})
.catch((error) => {
console.log(error);
});
},
/** 查询告警规则配置列表 */
getList() {
this.loading = true;
this.queryParams.partKey = this.partKey;
listConfig(this.queryParams).then((response) => {
this.configList = response.rows;
this.total = response.total;
this.loading = false;
});
},
},
};
</script>
<style scoped>
.el-input-number,
.el-select {
width: 100%;
}
.color-green {
color: green;
}
</style>
<style scoped>
.color-red {
color: red;
}
</style>

View File

@ -72,63 +72,9 @@
>重置</el-button> >重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- <el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['ipc:config:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['ipc:config:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['ipc:config:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['ipc:config:export']"
>导出</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> -->
<el-table <el-table
v-loading="loading" v-loading="loading"
:data="configList" :data="configList"
@selection-change="handleSelectionChange"
> >
<el-table-column <el-table-column
label="监测部位" label="监测部位"
@ -455,12 +401,6 @@ export default {
monitorParamsList: [], monitorParamsList: [],
// //
loading: true, loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
// //
showSearch: true, showSearch: true,
// //
@ -622,12 +562,6 @@ export default {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
@ -637,7 +571,7 @@ export default {
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const id = row.id || this.ids; const id = row.id;
getConfig(id).then((response) => { getConfig(id).then((response) => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;