Commit 4c051620b14a7f9fe4649059516abea91330aafc

Authored by puhui999
1 parent 2e5aa3d6

refactor:【IoT 物联网】重命名 RuleScene => SceneRule

Showing 21 changed files with 284 additions and 285 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/IotRuleSceneController.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/IotSceneRuleController.java
... ... @@ -4,12 +4,12 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
7   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleScenePageReqVO;
8   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleSceneRespVO;
9   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleSceneSaveReqVO;
10   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleSceneUpdateStatusReqVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRulePageReqVO;
  8 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRuleRespVO;
  9 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRuleSaveReqVO;
  10 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRuleUpdateStatusReqVO;
11 11 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
12   -import cn.iocoder.yudao.module.iot.service.rule.scene.IotRuleSceneService;
  12 +import cn.iocoder.yudao.module.iot.service.rule.scene.IotSceneRuleService;
13 13 import io.swagger.v3.oas.annotations.Operation;
14 14 import io.swagger.v3.oas.annotations.Parameter;
15 15 import io.swagger.v3.oas.annotations.tags.Tag;
... ... @@ -24,71 +24,70 @@ import java.util.List;
24 24 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
25 25 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
26 26  
27   -// TODO @puhui999:SceneRule 方法名,类名等;
28 27 @Tag(name = "管理后台 - IoT 场景联动")
29 28 @RestController
30   -@RequestMapping("/iot/rule-scene")
  29 +@RequestMapping("/iot/scene-rule")
