告警配置
这篇解决什么
场景命中之后,谁收短信 / 邮件 / 站内信,记录落哪张表、怎么标已处理。读完能对上 iot_alert_config、iot_alert_record 和 IotAlertTriggerSceneRuleAction。
告警自己不判断阈值。阈值、上下线、定时都在 场景联动。配置通过 sceneRuleIds 挂到场景。
示意图:动作按场景 id 查出已启用配置,先写记录再按 receiveTypes 发消息。
从哪改
| 名称 | 说明 | 仓库路径 |
|---|---|---|
| 配置 API | /iot/alert-config | ruoyi-office/yudao-module-iot/yudao-module-iot-server/.../IotAlertConfigController.java |
| 记录 API | /iot/alert-record,处理备注 | IotAlertRecordController.java |
| 配置表 | 级别、接收人、模板 | @TableName("iot_alert_config") |
| 记录表 | 冗余配置名 / 级别,带设备消息 | @TableName("iot_alert_record") |
| 触发动作 | 写记录 + 发消息 | IotAlertTriggerSceneRuleAction |
| 前端 | 配置与记录两页 | ruoyi-office-vben/apps/web-antd/src/views/iot/alert/ |
接收方式 IotAlertReceiveTypeEnum:短信 1、邮件 2、站内信 3。对应模板字段 smsTemplateCode / mailTemplateCode / notifyTemplateCode。枚举里还带了默认模板 code(iot_alert_sms 等),配置里可改成自己的模板编号。
level 走字典 ALERT_LEVEL,不是启用状态。启用看 status。分页会把 receiveUserIds 加成昵称 receiveUserNames。
记录里 processStatus / processRemark 给人处理,不自动关场景。恢复告警是场景动作 ALERT_RECOVER,要带 alertConfigId。
字段
| 名称 | 说明 | 仓库路径 |
|---|---|---|
sceneRuleIds | 反查哪些场景能拉响本配置 | IotAlertConfigDO |
receiveUserIds / receiveTypes | 接收人与渠道,缺一不发 | IotAlertConfigDO |
deviceMessage | 触发当时的设备消息 | IotAlertRecordDO |
processStatus | 是否已处理 | IotAlertRecordDO |
没挂场景等于不会响
ALERT_TRIGGER 按场景 id 查配置。配置里 sceneRuleIds 为空,或场景动作写成了恢复却没配 trigger,都不会出记录。
接收人与渠道都要填
receiveUserIds 或 receiveTypes 任一为空,sendAlertMessage 直接返回。只建了配置、没选人,记录可能有、消息没有。
@RequestMapping("/iot/alert-config")
public class IotAlertConfigController { }
@TableName(value = "iot_alert_config", autoResultMap = true)
public class IotAlertConfigDO extends BaseDO { }配置与操作
走 views/iot/alert/config/ 建 iot_alert_config:勾 sceneRuleIds、选 receiveUserIds 和 receiveTypes(短信 1 / 邮件 2 / 站内信 3),再填对应模板 code。记录页 views/iot/alert/record/ 标 processStatus。客户 dump 的 system_menu 没有独立告警叶子,能打开取决于角色动态路由。
告警自己不判断阈值。sceneRuleIds 为空不会响。接收人或渠道缺一则可能有记录、没消息。开启见 IoT 功能设计。

本系统截图:场景联动。客户 dump 没有告警叶子;触发告警动作和阈值都在场景里。
