10.27首页预警信息修改,增加预警信息修改

dev
xiaohuo 8 months ago
parent 7f516a6e9b
commit 0950044a88
  1. 46
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java
  2. 4
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertMessage.java
  3. 6
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessageVo.java
  4. 4
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/hander/WebSocketServer.java
  5. 1
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java
  6. 5
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java
  7. 24
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertMessageMapper.xml

@ -44,26 +44,26 @@ public class AlertMessageController extends BaseController
/**
* 立即执行预警带规则 ID 列表
*/
// @PreAuthorize("@ss.hasPermi('equipment:rules:execute')")
// @ApiOperation("立即执行预警")
// @Log(title = "【立即执行预警】", businessType = BusinessType.DELETE)
// @PostMapping("/executeImmediate")
// public AjaxResult executeImmediate(@RequestBody Map<String, List<Long>> paramMap) {
// try {
// List<Long> ruleIds = paramMap.get("ruleIds");
// if (ruleIds == null || ruleIds.isEmpty()) {
// return AjaxResult.error("请选择至少一条规则");
// }
//
// iAlertLaunchService.executeImmediateAlerts(); // 调用 Service 执行
// return AjaxResult.success("立即预警任务已触发,存入成功,请查看");
//
// } catch (Exception e) {
// e.printStackTrace();
// return AjaxResult.error("执行立即预警失败: " + e.getMessage());
// }
//
// }
@PreAuthorize("@ss.hasPermi('equipment:rules:execute')")
@ApiOperation("立即执行预警")
@Log(title = "【立即执行预警】", businessType = BusinessType.DELETE)
@PostMapping("/executeImmediate")
public AjaxResult executeImmediate(@RequestBody Map<String, List<Long>> paramMap) {
try {
List<Long> ruleIds = paramMap.get("ruleIds");
if (ruleIds == null || ruleIds.isEmpty()) {
return AjaxResult.error("请选择至少一条规则");
}
iAlertLaunchService.executeImmediateAlerts(); // 调用 Service 执行
return AjaxResult.success("立即预警任务已触发,存入成功,请查看");
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("执行立即预警失败: " + e.getMessage());
}
}
/**
* 修改预警信息
@ -78,11 +78,11 @@ public class AlertMessageController extends BaseController
}
/**
* 查询预警信息统计列表
* 首页查询预警信息统计列表
*/
@PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:statistic:list')")
@GetMapping ("/statistic/list")
@ApiOperation("查询预警信息")
@ApiOperation("首页查询预警信息")
@Log(title = "查询预警信息", businessType = BusinessType.UPDATE)
public TableDataInfo homeList()
{
@ -93,7 +93,7 @@ public class AlertMessageController extends BaseController
/**
* 首页查询预警信息统计列表
* 查询预警信息统计列表
*/
@PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:list')")
@GetMapping ("/list")

@ -5,6 +5,7 @@ import java.util.Date;
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 org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -73,6 +74,9 @@ public class AlertMessage
@Excel(name ="预警信息")
private String message;
@JsonIgnore
@Excel(name ="预警规则id")
private Long alertRuleId;

@ -26,12 +26,14 @@ public class homeEquAlertMessageVo {
@Excel(name = "处理状态")
private String status;
@Excel(name = "处理状态")
@Excel(name = "设备名称")
private String name;
@Excel(name = "处理状态")
@Excel(name = "设备位置")
private String location;
@Excel(name = "预警规则名称")
private String ruleName;
}

@ -128,10 +128,10 @@ public class WebSocketServer extends TextWebSocketHandler {
// 发送
session.sendMessage(new TextMessage(jsonMessage));
logger.info("成功向用户 [{}] 发送预警消息: {}", session.getId(), jsonMessage);
logger.info("成功向用户 [{}] 发送通知: {}", session.getId(), jsonMessage);
}
} catch (Exception e) {
logger.error("发送预警消息失败: messageId=" + messageId, e);
logger.error("发送通知失败: messageId=" + messageId, e);
}
}

@ -154,6 +154,7 @@ public class AlertLaunchServiceImpl implements IAlertLaunchService {
msg.setBatch(currentBatch);
msg.setMessage(msgdes);
msg.setAlertRuleId(rule.getId());
messages.add(msg);
msgs.add(msgdes);

@ -424,9 +424,10 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService {
throw new RuntimeException(msg.toString());
}
// 事务内:删除旧表 + 插入成功设备数据
// 事务内:删除旧表 + 插入成功设备数据+执行预警
deleteAllEquipmentData(); // 删除依附表,不含 equ_gather
int inserted = persistAndUpdate(successList); // 插入成功设备数据
int inserted = persistAndUpdate(successList);
if (inserted <= 0) {
throw new RuntimeException("成功采集设备写入失败,回滚事务");

@ -20,6 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" />
<result property="batch" column="batch" />
<result property="message" column="message" />
<result property="alertRuleId" column="alert_rule_id" />
</resultMap>
<select id="selectMaxBatch" resultType="integer">
@ -30,12 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO alert_message
(equ_id, type, equ_type, solution, level, occur_time, handler, handle_time, status,batch,message)
(equ_id, type, equ_type, solution, level, occur_time, handler, handle_time, status,batch,message,alert_rule_id)
VALUES
<foreach collection="list" item="msg" separator=",">
(#{msg.equId},#{msg.type}, #{msg.equType},
#{msg.solution}, #{msg.level}, #{msg.occurTime},
#{msg.handler}, #{msg.handleTime}, #{msg.status}, #{msg.batch}, #{msg.message})
#{msg.handler}, #{msg.handleTime}, #{msg.status}, #{msg.batch}, #{msg.message}, #{msg.alertRuleId})
</foreach>
</insert>
@ -86,6 +88,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<!-- 查询最新预警信息(按时间排序,取前N条) -->
<!-- <select id="selectStaticAlertMessageList" resultType="homeEquAlertMessageVo">-->
<!-- SELECT-->
<!-- a.level,-->
<!-- a.occur_time AS occurTime,-->
<!-- a.status,-->
<!-- a.message,-->
<!-- e.name,-->
<!-- e.location-->
<!-- FROM alert_message a-->
<!-- LEFT JOIN equ_base e ON a.equ_id = e.id-->
<!-- ORDER BY a.occur_time DESC-->
<!-- </select>-->
<!-- 查询最新预警信息(按时间排序,取前N条),关联规则名称 -->
<select id="selectStaticAlertMessageList" resultType="homeEquAlertMessageVo">
SELECT
a.level,
@ -93,14 +108,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.status,
a.message,
e.name,
e.location
e.location,
r.rule_name AS ruleName <!-- 新增字段 -->
FROM alert_message a
LEFT JOIN equ_base e ON a.equ_id = e.id
LEFT JOIN alert_rule r ON a.alert_rule_id = r.id <!-- 新增关联 -->
ORDER BY a.occur_time DESC
</select>
<select id="selectAlertMessageById" parameterType="Long" resultMap="AlertMessageResult">
<include refid="selectAlertMessageVo"/>
where am.id = #{id}

Loading…
Cancel
Save