10.7预警规则list修改

dev
xiaohuo 9 months ago
parent 637c9d346f
commit 0cf75ce555
  1. 5
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java
  2. 1
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java
  3. 75
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/AlertRuleVo.java
  4. 6
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java
  5. 7
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java
  6. 5
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java
  7. 13
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java
  8. 41
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertRuleMapper.xml

@ -12,6 +12,7 @@ import com.alops.common.enums.BusinessType;
import com.alops.common.utils.poi.ExcelUtil; import com.alops.common.utils.poi.ExcelUtil;
import com.alops.system.domain.AlertRule; import com.alops.system.domain.AlertRule;
import com.alops.system.domain.dto.AlertRuleAddDto; import com.alops.system.domain.dto.AlertRuleAddDto;
import com.alops.system.domain.vo.AlertRuleVo;
import com.alops.system.service.IAlertLaunchService; import com.alops.system.service.IAlertLaunchService;
import com.alops.system.service.IAlertRuleService; import com.alops.system.service.IAlertRuleService;
import com.alops.system.service.IDictAlarmParamService; import com.alops.system.service.IDictAlarmParamService;
@ -55,7 +56,7 @@ public class AlertRuleController extends BaseController {
try { try {
AlertRule alertRule = alertRuleService.saveRule(dto); AlertRuleVo alertRule = alertRuleService.saveRule(dto);
return AjaxResult.success("预警规则新增成功", alertRule); return AjaxResult.success("预警规则新增成功", alertRule);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -89,7 +90,7 @@ public class AlertRuleController extends BaseController {
@ApiOperation("查询预警规则") @ApiOperation("查询预警规则")
public TableDataInfo list(AlertRule alertRule) { public TableDataInfo list(AlertRule alertRule) {
startPage(); startPage();
List<AlertRule> list = alertRuleService.selectAlertRuleList(alertRule); List<AlertRuleVo> list = alertRuleService.selectAlertRuleList(alertRule);
return getDataTable(list); return getDataTable(list);
} }

@ -62,6 +62,7 @@ public class AlertRule extends BaseEntity
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;

@ -0,0 +1,75 @@
package com.alops.system.domain.vo;
import com.alops.common.annotation.Excel;
import com.alops.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.util.Date;
@Data
public class AlertRuleVo extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 预警规则名称 */
@Excel(name = "预警规则名称")
private String ruleName;
/** 预警级别 */
@Excel(name = "预警级别")
private Long severity;
/** 预警方式(email/message) */
@Excel(name = "预警方式(email/message)")
private String alertWay;
/** 预警到站方 */
@Excel(name = "预警到站方")
private String alertStation;
/** 预警规则内容描述 */
@Excel(name = "预警规则内容描述")
private String description;
/** 启用状态(0为启用) */
@Excel(name = "启用状态", readConverterExp = "0=为启用")
private Integer enable;
/** 表格名称 */
@Excel(name = "表格名称")
private String tableName;
/** 预警sql语句查询 */
@Excel(name = "预警sql语句查询")
@JsonIgnore
private String alertSql;
/** 预警模版(参数用数据库命名法) */
@Excel(name = "预警模版", readConverterExp = "参=数用数据库命名法")
private String alertTemplate;
/** 预警类型 */
@Excel(name = "预警类型")
private String type;
/** 参数名称 */
@Excel(name = "参数名称")
private String paramName;
/** 比较符号 */
@Excel(name = "比较符号")
private String operator;
/** 比较值 */
@Excel(name = "比较值")
private String compareValue;
}

@ -59,7 +59,7 @@ public class queryEquBaseVO {
/** 安装日期 */ /** 安装日期 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "安装日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "安装日期", width = 30)
private Date installDate; private Date installDate;
/** 预计年限(年) */ /** 预计年限(年) */
@ -78,8 +78,8 @@ public class queryEquBaseVO {
@Excel(name = "健康度") @Excel(name = "健康度")
private BigDecimal health; private BigDecimal health;
/** 添加日期 */ /** 添加日期 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "添加日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "添加日期", width = 30)
private Date createDate; private Date createDate;
/** 启用状态 */ /** 启用状态 */
@Excel(name = "启用状态") @Excel(name = "启用状态")

@ -2,6 +2,7 @@ package com.alops.system.mapper;
import com.alops.system.domain.AlertRule; import com.alops.system.domain.AlertRule;
import com.alops.system.domain.dto.AlertRuleAddDto; import com.alops.system.domain.dto.AlertRuleAddDto;
import com.alops.system.domain.vo.AlertRuleVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
@ -26,15 +27,15 @@ public interface AlertRuleMapper
* @param id 请填写功能名称主键 * @param id 请填写功能名称主键
* @return 请填写功能名称 * @return 请填写功能名称
*/ */
public AlertRule selectAlertRuleById(Long id); public AlertRuleVo selectAlertRuleById(Long id);
public AlertRule selectAlertRuleByToId(Long id);
/** /**
* 查询请填写功能名称列表 * 查询请填写功能名称列表
* *
* @param alertRule 请填写功能名称 * @param alertRule 请填写功能名称
* @return 请填写功能名称集合 * @return 请填写功能名称集合
*/ */
public List<AlertRule> selectAlertRuleList(AlertRule alertRule); public List<AlertRuleVo> selectAlertRuleList(AlertRule alertRule);
/** /**
* 新增请填写功能名称 * 新增请填写功能名称

@ -2,6 +2,7 @@ package com.alops.system.service;
import com.alops.system.domain.AlertRule; import com.alops.system.domain.AlertRule;
import com.alops.system.domain.dto.AlertRuleAddDto; import com.alops.system.domain.dto.AlertRuleAddDto;
import com.alops.system.domain.vo.AlertRuleVo;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -15,7 +16,7 @@ import java.util.Map;
public interface IAlertRuleService public interface IAlertRuleService
{ {
public AlertRule saveRule(AlertRuleAddDto dto); public AlertRuleVo saveRule(AlertRuleAddDto dto);
public AlertRule updateRule(AlertRuleAddDto dto); public AlertRule updateRule(AlertRuleAddDto dto);
@ -40,7 +41,7 @@ public interface IAlertRuleService
* @param alertRule 请填写功能名称 * @param alertRule 请填写功能名称
* @return 请填写功能名称集合 * @return 请填写功能名称集合
*/ */
public List<AlertRule> selectAlertRuleList(AlertRule alertRule); public List<AlertRuleVo> selectAlertRuleList(AlertRule alertRule);
/** /**
* 新增请填写功能名称 * 新增请填写功能名称

@ -8,6 +8,7 @@ import com.alops.common.utils.SecurityUtils;
import com.alops.system.domain.AlertRule; import com.alops.system.domain.AlertRule;
import com.alops.system.domain.AlertRuleCondition; import com.alops.system.domain.AlertRuleCondition;
import com.alops.system.domain.dto.AlertRuleAddDto; import com.alops.system.domain.dto.AlertRuleAddDto;
import com.alops.system.domain.vo.AlertRuleVo;
import com.alops.system.mapper.AlertRuleConditionMapper; import com.alops.system.mapper.AlertRuleConditionMapper;
import com.alops.system.mapper.AlertRuleMapper; import com.alops.system.mapper.AlertRuleMapper;
import com.alops.system.service.IAlertRuleService; import com.alops.system.service.IAlertRuleService;
@ -37,7 +38,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService
*/ */
@Override @Override
public AlertRule saveRule(AlertRuleAddDto dto) { public AlertRuleVo saveRule(AlertRuleAddDto dto) {
Long userId = SecurityUtils.getLoginUser().getUserId(); Long userId = SecurityUtils.getLoginUser().getUserId();
AlertRule rule = dto.getAlertRule(); AlertRule rule = dto.getAlertRule();
@ -67,7 +68,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService
alertRuleConditionMapper.insertAlertRuleCondition(c); alertRuleConditionMapper.insertAlertRuleCondition(c);
} }
} }
AlertRule fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); AlertRuleVo fullRule = alertRuleMapper.selectAlertRuleById(rule.getId());
return fullRule; return fullRule;
} }
@ -104,14 +105,14 @@ public class AlertRuleServiceImpl implements IAlertRuleService
alertRuleConditionMapper.insertAlertRuleCondition(c); alertRuleConditionMapper.insertAlertRuleCondition(c);
} }
} }
AlertRule fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); AlertRule fullRule = alertRuleMapper.selectAlertRuleByToId(rule.getId());
return fullRule; return fullRule;
} }
@Override @Override
public AlertRuleAddDto selectDetailAlertRuleById(Long id) { public AlertRuleAddDto selectDetailAlertRuleById(Long id) {
// 1. 查询主表 // 1. 查询主表
AlertRule rule = alertRuleMapper.selectAlertRuleById(id); AlertRule rule = alertRuleMapper.selectAlertRuleByToId(id);
if (rule == null) { if (rule == null) {
return null; return null;
} }
@ -316,7 +317,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService
@Override @Override
public AlertRule selectAlertRuleById(Long id) public AlertRule selectAlertRuleById(Long id)
{ {
return alertRuleMapper.selectAlertRuleById(id); return alertRuleMapper.selectAlertRuleByToId(id);
} }
/** /**
@ -326,7 +327,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService
* @return 请填写功能名称 * @return 请填写功能名称
*/ */
@Override @Override
public List<AlertRule> selectAlertRuleList(AlertRule alertRule) public List<AlertRuleVo> selectAlertRuleList(AlertRule alertRule)
{ {
return alertRuleMapper.selectAlertRuleList(alertRule); return alertRuleMapper.selectAlertRuleList(alertRule);
} }

@ -29,6 +29,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<sql id="selectAlertRuleVo"> <sql id="selectAlertRuleVo">
SELECT
ar.id,
ar.rule_name AS ruleName,
ar.severity,
ar.alert_way AS alertWay,
ar.alert_station AS alertStation,
ar.description,
ar.enable,
ar.create_time as createTime,
ar.update_time as updateTime,
su1.user_name AS createBy,
su2.user_name AS updateBy,
ar.table_name as tableName,
ar.alert_sql AS alertSql,
ar.alert_template AS alertTemplate,
ar.type,
ac.param_name AS paramName,
ac.operator,
ac.compare_value AS compareValue
FROM alert_rule ar
LEFT JOIN sys_user su1 ON ar.create_by = su1.user_id
LEFT JOIN sys_user su2 ON ar.update_by = su2.user_id
LEFT JOIN alert_rule_condition ac ON ar.id = ac.alert_rule_id
</sql>
<sql id="selectAlertRuleVo2">
SELECT SELECT
ar.id, ar.id,
ar.rule_name , ar.rule_name ,
@ -39,8 +65,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ar.enable, ar.enable,
ar.create_time , ar.create_time ,
ar.update_time , ar.update_time ,
su1.user_name AS create_by, su1.user_name as create_by,
su2.user_name AS update_by, su2.user_name as update_by,
ar.table_name , ar.table_name ,
ar.alert_sql , ar.alert_sql ,
ar.alert_template, ar.alert_template,
@ -50,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN sys_user su2 ON ar.update_by = su2.user_id LEFT JOIN sys_user su2 ON ar.update_by = su2.user_id
</sql> </sql>
<select id="selectAlertRuleList" parameterType="AlertRule" resultMap="AlertRuleResult"> <select id="selectAlertRuleList" parameterType="AlertRule" resultType="alertRuleVo">
<include refid="selectAlertRuleVo"/> <include refid="selectAlertRuleVo"/>
<where> <where>
<if test="ruleName != null and ruleName != ''"> and ar.rule_name like concat('%', #{ruleName}, '%')</if> <if test="ruleName != null and ruleName != ''"> and ar.rule_name like concat('%', #{ruleName}, '%')</if>
@ -65,9 +91,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAlertRuleById" parameterType="Long" resultMap="AlertRuleResult"> <select id="selectAlertRuleById" parameterType="Long" resultType="AlertRuleVo">
<include refid="selectAlertRuleVo"/> <include refid="selectAlertRuleVo"/>
where id = #{id} where ar.id = #{id}
</select>
<select id="selectAlertRuleByToId" parameterType="Long" resultMap="AlertRuleResult">
<include refid="selectAlertRuleVo2"/>
where ar.id = #{id}
</select> </select>
<insert id="insertAlertRule" parameterType="AlertRule" useGeneratedKeys="true" keyProperty="id"> <insert id="insertAlertRule" parameterType="AlertRule" useGeneratedKeys="true" keyProperty="id">

Loading…
Cancel
Save