reactor:【IoT 物联网】增加 IotRuleScene2DO 新的定义,对标阿里云 IoT 的「事件响应」
This commit is contained in:
@@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* IoT 设备消息类型枚举
|
||||
*/
|
||||
@Deprecated
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum IotDeviceMessageTypeEnum implements ArrayValuable<String> {
|
||||
|
||||
@@ -15,8 +15,33 @@ import java.util.Arrays;
|
||||
@Getter
|
||||
public enum IotRuleSceneActionTypeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
DEVICE_CONTROL(1), // 设备执行
|
||||
// TODO @芋艿:后续“对应”部分,要 @下,等包结构梳理完;
|
||||
/**
|
||||
* 设备属性设置
|
||||
*
|
||||
* 对应 IotDeviceMessageMethodEnum.DEVICE_PROPERTY_SET
|
||||
*/
|
||||
DEVICE_PROPERTY_SET(1),
|
||||
/**
|
||||
* 设备服务调用
|
||||
*
|
||||
* 对应 IotDeviceMessageMethodEnum.DEVICE_SERVICE_INVOKE
|
||||
*/
|
||||
DEVICE_SERVICE_INVOKE(2),
|
||||
|
||||
/**
|
||||
* 告警触发
|
||||
*/
|
||||
ALERT_TRIGGER(100),
|
||||
/**
|
||||
* 告警恢复
|
||||
*/
|
||||
ALERT_RECOVER(101),
|
||||
|
||||
@Deprecated
|
||||
ALERT(2), // 告警执行
|
||||
|
||||
@Deprecated
|
||||
DATA_BRIDGE(3); // 桥接执行
|
||||
|
||||
private final Integer type;
|
||||
|
||||
@@ -8,13 +8,13 @@ import lombok.RequiredArgsConstructor;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* IoT 场景触发条件参数的操作符枚举
|
||||
* IoT 场景触发条件的操作符枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum IotRuleSceneTriggerConditionParameterOperatorEnum implements ArrayValuable<String> {
|
||||
public enum IotRuleSceneConditionOperatorEnum implements ArrayValuable<String> {
|
||||
|
||||
EQUALS("=", "#source == #value"),
|
||||
NOT_EQUALS("!=", "!(#source == #value)"),
|
||||
@@ -32,12 +32,28 @@ public enum IotRuleSceneTriggerConditionParameterOperatorEnum implements ArrayVa
|
||||
NOT_BETWEEN("not between", "(#source < #values.get(0)) || (#source > #values.get(1))"),
|
||||
|
||||
LIKE("like", "#source.contains(#value)"), // 字符串匹配
|
||||
NOT_NULL("not null", "#source != null && #source.length() > 0"); // 非空
|
||||
NOT_NULL("not null", "#source != null && #source.length() > 0"), // 非空
|
||||
|
||||
// ========== 特殊:不放在字典里 ==========
|
||||
|
||||
// TODO @puhui999:@芋艿:需要测试下
|
||||
DATE_TIME_GREATER_THAN("date_time_>", "#source > #value"), // 在时间之后:时间戳
|
||||
DATE_TIME_LESS_THAN("date_time_<", "#source < #value"), // 在时间之前:时间戳
|
||||
DATE_TIME_BETWEEN("date_time_between", // 在时间之间:时间戳
|
||||
"(#source >= #values.get(0)) && (#source <= #values.get(1))"),
|
||||
|
||||
// TODO @puhui999:@芋艿:需要测试下
|
||||
TIME_GREATER_THAN("time_>", "#source.isAfter(#value)"), // 在当日时间之后:HH:mm:ss
|
||||
TIME_LESS_THAN("time_<", "#source.isBefore(#value)"), // 在当日时间之前:HH:mm:ss
|
||||
TIME_BETWEEN("time_between", // 在当日时间之间:HH:mm:ss
|
||||
"(#source >= #values.get(0)) && (#source <= #values.get(1))"),
|
||||
|
||||
;
|
||||
|
||||
private final String operator;
|
||||
private final String springExpression;
|
||||
|
||||
public static final String[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneTriggerConditionParameterOperatorEnum::getOperator).toArray(String[]::new);
|
||||
public static final String[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneConditionOperatorEnum::getOperator).toArray(String[]::new);
|
||||
|
||||
/**
|
||||
* Spring 表达式 - 原始值
|
||||
@@ -52,7 +68,7 @@ public enum IotRuleSceneTriggerConditionParameterOperatorEnum implements ArrayVa
|
||||
*/
|
||||
public static final String SPRING_EXPRESSION_VALUE_LIST = "values";
|
||||
|
||||
public static IotRuleSceneTriggerConditionParameterOperatorEnum operatorOf(String operator) {
|
||||
public static IotRuleSceneConditionOperatorEnum operatorOf(String operator) {
|
||||
return ArrayUtil.firstMatch(item -> item.getOperator().equals(operator), values());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
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 IotRuleSceneConditionTypeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
DEVICE_STATE(1, "设备状态"),
|
||||
DEVICE_PROPERTY(2, "设备属性"),
|
||||
|
||||
CURRENT_TIME(100, "当前时间"),
|
||||
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String name;
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneConditionTypeEnum::getType).toArray(Integer[]::new);
|
||||
|
||||
@Override
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,14 +9,47 @@ import java.util.Arrays;
|
||||
/**
|
||||
* IoT 场景流转的触发类型枚举
|
||||
*
|
||||
* 为什么不直接使用 IotDeviceMessageMethodEnum 呢?
|
||||
* 原因是,物模型属性上报,存在批量上报的情况,不只对应一个 method!!!
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum IotRuleSceneTriggerTypeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
DEVICE(1), // 设备触发
|
||||
TIMER(2); // 定时触发
|
||||
@Deprecated
|
||||
DEVICE(1), // 设备触发 // TODO @puhui999:@芋艿:这个可以作废
|
||||
|
||||
// TODO @芋艿:后续“对应”部分,要 @下,等包结构梳理完;
|
||||
/**
|
||||
* 设备上下线变更
|
||||
*
|
||||
* 对应 IotDeviceMessageMethodEnum.STATE_UPDATE
|
||||
*/
|
||||
DEVICE_STATE_UPDATE(1),
|
||||
/**
|
||||
* 物模型属性上报
|
||||
*
|
||||
* 对应 IotDeviceMessageMethodEnum.DEVICE_PROPERTY_POST
|
||||
*/
|
||||
DEVICE_PROPERTY_POST(2),
|
||||
/**
|
||||
* 设备事件上报
|
||||
*
|
||||
* 对应 IotDeviceMessageMethodEnum.DEVICE_EVENT_POST
|
||||
*/
|
||||
DEVICE_EVENT_POST(3),
|
||||
/**
|
||||
* 设备服务调用
|
||||
*
|
||||
* 对应 IotDeviceMessageMethodEnum.DEVICE_SERVICE_INVOKE
|
||||
*/
|
||||
DEVICE_SERVICE_INVOKE(4),
|
||||
|
||||
TIMER(100) // 定时触发
|
||||
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user