Commit 06749a18fcd8a1b5e81a7b0352eb1c5b4efef2b4
1 parent
f46a2fb0
【代码新增】IoT:增加规则引擎的 IotRuleSceneDO 场景联动的实体
Showing
2 changed files
with
237 additions
and
0 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/device/IotDeviceMessageIdentifierEnum.java
| @@ -20,6 +20,7 @@ public enum IotDeviceMessageIdentifierEnum { | @@ -20,6 +20,7 @@ public enum IotDeviceMessageIdentifierEnum { | ||
| 20 | CONFIG_GET("get"), // 上行 TODO 芋艿:【讨论】暂时没有上行的场景 | 20 | CONFIG_GET("get"), // 上行 TODO 芋艿:【讨论】暂时没有上行的场景 |
| 21 | CONFIG_SET("set"), // 下行 | 21 | CONFIG_SET("set"), // 下行 |
| 22 | 22 | ||
| 23 | + SERVICE_INVOKE("${identifier}"), // 下行 | ||
| 23 | SERVICE_REPLY_SUFFIX("_reply"); // 芋艿:TODO 芋艿:【讨论】上行 or 下行 | 24 | SERVICE_REPLY_SUFFIX("_reply"); // 芋艿:TODO 芋艿:【讨论】上行 or 下行 |
| 24 | 25 | ||
| 25 | /** | 26 | /** |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotRuleSceneDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.dal.dataobject.rule; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; | ||
| 5 | +import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; | ||
| 6 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | ||
| 7 | +import cn.iocoder.yudao.module.iot.enums.device.IotDeviceMessageIdentifierEnum; | ||
| 8 | +import cn.iocoder.yudao.module.iot.enums.device.IotDeviceMessageTypeEnum; | ||
| 9 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 10 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 11 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 12 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 13 | +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | ||
| 14 | +import lombok.*; | ||
| 15 | + | ||
| 16 | +import java.util.List; | ||
| 17 | +import java.util.Map; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * IoT 场景联动 DO | ||
| 21 | + * | ||
| 22 | + * @author 芋道源码 | ||
| 23 | + */ | ||
| 24 | +@TableName("iot_rule_scene") | ||
| 25 | +@KeySequence("iot_rule_scene_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 26 | +@Data | ||
| 27 | +@EqualsAndHashCode(callSuper = true) | ||
| 28 | +@ToString(callSuper = true) | ||
| 29 | +@Builder | ||
| 30 | +@NoArgsConstructor | ||
| 31 | +@AllArgsConstructor | ||
| 32 | +public class IotRuleSceneDO extends BaseDO { | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 场景编号 | ||
| 36 | + */ | ||
| 37 | + @TableId | ||
| 38 | + private Long id; | ||
| 39 | + /** | ||
| 40 | + * 场景名称 | ||
| 41 | + */ | ||
| 42 | + private String name; | ||
| 43 | + /** | ||
| 44 | + * 场景描述 | ||
| 45 | + */ | ||
| 46 | + private String description; | ||
| 47 | + /** | ||
| 48 | + * 场景状态 | ||
| 49 | + * | ||
| 50 | + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | ||
| 51 | + */ | ||
| 52 | + private Integer status; | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 触发器数组 | ||
| 56 | + */ | ||
| 57 | + @TableField(typeHandler = JacksonTypeHandler.class) | ||
| 58 | + private List<Trigger> triggers; | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 执行器数组 | ||
| 62 | + */ | ||
| 63 | + @TableField(typeHandler = JacksonTypeHandler.class) | ||
| 64 | + private List<Actuator> actuators; | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 触发器 | ||
| 68 | + */ | ||
| 69 | + @Data | ||
| 70 | + public static class Trigger { | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 触发类型 | ||
| 74 | + * | ||
| 75 | + * TODO @芋艿:device、job | ||
| 76 | + */ | ||
| 77 | + private Integer type; | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 产品标识 | ||
| 81 | + * | ||
| 82 | + * 关联 {@link IotProductDO#getProductKey()} | ||
| 83 | + */ | ||
| 84 | + private String productKey; | ||
| 85 | + /** | ||
| 86 | + * 设备名称数组 | ||
| 87 | + * | ||
| 88 | + * 关联 {@link IotDeviceDO#getDeviceName()} | ||
| 89 | + */ | ||
| 90 | + private List<String> deviceNames; | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 触发条件数组 | ||
| 94 | + * | ||
| 95 | + * TODO @芋艿:注释说明 | ||
| 96 | + */ | ||
| 97 | + private List<TriggerCondition> conditions; | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * CRON 表达式 | ||
| 101 | + * | ||
| 102 | + * TODO @芋艿:注释说明 | ||
| 103 | + */ | ||
| 104 | + private String cronExpression; | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + /** | ||
| 109 | + * 触发条件 | ||
| 110 | + */ | ||
| 111 | + @Data | ||
| 112 | + public static class TriggerCondition { | ||
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * 消息类型 | ||
| 116 | + * | ||
| 117 | + * 枚举 {@link IotDeviceMessageTypeEnum} | ||
| 118 | + */ | ||
| 119 | + private String type; | ||
| 120 | + /** | ||
| 121 | + * 消息标识符 | ||
| 122 | + * | ||
| 123 | + * 枚举 {@link IotDeviceMessageIdentifierEnum} | ||
| 124 | + */ | ||
| 125 | + private String identifier; | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 参数数组 | ||
| 129 | + */ | ||
| 130 | + private List<TriggerConditionParameter> parameters; | ||
| 131 | + | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * 触发条件参数 | ||
| 136 | + */ | ||
| 137 | + @Data | ||
| 138 | + public static class TriggerConditionParameter { | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * 标识符(属性、事件、服务) | ||
| 142 | + * | ||
| 143 | + * 关联 {@link IotThingModelDO#getIdentifier()} | ||
| 144 | + */ | ||
| 145 | + private String identifier; | ||
| 146 | + | ||
| 147 | + /** | ||
| 148 | + * 操作符 | ||
| 149 | + * | ||
| 150 | + * TODO 芋艿:枚举 | ||
| 151 | + */ | ||
| 152 | + private String operator; | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * 值 | ||
| 156 | + */ | ||
| 157 | + private String value; | ||
| 158 | + | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * 执行器 | ||
| 163 | + */ | ||
| 164 | + @Data | ||
| 165 | + public static class Actuator { | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * 执行类型 | ||
| 169 | + * | ||
| 170 | + * TODO @芋艿:control、alert、webhook(待定) | ||
| 171 | + */ | ||
| 172 | + private Integer type; | ||
| 173 | + | ||
| 174 | + /** | ||
| 175 | + * 产品标识 | ||
| 176 | + * | ||
| 177 | + * 关联 {@link IotProductDO#getProductKey()} | ||
| 178 | + */ | ||
| 179 | + private String productKey; | ||
| 180 | + /** | ||
| 181 | + * 设备名称数组 | ||
| 182 | + * | ||
| 183 | + * 关联 {@link IotDeviceDO#getDeviceName()} | ||
| 184 | + */ | ||
| 185 | + private List<String> deviceNames; | ||
| 186 | + | ||
| 187 | + /** | ||
| 188 | + * 控制数组 | ||
| 189 | + * | ||
| 190 | + * TODO 芋艿:类型的情况下 | ||
| 191 | + */ | ||
| 192 | + private List<ActuatorControl> controls; | ||
| 193 | + | ||
| 194 | + /** | ||
| 195 | + * 数据桥接编号 | ||
| 196 | + * | ||
| 197 | + * TODO 芋艿:暂定! | ||
| 198 | + * TODO 芋艿:关联 | ||
| 199 | + */ | ||
| 200 | + private Long bridgeId; | ||
| 201 | + | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + /** | ||
| 205 | + * 执行器控制 | ||
| 206 | + */ | ||
| 207 | + @Data | ||
| 208 | + public static class ActuatorControl { | ||
| 209 | + | ||
| 210 | + /** | ||
| 211 | + * 消息类型 | ||
| 212 | + * | ||
| 213 | + * 枚举 {@link IotDeviceMessageTypeEnum#PROPERTY}、{@link IotDeviceMessageTypeEnum#SERVICE} | ||
| 214 | + */ | ||
| 215 | + private Integer type; | ||
| 216 | + /** | ||
| 217 | + * 消息标识符 | ||
| 218 | + * | ||
| 219 | + * 枚举 {@link IotDeviceMessageIdentifierEnum} | ||
| 220 | + * | ||
| 221 | + * 1. 属性设置:对应 {@link IotDeviceMessageIdentifierEnum#PROPERTY_SET} | ||
| 222 | + * 2. 服务调用:对应 {@link IotDeviceMessageIdentifierEnum#SERVICE_INVOKE} | ||
| 223 | + */ | ||
| 224 | + private String identifier; | ||
| 225 | + | ||
| 226 | + /** | ||
| 227 | + * 具体数据 | ||
| 228 | + * | ||
| 229 | + * 1. 属性设置:在 {@link #type} 是 {@link IotDeviceMessageTypeEnum#PROPERTY} 时,对应 properties | ||
| 230 | + * 2. 服务调用:在 {@link #type} 是 {@link IotDeviceMessageTypeEnum#SERVICE} 时,对应 params | ||
| 231 | + */ | ||
| 232 | + private Map<String, Object> data; | ||
| 233 | + | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | +} |