diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java index 8a7dfce0..d2aaeff3 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java @@ -12,6 +12,7 @@ import com.alops.common.enums.BusinessType; import com.alops.common.utils.poi.ExcelUtil; import com.alops.system.domain.AlertRule; 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.IAlertRuleService; import com.alops.system.service.IDictAlarmParamService; @@ -55,7 +56,7 @@ public class AlertRuleController extends BaseController { try { - AlertRule alertRule = alertRuleService.saveRule(dto); + AlertRuleVo alertRule = alertRuleService.saveRule(dto); return AjaxResult.success("预警规则新增成功", alertRule); } catch (Exception e) { e.printStackTrace(); @@ -89,7 +90,7 @@ public class AlertRuleController extends BaseController { @ApiOperation("查询预警规则") public TableDataInfo list(AlertRule alertRule) { startPage(); - List list = alertRuleService.selectAlertRuleList(alertRule); + List list = alertRuleService.selectAlertRuleList(alertRule); return getDataTable(list); } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java index ff6a59fe..1a593e09 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java @@ -62,6 +62,7 @@ public class AlertRule extends BaseEntity + public void setId(Long id) { this.id = id; diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/AlertRuleVo.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/AlertRuleVo.java new file mode 100644 index 00000000..b790d1f8 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/AlertRuleVo.java @@ -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; + + + + +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java index 4c30a6ef..c806e4e0 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java @@ -59,7 +59,7 @@ public class queryEquBaseVO { /** 安装日期 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "安装日期", width = 30, dateFormat = "yyyy-MM-dd") + @Excel(name = "安装日期", width = 30) private Date installDate; /** 预计年限(年) */ @@ -78,8 +78,8 @@ public class queryEquBaseVO { @Excel(name = "健康度") private BigDecimal health; /** 添加日期 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "添加日期", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "添加日期", width = 30) private Date createDate; /** 启用状态 */ @Excel(name = "启用状态") diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java index b0dc7705..6c51a8e4 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java @@ -2,6 +2,7 @@ package com.alops.system.mapper; import com.alops.system.domain.AlertRule; import com.alops.system.domain.dto.AlertRuleAddDto; +import com.alops.system.domain.vo.AlertRuleVo; import org.apache.ibatis.annotations.Mapper; import org.springframework.data.repository.query.Param; @@ -26,15 +27,15 @@ public interface AlertRuleMapper * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ - public AlertRule selectAlertRuleById(Long id); - + public AlertRuleVo selectAlertRuleById(Long id); + public AlertRule selectAlertRuleByToId(Long id); /** * 查询【请填写功能名称】列表 * * @param alertRule 【请填写功能名称】 * @return 【请填写功能名称】集合 */ - public List selectAlertRuleList(AlertRule alertRule); + public List selectAlertRuleList(AlertRule alertRule); /** * 新增【请填写功能名称】 diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java index ee90857d..0ec2269b 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java @@ -2,6 +2,7 @@ package com.alops.system.service; import com.alops.system.domain.AlertRule; import com.alops.system.domain.dto.AlertRuleAddDto; +import com.alops.system.domain.vo.AlertRuleVo; import java.util.List; import java.util.Map; @@ -15,7 +16,7 @@ import java.util.Map; public interface IAlertRuleService { - public AlertRule saveRule(AlertRuleAddDto dto); + public AlertRuleVo saveRule(AlertRuleAddDto dto); public AlertRule updateRule(AlertRuleAddDto dto); @@ -40,7 +41,7 @@ public interface IAlertRuleService * @param alertRule 【请填写功能名称】 * @return 【请填写功能名称】集合 */ - public List selectAlertRuleList(AlertRule alertRule); + public List selectAlertRuleList(AlertRule alertRule); /** * 新增【请填写功能名称】 diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java index 0cd383f0..bad959f0 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java @@ -8,6 +8,7 @@ import com.alops.common.utils.SecurityUtils; import com.alops.system.domain.AlertRule; import com.alops.system.domain.AlertRuleCondition; 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.AlertRuleMapper; import com.alops.system.service.IAlertRuleService; @@ -37,7 +38,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService */ @Override - public AlertRule saveRule(AlertRuleAddDto dto) { + public AlertRuleVo saveRule(AlertRuleAddDto dto) { Long userId = SecurityUtils.getLoginUser().getUserId(); AlertRule rule = dto.getAlertRule(); @@ -67,7 +68,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService alertRuleConditionMapper.insertAlertRuleCondition(c); } } - AlertRule fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); + AlertRuleVo fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); return fullRule; } @@ -104,14 +105,14 @@ public class AlertRuleServiceImpl implements IAlertRuleService alertRuleConditionMapper.insertAlertRuleCondition(c); } } - AlertRule fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); + AlertRule fullRule = alertRuleMapper.selectAlertRuleByToId(rule.getId()); return fullRule; } @Override public AlertRuleAddDto selectDetailAlertRuleById(Long id) { // 1. 查询主表 - AlertRule rule = alertRuleMapper.selectAlertRuleById(id); + AlertRule rule = alertRuleMapper.selectAlertRuleByToId(id); if (rule == null) { return null; } @@ -316,7 +317,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService @Override public AlertRule selectAlertRuleById(Long id) { - return alertRuleMapper.selectAlertRuleById(id); + return alertRuleMapper.selectAlertRuleByToId(id); } /** @@ -326,7 +327,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService * @return 【请填写功能名称】 */ @Override - public List selectAlertRuleList(AlertRule alertRule) + public List selectAlertRuleList(AlertRule alertRule) { return alertRuleMapper.selectAlertRuleList(alertRule); } diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertRuleMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertRuleMapper.xml index 9c3b690a..495e3d76 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertRuleMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertRuleMapper.xml @@ -31,18 +31,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT ar.id, - ar.rule_name, + ar.rule_name AS ruleName, ar.severity, - ar.alert_way, - ar.alert_station, + ar.alert_way AS alertWay, + ar.alert_station AS alertStation, ar.description, ar.enable, - ar.create_time, - ar.update_time, - su1.user_name AS create_by, - su2.user_name AS update_by, - ar.table_name, - ar.alert_sql, + 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 + + + + SELECT + ar.id, + ar.rule_name , + ar.severity, + ar.alert_way , + ar.alert_station , + ar.description, + ar.enable, + ar.create_time , + ar.update_time , + su1.user_name as create_by, + su2.user_name as update_by, + ar.table_name , + ar.alert_sql , ar.alert_template, ar.type FROM alert_rule ar @@ -50,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN sys_user su2 ON ar.update_by = su2.user_id - and ar.rule_name like concat('%', #{ruleName}, '%') @@ -65,9 +91,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - where id = #{id} + where ar.id = #{id} + + +