【功能新增】IoT:增加 alert 告警相关的表结构
This commit is contained in:
parent
f6f162ad2f
commit
d24e3ad773
|
@ -0,0 +1,31 @@
|
|||
package cn.iocoder.yudao.module.iot.enums.rule;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Iot 告警配置的接收方式枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum IotAlertConfigReceiveTypeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
SMS(1), // 短信
|
||||
MAIL(2), // 邮箱
|
||||
NOTIFY(3); // 通知
|
||||
|
||||
private final Integer type;
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotAlertConfigReceiveTypeEnum::getType).toArray(Integer[]::new);
|
||||
|
||||
@Override
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.iot.enums.thingmodel;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO @puhui999:加个 ArrayValuable
|
||||
/**
|
||||
* IoT 数据定义的数据类型枚举类
|
||||
*
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.iot.enums.thingmodel;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO @puhui999:加个 ArrayValuable
|
||||
/**
|
||||
* IOT 产品物模型属性读取类型枚举
|
||||
*
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.iot.enums.thingmodel;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO @puhui999:加个 ArrayValuable
|
||||
/**
|
||||
* IOT 产品物模型参数是输入参数还是输出参数枚举
|
||||
*
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.iot.enums.thingmodel;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO @puhui999:加个 ArrayValuable
|
||||
/**
|
||||
* IOT 产品物模型服务调用方式枚举
|
||||
*
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.iot.enums.thingmodel;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO @puhui999:加个 ArrayValuable
|
||||
/**
|
||||
* IOT 产品物模型事件类型枚举
|
||||
*
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package cn.iocoder.yudao.module.iot.dal.dataobject.rule;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.iot.enums.rule.IotAlertConfigReceiveTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IoT 告警配置 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("iot_alert_config")
|
||||
@KeySequence("iot_alert_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class IotAlertConfig extends BaseDO {
|
||||
|
||||
/**
|
||||
* 配置编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 配置名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 配置描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 配置状态
|
||||
*
|
||||
* TODO 数据字典
|
||||
*/
|
||||
private Integer level;
|
||||
/**
|
||||
* 配置状态
|
||||
*
|
||||
* 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 关联的规则场景编号数组
|
||||
*
|
||||
* 关联 {@link IotRuleSceneDO#getId()}
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Long> ruleSceneIds;
|
||||
|
||||
/**
|
||||
* 接收的用户编号数组
|
||||
*
|
||||
* 关联 {@link AdminUserRespDTO#getId()}
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Long> receiveUserIds;
|
||||
/**
|
||||
* 接收的类型数组
|
||||
*
|
||||
* 枚举 {@link IotAlertConfigReceiveTypeEnum}
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Integer> receiveTypes;
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package cn.iocoder.yudao.module.iot.dal.dataobject.rule;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
|
||||
import cn.iocoder.yudao.module.iot.mq.message.IotDeviceMessage;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* IoT 告警记录 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("iot_alert_record")
|
||||
@KeySequence("iot_alert_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class IotAlertRecordDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 记录编号
|
||||
*/
|
||||
@TableField
|
||||
private Long id;
|
||||
/**
|
||||
* 告警名称
|
||||
*
|
||||
* 冗余 {@link IotAlertConfig#getName()}
|
||||
*/
|
||||
private Long configId;
|
||||
/**
|
||||
* 告警名称
|
||||
*
|
||||
* 冗余 {@link IotAlertConfig#getName()}
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 产品标识
|
||||
*
|
||||
* 关联 {@link IotProductDO#getProductKey()} ()}
|
||||
*/
|
||||
private String productKey;
|
||||
/**
|
||||
* 设备名称
|
||||
*
|
||||
* 冗余 {@link IotDeviceDO#getDeviceName()}
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
// TODO @芋艿:有没更好的方式
|
||||
/**
|
||||
* 触发的设备消息
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private IotDeviceMessage deviceMessage;
|
||||
|
||||
/**
|
||||
* 处理状态
|
||||
*
|
||||
* true - 已处理
|
||||
* false - 未处理
|
||||
*/
|
||||
private Boolean processStatus;
|
||||
/**
|
||||
* 处理结果(备注)
|
||||
*/
|
||||
private String processRemark;
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import javax.annotation.Nullable;
|
|||
*/
|
||||
public interface IotRuleSceneAction {
|
||||
|
||||
// TODO @芋艿:groovy 或者 javascript 实现数据的转换;可以考虑基于 hutool 的 ScriptUtil 做
|
||||
/**
|
||||
* 执行场景
|
||||
*
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package cn.iocoder.yudao.module.iot.service.rule.action;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotRuleSceneDO;
|
||||
import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum;
|
||||
import cn.iocoder.yudao.module.iot.mq.message.IotDeviceMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* IoT 告警的 {@link IotRuleSceneAction} 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class IotRuleSceneAlertAction implements IotRuleSceneAction {
|
||||
|
||||
@Override
|
||||
public void execute(@Nullable IotDeviceMessage message, IotRuleSceneDO.ActionConfig config) {
|
||||
// TODO @芋艿:待实现
|
||||
}
|
||||
|
||||
@Override
|
||||
public IotRuleSceneActionTypeEnum getType() {
|
||||
return IotRuleSceneActionTypeEnum.ALERT;
|
||||
}
|
||||
|
||||
}
|
|
@ -60,7 +60,6 @@ public class IotRuleSceneDataBridgeAction implements IotRuleSceneAction {
|
|||
}
|
||||
|
||||
// 2.1 执行 HTTP 请求
|
||||
// TODO @芋艿:groovy 或者 javascript 实现数据的转换;可以考虑基于 hutool 的 ScriptUtil 做
|
||||
if (IotDataBridgTypeEnum.HTTP.getType().equals(dataBridge.getType())) {
|
||||
executeHttp(message, (IotDataBridgeDO.HttpConfig) dataBridge.getConfig());
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue