Commit 779cde24ecbd3a8f23ed9f46953e028c175a5867
1 parent
1beb5c03
reactor:【IoT 物联网】调整下 IotSceneRuleAction 等类名
Showing
13 changed files
with
32 additions
and
42 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/IotAlertConfigController.java
| ... | ... | @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.iot.controller.admin.alert; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.IotAlertConfigPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.IotAlertConfigRespVO; | |
| 8 | -import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.IotAlertConfigSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigRespVO; | |
| 8 | +import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigSaveReqVO; | |
| 9 | 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO; |
| 10 | 10 | import cn.iocoder.yudao.module.iot.service.alert.IotAlertConfigService; |
| 11 | 11 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/IotAlertConfigPageReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/config/IotAlertConfigPageReqVO.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/IotAlertConfigRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/config/IotAlertConfigRespVO.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/IotAlertConfigSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/alert/vo/config/IotAlertConfigSaveReqVO.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/alert/IotAlertRecordDO.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 7 | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 8 | 8 | import com.baomidou.mybatisplus.annotation.TableField; |
| 9 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 9 | 10 | import com.baomidou.mybatisplus.annotation.TableName; |
| 10 | 11 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; |
| 11 | 12 | import lombok.AllArgsConstructor; |
| ... | ... | @@ -29,12 +30,12 @@ public class IotAlertRecordDO extends BaseDO { |
| 29 | 30 | /** |
| 30 | 31 | * 记录编号 |
| 31 | 32 | */ |
| 32 | - @TableField | |
| 33 | + @TableId | |
| 33 | 34 | private Long id; |
| 34 | 35 | /** |
| 35 | 36 | * 告警名称 |
| 36 | 37 | * |
| 37 | - * 冗余 {@link IotAlertConfigDO#getName()} | |
| 38 | + * 冗余 {@link IotAlertConfigDO#getId()} | |
| 38 | 39 | */ |
| 39 | 40 | private Long configId; |
| 40 | 41 | /** |
| ... | ... | @@ -42,7 +43,7 @@ public class IotAlertRecordDO extends BaseDO { |
| 42 | 43 | * |
| 43 | 44 | * 冗余 {@link IotAlertConfigDO#getName()} |
| 44 | 45 | */ |
| 45 | - private String name; | |
| 46 | + private String configName; | |
| 46 | 47 | |
| 47 | 48 | /** |
| 48 | 49 | * 产品编号 |
| ... | ... | @@ -56,8 +57,6 @@ public class IotAlertRecordDO extends BaseDO { |
| 56 | 57 | * 关联 {@link IotDeviceDO#getId()} |
| 57 | 58 | */ |
| 58 | 59 | private String deviceId; |
| 59 | - | |
| 60 | - // TODO @芋艿:有没更好的方式 | |
| 61 | 60 | /** |
| 62 | 61 | * 触发的设备消息 |
| 63 | 62 | */ |
| ... | ... | @@ -65,10 +64,7 @@ public class IotAlertRecordDO extends BaseDO { |
| 65 | 64 | private IotDeviceMessage deviceMessage; |
| 66 | 65 | |
| 67 | 66 | /** |
| 68 | - * 处理状态 | |
| 69 | - * | |
| 70 | - * true - 已处理 | |
| 71 | - * false - 未处理 | |
| 67 | + * 是否处理 | |
| 72 | 68 | */ |
| 73 | 69 | private Boolean processStatus; |
| 74 | 70 | /** | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/alert/IotAlertConfigMapper.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.dal.mysql.alert; |
| 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.alert.vo.IotAlertConfigPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigPageReqVO; | |
| 7 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO; |
| 8 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneActionTypeEnum.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.enums.rule; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.core.ArrayValuable; |
| 4 | +import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; | |
| 4 | 5 | import lombok.Getter; |
| 5 | 6 | import lombok.RequiredArgsConstructor; |
| 6 | 7 | |
| ... | ... | @@ -15,17 +16,16 @@ import java.util.Arrays; |
| 15 | 16 | @Getter |
| 16 | 17 | public enum IotRuleSceneActionTypeEnum implements ArrayValuable<Integer> { |
| 17 | 18 | |
| 18 | - // TODO @芋艿:后续“对应”部分,要 @下,等包结构梳理完; | |
| 19 | 19 | /** |
| 20 | 20 | * 设备属性设置 |
| 21 | 21 | * |
| 22 | - * 对应 IotDeviceMessageMethodEnum.DEVICE_PROPERTY_SET | |
| 22 | + * 对应 {@link IotDeviceMessageMethodEnum#PROPERTY_SET} | |
| 23 | 23 | */ |
| 24 | 24 | DEVICE_PROPERTY_SET(1), |
| 25 | 25 | /** |
| 26 | 26 | * 设备服务调用 |
| 27 | 27 | * |
| 28 | - * 对应 IotDeviceMessageMethodEnum.DEVICE_SERVICE_INVOKE | |
| 28 | + * 对应 {@link IotDeviceMessageMethodEnum#SERVICE_INVOKE} | |
| 29 | 29 | */ |
| 30 | 30 | DEVICE_SERVICE_INVOKE(2), |
| 31 | 31 | |
| ... | ... | @@ -38,8 +38,6 @@ public enum IotRuleSceneActionTypeEnum implements ArrayValuable<Integer> { |
| 38 | 38 | */ |
| 39 | 39 | ALERT_RECOVER(101), |
| 40 | 40 | |
| 41 | - @Deprecated | |
| 42 | - ALERT(2), // 告警执行 | |
| 43 | 41 | ; |
| 44 | 42 | |
| 45 | 43 | private final Integer type; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigService.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.alert; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.IotAlertConfigPageReqVO; | |
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.IotAlertConfigSaveReqVO; | |
| 4 | +import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigSaveReqVO; | |
| 6 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.alert.IotAlertConfigDO; |
| 7 | 7 | import jakarta.validation.Valid; |
| 8 | 8 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigServiceImpl.java
| ... | ... | @@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.iot.service.alert; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.IotAlertConfigPageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.IotAlertConfigSaveReqVO; | |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.config.IotAlertConfigPageReqVO; | |
| 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 | 9 | import cn.iocoder.yudao.module.iot.service.rule.scene.IotRuleSceneService; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/IotRuleSceneServiceImpl.java
| ... | ... | @@ -27,7 +27,7 @@ import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneConditionOperatorEnum; |
| 27 | 27 | import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneTriggerTypeEnum; |
| 28 | 28 | import cn.iocoder.yudao.module.iot.framework.job.core.IotSchedulerManager; |
| 29 | 29 | import cn.iocoder.yudao.module.iot.job.rule.IotRuleSceneJob; |
| 30 | -import cn.iocoder.yudao.module.iot.service.rule.scene.action.IotRuleSceneAction; | |
| 30 | +import cn.iocoder.yudao.module.iot.service.rule.scene.action.IotSceneRuleAction; | |
| 31 | 31 | import jakarta.annotation.Resource; |
| 32 | 32 | import lombok.SneakyThrows; |
| 33 | 33 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -39,15 +39,13 @@ import org.quartz.impl.StdSchedulerFactory; |
| 39 | 39 | import org.springframework.stereotype.Service; |
| 40 | 40 | import org.springframework.validation.annotation.Validated; |
| 41 | 41 | |
| 42 | +import java.util.Collection; | |
| 42 | 43 | import java.util.HashMap; |
| 43 | 44 | import java.util.List; |
| 44 | 45 | import java.util.Map; |
| 45 | -import java.util.Collection; | |
| 46 | -import java.util.Set; | |
| 47 | 46 | |
| 48 | 47 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 49 | 48 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| 50 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 51 | 49 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; |
| 52 | 50 | import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.RULE_SCENE_NOT_EXISTS; |
| 53 | 51 | |
| ... | ... | @@ -65,7 +63,7 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService { |
| 65 | 63 | private IotRuleSceneMapper ruleSceneMapper; |
| 66 | 64 | |
| 67 | 65 | @Resource |
| 68 | - private List<IotRuleSceneAction> ruleSceneActions; | |
| 66 | + private List<IotSceneRuleAction> ruleSceneActions; | |
| 69 | 67 | |
| 70 | 68 | @Resource(name = "iotSchedulerManager") |
| 71 | 69 | private IotSchedulerManager schedulerManager; |
| ... | ... | @@ -437,7 +435,7 @@ public class IotRuleSceneServiceImpl implements IotRuleSceneService { |
| 437 | 435 | // 2. 遍历规则场景的动作 |
| 438 | 436 | ruleScene.getActions().forEach(actionConfig -> { |
| 439 | 437 | // 3.1 获取对应的动作 Action 数组 |
| 440 | - List<IotRuleSceneAction> actions = filterList(ruleSceneActions, | |
| 438 | + List<IotSceneRuleAction> actions = filterList(ruleSceneActions, | |
| 441 | 439 | action -> action.getType().getType().equals(actionConfig.getType())); |
| 442 | 440 | if (CollUtil.isEmpty(actions)) { |
| 443 | 441 | return; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotRuleSceneAlertAction.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotAlertTriggerRuleSceneAction.java
| ... | ... | @@ -8,21 +8,21 @@ import org.springframework.stereotype.Component; |
| 8 | 8 | import javax.annotation.Nullable; |
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | - * IoT 告警的 {@link IotRuleSceneAction} 实现类 | |
| 11 | + * IoT 告警触发的 {@link IotSceneRuleAction} 实现类 | |
| 12 | 12 | * |
| 13 | 13 | * @author 芋道源码 |
| 14 | 14 | */ |
| 15 | 15 | @Component |
| 16 | -public class IotRuleSceneAlertAction implements IotRuleSceneAction { | |
| 16 | +public class IotAlertTriggerRuleSceneAction implements IotSceneRuleAction { | |
| 17 | 17 | |
| 18 | 18 | @Override |
| 19 | 19 | public void execute(@Nullable IotDeviceMessage message, IotRuleSceneDO.ActionConfig config) { |
| 20 | - // TODO @芋艿:待实现 | |
| 20 | + // TODO @AI: | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | @Override |
| 24 | 24 | public IotRuleSceneActionTypeEnum getType() { |
| 25 | - return IotRuleSceneActionTypeEnum.ALERT; | |
| 25 | + return IotRuleSceneActionTypeEnum.ALERT_TRIGGER; | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotRuleSceneDeviceControlAction.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotDeviceControlRuleSceneAction.java
| ... | ... | @@ -12,13 +12,13 @@ import lombok.extern.slf4j.Slf4j; |
| 12 | 12 | import org.springframework.stereotype.Component; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * IoT 设备控制的 {@link IotRuleSceneAction} 实现类 | |
| 15 | + * IoT 设备控制的 {@link IotSceneRuleAction} 实现类 | |
| 16 | 16 | * |
| 17 | 17 | * @author 芋道源码 |
| 18 | 18 | */ |
| 19 | 19 | @Component |
| 20 | 20 | @Slf4j |
| 21 | -public class IotRuleSceneDeviceControlAction implements IotRuleSceneAction { | |
| 21 | +public class IotDeviceControlRuleSceneAction implements IotSceneRuleAction { | |
| 22 | 22 | |
| 23 | 23 | @Resource |
| 24 | 24 | private IotDeviceService deviceService; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotRuleSceneAction.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotSceneRuleAction.java
| ... | ... | @@ -7,16 +7,14 @@ import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum; |
| 7 | 7 | import javax.annotation.Nullable; |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * IoT 规则场景的场景执行器接口 | |
| 10 | + * IoT 场景联动的执行器接口 | |
| 11 | 11 | * |
| 12 | 12 | * @author 芋道源码 |
| 13 | 13 | */ |
| 14 | -public interface IotRuleSceneAction { | |
| 15 | - | |
| 16 | - // TODO @芋艿:groovy 或者 javascript 实现数据的转换;可以考虑基于 hutool 的 ScriptUtil 做 | |
| 14 | +public interface IotSceneRuleAction { | |
| 17 | 15 | |
| 18 | 16 | /** |
| 19 | - * 执行场景 | |
| 17 | + * 执行场景联动 | |
| 20 | 18 | * |
| 21 | 19 | * @param message 消息,允许空 |
| 22 | 20 | * 1. 空的情况:定时触发 | ... | ... |