31 30 @Validated
32   -public class IotRuleSceneController {
  31 +public class IotSceneRuleController {
33 32  
34 33 @Resource
35   - private IotRuleSceneService ruleSceneService;
  34 + private IotSceneRuleService sceneRuleService;
36 35  
37 36 @PostMapping("/create")
38 37 @Operation(summary = "创建场景联动")
39   - @PreAuthorize("@ss.hasPermission('iot:rule-scene:create')")
40   - public CommonResult<Long> createRuleScene(@Valid @RequestBody IotRuleSceneSaveReqVO createReqVO) {
41   - return success(ruleSceneService.createRuleScene(createReqVO));
  38 + @PreAuthorize("@ss.hasPermission('iot:scene-rule:create')")
  39 + public CommonResult<Long> createSceneRule(@Valid @RequestBody IotSceneRuleSaveReqVO createReqVO) {
  40 + return success(sceneRuleService.createSceneRule(createReqVO));
42 41 }
43 42  
44 43 @PutMapping("/update")
45 44 @Operation(summary = "更新场景联动")
46   - @PreAuthorize("@ss.hasPermission('iot:rule-scene:update')")
47   - public CommonResult<Boolean> updateRuleScene(@Valid @RequestBody IotRuleSceneSaveReqVO updateReqVO) {
48   - ruleSceneService.updateRuleScene(updateReqVO);
  45 + @PreAuthorize("@ss.hasPermission('iot:scene-rule:update')")
  46 + public CommonResult<Boolean> updateSceneRule(@Valid @RequestBody IotSceneRuleSaveReqVO updateReqVO) {
  47 + sceneRuleService.updateSceneRule(updateReqVO);
49 48 return success(true);
50 49 }
51 50  
52 51 @PutMapping("/update-status")
53 52 @Operation(summary = "更新场景联动状态")
54   - @PreAuthorize("@ss.hasPermission('iot:rule-scene:update')")
55   - public CommonResult<Boolean> updateRuleSceneStatus(@Valid @RequestBody IotRuleSceneUpdateStatusReqVO updateReqVO) {
56   - ruleSceneService.updateRuleSceneStatus(updateReqVO.getId(), updateReqVO.getStatus());
  53 + @PreAuthorize("@ss.hasPermission('iot:scene-rule:update')")
  54 + public CommonResult<Boolean> updateSceneRuleStatus(@Valid @RequestBody IotSceneRuleUpdateStatusReqVO updateReqVO) {
  55 + sceneRuleService.updateSceneRuleStatus(updateReqVO.getId(), updateReqVO.getStatus());
57 56 return success(true);
58 57 }
59 58  
60 59 @DeleteMapping("/delete")
61 60 @Operation(summary = "删除场景联动")
62 61 @Parameter(name = "id", description = "编号", required = true)
63   - @PreAuthorize("@ss.hasPermission('iot:rule-scene:delete')")
64   - public CommonResult<Boolean> deleteRuleScene(@RequestParam("id") Long id) {
65   - ruleSceneService.deleteRuleScene(id);
  62 + @PreAuthorize("@ss.hasPermission('iot:scene-rule:delete')")
  63 + public CommonResult<Boolean> deleteSceneRule(@RequestParam("id") Long id) {
  64 + sceneRuleService.deleteSceneRule(id);
66 65 return success(true);
67 66 }
68 67  
69 68 @GetMapping("/get")
70 69 @Operation(summary = "获得场景联动")
71 70 @Parameter(name = "id", description = "编号", required = true, example = "1024")
72   - @PreAuthorize("@ss.hasPermission('iot:rule-scene:query')")
73   - public CommonResult<IotRuleSceneRespVO> getRuleScene(@RequestParam("id") Long id) {
74   - IotSceneRuleDO ruleScene = ruleSceneService.getRuleScene(id);
75   - return success(BeanUtils.toBean(ruleScene, IotRuleSceneRespVO.class));
  71 + @PreAuthorize("@ss.hasPermission('iot:scene-rule:query')")
  72 + public CommonResult<IotSceneRuleRespVO> getSceneRule(@RequestParam("id") Long id) {
  73 + IotSceneRuleDO sceneRule = sceneRuleService.getSceneRule(id);
  74 + return success(BeanUtils.toBean(sceneRule, IotSceneRuleRespVO.class));
76 75 }
77 76  
78 77 @GetMapping("/page")
79 78 @Operation(summary = "获得场景联动分页")
80   - @PreAuthorize("@ss.hasPermission('iot:rule-scene:query')")
81   - public CommonResult<PageResult<IotRuleSceneRespVO>> getRuleScenePage(@Valid IotRuleScenePageReqVO pageReqVO) {
82   - PageResult<IotSceneRuleDO> pageResult = ruleSceneService.getRuleScenePage(pageReqVO);
83   - return success(BeanUtils.toBean(pageResult, IotRuleSceneRespVO.class));
  79 + @PreAuthorize("@ss.hasPermission('iot:scene-rule:query')")
  80 + public CommonResult<PageResult<IotSceneRuleRespVO>> getSceneRulePage(@Valid IotSceneRulePageReqVO pageReqVO) {
  81 + PageResult<IotSceneRuleDO> pageResult = sceneRuleService.getSceneRulePage(pageReqVO);
  82 + return success(BeanUtils.toBean(pageResult, IotSceneRuleRespVO.class));
84 83 }
85 84  
86 85 @GetMapping("/simple-list")
87 86 @Operation(summary = "获取场景联动的精简信息列表", description = "主要用于前端的下拉选项")
88   - public CommonResult<List<IotRuleSceneRespVO>> getRuleSceneSimpleList() {
89   - List<IotSceneRuleDO> list = ruleSceneService.getRuleSceneListByStatus(CommonStatusEnum.ENABLE.getStatus());
  87 + public CommonResult<List<IotSceneRuleRespVO>> getSceneRuleSimpleList() {
  88 + List<IotSceneRuleDO> list = sceneRuleService.getSceneRuleListByStatus(CommonStatusEnum.ENABLE.getStatus());
90 89 return success(convertList(list, scene -> // 只返回 id、name 字段
91   - new IotRuleSceneRespVO().setId(scene.getId()).setName(scene.getName())));
  90 + new IotSceneRuleRespVO().setId(scene.getId()).setName(scene.getName())));
92 91 }
93 92  
94 93 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotRuleScenePageReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotSceneRulePageReqVO.java
... ... @@ -17,7 +17,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
17 17 @Data
18 18 @EqualsAndHashCode(callSuper = true)
19 19 @ToString(callSuper = true)
20   -public class IotRuleScenePageReqVO extends PageParam {
  20 +public class IotSceneRulePageReqVO extends PageParam {
21 21  
22 22 @Schema(description = "场景名称", example = "赵六")
23 23 private String name;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotRuleSceneRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotSceneRuleRespVO.java
... ... @@ -9,7 +9,7 @@ import java.util.List;
9 9  
10 10 @Schema(description = "管理后台 - IoT 场景联动 Response VO")
11 11 @Data
12   -public class IotRuleSceneRespVO {
  12 +public class IotSceneRuleRespVO {
13 13  
14 14 @Schema(description = "场景编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15865")
15 15 private Long id;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotRuleSceneSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotSceneRuleSaveReqVO.java
... ... @@ -12,7 +12,7 @@ import java.util.List;
12 12  
13 13 @Schema(description = "管理后台 - IoT 场景联动新增/修改 Request VO")
14 14 @Data
15   -public class IotRuleSceneSaveReqVO {
  15 +public class IotSceneRuleSaveReqVO {
16 16  
17 17 @Schema(description = "场景编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15865")
18 18 private Long id;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotRuleSceneUpdateStatusReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/scene/IotSceneRuleUpdateStatusReqVO.java
... ... @@ -8,7 +8,7 @@ import lombok.Data;
8 8  
9 9 @Schema(description = "管理后台 - IoT 场景联动更新状态 Request VO")
10 10 @Data
11   -public class IotRuleSceneUpdateStatusReqVO {
  11 +public class IotSceneRuleUpdateStatusReqVO {
12 12  
13 13 @Schema(description = "场景联动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
14 14 @NotNull(message = "场景联动编号不能为空")
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotSceneRuleDO.java
... ... @@ -7,10 +7,10 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
8 8 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
9 9 import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO;
10   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum;
11   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneConditionOperatorEnum;
12   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneConditionTypeEnum;
13   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneTriggerTypeEnum;
  10 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleActionTypeEnum;
  11 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum;
  12 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionTypeEnum;
  13 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum;
14 14 import com.baomidou.mybatisplus.annotation.KeySequence;
15 15 import com.baomidou.mybatisplus.annotation.TableField;
16 16 import com.baomidou.mybatisplus.annotation.TableId;
... ... @@ -79,13 +79,13 @@ public class IotSceneRuleDO extends TenantBaseDO {
79 79 /**
80 80 * 场景事件类型
81 81 *
82   - * 枚举 {@link IotRuleSceneTriggerTypeEnum}
83   - * 1. {@link IotRuleSceneTriggerTypeEnum#DEVICE_STATE_UPDATE} 时,operator 非空,并且 value 为在线状态
84   - * 2. {@link IotRuleSceneTriggerTypeEnum#DEVICE_PROPERTY_POST}
85   - * {@link IotRuleSceneTriggerTypeEnum#DEVICE_EVENT_POST} 时,identifier、operator 非空,并且 value 为属性值
86   - * 3. {@link IotRuleSceneTriggerTypeEnum#DEVICE_EVENT_POST}
87   - * {@link IotRuleSceneTriggerTypeEnum#DEVICE_SERVICE_INVOKE} 时,identifier 非空,但是 operator、value 为空
88   - * 4. {@link IotRuleSceneTriggerTypeEnum#TIMER} 时,conditions 非空,并且设备无关(无需 productId、deviceId 字段)
  82 + * 枚举 {@link IotSceneRuleTriggerTypeEnum}
  83 + * 1. {@link IotSceneRuleTriggerTypeEnum#DEVICE_STATE_UPDATE} 时,operator 非空,并且 value 为在线状态
  84 + * 2. {@link IotSceneRuleTriggerTypeEnum#DEVICE_PROPERTY_POST}
  85 + * {@link IotSceneRuleTriggerTypeEnum#DEVICE_EVENT_POST} 时,identifier、operator 非空,并且 value 为属性值
  86 + * 3. {@link IotSceneRuleTriggerTypeEnum#DEVICE_EVENT_POST}
  87 + * {@link IotSceneRuleTriggerTypeEnum#DEVICE_SERVICE_INVOKE} 时,identifier 非空,但是 operator、value 为空
  88 + * 4. {@link IotSceneRuleTriggerTypeEnum#TIMER} 时,conditions 非空,并且设备无关(无需 productId、deviceId 字段)
89 89 */
90 90 private Integer type;
91 91  
... ... @@ -111,14 +111,14 @@ public class IotSceneRuleDO extends TenantBaseDO {
111 111 /**
112 112 * 操作符
113 113 *
114   - * 枚举 {@link IotRuleSceneConditionOperatorEnum}
  114 + * 枚举 {@link IotSceneRuleConditionOperatorEnum}
115 115 */
116 116 private String operator;
117 117 /**
118 118 * 参数(属性值、在线状态)
119 119 * <p>
120 120 * 如果有多个值,则使用 "," 分隔,类似 "1,2,3"。
121   - * 例如说,{@link IotRuleSceneConditionOperatorEnum#IN}、{@link IotRuleSceneConditionOperatorEnum#BETWEEN}
  121 + * 例如说,{@link IotSceneRuleConditionOperatorEnum#IN}、{@link IotSceneRuleConditionOperatorEnum#BETWEEN}
122 122 */
123 123 private String value;
124 124  
... ... @@ -148,10 +148,10 @@ public class IotSceneRuleDO extends TenantBaseDO {
148 148 /**
149 149 * 触发条件类型
150 150 *
151   - * 枚举 {@link IotRuleSceneConditionTypeEnum}
152   - * 1. {@link IotRuleSceneConditionTypeEnum#DEVICE_STATE} 时,operator 非空,并且 value 为在线状态
153   - * 2. {@link IotRuleSceneConditionTypeEnum#DEVICE_PROPERTY} 时,identifier、operator 非空,并且 value 为属性值
154   - * 3. {@link IotRuleSceneConditionTypeEnum#CURRENT_TIME} 时,operator 非空(使用 DATE_TIME_ 和 TIME_ 部分),并且 value 非空
  151 + * 枚举 {@link IotSceneRuleConditionTypeEnum}
  152 + * 1. {@link IotSceneRuleConditionTypeEnum#DEVICE_STATE} 时,operator 非空,并且 value 为在线状态
  153 + * 2. {@link IotSceneRuleConditionTypeEnum#DEVICE_PROPERTY} 时,identifier、operator 非空,并且 value 为属性值
  154 + * 3. {@link IotSceneRuleConditionTypeEnum#CURRENT_TIME} 时,operator 非空(使用 DATE_TIME_ 和 TIME_ 部分),并且 value 非空
155 155 */
156 156 private Integer type;
157 157  
... ... @@ -176,14 +176,14 @@ public class IotSceneRuleDO extends TenantBaseDO {
176 176 /**
177 177 * 操作符
178 178 *
179   - * 枚举 {@link IotRuleSceneConditionOperatorEnum}
  179 + * 枚举 {@link IotSceneRuleConditionOperatorEnum}
180 180 */
181 181 private String operator;
182 182 /**
183 183 * 参数
184 184 *
185 185 * 如果有多个值,则使用 "," 分隔,类似 "1,2,3"。
186   - * 例如说,{@link IotRuleSceneConditionOperatorEnum#IN}、{@link IotRuleSceneConditionOperatorEnum#BETWEEN}
  186 + * 例如说,{@link IotSceneRuleConditionOperatorEnum#IN}、{@link IotSceneRuleConditionOperatorEnum#BETWEEN}
187 187 */
188 188 private String param;
189 189  
... ... @@ -198,11 +198,11 @@ public class IotSceneRuleDO extends TenantBaseDO {
198 198 /**
199 199 * 执行类型
200 200 *
201   - * 枚举 {@link IotRuleSceneActionTypeEnum}
202   - * 1. {@link IotRuleSceneActionTypeEnum#DEVICE_PROPERTY_SET} 时,params 非空
203   - * {@link IotRuleSceneActionTypeEnum#DEVICE_SERVICE_INVOKE} 时,params 非空
204   - * 2. {@link IotRuleSceneActionTypeEnum#ALERT_TRIGGER} 时,alertConfigId 为空,因为是 {@link IotAlertConfigDO} 里面关联它
205   - * 3. {@link IotRuleSceneActionTypeEnum#ALERT_RECOVER} 时,alertConfigId 非空
  201 + * 枚举 {@link IotSceneRuleActionTypeEnum}
  202 + * 1. {@link IotSceneRuleActionTypeEnum#DEVICE_PROPERTY_SET} 时,params 非空
  203 + * {@link IotSceneRuleActionTypeEnum#DEVICE_SERVICE_INVOKE} 时,params 非空
  204 + * 2. {@link IotSceneRuleActionTypeEnum#ALERT_TRIGGER} 时,alertConfigId 为空,因为是 {@link IotAlertConfigDO} 里面关联它
  205 + * 3. {@link IotSceneRuleActionTypeEnum#ALERT_RECOVER} 时,alertConfigId 非空
206 206 */
207 207 private Integer type;
208 208  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/rule/IotRuleSceneMapper.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/rule/IotSceneRuleMapper.java
... ... @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.dal.mysql.rule;
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleScenePageReqVO;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRulePageReqVO;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
8 8 import org.apache.ibatis.annotations.Mapper;
9 9  
... ... @@ -15,9 +15,9 @@ import java.util.List;
15 15 * @author HUIHUI
16 16 */
17 17 @Mapper
18   -public interface IotRuleSceneMapper extends BaseMapperX<IotSceneRuleDO> {
  18 +public interface IotSceneRuleMapper extends BaseMapperX<IotSceneRuleDO> {
19 19  
20   - default PageResult<IotSceneRuleDO> selectPage(IotRuleScenePageReqVO reqVO) {
  20 + default PageResult<IotSceneRuleDO> selectPage(IotSceneRulePageReqVO reqVO) {
21 21 return selectPage(reqVO, new LambdaQueryWrapperX<IotSceneRuleDO>()
22 22 .likeIfPresent(IotSceneRuleDO::getName, reqVO.getName())
23 23 .likeIfPresent(IotSceneRuleDO::getDescription, reqVO.getDescription())
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneActionTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotSceneRuleActionTypeEnum.java
... ... @@ -14,7 +14,7 @@ import java.util.Arrays;
14 14 */
15 15 @RequiredArgsConstructor
16 16 @Getter
17   -public enum IotRuleSceneActionTypeEnum implements ArrayValuable<Integer> {
  17 +public enum IotSceneRuleActionTypeEnum implements ArrayValuable<Integer> {
18 18  
19 19 /**
20 20 * 设备属性设置
... ... @@ -42,7 +42,7 @@ public enum IotRuleSceneActionTypeEnum implements ArrayValuable&lt;Integer&gt; {
42 42  
43 43 private final Integer type;
44 44  
45   - public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneActionTypeEnum::getType).toArray(Integer[]::new);
  45 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotSceneRuleActionTypeEnum::getType).toArray(Integer[]::new);
46 46  
47 47 @Override
48 48 public Integer[] array() {
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneConditionOperatorEnum.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotSceneRuleConditionOperatorEnum.java
... ... @@ -14,7 +14,7 @@ import java.util.Arrays;
14 14 */
15 15 @RequiredArgsConstructor
16 16 @Getter
17   -public enum IotRuleSceneConditionOperatorEnum implements ArrayValuable<String> {
  17 +public enum IotSceneRuleConditionOperatorEnum implements ArrayValuable<String> {
18 18  
19 19 EQUALS("=", "#source == #value"),
20 20 NOT_EQUALS("!=", "!(#source == #value)"),
... ... @@ -53,7 +53,7 @@ public enum IotRuleSceneConditionOperatorEnum implements ArrayValuable&lt;String&gt; {
53 53 private final String operator;
54 54 private final String springExpression;
55 55  
56   - public static final String[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneConditionOperatorEnum::getOperator).toArray(String[]::new);
  56 + public static final String[] ARRAYS = Arrays.stream(values()).map(IotSceneRuleConditionOperatorEnum::getOperator).toArray(String[]::new);
57 57  
58 58 /**
59 59 * Spring 表达式 - 原始值
... ... @@ -68,7 +68,7 @@ public enum IotRuleSceneConditionOperatorEnum implements ArrayValuable&lt;String&gt; {
68 68 */
69 69 public static final String SPRING_EXPRESSION_VALUE_LIST = "values";
70 70  
71   - public static IotRuleSceneConditionOperatorEnum operatorOf(String operator) {
  71 + public static IotSceneRuleConditionOperatorEnum operatorOf(String operator) {
72 72 return ArrayUtil.firstMatch(item -> item.getOperator().equals(operator), values());
73 73 }
74 74  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneConditionTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotSceneRuleConditionTypeEnum.java
... ... @@ -13,7 +13,7 @@ import java.util.Arrays;
13 13 */
14 14 @RequiredArgsConstructor
15 15 @Getter
16   -public enum IotRuleSceneConditionTypeEnum implements ArrayValuable<Integer> {
  16 +public enum IotSceneRuleConditionTypeEnum implements ArrayValuable<Integer> {
17 17  
18 18 DEVICE_STATE(1, "设备状态"),
19 19 DEVICE_PROPERTY(2, "设备属性"),
... ... @@ -25,7 +25,7 @@ public enum IotRuleSceneConditionTypeEnum implements ArrayValuable&lt;Integer&gt; {
25 25 private final Integer type;
26 26 private final String name;
27 27  
28   - public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneConditionTypeEnum::getType).toArray(Integer[]::new);
  28 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotSceneRuleConditionTypeEnum::getType).toArray(Integer[]::new);
29 29  
30 30 @Override
31 31 public Integer[] array() {
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneTriggerTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotSceneRuleTriggerTypeEnum.java
... ... @@ -16,7 +16,7 @@ import java.util.Arrays;
16 16 */
17 17 @RequiredArgsConstructor
18 18 @Getter
19   -public enum IotRuleSceneTriggerTypeEnum implements ArrayValuable<Integer> {
  19 +public enum IotSceneRuleTriggerTypeEnum implements ArrayValuable<Integer> {
20 20  
21 21 @Deprecated
22 22 DEVICE(1), // 设备触发 // TODO @puhui999:@芋艿:这个可以作废
... ... @@ -56,7 +56,7 @@ public enum IotRuleSceneTriggerTypeEnum implements ArrayValuable&lt;Integer&gt; {
56 56  
57 57 private final Integer type;
58 58  
59   - public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneTriggerTypeEnum::getType).toArray(Integer[]::new);
  59 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotSceneRuleTriggerTypeEnum::getType).toArray(Integer[]::new);
60 60  
61 61 @Override
62 62 public Integer[] array() {
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/job/rule/IotRuleSceneJob.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/job/rule/IotSceneRuleJob.java
1 1 package cn.iocoder.yudao.module.iot.job.rule;
2 2  
3 3 import cn.hutool.core.map.MapUtil;
4   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneTriggerTypeEnum;
5   -import cn.iocoder.yudao.module.iot.service.rule.scene.IotRuleSceneService;
  4 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum;
  5 +import cn.iocoder.yudao.module.iot.service.rule.scene.IotSceneRuleService;
6 6 import jakarta.annotation.Resource;
7 7 import lombok.extern.slf4j.Slf4j;
8 8 import org.quartz.JobExecutionContext;
... ... @@ -11,48 +11,48 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
11 11 import java.util.Map;
12 12  
13 13 /**
14   - * IoT 规则场景 Job,用于执行 {@link IotRuleSceneTriggerTypeEnum#TIMER} 类型的规则场景
  14 + * IoT 规则场景 Job,用于执行 {@link IotSceneRuleTriggerTypeEnum#TIMER} 类型的规则场景
15 15 *
16 16 * @author 芋道源码
17 17 */
18 18 @Slf4j
19   -public class IotRuleSceneJob extends QuartzJobBean {
  19 +public class IotSceneRuleJob extends QuartzJobBean {
20 20  
21 21 /**
22 22 * JobData Key - 规则场景编号
23 23 */
24   - public static final String JOB_DATA_KEY_RULE_SCENE_ID = "ruleSceneId";
  24 + public static final String JOB_DATA_KEY_RULE_SCENE_ID = "sceneRuleId";
25 25  
26 26 @Resource
27   - private IotRuleSceneService ruleSceneService;
  27 + private IotSceneRuleService sceneRuleService;
28 28  
29 29 @Override
30 30 protected void executeInternal(JobExecutionContext context) {
31 31 // 获得规则场景编号
32   - Long ruleSceneId = context.getMergedJobDataMap().getLong(JOB_DATA_KEY_RULE_SCENE_ID);
  32 + Long sceneRuleId = context.getMergedJobDataMap().getLong(JOB_DATA_KEY_RULE_SCENE_ID);
33 33  
34 34 // 执行规则场景
35   - ruleSceneService.executeRuleSceneByTimer(ruleSceneId);
  35 + sceneRuleService.executeSceneRuleByTimer(sceneRuleId);
36 36 }
37 37  
38 38 /**
39 39 * 创建 JobData Map
40 40 *
41   - * @param ruleSceneId 规则场景编号
  41 + * @param sceneRuleId 规则场景编号
42 42 * @return JobData Map
43 43 */
44   - public static Map<String, Object> buildJobDataMap(Long ruleSceneId) {
45   - return MapUtil.of(JOB_DATA_KEY_RULE_SCENE_ID, ruleSceneId);
  44 + public static Map<String, Object> buildJobDataMap(Long sceneRuleId) {
  45 + return MapUtil.of(JOB_DATA_KEY_RULE_SCENE_ID, sceneRuleId);
46 46 }
47 47  
48 48 /**
49 49 * 创建 Job 名字
50 50 *
51   - * @param ruleSceneId 规则场景编号
  51 + * @param sceneRuleId 规则场景编号
52 52 * @return Job 名字
53 53 */
54   - public static String buildJobName(Long ruleSceneId) {
55   - return String.format("%s_%d", IotRuleSceneJob.class.getSimpleName(), ruleSceneId);
  54 + public static String buildJobName(Long sceneRuleId) {
  55 + return String.format("%s_%d", IotSceneRuleJob.class.getSimpleName(), sceneRuleId);
56 56 }
57 57  
58 58 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/consumer/rule/IotRuleSceneMessageHandler.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/consumer/rule/IotSceneRuleMessageHandler.java
... ... @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.mq.consumer.rule;
3 3 import cn.iocoder.yudao.module.iot.core.messagebus.core.IotMessageBus;
4 4 import cn.iocoder.yudao.module.iot.core.messagebus.core.IotMessageSubscriber;
5 5 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
6   -import cn.iocoder.yudao.module.iot.service.rule.scene.IotRuleSceneService;
  6 +import cn.iocoder.yudao.module.iot.service.rule.scene.IotSceneRuleService;
7 7 import jakarta.annotation.PostConstruct;
8 8 import jakarta.annotation.Resource;
9 9 import lombok.extern.slf4j.Slf4j;
... ... @@ -17,10 +17,10 @@ import org.springframework.stereotype.Component;
17 17 */
18 18 @Component
19 19 @Slf4j
20   -public class IotRuleSceneMessageHandler implements IotMessageSubscriber<IotDeviceMessage> {
  20 +public class IotSceneRuleMessageHandler implements IotMessageSubscriber<IotDeviceMessage> {
21 21  
22 22 @Resource
23   - private IotRuleSceneService ruleSceneService;
  23 + private IotSceneRuleService sceneRuleService;
24 24  
25 25 @Resource
26 26 private IotMessageBus messageBus;
... ... @@ -46,7 +46,7 @@ public class IotRuleSceneMessageHandler implements IotMessageSubscriber&lt;IotDevic
46 46 return;
47 47 }
48 48 log.info("[onMessage][消息内容({})]", message);
49   - ruleSceneService.executeRuleSceneByDevice(message);
  49 + sceneRuleService.executeSceneRuleByDevice(message);
50 50 }
51 51  
52 52 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigServiceImpl.java
... ... @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConf
6 6 import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigSaveReqVO;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO;
8 8 import cn.iocoder.yudao.module.iot.dal.mysql.alert.IotAlertConfigMapper;
9   -import cn.iocoder.yudao.module.iot.service.rule.scene.IotRuleSceneService;
  9 +import cn.iocoder.yudao.module.iot.service.rule.scene.IotSceneRuleService;
10 10 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
11 11 import jakarta.annotation.Resource;
12 12 import org.springframework.context.annotation.Lazy;
... ... @@ -32,7 +32,7 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService {
32 32  
33 33 @Resource
34 34 @Lazy // 延迟,避免循环依赖报错
35   - private IotRuleSceneService ruleSceneService;
  35 + private IotSceneRuleService sceneRuleService;
36 36  
37 37 @Resource
38 38 private AdminUserApi adminUserApi;
... ... @@ -40,7 +40,7 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService {
40 40 @Override
41 41 public Long createAlertConfig(IotAlertConfigSaveReqVO createReqVO) {
42 42 // 校验关联数据是否存在
43   - ruleSceneService.validateRuleSceneList(createReqVO.getSceneRuleIds());
  43 + sceneRuleService.validateSceneRuleList(createReqVO.getSceneRuleIds());
44 44 adminUserApi.validateUserList(createReqVO.getReceiveUserIds());
45 45  
46 46 // 插入
... ... @@ -54,7 +54,7 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService {
54 54 // 校验存在
55 55 validateAlertConfigExists(updateReqVO.getId());
56 56 // 校验关联数据是否存在
57   - ruleSceneService.validateRuleSceneList(updateReqVO.getSceneRuleIds());
  57 + sceneRuleService.validateSceneRuleList(updateReqVO.getSceneRuleIds());
58 58 adminUserApi.validateUserList(updateReqVO.getReceiveUserIds());
59 59  
60 60 // 更新
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/IotRuleSceneService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/IotSceneRuleService.java
1 1 package cn.iocoder.yudao.module.iot.service.rule.scene;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleScenePageReqVO;
5   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleSceneSaveReqVO;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRulePageReqVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRuleSaveReqVO;
6 6 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
8   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneTriggerTypeEnum;
  8 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum;
9 9 import jakarta.validation.Valid;
10 10  
11 11 import java.util.Collection;
... ... @@ -16,7 +16,7 @@ import java.util.List;
16 16 *
17 17 * @author 芋道源码
18 18 */
19   -public interface IotRuleSceneService {
  19 +public interface IotSceneRuleService {
20 20  
21 21 /**
22 22 * 创建场景联动
... ... @@ -24,14 +24,14 @@ public interface IotRuleSceneService {
24 24 * @param createReqVO 创建信息
25 25 * @return 编号
26 26 */
27   - Long createRuleScene(@Valid IotRuleSceneSaveReqVO createReqVO);
  27 + Long createSceneRule(@Valid IotSceneRuleSaveReqVO createReqVO);
28 28  
29 29 /**
30 30 * 更新场景联动
31 31 *
32 32 * @param updateReqVO 更新信息
33 33 */
34   - void updateRuleScene(@Valid IotRuleSceneSaveReqVO updateReqVO);
  34 + void updateSceneRule(@Valid IotSceneRuleSaveReqVO updateReqVO);
35 35  
36 36 /**
37 37 * 更新场景联动状态
... ... @@ -39,14 +39,14 @@ public interface IotRuleSceneService {
39 39 * @param id 场景联动编号
40 40 * @param status 状态
41 41 */
42   - void updateRuleSceneStatus(Long id, Integer status);
  42 + void updateSceneRuleStatus(Long id, Integer status);
43 43  
44 44 /**
45 45 * 删除场景联动
46 46 *
47 47 * @param id 编号
48 48 */
49   - void deleteRuleScene(Long id);
  49 + void deleteSceneRule(Long id);
50 50  
51 51 /**
52 52 * 获得场景联动
... ... @@ -54,7 +54,7 @@ public interface IotRuleSceneService {
54 54 * @param id 编号
55 55 * @return 场景联动
56 56 */
57   - IotSceneRuleDO getRuleScene(Long id);
  57 + IotSceneRuleDO getSceneRule(Long id);
58 58  
59 59 /**
60 60 * 获得场景联动分页
... ... @@ -62,7 +62,7 @@ public interface IotRuleSceneService {
62 62 * @param pageReqVO 分页查询
63 63 * @return 场景联动分页
64 64 */
65   - PageResult<IotSceneRuleDO> getRuleScenePage(IotRuleScenePageReqVO pageReqVO);
  65 + PageResult<IotSceneRuleDO> getSceneRulePage(IotSceneRulePageReqVO pageReqVO);
66 66  
67 67 /**
68 68 * 校验规则场景联动规则编号们是否存在。如下情况,视为无效:
... ... @@ -70,7 +70,7 @@ public interface IotRuleSceneService {
70 70 *
71 71 * @param ids 场景联动规则编号数组
72 72 */
73   - void validateRuleSceneList(Collection<Long> ids);
  73 + void validateSceneRuleList(Collection<Long> ids);
74 74  
75 75 /**
76 76 * 获得指定状态的场景联动列表
... ... @@ -78,7 +78,7 @@ public interface IotRuleSceneService {
78 78 * @param status 状态
79 79 * @return 场景联动列表
80 80 */
81   - List<IotSceneRuleDO> getRuleSceneListByStatus(Integer status);
  81 + List<IotSceneRuleDO> getSceneRuleListByStatus(Integer status);
82 82  
83 83 /**
84 84 * 【缓存】获得指定设备的场景列表
... ... @@ -87,20 +87,20 @@ public interface IotRuleSceneService {
87 87 * @param deviceName 设备名称
88 88 * @return 场景列表
89 89 */
90   - List<IotSceneRuleDO> getRuleSceneListByProductKeyAndDeviceNameFromCache(String productKey, String deviceName);
  90 + List<IotSceneRuleDO> getSceneRuleListByProductKeyAndDeviceNameFromCache(String productKey, String deviceName);
91 91  
92 92 /**
93   - * 基于 {@link IotRuleSceneTriggerTypeEnum#DEVICE} 场景,执行规则场景
  93 + * 基于 {@link IotSceneRuleTriggerTypeEnum#DEVICE} 场景,执行规则场景
94 94 *
95 95 * @param message 消息
96 96 */
97   - void executeRuleSceneByDevice(IotDeviceMessage message);
  97 + void executeSceneRuleByDevice(IotDeviceMessage message);
98 98  
99 99 /**
100   - * 基于 {@link IotRuleSceneTriggerTypeEnum#TIMER} 场景,执行规则场景
  100 + * 基于 {@link IotSceneRuleTriggerTypeEnum#TIMER} 场景,执行规则场景
101 101 *
102 102 * @param id 场景联动规则编号
103 103 */
104   - void executeRuleSceneByTimer(Long id);
  104 + void executeSceneRuleByTimer(Long id);
105 105  
106 106 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/IotRuleSceneServiceImpl.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/IotSceneRuleServiceImpl.java
... ... @@ -15,17 +15,17 @@ import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
15 15 import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils;
16 16 import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
17 17 import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
18   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleScenePageReqVO;
19   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleSceneSaveReqVO;
  18 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRulePageReqVO;
  19 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRuleSaveReqVO;
20 20 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
21 21 import cn.iocoder.yudao.module.iot.core.util.IotDeviceMessageUtils;
22 22 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
23 23 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
24 24 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
25   -import cn.iocoder.yudao.module.iot.dal.mysql.rule.IotRuleSceneMapper;
26   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneConditionOperatorEnum;
27   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneConditionTypeEnum;
28   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneTriggerTypeEnum;
  25 +import cn.iocoder.yudao.module.iot.dal.mysql.rule.IotSceneRuleMapper;
  26 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionOperatorEnum;
  27 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleConditionTypeEnum;
  28 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleTriggerTypeEnum;
29 29 import cn.iocoder.yudao.module.iot.framework.job.core.IotSchedulerManager;
30 30 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
31 31 import cn.iocoder.yudao.module.iot.service.product.IotProductService;
... ... @@ -53,13 +53,13 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.RULE_SCENE_NO
53 53 @Service
54 54 @Validated
55 55 @Slf4j
56   -public class IotRuleSceneServiceImpl implements IotRuleSceneService {
  56 +public class IotSceneRuleServiceImpl implements IotSceneRuleService {
57 57  
58 58 @Resource
59   - private IotRuleSceneMapper ruleSceneMapper;
  59 + private IotSceneRuleMapper sceneRuleMapper;
60 60  
61 61 @Resource
62   - private List<IotSceneRuleAction> ruleSceneActions;
  62 + private List<IotSceneRuleAction> sceneRuleActions;
63 63  
64 64 @Resource(name = "iotSchedulerManager")
65 65 private IotSchedulerManager schedulerManager;
... ... @@ -71,90 +71,90 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
71 71 private IotDeviceService deviceService;
72 72  
73 73 @Override
74   - public Long createRuleScene(IotRuleSceneSaveReqVO createReqVO) {
75   - IotSceneRuleDO ruleScene = BeanUtils.toBean(createReqVO, IotSceneRuleDO.class);
76   - ruleSceneMapper.insert(ruleScene);
77   - return ruleScene.getId();
  74 + public Long createSceneRule(IotSceneRuleSaveReqVO createReqVO) {
  75 + IotSceneRuleDO sceneRule = BeanUtils.toBean(createReqVO, IotSceneRuleDO.class);
  76 + sceneRuleMapper.insert(sceneRule);
  77 + return sceneRule.getId();
78 78 }
79 79  
80 80 @Override
81   - public void updateRuleScene(IotRuleSceneSaveReqVO updateReqVO) {
  81 + public void updateSceneRule(IotSceneRuleSaveReqVO updateReqVO) {
82 82 // 校验存在
83   - validateRuleSceneExists(updateReqVO.getId());
  83 + validateSceneRuleExists(updateReqVO.getId());
84 84 // 更新
85 85 IotSceneRuleDO updateObj = BeanUtils.toBean(updateReqVO, IotSceneRuleDO.class);
86   - ruleSceneMapper.updateById(updateObj);
  86 + sceneRuleMapper.updateById(updateObj);
87 87 }
88 88  
89 89 @Override
90   - public void updateRuleSceneStatus(Long id, Integer status) {
  90 + public void updateSceneRuleStatus(Long id, Integer status) {
91 91 // 校验存在
92   - validateRuleSceneExists(id);
  92 + validateSceneRuleExists(id);
93 93 // 更新状态
94 94 IotSceneRuleDO updateObj = new IotSceneRuleDO().setId(id).setStatus(status);
95   - ruleSceneMapper.updateById(updateObj);
  95 + sceneRuleMapper.updateById(updateObj);
96 96 }
97 97  
98 98 @Override
99   - public void deleteRuleScene(Long id) {
  99 + public void deleteSceneRule(Long id) {
100 100 // 校验存在
101   - validateRuleSceneExists(id);
  101 + validateSceneRuleExists(id);
102 102 // 删除
103   - ruleSceneMapper.deleteById(id);
  103 + sceneRuleMapper.deleteById(id);
104 104 }
105 105  
106   - private void validateRuleSceneExists(Long id) {
107   - if (ruleSceneMapper.selectById(id) == null) {
  106 + private void validateSceneRuleExists(Long id) {
  107 + if (sceneRuleMapper.selectById(id) == null) {
108 108 throw exception(RULE_SCENE_NOT_EXISTS);
109 109 }
110 110 }
111 111  
112 112 @Override
113   - public IotSceneRuleDO getRuleScene(Long id) {
114   - return ruleSceneMapper.selectById(id);
  113 + public IotSceneRuleDO getSceneRule(Long id) {
  114 + return sceneRuleMapper.selectById(id);
115 115 }
116 116  
117 117 @Override
118   - public PageResult<IotSceneRuleDO> getRuleScenePage(IotRuleScenePageReqVO pageReqVO) {
119   - return ruleSceneMapper.selectPage(pageReqVO);
  118 + public PageResult<IotSceneRuleDO> getSceneRulePage(IotSceneRulePageReqVO pageReqVO) {
  119 + return sceneRuleMapper.selectPage(pageReqVO);
120 120 }
121 121  
122 122 @Override
123   - public void validateRuleSceneList(Collection<Long> ids) {
  123 + public void validateSceneRuleList(Collection<Long> ids) {
124 124 if (CollUtil.isEmpty(ids)) {
125 125 return;
126 126 }
127 127 // 批量查询存在的规则场景
128   - List<IotSceneRuleDO> existingScenes = ruleSceneMapper.selectByIds(ids);
  128 + List<IotSceneRuleDO> existingScenes = sceneRuleMapper.selectByIds(ids);
129 129 if (existingScenes.size() != ids.size()) {
130 130 throw exception(RULE_SCENE_NOT_EXISTS);
131 131 }
132 132 }
133 133  
134 134 @Override
135   - public List<IotSceneRuleDO> getRuleSceneListByStatus(Integer status) {
136   - return ruleSceneMapper.selectListByStatus(status);
  135 + public List<IotSceneRuleDO> getSceneRuleListByStatus(Integer status) {
  136 + return sceneRuleMapper.selectListByStatus(status);
137 137 }
138 138  
139 139 // TODO 芋艿,缓存待实现
140 140 @Override
141   - @TenantIgnore // 忽略租户隔离:因为 IotRuleSceneMessageHandler 调用时,一般未传递租户,所以需要忽略
142   - public List<IotSceneRuleDO> getRuleSceneListByProductKeyAndDeviceNameFromCache(String productKey, String deviceName) {
  141 + @TenantIgnore // 忽略租户隔离:因为 IotSceneRuleMessageHandler 调用时,一般未传递租户,所以需要忽略
  142 + public List<IotSceneRuleDO> getSceneRuleListByProductKeyAndDeviceNameFromCache(String productKey, String deviceName) {
143 143 // TODO @puhui999:一些注释,看看要不要优化下;
144 144 // 注意:旧的测试代码已删除,因为使用了废弃的数据结构
145 145 // 如需测试,请使用上面的新结构测试代码示例
146   - List<IotSceneRuleDO> list = ruleSceneMapper.selectList();
  146 + List<IotSceneRuleDO> list = sceneRuleMapper.selectList();
147 147 // 只返回启用状态的规则场景
148 148 List<IotSceneRuleDO> enabledList = filterList(list,
149   - ruleScene -> CommonStatusEnum.ENABLE.getStatus().equals(ruleScene.getStatus()));
  149 + sceneRule -> CommonStatusEnum.ENABLE.getStatus().equals(sceneRule.getStatus()));
150 150  
151 151 // 根据 productKey 和 deviceName 进行匹配
152   - return filterList(enabledList, ruleScene -> {
153   - if (CollUtil.isEmpty(ruleScene.getTriggers())) {
  152 + return filterList(enabledList, sceneRule -> {
  153 + if (CollUtil.isEmpty(sceneRule.getTriggers())) {
154 154 return false;
155 155 }
156 156  
157   - for (IotSceneRuleDO.Trigger trigger : ruleScene.getTriggers()) {
  157 + for (IotSceneRuleDO.Trigger trigger : sceneRule.getTriggers()) {
158 158 // 检查触发器是否匹配指定的产品和设备
159 159 if (isMatchProductAndDevice(trigger, productKey, deviceName)) {
160 160 return true;
... ... @@ -210,43 +210,43 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
210 210 }
211 211  
212 212 @Override
213   - public void executeRuleSceneByDevice(IotDeviceMessage message) {
  213 + public void executeSceneRuleByDevice(IotDeviceMessage message) {
214 214 // TODO @芋艿:这里的 tenantId,通过设备获取;
215 215 TenantUtils.execute(message.getTenantId(), () -> {
216 216 // 1. 获得设备匹配的规则场景
217   - List<IotSceneRuleDO> ruleScenes = getMatchedRuleSceneListByMessage(message);
218   - if (CollUtil.isEmpty(ruleScenes)) {
  217 + List<IotSceneRuleDO> sceneRules = getMatchedSceneRuleListByMessage(message);
  218 + if (CollUtil.isEmpty(sceneRules)) {
219 219 return;
220 220 }
221 221  
222 222 // 2. 执行规则场景
223   - executeRuleSceneAction(message, ruleScenes);
  223 + executeSceneRuleAction(message, sceneRules);
224 224 });
225 225 }
226 226  
227 227 @Override
228   - public void executeRuleSceneByTimer(Long id) {
  228 + public void executeSceneRuleByTimer(Long id) {
229 229 // 1.1 获得规则场景
230   - IotSceneRuleDO scene = TenantUtils.executeIgnore(() -> ruleSceneMapper.selectById(id));
  230 + IotSceneRuleDO scene = TenantUtils.executeIgnore(() -> sceneRuleMapper.selectById(id));
231 231 if (scene == null) {
232   - log.error("[executeRuleSceneByTimer][规则场景({}) 不存在]", id);
  232 + log.error("[executeSceneRuleByTimer][规则场景({}) 不存在]", id);
233 233 return;
234 234 }
235 235 if (CommonStatusEnum.isDisable(scene.getStatus())) {
236   - log.info("[executeRuleSceneByTimer][规则场景({}) 已被禁用]", id);
  236 + log.info("[executeSceneRuleByTimer][规则场景({}) 已被禁用]", id);
237 237 return;
238 238 }
239 239 // 1.2 判断是否有定时触发器,避免脏数据
240 240 IotSceneRuleDO.Trigger config = CollUtil.findOne(scene.getTriggers(),
241   - trigger -> ObjUtil.equals(trigger.getType(), IotRuleSceneTriggerTypeEnum.TIMER.getType()));
  241 + trigger -> ObjUtil.equals(trigger.getType(), IotSceneRuleTriggerTypeEnum.TIMER.getType()));
242 242 if (config == null) {
243   - log.error("[executeRuleSceneByTimer][规则场景({}) 不存在定时触发器]", scene);
  243 + log.error("[executeSceneRuleByTimer][规则场景({}) 不存在定时触发器]", scene);
244 244 return;
245 245 }
246 246  
247 247 // 2. 执行规则场景
248 248 TenantUtils.execute(scene.getTenantId(),
249   - () -> executeRuleSceneAction(null, ListUtil.toList(scene)));
  249 + () -> executeSceneRuleAction(null, ListUtil.toList(scene)));
250 250 }
251 251  
252 252 /**
... ... @@ -255,36 +255,36 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
255 255 * @param message 设备消息
256 256 * @return 规则场景列表
257 257 */
258   - private List<IotSceneRuleDO> getMatchedRuleSceneListByMessage(IotDeviceMessage message) {
  258 + private List<IotSceneRuleDO> getMatchedSceneRuleListByMessage(IotDeviceMessage message) {
259 259 // 1. 匹配设备
260 260 // TODO @芋艿:可能需要 getSelf(); 缓存
261 261 // 1.1 通过 deviceId 获取设备信息
262 262 IotDeviceDO device = deviceService.getDeviceFromCache(message.getDeviceId());
263 263 if (device == null) {
264   - log.warn("[getMatchedRuleSceneListByMessage][设备({}) 不存在]", message.getDeviceId());
  264 + log.warn("[getMatchedSceneRuleListByMessage][设备({}) 不存在]", message.getDeviceId());
265 265 return List.of();
266 266 }
267 267  
268 268 // 1.2 通过 productId 获取产品信息
269 269 IotProductDO product = productService.getProductFromCache(device.getProductId());
270 270 if (product == null) {
271   - log.warn("[getMatchedRuleSceneListByMessage][产品({}) 不存在]", device.getProductId());
  271 + log.warn("[getMatchedSceneRuleListByMessage][产品({}) 不存在]", device.getProductId());
272 272 return List.of();
273 273 }
274 274  
275 275 // 1.3 获取匹配的规则场景
276   - List<IotSceneRuleDO> ruleScenes = getRuleSceneListByProductKeyAndDeviceNameFromCache(
  276 + List<IotSceneRuleDO> sceneRules = getSceneRuleListByProductKeyAndDeviceNameFromCache(
277 277 product.getProductKey(), device.getDeviceName());
278   - if (CollUtil.isEmpty(ruleScenes)) {
279   - return ruleScenes;
  278 + if (CollUtil.isEmpty(sceneRules)) {
  279 + return sceneRules;
280 280 }
281 281  
282 282 // 2. 匹配 trigger 触发器的条件
283   - return filterList(ruleScenes, ruleScene -> {
284   - for (IotSceneRuleDO.Trigger trigger : ruleScene.getTriggers()) {
  283 + return filterList(sceneRules, sceneRule -> {
  284 + for (IotSceneRuleDO.Trigger trigger : sceneRule.getTriggers()) {
285 285 // 2.1 检查触发器类型,根据新的枚举值进行匹配
286 286 // TODO @芋艿:需要根据新的触发器类型枚举进行适配
287   - // 原来使用 IotRuleSceneTriggerTypeEnum.DEVICE,新结构可能有不同的类型
  287 + // 原来使用 IotSceneRuleTriggerTypeEnum.DEVICE,新结构可能有不同的类型
288 288  
289 289 // 2.2 条件分组为空,说明没有匹配的条件,因此不匹配
290 290 if (CollUtil.isEmpty(trigger.getConditionGroups())) {
... ... @@ -303,7 +303,7 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
303 303 for (IotSceneRuleDO.TriggerCondition condition : conditionGroup) {
304 304 // TODO @芋艿:这里需要实现具体的条件匹配逻辑
305 305 // 根据新的 TriggerCondition 结构进行匹配
306   - if (!isTriggerConditionMatched(message, condition, ruleScene, trigger)) {
  306 + if (!isTriggerConditionMatched(message, condition, sceneRule, trigger)) {
307 307 allConditionsMatched = false;
308 308 break;
309 309 }
... ... @@ -316,7 +316,7 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
316 316 }
317 317  
318 318 if (anyGroupMatched) {
319   - log.info("[getMatchedRuleSceneList][消息({}) 匹配到规则场景编号({}) 的触发器({})]", message, ruleScene.getId(), trigger);
  319 + log.info("[getMatchedSceneRuleList][消息({}) 匹配到规则场景编号({}) 的触发器({})]", message, sceneRule.getId(), trigger);
320 320 return true;
321 321 }
322 322 }
... ... @@ -329,31 +329,31 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
329 329 *
330 330 * @param message 设备消息
331 331 * @param condition 触发条件
332   - * @param ruleScene 规则场景(用于日志,无其它作用)
  332 + * @param sceneRule 规则场景(用于日志,无其它作用)
333 333 * @param trigger 触发器(用于日志,无其它作用)
334 334 * @return 是否匹配
335 335 */
336 336 private boolean isTriggerConditionMatched(IotDeviceMessage message, IotSceneRuleDO.TriggerCondition condition,
337   - IotSceneRuleDO ruleScene, IotSceneRuleDO.Trigger trigger) {
  337 + IotSceneRuleDO sceneRule, IotSceneRuleDO.Trigger trigger) {
338 338 try {
339 339 // 1. 根据条件类型进行匹配
340   - if (IotRuleSceneConditionTypeEnum.DEVICE_STATE.getType().equals(condition.getType())) {
  340 + if (IotSceneRuleConditionTypeEnum.DEVICE_STATE.getType().equals(condition.getType())) {
341 341 // 设备状态条件匹配
342 342 return matchDeviceStateCondition(message, condition);
343   - } else if (IotRuleSceneConditionTypeEnum.DEVICE_PROPERTY.getType().equals(condition.getType())) {
  343 + } else if (IotSceneRuleConditionTypeEnum.DEVICE_PROPERTY.getType().equals(condition.getType())) {
344 344 // 设备属性条件匹配
345 345 return matchDevicePropertyCondition(message, condition);
346   - } else if (IotRuleSceneConditionTypeEnum.CURRENT_TIME.getType().equals(condition.getType())) {
  346 + } else if (IotSceneRuleConditionTypeEnum.CURRENT_TIME.getType().equals(condition.getType())) {
347 347 // 当前时间条件匹配
348 348 return matchCurrentTimeCondition(condition);
349 349 } else {
350 350 log.warn("[isTriggerConditionMatched][规则场景编号({}) 的触发器({}) 存在未知的条件类型({})]",
351   - ruleScene.getId(), trigger, condition.getType());
  351 + sceneRule.getId(), trigger, condition.getType());
352 352 return false;
353 353 }
354 354 } catch (Exception e) {
355 355 log.error("[isTriggerConditionMatched][规则场景编号({}) 的触发器({}) 条件匹配异常]",
356   - ruleScene.getId(), trigger, e);
  356 + sceneRule.getId(), trigger, e);
357 357 return false;
358 358 }
359 359 }
... ... @@ -420,7 +420,7 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
420 420 private boolean evaluateCondition(Object sourceValue, String operator, String paramValue) {
421 421 try {
422 422 // 1. 校验操作符是否合法
423   - IotRuleSceneConditionOperatorEnum operatorEnum = IotRuleSceneConditionOperatorEnum.operatorOf(operator);
  423 + IotSceneRuleConditionOperatorEnum operatorEnum = IotSceneRuleConditionOperatorEnum.operatorOf(operator);
424 424 if (operatorEnum == null) {
425 425 log.warn("[evaluateCondition][存在错误的操作符({})]", operator);
426 426 return false;
... ... @@ -428,22 +428,22 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
428 428  
429 429 // 2.1 构建 Spring 表达式的变量
430 430 Map<String, Object> springExpressionVariables = MapUtil.<String, Object>builder()
431   - .put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_SOURCE, sourceValue)
  431 + .put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_SOURCE, sourceValue)
432 432 .build();
433 433 // 2.2 根据操作符类型处理参数值
434 434 if (StrUtil.isNotBlank(paramValue)) {
435   - // TODO @puhui999:这里是不是在 IotRuleSceneConditionOperatorEnum 加个属性;
436   - if (operatorEnum == IotRuleSceneConditionOperatorEnum.IN
437   - || operatorEnum == IotRuleSceneConditionOperatorEnum.NOT_IN
438   - || operatorEnum == IotRuleSceneConditionOperatorEnum.BETWEEN
439   - || operatorEnum == IotRuleSceneConditionOperatorEnum.NOT_BETWEEN) {
  435 + // TODO @puhui999:这里是不是在 IotSceneRuleConditionOperatorEnum 加个属性;
  436 + if (operatorEnum == IotSceneRuleConditionOperatorEnum.IN
  437 + || operatorEnum == IotSceneRuleConditionOperatorEnum.NOT_IN
  438 + || operatorEnum == IotSceneRuleConditionOperatorEnum.BETWEEN
  439 + || operatorEnum == IotSceneRuleConditionOperatorEnum.NOT_BETWEEN) {
440 440 // 处理多值情况
441 441 List<String> paramValues = StrUtil.split(paramValue, CharPool.COMMA);
442   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_VALUE_LIST,
  442 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_VALUE_LIST,
443 443 convertList(paramValues, NumberUtil::parseDouble));
444 444 } else {
445 445 // 处理单值情况
446   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_VALUE,
  446 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_VALUE,
447 447 NumberUtil.parseDouble(paramValue));
448 448 }
449 449 }
... ... @@ -464,19 +464,19 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
464 464 *
465 465 * @param message 设备消息
466 466 * @param condition 触发条件
467   - * @param ruleScene 规则场景(用于日志,无其它作用)
  467 + * @param sceneRule 规则场景(用于日志,无其它作用)
468 468 * @param trigger 触发器(用于日志,无其它作用)
469 469 * @return 是否匹配
470 470 */
471 471 @SuppressWarnings({"unchecked", "DataFlowIssue"})
472 472 private boolean isTriggerConditionParameterMatched(IotDeviceMessage message, IotSceneRuleDO.TriggerCondition condition,
473   - IotSceneRuleDO ruleScene, IotSceneRuleDO.Trigger trigger) {
  473 + IotSceneRuleDO sceneRule, IotSceneRuleDO.Trigger trigger) {
474 474 // 1.1 校验操作符是否合法
475   - IotRuleSceneConditionOperatorEnum operator =
476   - IotRuleSceneConditionOperatorEnum.operatorOf(condition.getOperator());
  475 + IotSceneRuleConditionOperatorEnum operator =
  476 + IotSceneRuleConditionOperatorEnum.operatorOf(condition.getOperator());
477 477 if (operator == null) {
478 478 log.error("[isTriggerConditionParameterMatched][规则场景编号({}) 的触发器({}) 存在错误的操作符({})]",
479   - ruleScene.getId(), trigger, condition.getOperator());
  479 + sceneRule.getId(), trigger, condition.getOperator());
480 480 return false;
481 481 }
482 482 // 1.2 校验消息是否包含对应的值
... ... @@ -488,31 +488,31 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
488 488 // 2.1 构建 Spring 表达式的变量
489 489 Map<String, Object> springExpressionVariables = new HashMap<>();
490 490 try {
491   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_SOURCE, messageValue);
492   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_VALUE, condition.getParam());
  491 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_SOURCE, messageValue);
  492 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_VALUE, condition.getParam());
493 493 List<String> parameterValues = StrUtil.splitTrim(condition.getParam(), CharPool.COMMA);
494   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_VALUE_LIST, parameterValues);
  494 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_VALUE_LIST, parameterValues);
495 495 // 特殊:解决数字的比较。因为 Spring 是基于它的 compareTo 方法,对数字的比较存在问题!
496   - if (ObjectUtils.equalsAny(operator, IotRuleSceneConditionOperatorEnum.BETWEEN,
497   - IotRuleSceneConditionOperatorEnum.NOT_BETWEEN,
498   - IotRuleSceneConditionOperatorEnum.GREATER_THAN,
499   - IotRuleSceneConditionOperatorEnum.GREATER_THAN_OR_EQUALS,
500   - IotRuleSceneConditionOperatorEnum.LESS_THAN,
501   - IotRuleSceneConditionOperatorEnum.LESS_THAN_OR_EQUALS)
  496 + if (ObjectUtils.equalsAny(operator, IotSceneRuleConditionOperatorEnum.BETWEEN,
  497 + IotSceneRuleConditionOperatorEnum.NOT_BETWEEN,
  498 + IotSceneRuleConditionOperatorEnum.GREATER_THAN,
  499 + IotSceneRuleConditionOperatorEnum.GREATER_THAN_OR_EQUALS,
  500 + IotSceneRuleConditionOperatorEnum.LESS_THAN,
  501 + IotSceneRuleConditionOperatorEnum.LESS_THAN_OR_EQUALS)
502 502 && NumberUtil.isNumber(messageValue)
503 503 && NumberUtils.isAllNumber(parameterValues)) {
504   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_SOURCE,
  504 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_SOURCE,
505 505 NumberUtil.parseDouble(messageValue));
506   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_VALUE,
  506 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_VALUE,
507 507 NumberUtil.parseDouble(condition.getParam()));
508   - springExpressionVariables.put(IotRuleSceneConditionOperatorEnum.SPRING_EXPRESSION_VALUE_LIST,
  508 + springExpressionVariables.put(IotSceneRuleConditionOperatorEnum.SPRING_EXPRESSION_VALUE_LIST,
509 509 convertList(parameterValues, NumberUtil::parseDouble));
510 510 }
511 511 // 2.2 计算 Spring 表达式
512 512 return (Boolean) SpringExpressionUtils.parseExpression(operator.getSpringExpression(), springExpressionVariables);
513 513 } catch (Exception e) {
514 514 log.error("[isTriggerConditionParameterMatched][消息({}) 规则场景编号({}) 的触发器({}) 的匹配表达式({}/{}) 计算异常]",
515   - message, ruleScene.getId(), trigger, operator, springExpressionVariables, e);
  515 + message, sceneRule.getId(), trigger, operator, springExpressionVariables, e);
516 516 return false;
517 517 }
518 518 }
... ... @@ -521,15 +521,15 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
521 521 * 执行规则场景的动作
522 522 *
523 523 * @param message 设备消息
524   - * @param ruleScenes 规则场景列表
  524 + * @param sceneRules 规则场景列表
525 525 */
526   - private void executeRuleSceneAction(IotDeviceMessage message, List<IotSceneRuleDO> ruleScenes) {
  526 + private void executeSceneRuleAction(IotDeviceMessage message, List<IotSceneRuleDO> sceneRules) {
527 527 // 1. 遍历规则场景
528   - ruleScenes.forEach(ruleScene -> {
  528 + sceneRules.forEach(sceneRule -> {
529 529 // 2. 遍历规则场景的动作
530   - ruleScene.getActions().forEach(actionConfig -> {
  530 + sceneRule.getActions().forEach(actionConfig -> {
531 531 // 3.1 获取对应的动作 Action 数组
532   - List<IotSceneRuleAction> actions = filterList(ruleSceneActions,
  532 + List<IotSceneRuleAction> actions = filterList(sceneRuleActions,
533 533 action -> action.getType().getType().equals(actionConfig.getType()));
534 534 if (CollUtil.isEmpty(actions)) {
535 535 return;
... ... @@ -537,12 +537,12 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService {
537 537 // 3.2 执行动作
538 538 actions.forEach(action -> {
539 539 try {
540   - action.execute(message, ruleScene, actionConfig);
541   - log.info("[executeRuleSceneAction][消息({}) 规则场景编号({}) 的执行动作({}) 成功]",
542   - message, ruleScene.getId(), actionConfig);
  540 + action.execute(message, sceneRule, actionConfig);
  541 + log.info("[executeSceneRuleAction][消息({}) 规则场景编号({}) 的执行动作({}) 成功]",
  542 + message, sceneRule.getId(), actionConfig);
543 543 } catch (Exception e) {
544   - log.error("[executeRuleSceneAction][消息({}) 规则场景编号({}) 的执行动作({}) 执行异常]",
545   - message, ruleScene.getId(), actionConfig, e);
  544 + log.error("[executeSceneRuleAction][消息({}) 规则场景编号({}) 的执行动作({}) 执行异常]",
  545 + message, sceneRule.getId(), actionConfig, e);
546 546 }
547 547 });
548 548 });
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotAlertRecoverSceneRuleAction.java
... ... @@ -5,7 +5,7 @@ import cn.hutool.core.util.StrUtil;
5 5 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
6 6 import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertRecordDO;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
8   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum;
  8 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleActionTypeEnum;
9 9 import cn.iocoder.yudao.module.iot.service.alert.IotAlertRecordService;
10 10 import jakarta.annotation.Resource;
11 11 import org.springframework.stereotype.Component;
... ... @@ -42,8 +42,8 @@ public class IotAlertRecoverSceneRuleAction implements IotSceneRuleAction {
42 42 }
43 43  
44 44 @Override
45   - public IotRuleSceneActionTypeEnum getType() {
46   - return IotRuleSceneActionTypeEnum.ALERT_RECOVER;
  45 + public IotSceneRuleActionTypeEnum getType() {
  46 + return IotSceneRuleActionTypeEnum.ALERT_RECOVER;
47 47 }
48 48  
49 49 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotAlertTriggerSceneRuleAction.java
... ... @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
5 5 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
6 6 import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
8   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum;
  8 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleActionTypeEnum;
9 9 import cn.iocoder.yudao.module.iot.service.alert.IotAlertConfigService;
10 10 import cn.iocoder.yudao.module.iot.service.alert.IotAlertRecordService;
11 11 import cn.iocoder.yudao.module.system.api.mail.MailSendApi;
... ... @@ -62,8 +62,8 @@ public class IotAlertTriggerSceneRuleAction implements IotSceneRuleAction {
62 62 }
63 63  
64 64 @Override
65   - public IotRuleSceneActionTypeEnum getType() {
66   - return IotRuleSceneActionTypeEnum.ALERT_TRIGGER;
  65 + public IotSceneRuleActionTypeEnum getType() {
  66 + return IotSceneRuleActionTypeEnum.ALERT_TRIGGER;
67 67 }
68 68  
69 69 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotDeviceControlRuleSceneAction.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotDeviceControlSceneRuleAction.java
... ... @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.service.rule.scene.action;
2 2  
3 3 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
4 4 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
5   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum;
  5 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleActionTypeEnum;
6 6 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
7 7 import cn.iocoder.yudao.module.iot.service.device.message.IotDeviceMessageService;
8 8 import jakarta.annotation.Resource;
... ... @@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
16 16 */
17 17 @Component
18 18 @Slf4j
19   -public class IotDeviceControlRuleSceneAction implements IotSceneRuleAction {
  19 +public class IotDeviceControlSceneRuleAction implements IotSceneRuleAction {
20 20  
21 21 @Resource
22 22 private IotDeviceService deviceService;
... ... @@ -48,8 +48,8 @@ public class IotDeviceControlRuleSceneAction implements IotSceneRuleAction {
48 48 }
49 49  
50 50 @Override
51   - public IotRuleSceneActionTypeEnum getType() {
52   - return IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET;
  51 + public IotSceneRuleActionTypeEnum getType() {
  52 + return IotSceneRuleActionTypeEnum.DEVICE_PROPERTY_SET;
53 53 }
54 54  
55 55 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotSceneRuleAction.java
... ... @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.service.rule.scene.action;
2 2  
3 3 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
4 4 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
5   -import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum;
  5 +import cn.iocoder.yudao.module.iot.enums.rule.IotSceneRuleActionTypeEnum;
6 6  
7 7 import javax.annotation.Nullable;
8 8  
... ... @@ -31,6 +31,6 @@ public interface IotSceneRuleAction {
31 31 *
32 32 * @return 类型
33 33 */
34   - IotRuleSceneActionTypeEnum getType();
  34 + IotSceneRuleActionTypeEnum getType();
35 35  
36 36 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/IotRuleSceneServiceSimpleTest.java renamed to yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/scene/IotSceneRuleServiceSimpleTest.java
... ... @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.iot.service.rule.scene;
2 2  
3 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
4 4 import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
5   -import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotRuleSceneSaveReqVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene.IotSceneRuleSaveReqVO;
6 6 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotSceneRuleDO;
7   -import cn.iocoder.yudao.module.iot.dal.mysql.rule.IotRuleSceneMapper;
  7 +import cn.iocoder.yudao.module.iot.dal.mysql.rule.IotSceneRuleMapper;
8 8 import cn.iocoder.yudao.module.iot.framework.job.core.IotSchedulerManager;
9 9 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
10 10 import cn.iocoder.yudao.module.iot.service.product.IotProductService;
... ... @@ -24,21 +24,21 @@ import static org.mockito.ArgumentMatchers.any;
24 24 import static org.mockito.Mockito.*;
25 25  
26 26 /**
27   - * {@link IotRuleSceneServiceImpl} 的简化单元测试类
  27 + * {@link IotSceneRuleServiceImpl} 的简化单元测试类
28 28 * 使用 Mockito 进行纯单元测试,不依赖 Spring 容器
29 29 *
30 30 * @author 芋道源码
31 31 */
32   -public class IotRuleSceneServiceSimpleTest extends BaseMockitoUnitTest {
  32 +public class IotSceneRuleServiceSimpleTest extends BaseMockitoUnitTest {
33 33  
34 34 @InjectMocks
35   - private IotRuleSceneServiceImpl ruleSceneService;
  35 + private IotSceneRuleServiceImpl sceneRuleService;
36 36  
37 37 @Mock
38   - private IotRuleSceneMapper ruleSceneMapper;
  38 + private IotSceneRuleMapper sceneRuleMapper;
39 39  
40 40 @Mock
41   - private List<IotSceneRuleAction> ruleSceneActions;
  41 + private List<IotSceneRuleAction> sceneRuleActions;
42 42  
43 43 @Mock
44 44 private IotSchedulerManager schedulerManager;
... ... @@ -50,9 +50,9 @@ public class IotRuleSceneServiceSimpleTest extends BaseMockitoUnitTest {
50 50 private IotDeviceService deviceService;
51 51  
52 52 @Test
53   - public void testCreateRuleScene_success() {
  53 + public void testCreateScene_Rule_success() {
54 54 // 准备参数
55   - IotRuleSceneSaveReqVO createReqVO = randomPojo(IotRuleSceneSaveReqVO.class, o -> {
  55 + IotSceneRuleSaveReqVO createReqVO = randomPojo(IotSceneRuleSaveReqVO.class, o -> {
56 56 o.setId(null);
57 57 o.setStatus(CommonStatusEnum.ENABLE.getStatus());
58 58 o.setTriggers(Collections.singletonList(randomPojo(IotSceneRuleDO.Trigger.class)));
... ... @@ -61,25 +61,25 @@ public class IotRuleSceneServiceSimpleTest extends BaseMockitoUnitTest {
61 61  
62 62 // Mock 行为
63 63 Long expectedId = randomLongId();
64   - when(ruleSceneMapper.insert(any(IotSceneRuleDO.class))).thenAnswer(invocation -> {
65   - IotSceneRuleDO ruleScene = invocation.getArgument(0);
66   - ruleScene.setId(expectedId);
  64 + when(sceneRuleMapper.insert(any(IotSceneRuleDO.class))).thenAnswer(invocation -> {
  65 + IotSceneRuleDO sceneRule = invocation.getArgument(0);
  66 + sceneRule.setId(expectedId);
67 67 return 1;
68 68 });
69 69  
70 70 // 调用
71   - Long ruleSceneId = ruleSceneService.createRuleScene(createReqVO);
  71 + Long sceneRuleId = sceneRuleService.createSceneRule(createReqVO);
72 72  
73 73 // 断言
74   - assertEquals(expectedId, ruleSceneId);
75   - verify(ruleSceneMapper, times(1)).insert(any(IotSceneRuleDO.class));
  74 + assertEquals(expectedId, sceneRuleId);
  75 + verify(sceneRuleMapper, times(1)).insert(any(IotSceneRuleDO.class));
76 76 }
77 77  
78 78 @Test
79   - public void testUpdateRuleScene_success() {
  79 + public void testUpdateScene_Rule_success() {
80 80 // 准备参数
81 81 Long id = randomLongId();
82   - IotRuleSceneSaveReqVO updateReqVO = randomPojo(IotRuleSceneSaveReqVO.class, o -> {
  82 + IotSceneRuleSaveReqVO updateReqVO = randomPojo(IotSceneRuleSaveReqVO.class, o -> {
83 83 o.setId(id);
84 84 o.setStatus(CommonStatusEnum.ENABLE.getStatus());
85 85 o.setTriggers(Collections.singletonList(randomPojo(IotSceneRuleDO.Trigger.class)));
... ... @@ -87,125 +87,125 @@ public class IotRuleSceneServiceSimpleTest extends BaseMockitoUnitTest {
87 87 });
88 88  
89 89 // Mock 行为
90   - IotSceneRuleDO existingRuleScene = randomPojo(IotSceneRuleDO.class, o -> o.setId(id));
91   - when(ruleSceneMapper.selectById(id)).thenReturn(existingRuleScene);
92   - when(ruleSceneMapper.updateById(any(IotSceneRuleDO.class))).thenReturn(1);
  90 + IotSceneRuleDO existingSceneRule = randomPojo(IotSceneRuleDO.class, o -> o.setId(id));
  91 + when(sceneRuleMapper.selectById(id)).thenReturn(existingSceneRule);
  92 + when(sceneRuleMapper.updateById(any(IotSceneRuleDO.class))).thenReturn(1);
93 93  
94 94 // 调用
95   - assertDoesNotThrow(() -> ruleSceneService.updateRuleScene(updateReqVO));
  95 + assertDoesNotThrow(() -> sceneRuleService.updateSceneRule(updateReqVO));
96 96  
97 97 // 验证
98   - verify(ruleSceneMapper, times(1)).selectById(id);
99   - verify(ruleSceneMapper, times(1)).updateById(any(IotSceneRuleDO.class));
  98 + verify(sceneRuleMapper, times(1)).selectById(id);
  99 + verify(sceneRuleMapper, times(1)).updateById(any(IotSceneRuleDO.class));
100 100 }
101 101  
102 102 @Test
103   - public void testDeleteRuleScene_success() {
  103 + public void testDeleteSceneRule_success() {
104 104 // 准备参数
105 105 Long id = randomLongId();
106 106  
107 107 // Mock 行为
108   - IotSceneRuleDO existingRuleScene = randomPojo(IotSceneRuleDO.class, o -> o.setId(id));
109   - when(ruleSceneMapper.selectById(id)).thenReturn(existingRuleScene);
110   - when(ruleSceneMapper.deleteById(id)).thenReturn(1);
  108 + IotSceneRuleDO existingSceneRule = randomPojo(IotSceneRuleDO.class, o -> o.setId(id));
  109 + when(sceneRuleMapper.selectById(id)).thenReturn(existingSceneRule);
  110 + when(sceneRuleMapper.deleteById(id)).thenReturn(1);
111 111  
112 112 // 调用
113   - assertDoesNotThrow(() -> ruleSceneService.deleteRuleScene(id));
  113 + assertDoesNotThrow(() -> sceneRuleService.deleteSceneRule(id));
114 114  
115 115 // 验证
116   - verify(ruleSceneMapper, times(1)).selectById(id);
117   - verify(ruleSceneMapper, times(1)).deleteById(id);
  116 + verify(sceneRuleMapper, times(1)).selectById(id);
  117 + verify(sceneRuleMapper, times(1)).deleteById(id);
118 118 }
119 119  
120 120 @Test
121   - public void testGetRuleScene() {
  121 + public void testGetSceneRule() {
122 122 // 准备参数
123 123 Long id = randomLongId();
124   - IotSceneRuleDO expectedRuleScene = randomPojo(IotSceneRuleDO.class, o -> o.setId(id));
  124 + IotSceneRuleDO expectedSceneRule = randomPojo(IotSceneRuleDO.class, o -> o.setId(id));
125 125  
126 126 // Mock 行为
127   - when(ruleSceneMapper.selectById(id)).thenReturn(expectedRuleScene);
  127 + when(sceneRuleMapper.selectById(id)).thenReturn(expectedSceneRule);
128 128  
129 129 // 调用
130   - IotSceneRuleDO result = ruleSceneService.getRuleScene(id);
  130 + IotSceneRuleDO result = sceneRuleService.getSceneRule(id);
131 131  
132 132 // 断言
133   - assertEquals(expectedRuleScene, result);
134   - verify(ruleSceneMapper, times(1)).selectById(id);
  133 + assertEquals(expectedSceneRule, result);
  134 + verify(sceneRuleMapper, times(1)).selectById(id);
135 135 }
136 136  
137 137 @Test
138   - public void testUpdateRuleSceneStatus_success() {
  138 + public void testUpdateSceneRuleStatus_success() {
139 139 // 准备参数
140 140 Long id = randomLongId();
141 141 Integer status = CommonStatusEnum.DISABLE.getStatus();
142 142  
143 143 // Mock 行为
144   - IotSceneRuleDO existingRuleScene = randomPojo(IotSceneRuleDO.class, o -> {
  144 + IotSceneRuleDO existingSceneRule = randomPojo(IotSceneRuleDO.class, o -> {
145 145 o.setId(id);
146 146 o.setStatus(CommonStatusEnum.ENABLE.getStatus());
147 147 });
148   - when(ruleSceneMapper.selectById(id)).thenReturn(existingRuleScene);
149   - when(ruleSceneMapper.updateById(any(IotSceneRuleDO.class))).thenReturn(1);
  148 + when(sceneRuleMapper.selectById(id)).thenReturn(existingSceneRule);
  149 + when(sceneRuleMapper.updateById(any(IotSceneRuleDO.class))).thenReturn(1);
150 150  
151 151 // 调用
152   - assertDoesNotThrow(() -> ruleSceneService.updateRuleSceneStatus(id, status));
  152 + assertDoesNotThrow(() -> sceneRuleService.updateSceneRuleStatus(id, status));
153 153  
154 154 // 验证
155   - verify(ruleSceneMapper, times(1)).selectById(id);
156   - verify(ruleSceneMapper, times(1)).updateById(any(IotSceneRuleDO.class));
  155 + verify(sceneRuleMapper, times(1)).selectById(id);
  156 + verify(sceneRuleMapper, times(1)).updateById(any(IotSceneRuleDO.class));
157 157 }
158 158  
159 159 @Test
160   - public void testExecuteRuleSceneByTimer_success() {
  160 + public void testExecuteSceneRuleByTimer_success() {
161 161 // 准备参数
162 162 Long id = randomLongId();
163 163  
164 164 // Mock 行为
165   - IotSceneRuleDO ruleScene = randomPojo(IotSceneRuleDO.class, o -> {
  165 + IotSceneRuleDO sceneRule = randomPojo(IotSceneRuleDO.class, o -> {
166 166 o.setId(id);
167 167 o.setStatus(CommonStatusEnum.ENABLE.getStatus());
168 168 });
169   - when(ruleSceneMapper.selectById(id)).thenReturn(ruleScene);
  169 + when(sceneRuleMapper.selectById(id)).thenReturn(sceneRule);
170 170  
171 171 // 调用
172   - assertDoesNotThrow(() -> ruleSceneService.executeRuleSceneByTimer(id));
  172 + assertDoesNotThrow(() -> sceneRuleService.executeSceneRuleByTimer(id));
173 173  
174 174 // 验证
175   - verify(ruleSceneMapper, times(1)).selectById(id);
  175 + verify(sceneRuleMapper, times(1)).selectById(id);
176 176 }
177 177  
178 178 @Test
179   - public void testExecuteRuleSceneByTimer_notExists() {
  179 + public void testExecuteSceneRuleByTimer_notExists() {
180 180 // 准备参数
181 181 Long id = randomLongId();
182 182  
183 183 // Mock 行为
184   - when(ruleSceneMapper.selectById(id)).thenReturn(null);
  184 + when(sceneRuleMapper.selectById(id)).thenReturn(null);
185 185  
186 186 // 调用 - 不存在的场景规则应该不会抛异常,只是记录日志
187   - assertDoesNotThrow(() -> ruleSceneService.executeRuleSceneByTimer(id));
  187 + assertDoesNotThrow(() -> sceneRuleService.executeSceneRuleByTimer(id));
188 188  
189 189 // 验证
190   - verify(ruleSceneMapper, times(1)).selectById(id);
  190 + verify(sceneRuleMapper, times(1)).selectById(id);
191 191 }
192 192  
193 193 @Test
194   - public void testExecuteRuleSceneByTimer_disabled() {
  194 + public void testExecuteSceneRuleByTimer_disabled() {
195 195 // 准备参数
196 196 Long id = randomLongId();
197 197  
198 198 // Mock 行为
199   - IotSceneRuleDO ruleScene = randomPojo(IotSceneRuleDO.class, o -> {
  199 + IotSceneRuleDO sceneRule = randomPojo(IotSceneRuleDO.class, o -> {
200 200 o.setId(id);
201 201 o.setStatus(CommonStatusEnum.DISABLE.getStatus());
202 202 });
203   - when(ruleSceneMapper.selectById(id)).thenReturn(ruleScene);
  203 + when(sceneRuleMapper.selectById(id)).thenReturn(sceneRule);
204 204  
205 205 // 调用 - 禁用的场景规则应该不会执行,只是记录日志
206   - assertDoesNotThrow(() -> ruleSceneService.executeRuleSceneByTimer(id));
  206 + assertDoesNotThrow(() -> sceneRuleService.executeSceneRuleByTimer(id));
207 207  
208 208 // 验证
209   - verify(ruleSceneMapper, times(1)).selectById(id);
  209 + verify(sceneRuleMapper, times(1)).selectById(id);
210 210 }
211 211 }
... ...