Commit 956418d31fa247b42247d36add038d8b99530e16
1 parent
afda934c
feat:【IoT 物联网】初步实现“数据流转”功能
Showing
31 changed files
with
423 additions
and
94 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ErrorCodeConstants.java
| @@ -54,10 +54,13 @@ public interface ErrorCodeConstants { | @@ -54,10 +54,13 @@ public interface ErrorCodeConstants { | ||
| 54 | ErrorCode OTA_UPGRADE_RECORD_DUPLICATE = new ErrorCode(1_050_008_201, "升级记录重复"); | 54 | ErrorCode OTA_UPGRADE_RECORD_DUPLICATE = new ErrorCode(1_050_008_201, "升级记录重复"); |
| 55 | ErrorCode OTA_UPGRADE_RECORD_CANNOT_RETRY = new ErrorCode(1_050_008_202, "升级记录不能重试"); | 55 | ErrorCode OTA_UPGRADE_RECORD_CANNOT_RETRY = new ErrorCode(1_050_008_202, "升级记录不能重试"); |
| 56 | 56 | ||
| 57 | - // ========== IoT 数据桥梁 1-050-010-000 ========== | ||
| 58 | - ErrorCode DATA_BRIDGE_NOT_EXISTS = new ErrorCode(1_050_010_000, "IoT 数据桥梁不存在"); | 57 | + // ========== IoT 数据流转规则 1-050-010-000 ========== |
| 58 | + ErrorCode DATA_RULE_NOT_EXISTS = new ErrorCode(1_050_010_000, "数据流转规则不存在"); | ||
| 59 | 59 | ||
| 60 | - // ========== IoT 场景联动 1-050-011-000 ========== | ||
| 61 | - ErrorCode RULE_SCENE_NOT_EXISTS = new ErrorCode(1_050_011_000, "IoT 场景联动不存在"); | 60 | + // ========== IoT 数据流转目的 1-050-011-000 ========== |
| 61 | + ErrorCode DATA_BRIDGE_NOT_EXISTS = new ErrorCode(1_050_011_000, "数据桥梁不存在"); | ||
| 62 | + | ||
| 63 | + // ========== IoT 场景联动 1-050-012-000 ========== | ||
| 64 | + ErrorCode RULE_SCENE_NOT_EXISTS = new ErrorCode(1_050_012_000, "场景联动不存在"); | ||
| 62 | 65 | ||
| 63 | } | 66 | } |
| 64 | \ No newline at end of file | 67 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/IotDataRuleController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRulePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRuleRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRuleSaveReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataRuleDO; | ||
| 10 | +import cn.iocoder.yudao.module.iot.service.rule.data.IotDataRuleService; | ||
| 11 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 12 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | +import jakarta.annotation.Resource; | ||
| 15 | +import jakarta.validation.Valid; | ||
| 16 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 17 | +import org.springframework.validation.annotation.Validated; | ||
| 18 | +import org.springframework.web.bind.annotation.*; | ||
| 19 | + | ||
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 21 | + | ||
| 22 | +@Tag(name = "管理后台 - IoT 数据流转规则") | ||
| 23 | +@RestController | ||
| 24 | +@RequestMapping("/iot/data-rule") | ||
| 25 | +@Validated | ||
| 26 | +public class IotDataRuleController { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private IotDataRuleService dataRuleService; | ||
| 30 | + | ||
| 31 | + @PostMapping("/create") | ||
| 32 | + @Operation(summary = "创建数据流转规则") | ||
| 33 | + @PreAuthorize("@ss.hasPermission('iot:data-rule:create')") | ||
| 34 | + public CommonResult<Long> createDataRule(@Valid @RequestBody IotDataRuleSaveReqVO createReqVO) { | ||
| 35 | + return success(dataRuleService.createDataRule(createReqVO)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @PutMapping("/update") | ||
| 39 | + @Operation(summary = "更新数据流转规则") | ||
| 40 | + @PreAuthorize("@ss.hasPermission('iot:data-rule:update')") | ||
| 41 | + public CommonResult<Boolean> updateDataRule(@Valid @RequestBody IotDataRuleSaveReqVO updateReqVO) { | ||
| 42 | + dataRuleService.updateDataRule(updateReqVO); | ||
| 43 | + return success(true); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @DeleteMapping("/delete") | ||
| 47 | + @Operation(summary = "删除数据流转规则") | ||
| 48 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 49 | + @PreAuthorize("@ss.hasPermission('iot:data-rule:delete')") | ||
| 50 | + public CommonResult<Boolean> deleteDataRule(@RequestParam("id") Long id) { | ||
| 51 | + dataRuleService.deleteDataRule(id); | ||
| 52 | + return success(true); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @GetMapping("/get") | ||
| 56 | + @Operation(summary = "获得数据流转规则") | ||
| 57 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 58 | + @PreAuthorize("@ss.hasPermission('iot:data-rule:query')") | ||
| 59 | + public CommonResult<IotDataRuleRespVO> getDataRule(@RequestParam("id") Long id) { | ||
| 60 | + IotDataRuleDO dataRule = dataRuleService.getDataRule(id); | ||
| 61 | + return success(BeanUtils.toBean(dataRule, IotDataRuleRespVO.class)); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @GetMapping("/page") | ||
| 65 | + @Operation(summary = "获得数据流转规则分页") | ||
| 66 | + @PreAuthorize("@ss.hasPermission('iot:data-rule:query')") | ||
| 67 | + public CommonResult<PageResult<IotDataRuleRespVO>> getDataRulePage(@Valid IotDataRulePageReqVO pageReqVO) { | ||
| 68 | + PageResult<IotDataRuleDO> pageResult = dataRuleService.getDataRulePage(pageReqVO); | ||
| 69 | + return success(BeanUtils.toBean(pageResult, IotDataRuleRespVO.class)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | +} | ||
| 0 | \ No newline at end of file | 73 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/IotDataSinkController.java
| @@ -75,7 +75,7 @@ public class IotDataSinkController { | @@ -75,7 +75,7 @@ public class IotDataSinkController { | ||
| 75 | 75 | ||
| 76 | @GetMapping("/simple-list") | 76 | @GetMapping("/simple-list") |
| 77 | @Operation(summary = "获取数据目的的精简信息列表", description = "主要用于前端的下拉选项") | 77 | @Operation(summary = "获取数据目的的精简信息列表", description = "主要用于前端的下拉选项") |
| 78 | - public CommonResult<List<IotDataSinkRespVO>> getSimpleDataSinkList() { | 78 | + public CommonResult<List<IotDataSinkRespVO>> getDataSinkSimpleList() { |
| 79 | List<IotDataSinkDO> list = dataSinkService.getDataSinkListByStatus(CommonStatusEnum.ENABLE.getStatus()); | 79 | List<IotDataSinkDO> list = dataSinkService.getDataSinkListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 80 | return success(convertList(list, sink -> // 只返回 id、name 字段 | 80 | return success(convertList(list, sink -> // 只返回 id、name 字段 |
| 81 | new IotDataSinkRespVO().setId(sink.getId()).setName(sink.getName()))); | 81 | new IotDataSinkRespVO().setId(sink.getId()).setName(sink.getName()))); |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/data/rule/IotDataRulePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | + | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - IoT 数据流转规则分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +public class IotDataRulePageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "场景名称", example = "芋艿") | ||
| 17 | + private String name; | ||
| 18 | + | ||
| 19 | + @Schema(description = "场景状态", example = "1") | ||
| 20 | + private Integer status; | ||
| 21 | + | ||
| 22 | + @Schema(description = "创建时间") | ||
| 23 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 24 | + private LocalDateTime[] createTime; | ||
| 25 | + | ||
| 26 | +} | ||
| 0 | \ No newline at end of file | 27 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/data/rule/IotDataRuleRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataRuleDO; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - IoT 数据流转规则 Response VO") | ||
| 11 | +@Data | ||
| 12 | +public class IotDataRuleRespVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "场景编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8540") | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | + @Schema(description = "场景名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 18 | + private String name; | ||
| 19 | + | ||
| 20 | + @Schema(description = "场景描述", example = "你猜") | ||
| 21 | + private String description; | ||
| 22 | + | ||
| 23 | + @Schema(description = "场景状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 24 | + private Integer status; | ||
| 25 | + | ||
| 26 | + @Schema(description = "数据源配置数组", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 27 | + private List<IotDataRuleDO.SourceConfig> sourceConfigs; | ||
| 28 | + | ||
| 29 | + @Schema(description = "数据目的编号数组", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 30 | + private List<Long> sinkIds; | ||
| 31 | + | ||
| 32 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | + private LocalDateTime createTime; | ||
| 34 | + | ||
| 35 | +} | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/data/rule/IotDataRuleSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataRuleDO; | ||
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 7 | +import jakarta.validation.constraints.NotEmpty; | ||
| 8 | +import jakarta.validation.constraints.NotNull; | ||
| 9 | +import lombok.Data; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +@Schema(description = "管理后台 - IoT 数据流转规则新增/修改 Request VO") | ||
| 14 | +@Data | ||
| 15 | +public class IotDataRuleSaveReqVO { | ||
| 16 | + | ||
| 17 | + @Schema(description = "场景编号", example = "8540") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | + @Schema(description = "场景名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 21 | + @NotEmpty(message = "场景名称不能为空") | ||
| 22 | + private String name; | ||
| 23 | + | ||
| 24 | + @Schema(description = "场景描述", example = "你猜") | ||
| 25 | + private String description; | ||
| 26 | + | ||
| 27 | + @Schema(description = "场景状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 28 | + @NotNull(message = "场景状态不能为空") | ||
| 29 | + @InEnum(CommonStatusEnum.class) | ||
| 30 | + private Integer status; | ||
| 31 | + | ||
| 32 | + @Schema(description = "数据源配置数组", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | + @NotEmpty(message = "数据源配置数组不能为空") | ||
| 34 | + private List<IotDataRuleDO.SourceConfig> sourceConfigs; | ||
| 35 | + | ||
| 36 | + @Schema(description = "数据目的编号数组", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 37 | + @NotEmpty(message = "数据目的编号数组不能为空") | ||
| 38 | + private List<Long> sinkIds; | ||
| 39 | + | ||
| 40 | +} | ||
| 0 | \ No newline at end of file | 41 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/data/sink/IotDataSinkRespVO.java
| 1 | package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.sink; | 1 | package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.sink; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeAbstractConfig; | 3 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotAbstractDataSinkConfig; |
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | 6 | ||
| @@ -26,7 +26,7 @@ public class IotDataSinkRespVO { | @@ -26,7 +26,7 @@ public class IotDataSinkRespVO { | ||
| 26 | private Integer type; | 26 | private Integer type; |
| 27 | 27 | ||
| 28 | @Schema(description = "数据目的配置") | 28 | @Schema(description = "数据目的配置") |
| 29 | - private IotDataBridgeAbstractConfig config; | 29 | + private IotAbstractDataSinkConfig config; |
| 30 | 30 | ||
| 31 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 31 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 32 | private LocalDateTime createTime; | 32 | private LocalDateTime createTime; |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/data/sink/IotDataSinkSaveReqVO.java
| @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.sink; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.sink; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 5 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeAbstractConfig; | 5 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotAbstractDataSinkConfig; |
| 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; | 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; |
| 7 | import io.swagger.v3.oas.annotations.media.Schema; | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 8 | import jakarta.validation.constraints.NotEmpty; | 8 | import jakarta.validation.constraints.NotEmpty; |
| @@ -35,6 +35,6 @@ public class IotDataSinkSaveReqVO { | @@ -35,6 +35,6 @@ public class IotDataSinkSaveReqVO { | ||
| 35 | 35 | ||
| 36 | @Schema(description = "数据目的配置") | 36 | @Schema(description = "数据目的配置") |
| 37 | @NotNull(message = "数据目的配置不能为空") | 37 | @NotNull(message = "数据目的配置不能为空") |
| 38 | - private IotDataBridgeAbstractConfig config; | 38 | + private IotAbstractDataSinkConfig config; |
| 39 | 39 | ||
| 40 | } | 40 | } |
| 41 | \ No newline at end of file | 41 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotDataRuleDO.java
| 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.rule; | 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.rule; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; | 5 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; |
| 5 | import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; | 6 | import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; |
| 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| @@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; | @@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 10 | import com.baomidou.mybatisplus.annotation.TableField; | 11 | import com.baomidou.mybatisplus.annotation.TableField; |
| 11 | import com.baomidou.mybatisplus.annotation.TableName; | 12 | import com.baomidou.mybatisplus.annotation.TableName; |
| 12 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | 13 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; |
| 14 | +import jakarta.validation.constraints.NotEmpty; | ||
| 13 | import lombok.AllArgsConstructor; | 15 | import lombok.AllArgsConstructor; |
| 14 | import lombok.Builder; | 16 | import lombok.Builder; |
| 15 | import lombok.Data; | 17 | import lombok.Data; |
| @@ -24,28 +26,28 @@ import java.util.List; | @@ -24,28 +26,28 @@ import java.util.List; | ||
| 24 | * | 26 | * |
| 25 | * @author 芋道源码 | 27 | * @author 芋道源码 |
| 26 | */ | 28 | */ |
| 27 | -@TableName(value = "iot_data_flow", autoResultMap = true) | ||
| 28 | -@KeySequence("iot_data_flow_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | 29 | +@TableName(value = "iot_data_rule", autoResultMap = true) |
| 30 | +@KeySequence("iot_data_rule_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 29 | @Data | 31 | @Data |
| 30 | @Builder | 32 | @Builder |
| 31 | @NoArgsConstructor | 33 | @NoArgsConstructor |
| 32 | @AllArgsConstructor | 34 | @AllArgsConstructor |
| 33 | -public class IotDataRuleDO { | 35 | +public class IotDataRuleDO extends BaseDO { |
| 34 | 36 | ||
| 35 | /** | 37 | /** |
| 36 | - * 数据流转编号 | 38 | + * 数据流转规格编号 |
| 37 | */ | 39 | */ |
| 38 | private Long id; | 40 | private Long id; |
| 39 | /** | 41 | /** |
| 40 | - * 数据流转名称 | 42 | + * 数据流转规格名称 |
| 41 | */ | 43 | */ |
| 42 | private String name; | 44 | private String name; |
| 43 | /** | 45 | /** |
| 44 | - * 数据流转描述 | 46 | + * 数据流转规格描述 |
| 45 | */ | 47 | */ |
| 46 | private String description; | 48 | private String description; |
| 47 | /** | 49 | /** |
| 48 | - * 数据流转状态 | 50 | + * 数据流转规格状态 |
| 49 | * | 51 | * |
| 50 | * 枚举 {@link CommonStatusEnum} | 52 | * 枚举 {@link CommonStatusEnum} |
| 51 | */ | 53 | */ |
| @@ -57,7 +59,7 @@ public class IotDataRuleDO { | @@ -57,7 +59,7 @@ public class IotDataRuleDO { | ||
| 57 | @TableField(typeHandler = JacksonTypeHandler.class) | 59 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 58 | private List<SourceConfig> sourceConfigs; | 60 | private List<SourceConfig> sourceConfigs; |
| 59 | /** | 61 | /** |
| 60 | - * 数据目的编号 | 62 | + * 数据目的编号数组 |
| 61 | * | 63 | * |
| 62 | * 关联 {@link IotDataSinkDO#getId()} | 64 | * 关联 {@link IotDataSinkDO#getId()} |
| 63 | */ | 65 | */ |
| @@ -77,6 +79,7 @@ public class IotDataRuleDO { | @@ -77,6 +79,7 @@ public class IotDataRuleDO { | ||
| 77 | * | 79 | * |
| 78 | * 枚举 {@link IotDeviceMessageMethodEnum} 中的 upstream 上行部分 | 80 | * 枚举 {@link IotDeviceMessageMethodEnum} 中的 upstream 上行部分 |
| 79 | */ | 81 | */ |
| 82 | + @NotEmpty(message = "消息方法不能为空") | ||
| 80 | private String method; | 83 | private String method; |
| 81 | 84 | ||
| 82 | /** | 85 | /** |
| @@ -91,6 +94,7 @@ public class IotDataRuleDO { | @@ -91,6 +94,7 @@ public class IotDataRuleDO { | ||
| 91 | * 关联 {@link IotDeviceDO#getId()} | 94 | * 关联 {@link IotDeviceDO#getId()} |
| 92 | * 特殊:如果为 {@link IotDeviceDO#DEVICE_ID_ALL} 时,则是全部设备 | 95 | * 特殊:如果为 {@link IotDeviceDO#DEVICE_ID_ALL} 时,则是全部设备 |
| 93 | */ | 96 | */ |
| 97 | + @NotEmpty(message = "设备编号不能为空") | ||
| 94 | private Long deviceId; | 98 | private Long deviceId; |
| 95 | 99 | ||
| 96 | /** | 100 | /** |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotDataSinkDO.java
| @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeAbstractConfig; | 5 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotAbstractDataSinkConfig; |
| 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; | 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; |
| 7 | import com.baomidou.mybatisplus.annotation.KeySequence; | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 8 | import com.baomidou.mybatisplus.annotation.TableField; | 8 | import com.baomidou.mybatisplus.annotation.TableField; |
| @@ -28,35 +28,35 @@ import lombok.NoArgsConstructor; | @@ -28,35 +28,35 @@ import lombok.NoArgsConstructor; | ||
| 28 | public class IotDataSinkDO extends BaseDO { | 28 | public class IotDataSinkDO extends BaseDO { |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | - * 数据目的编号 | 31 | + * 数据流转目的编号 |
| 32 | */ | 32 | */ |
| 33 | @TableId | 33 | @TableId |
| 34 | private Long id; | 34 | private Long id; |
| 35 | /** | 35 | /** |
| 36 | - * 数据目的名称 | 36 | + * 数据流转目的名称 |
| 37 | */ | 37 | */ |
| 38 | private String name; | 38 | private String name; |
| 39 | /** | 39 | /** |
| 40 | - * 数据目的描述 | 40 | + * 数据流转目的描述 |
| 41 | */ | 41 | */ |
| 42 | private String description; | 42 | private String description; |
| 43 | /** | 43 | /** |
| 44 | - * 数据目的状态 | 44 | + * 数据流转目的状态 |
| 45 | * | 45 | * |
| 46 | * 枚举 {@link CommonStatusEnum} | 46 | * 枚举 {@link CommonStatusEnum} |
| 47 | */ | 47 | */ |
| 48 | private Integer status; | 48 | private Integer status; |
| 49 | 49 | ||
| 50 | /** | 50 | /** |
| 51 | - * 数据目的类型 | 51 | + * 数据流转目的类型 |
| 52 | * | 52 | * |
| 53 | * 枚举 {@link IotDataSinkTypeEnum} | 53 | * 枚举 {@link IotDataSinkTypeEnum} |
| 54 | */ | 54 | */ |
| 55 | private Integer type; | 55 | private Integer type; |
| 56 | /** | 56 | /** |
| 57 | - * 数据目的配置 | 57 | + * 数据流转目的配置 |
| 58 | */ | 58 | */ |
| 59 | @TableField(typeHandler = JacksonTypeHandler.class) | 59 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 60 | - private IotDataBridgeAbstractConfig config; | 60 | + private IotAbstractDataSinkConfig config; |
| 61 | 61 | ||
| 62 | } | 62 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotRuleSceneDO.java
| @@ -22,8 +22,9 @@ import lombok.NoArgsConstructor; | @@ -22,8 +22,9 @@ import lombok.NoArgsConstructor; | ||
| 22 | import java.util.List; | 22 | import java.util.List; |
| 23 | import java.util.Map; | 23 | import java.util.Map; |
| 24 | 24 | ||
| 25 | +// TODO @芋艿:优化注释; | ||
| 25 | /** | 26 | /** |
| 26 | - * IoT 场景联动 DO | 27 | + * IoT 场景联动规则 DO |
| 27 | * | 28 | * |
| 28 | * @author 芋道源码 | 29 | * @author 芋道源码 |
| 29 | */ | 30 | */ |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataBridgeAbstractConfig.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotAbstractDataSinkConfig.java
| @@ -16,14 +16,14 @@ import lombok.Data; | @@ -16,14 +16,14 @@ import lombok.Data; | ||
| 16 | @Data | 16 | @Data |
| 17 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true) | 17 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true) |
| 18 | @JsonSubTypes({ | 18 | @JsonSubTypes({ |
| 19 | - @JsonSubTypes.Type(value = IotDataBridgeHttpConfig.class, name = "1"), | ||
| 20 | - @JsonSubTypes.Type(value = IotDataBridgeMqttConfig.class, name = "10"), | ||
| 21 | - @JsonSubTypes.Type(value = IotDataBridgeRedisStreamConfig.class, name = "21"), | ||
| 22 | - @JsonSubTypes.Type(value = IotDataBridgeRocketMQConfig.class, name = "30"), | ||
| 23 | - @JsonSubTypes.Type(value = IotDataBridgeRabbitMQConfig.class, name = "31"), | ||
| 24 | - @JsonSubTypes.Type(value = IotDataBridgeKafkaMQConfig.class, name = "32"), | 19 | + @JsonSubTypes.Type(value = IotDataSinkHttpConfig.class, name = "1"), |
| 20 | + @JsonSubTypes.Type(value = IotDataSinkMqttConfig.class, name = "10"), | ||
| 21 | + @JsonSubTypes.Type(value = IotDataSinkRedisStreamConfig.class, name = "21"), | ||
| 22 | + @JsonSubTypes.Type(value = IotDataSinkRocketMQConfig.class, name = "30"), | ||
| 23 | + @JsonSubTypes.Type(value = IotDataSinkRabbitMQConfig.class, name = "31"), | ||
| 24 | + @JsonSubTypes.Type(value = IotDataSinkKafkaConfig.class, name = "32"), | ||
| 25 | }) | 25 | }) |
| 26 | -public abstract class IotDataBridgeAbstractConfig { | 26 | +public abstract class IotAbstractDataSinkConfig { |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | * 配置类型 | 29 | * 配置类型 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataBridgeHttpConfig.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataSinkHttpConfig.java
| @@ -5,12 +5,12 @@ import lombok.Data; | @@ -5,12 +5,12 @@ import lombok.Data; | ||
| 5 | import java.util.Map; | 5 | import java.util.Map; |
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | - * IoT HTTP 配置 {@link IotDataBridgeAbstractConfig} 实现类 | 8 | + * IoT HTTP 配置 {@link IotAbstractDataSinkConfig} 实现类 |
| 9 | * | 9 | * |
| 10 | * @author HUIHUI | 10 | * @author HUIHUI |
| 11 | */ | 11 | */ |
| 12 | @Data | 12 | @Data |
| 13 | -public class IotDataBridgeHttpConfig extends IotDataBridgeAbstractConfig { | 13 | +public class IotDataSinkHttpConfig extends IotAbstractDataSinkConfig { |
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 16 | * 请求 URL | 16 | * 请求 URL |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataBridgeKafkaMQConfig.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataSinkKafkaConfig.java
| @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * IoT Kafka 配置 {@link IotDataBridgeAbstractConfig} 实现类 | 6 | + * IoT Kafka 配置 {@link IotAbstractDataSinkConfig} 实现类 |
| 7 | * | 7 | * |
| 8 | * @author HUIHUI | 8 | * @author HUIHUI |
| 9 | */ | 9 | */ |
| 10 | @Data | 10 | @Data |
| 11 | -public class IotDataBridgeKafkaMQConfig extends IotDataBridgeAbstractConfig { | 11 | +public class IotDataSinkKafkaConfig extends IotAbstractDataSinkConfig { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * Kafka 服务器地址 | 14 | * Kafka 服务器地址 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataBridgeMqttConfig.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataSinkMqttConfig.java
| @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * IoT MQTT 配置 {@link IotDataBridgeAbstractConfig} 实现类 | 6 | + * IoT MQTT 配置 {@link IotAbstractDataSinkConfig} 实现类 |
| 7 | * | 7 | * |
| 8 | * @author HUIHUI | 8 | * @author HUIHUI |
| 9 | */ | 9 | */ |
| 10 | @Data | 10 | @Data |
| 11 | -public class IotDataBridgeMqttConfig extends IotDataBridgeAbstractConfig { | 11 | +public class IotDataSinkMqttConfig extends IotAbstractDataSinkConfig { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * MQTT 服务器地址 | 14 | * MQTT 服务器地址 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataBridgeRabbitMQConfig.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataSinkRabbitMQConfig.java
| @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * IoT RabbitMQ 配置 {@link IotDataBridgeAbstractConfig} 实现类 | 6 | + * IoT RabbitMQ 配置 {@link IotAbstractDataSinkConfig} 实现类 |
| 7 | * | 7 | * |
| 8 | * @author HUIHUI | 8 | * @author HUIHUI |
| 9 | */ | 9 | */ |
| 10 | @Data | 10 | @Data |
| 11 | -public class IotDataBridgeRabbitMQConfig extends IotDataBridgeAbstractConfig { | 11 | +public class IotDataSinkRabbitMQConfig extends IotAbstractDataSinkConfig { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * RabbitMQ 服务器地址 | 14 | * RabbitMQ 服务器地址 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataBridgeRedisStreamConfig.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataSinkRedisStreamConfig.java
| @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * IoT Redis Stream 配置 {@link IotDataBridgeAbstractConfig} 实现类 | 6 | + * IoT Redis Stream 配置 {@link IotAbstractDataSinkConfig} 实现类 |
| 7 | * | 7 | * |
| 8 | * @author HUIHUI | 8 | * @author HUIHUI |
| 9 | */ | 9 | */ |
| 10 | @Data | 10 | @Data |
| 11 | -public class IotDataBridgeRedisStreamConfig extends IotDataBridgeAbstractConfig { | 11 | +public class IotDataSinkRedisStreamConfig extends IotAbstractDataSinkConfig { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * Redis 服务器地址 | 14 | * Redis 服务器地址 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataBridgeRocketMQConfig.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/config/IotDataSinkRocketMQConfig.java
| @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.rule.config; | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * IoT RocketMQ 配置 {@link IotDataBridgeAbstractConfig} 实现类 | 6 | + * IoT RocketMQ 配置 {@link IotAbstractDataSinkConfig} 实现类 |
| 7 | * | 7 | * |
| 8 | * @author HUIHUI | 8 | * @author HUIHUI |
| 9 | */ | 9 | */ |
| 10 | @Data | 10 | @Data |
| 11 | -public class IotDataBridgeRocketMQConfig extends IotDataBridgeAbstractConfig { | 11 | +public class IotDataSinkRocketMQConfig extends IotAbstractDataSinkConfig { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * RocketMQ 名称服务器地址 | 14 | * RocketMQ 名称服务器地址 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/rule/IotDataRuleMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.dal.mysql.rule; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRulePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataRuleDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * IoT 数据流转规则 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface IotDataRuleMapper extends BaseMapperX<IotDataRuleDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<IotDataRuleDO> selectPage(IotDataRulePageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<IotDataRuleDO>() | ||
| 20 | + .likeIfPresent(IotDataRuleDO::getName, reqVO.getName()) | ||
| 21 | + .eqIfPresent(IotDataRuleDO::getStatus, reqVO.getStatus()) | ||
| 22 | + .betweenIfPresent(IotDataRuleDO::getCreateTime, reqVO.getCreateTime()) | ||
| 23 | + .orderByDesc(IotDataRuleDO::getId)); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | +} | ||
| 0 | \ No newline at end of file | 27 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/IotDataRuleService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.service.rule.data; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRulePageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRuleSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataRuleDO; | ||
| 7 | +import jakarta.validation.Valid; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * IoT 数据流转规则 Service 接口 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +public interface IotDataRuleService { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 创建数据流转规则 | ||
| 18 | + * | ||
| 19 | + * @param createReqVO 创建信息 | ||
| 20 | + * @return 编号 | ||
| 21 | + */ | ||
| 22 | + Long createDataRule(@Valid IotDataRuleSaveReqVO createReqVO); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 更新数据流转规则 | ||
| 26 | + * | ||
| 27 | + * @param updateReqVO 更新信息 | ||
| 28 | + */ | ||
| 29 | + void updateDataRule(@Valid IotDataRuleSaveReqVO updateReqVO); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 删除数据流转规则 | ||
| 33 | + * | ||
| 34 | + * @param id 编号 | ||
| 35 | + */ | ||
| 36 | + void deleteDataRule(Long id); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 获得数据流转规则 | ||
| 40 | + * | ||
| 41 | + * @param id 编号 | ||
| 42 | + * @return 数据流转规则 | ||
| 43 | + */ | ||
| 44 | + IotDataRuleDO getDataRule(Long id); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得数据流转规则分页 | ||
| 48 | + * | ||
| 49 | + * @param pageReqVO 分页查询 | ||
| 50 | + * @return 数据流转规则分页 | ||
| 51 | + */ | ||
| 52 | + PageResult<IotDataRuleDO> getDataRulePage(IotDataRulePageReqVO pageReqVO); | ||
| 53 | + | ||
| 54 | +} | ||
| 0 | \ No newline at end of file | 55 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/IotDataRuleServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.service.rule.data; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRulePageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.data.rule.IotDataRuleSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataRuleDO; | ||
| 8 | +import cn.iocoder.yudao.module.iot.dal.mysql.rule.IotDataRuleMapper; | ||
| 9 | +import jakarta.annotation.Resource; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | +import org.springframework.validation.annotation.Validated; | ||
| 12 | + | ||
| 13 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 14 | +import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DATA_RULE_NOT_EXISTS; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * IoT 数据流转规则 Service 实现类 | ||
| 18 | + * | ||
| 19 | + * @author 芋道源码 | ||
| 20 | + */ | ||
| 21 | +@Service | ||
| 22 | +@Validated | ||
| 23 | +public class IotDataRuleServiceImpl implements IotDataRuleService { | ||
| 24 | + | ||
| 25 | + @Resource | ||
| 26 | + private IotDataRuleMapper dataRuleMapper; | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public Long createDataRule(IotDataRuleSaveReqVO createReqVO) { | ||
| 30 | + IotDataRuleDO dataRule = BeanUtils.toBean(createReqVO, IotDataRuleDO.class); | ||
| 31 | + dataRuleMapper.insert(dataRule); | ||
| 32 | + return dataRule.getId(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public void updateDataRule(IotDataRuleSaveReqVO updateReqVO) { | ||
| 37 | + // 校验存在 | ||
| 38 | + validateDataRuleExists(updateReqVO.getId()); | ||
| 39 | + // 更新 | ||
| 40 | + IotDataRuleDO updateObj = BeanUtils.toBean(updateReqVO, IotDataRuleDO.class); | ||
| 41 | + dataRuleMapper.updateById(updateObj); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void deleteDataRule(Long id) { | ||
| 46 | + // 校验存在 | ||
| 47 | + validateDataRuleExists(id); | ||
| 48 | + // 删除 | ||
| 49 | + dataRuleMapper.deleteById(id); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + private void validateDataRuleExists(Long id) { | ||
| 53 | + if (dataRuleMapper.selectById(id) == null) { | ||
| 54 | + throw exception(DATA_RULE_NOT_EXISTS); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public IotDataRuleDO getDataRule(Long id) { | ||
| 60 | + return dataRuleMapper.selectById(id); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public PageResult<IotDataRuleDO> getDataRulePage(IotDataRulePageReqVO pageReqVO) { | ||
| 65 | + return dataRuleMapper.selectPage(pageReqVO); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | +} | ||
| 0 | \ No newline at end of file | 69 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/IotDataSinkService.java
| @@ -16,7 +16,7 @@ import java.util.List; | @@ -16,7 +16,7 @@ import java.util.List; | ||
| 16 | public interface IotDataSinkService { | 16 | public interface IotDataSinkService { |
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | - * 创建数据目的 | 19 | + * 创建数据流转目的 |
| 20 | * | 20 | * |
| 21 | * @param createReqVO 创建信息 | 21 | * @param createReqVO 创建信息 |
| 22 | * @return 编号 | 22 | * @return 编号 |
| @@ -24,40 +24,40 @@ public interface IotDataSinkService { | @@ -24,40 +24,40 @@ public interface IotDataSinkService { | ||
| 24 | Long createDataSink(@Valid IotDataSinkSaveReqVO createReqVO); | 24 | Long createDataSink(@Valid IotDataSinkSaveReqVO createReqVO); |
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | - * 更新数据目的 | 27 | + * 更新数据流转目的 |
| 28 | * | 28 | * |
| 29 | * @param updateReqVO 更新信息 | 29 | * @param updateReqVO 更新信息 |
| 30 | */ | 30 | */ |
| 31 | void updateDataSink(@Valid IotDataSinkSaveReqVO updateReqVO); | 31 | void updateDataSink(@Valid IotDataSinkSaveReqVO updateReqVO); |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | - * 删除数据目的 | 34 | + * 删除数据流转目的 |
| 35 | * | 35 | * |
| 36 | * @param id 编号 | 36 | * @param id 编号 |
| 37 | */ | 37 | */ |
| 38 | void deleteDataSink(Long id); | 38 | void deleteDataSink(Long id); |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | - * 获得数据目的 | 41 | + * 获得数据流转目的 |
| 42 | * | 42 | * |
| 43 | * @param id 编号 | 43 | * @param id 编号 |
| 44 | - * @return 数据目的 | 44 | + * @return 数据流转目的 |
| 45 | */ | 45 | */ |
| 46 | IotDataSinkDO getDataSink(Long id); | 46 | IotDataSinkDO getDataSink(Long id); |
| 47 | 47 | ||
| 48 | /** | 48 | /** |
| 49 | - * 获得数据目的分页 | 49 | + * 获得数据流转目的分页 |
| 50 | * | 50 | * |
| 51 | * @param pageReqVO 分页查询 | 51 | * @param pageReqVO 分页查询 |
| 52 | - * @return 数据目的分页 | 52 | + * @return 数据流转目的分页 |
| 53 | */ | 53 | */ |
| 54 | PageResult<IotDataSinkDO> getDataSinkPage(IotDataSinkPageReqVO pageReqVO); | 54 | PageResult<IotDataSinkDO> getDataSinkPage(IotDataSinkPageReqVO pageReqVO); |
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| 57 | - * 获取数据目的列表 | 57 | + * 获取数据流转目的列表 |
| 58 | * | 58 | * |
| 59 | * @param status 状态,如果为空,则不进行筛选 | 59 | * @param status 状态,如果为空,则不进行筛选 |
| 60 | - * @return 数据目的列表 | 60 | + * @return 数据流转目的列表 |
| 61 | */ | 61 | */ |
| 62 | List<IotDataSinkDO> getDataSinkListByStatus(Integer status); | 62 | List<IotDataSinkDO> getDataSinkListByStatus(Integer status); |
| 63 | 63 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/IotRuleSceneDataBridgeAction.java
| @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; | @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; | ||
| 15 | import java.util.List; | 15 | import java.util.List; |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | - * IoT 数据桥梁的 {@link IotRuleSceneAction} 实现类 | 18 | + * IoT 数据流转目的的 {@link IotRuleSceneAction} 实现类 |
| 19 | * | 19 | * |
| 20 | * @author 芋道源码 | 20 | * @author 芋道源码 |
| 21 | */ | 21 | */ |
| @@ -35,15 +35,15 @@ public class IotRuleSceneDataBridgeAction implements IotRuleSceneAction { | @@ -35,15 +35,15 @@ public class IotRuleSceneDataBridgeAction implements IotRuleSceneAction { | ||
| 35 | if (message == null) { | 35 | if (message == null) { |
| 36 | return; | 36 | return; |
| 37 | } | 37 | } |
| 38 | - // 1.2 获得数据桥梁 | ||
| 39 | - Assert.notNull(config.getDataBridgeId(), "数据桥梁编号不能为空"); | 38 | + // 1.2 获得数据流转目的 |
| 39 | + Assert.notNull(config.getDataBridgeId(), "数据流转目的编号不能为空"); | ||
| 40 | IotDataSinkDO dataBridge = dataBridgeService.getDataSink(config.getDataBridgeId()); | 40 | IotDataSinkDO dataBridge = dataBridgeService.getDataSink(config.getDataBridgeId()); |
| 41 | if (dataBridge == null || dataBridge.getConfig() == null) { | 41 | if (dataBridge == null || dataBridge.getConfig() == null) { |
| 42 | - log.error("[execute][message({}) config({}) 对应的数据桥梁不存在]", message, config); | 42 | + log.error("[execute][message({}) config({}) 对应的数据流转目的不存在]", message, config); |
| 43 | return; | 43 | return; |
| 44 | } | 44 | } |
| 45 | if (CommonStatusEnum.isDisable(dataBridge.getStatus())) { | 45 | if (CommonStatusEnum.isDisable(dataBridge.getStatus())) { |
| 46 | - log.info("[execute][message({}) config({}) 对应的数据桥梁({}) 状态为禁用]", message, config, dataBridge); | 46 | + log.info("[execute][message({}) config({}) 对应的数据流转目的({}) 状态为禁用]", message, config, dataBridge); |
| 47 | return; | 47 | return; |
| 48 | } | 48 | } |
| 49 | 49 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/AbstractCacheableDataBridgeExecute.java
| @@ -17,7 +17,7 @@ import java.time.Duration; | @@ -17,7 +17,7 @@ import java.time.Duration; | ||
| 17 | // TODO @芋艿:websocket | 17 | // TODO @芋艿:websocket |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | - * 带缓存功能的数据桥梁执行器抽象类 | 20 | + * 带缓存功能的数据流转目的执行器抽象类 |
| 21 | * | 21 | * |
| 22 | * 该类提供了一个通用的缓存机制,用于管理各类数据桥接的生产者(Producer)实例。 | 22 | * 该类提供了一个通用的缓存机制,用于管理各类数据桥接的生产者(Producer)实例。 |
| 23 | * | 23 | * |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/IotDataBridgeExecute.java
| @@ -4,38 +4,38 @@ import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | @@ -4,38 +4,38 @@ import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | ||
| 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataSinkDO; | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataSinkDO; |
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| 7 | - * IoT 数据桥梁的执行器 execute 接口 | 7 | + * IoT 数据流转目的的执行器 execute 接口 |
| 8 | * | 8 | * |
| 9 | * @author HUIHUI | 9 | * @author HUIHUI |
| 10 | */ | 10 | */ |
| 11 | public interface IotDataBridgeExecute<Config> { | 11 | public interface IotDataBridgeExecute<Config> { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | - * 获取数据桥梁类型 | 14 | + * 获取数据流转目的类型 |
| 15 | * | 15 | * |
| 16 | - * @return 数据桥梁类型 | 16 | + * @return 数据流转目的类型 |
| 17 | */ | 17 | */ |
| 18 | Integer getType(); | 18 | Integer getType(); |
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | - * 执行数据桥梁操作 | 21 | + * 执行数据流转目的操作 |
| 22 | * | 22 | * |
| 23 | * @param message 设备消息 | 23 | * @param message 设备消息 |
| 24 | - * @param dataBridge 数据桥梁 | 24 | + * @param dataBridge 数据流转目的 |
| 25 | */ | 25 | */ |
| 26 | @SuppressWarnings({"unchecked"}) | 26 | @SuppressWarnings({"unchecked"}) |
| 27 | default void execute(IotDeviceMessage message, IotDataSinkDO dataBridge) throws Exception { | 27 | default void execute(IotDeviceMessage message, IotDataSinkDO dataBridge) throws Exception { |
| 28 | - // 1.1 校验数据桥梁类型 | 28 | + // 1.1 校验数据流转目的类型 |
| 29 | if (!getType().equals(dataBridge.getType())) { | 29 | if (!getType().equals(dataBridge.getType())) { |
| 30 | return; | 30 | return; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | - // 1.2 执行对应的数据桥梁发送消息 | 33 | + // 1.2 执行对应的数据流转目的发送消息 |
| 34 | execute0(message, (Config) dataBridge.getConfig()); | 34 | execute0(message, (Config) dataBridge.getConfig()); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| 38 | - * 【真正】执行数据桥梁操作 | 38 | + * 【真正】执行数据流转目的操作 |
| 39 | * | 39 | * |
| 40 | * @param message 设备消息 | 40 | * @param message 设备消息 |
| 41 | * @param config 桥梁配置 | 41 | * @param config 桥梁配置 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/IotHttpDataBridgeExecute.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.service.rule.data.action; | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.service.rule.data.action; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; | 4 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| 5 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 5 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 6 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeHttpConfig; | 6 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataSinkHttpConfig; |
| 7 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | 7 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 8 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; | 8 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; |
| 9 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| @@ -23,7 +23,7 @@ import java.util.Map; | @@ -23,7 +23,7 @@ import java.util.Map; | ||
| 23 | */ | 23 | */ |
| 24 | @Component | 24 | @Component |
| 25 | @Slf4j | 25 | @Slf4j |
| 26 | -public class IotHttpDataBridgeExecute implements IotDataBridgeExecute<IotDataBridgeHttpConfig> { | 26 | +public class IotHttpDataBridgeExecute implements IotDataBridgeExecute<IotDataSinkHttpConfig> { |
| 27 | 27 | ||
| 28 | @Resource | 28 | @Resource |
| 29 | private RestTemplate restTemplate; | 29 | private RestTemplate restTemplate; |
| @@ -35,7 +35,7 @@ public class IotHttpDataBridgeExecute implements IotDataBridgeExecute<IotDataBri | @@ -35,7 +35,7 @@ public class IotHttpDataBridgeExecute implements IotDataBridgeExecute<IotDataBri | ||
| 35 | 35 | ||
| 36 | @Override | 36 | @Override |
| 37 | @SuppressWarnings({"unchecked", "deprecation"}) | 37 | @SuppressWarnings({"unchecked", "deprecation"}) |
| 38 | - public void execute0(IotDeviceMessage message, IotDataBridgeHttpConfig config) { | 38 | + public void execute0(IotDeviceMessage message, IotDataSinkHttpConfig config) { |
| 39 | String url = null; | 39 | String url = null; |
| 40 | HttpMethod method = HttpMethod.valueOf(config.getMethod().toUpperCase()); | 40 | HttpMethod method = HttpMethod.valueOf(config.getMethod().toUpperCase()); |
| 41 | HttpEntity<String> requestEntity = null; | 41 | HttpEntity<String> requestEntity = null; |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/IotKafkaMQDataBridgeExecute.java
| 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; | 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeKafkaMQConfig; | 3 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataSinkKafkaConfig; |
| 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; | 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; |
| 6 | import lombok.extern.slf4j.Slf4j; | 6 | import lombok.extern.slf4j.Slf4j; |
| @@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit; | @@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit; | ||
| 25 | @Component | 25 | @Component |
| 26 | @Slf4j | 26 | @Slf4j |
| 27 | public class IotKafkaMQDataBridgeExecute extends | 27 | public class IotKafkaMQDataBridgeExecute extends |
| 28 | - AbstractCacheableDataBridgeExecute<IotDataBridgeKafkaMQConfig, KafkaTemplate<String, String>> { | 28 | + AbstractCacheableDataBridgeExecute<IotDataSinkKafkaConfig, KafkaTemplate<String, String>> { |
| 29 | 29 | ||
| 30 | private static final Duration SEND_TIMEOUT = Duration.ofMillis(10000); // 10 秒超时时间 | 30 | private static final Duration SEND_TIMEOUT = Duration.ofMillis(10000); // 10 秒超时时间 |
| 31 | 31 | ||
| @@ -35,7 +35,7 @@ public class IotKafkaMQDataBridgeExecute extends | @@ -35,7 +35,7 @@ public class IotKafkaMQDataBridgeExecute extends | ||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | @Override | 37 | @Override |
| 38 | - public void execute0(IotDeviceMessage message, IotDataBridgeKafkaMQConfig config) throws Exception { | 38 | + public void execute0(IotDeviceMessage message, IotDataSinkKafkaConfig config) throws Exception { |
| 39 | // 1. 获取或创建 KafkaTemplate | 39 | // 1. 获取或创建 KafkaTemplate |
| 40 | KafkaTemplate<String, String> kafkaTemplate = getProducer(config); | 40 | KafkaTemplate<String, String> kafkaTemplate = getProducer(config); |
| 41 | 41 | ||
| @@ -46,7 +46,7 @@ public class IotKafkaMQDataBridgeExecute extends | @@ -46,7 +46,7 @@ public class IotKafkaMQDataBridgeExecute extends | ||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | @Override | 48 | @Override |
| 49 | - protected KafkaTemplate<String, String> initProducer(IotDataBridgeKafkaMQConfig config) { | 49 | + protected KafkaTemplate<String, String> initProducer(IotDataSinkKafkaConfig config) { |
| 50 | // 1.1 构建生产者配置 | 50 | // 1.1 构建生产者配置 |
| 51 | Map<String, Object> props = new HashMap<>(); | 51 | Map<String, Object> props = new HashMap<>(); |
| 52 | props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, config.getBootstrapServers()); | 52 | props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, config.getBootstrapServers()); |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/IotRabbitMQDataBridgeExecute.java
| 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; | 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeRabbitMQConfig; | 3 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataSinkRabbitMQConfig; |
| 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; | 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; |
| 6 | import com.rabbitmq.client.Channel; | 6 | import com.rabbitmq.client.Channel; |
| @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; | @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; | ||
| 21 | @Component | 21 | @Component |
| 22 | @Slf4j | 22 | @Slf4j |
| 23 | public class IotRabbitMQDataBridgeExecute extends | 23 | public class IotRabbitMQDataBridgeExecute extends |
| 24 | - AbstractCacheableDataBridgeExecute<IotDataBridgeRabbitMQConfig, Channel> { | 24 | + AbstractCacheableDataBridgeExecute<IotDataSinkRabbitMQConfig, Channel> { |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | @Override | 27 | @Override |
| @@ -30,7 +30,7 @@ public class IotRabbitMQDataBridgeExecute extends | @@ -30,7 +30,7 @@ public class IotRabbitMQDataBridgeExecute extends | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | @Override | 32 | @Override |
| 33 | - public void execute0(IotDeviceMessage message, IotDataBridgeRabbitMQConfig config) throws Exception { | 33 | + public void execute0(IotDeviceMessage message, IotDataSinkRabbitMQConfig config) throws Exception { |
| 34 | // 1. 获取或创建 Channel | 34 | // 1. 获取或创建 Channel |
| 35 | Channel channel = getProducer(config); | 35 | Channel channel = getProducer(config); |
| 36 | 36 | ||
| @@ -47,7 +47,7 @@ public class IotRabbitMQDataBridgeExecute extends | @@ -47,7 +47,7 @@ public class IotRabbitMQDataBridgeExecute extends | ||
| 47 | 47 | ||
| 48 | @Override | 48 | @Override |
| 49 | @SuppressWarnings("resource") | 49 | @SuppressWarnings("resource") |
| 50 | - protected Channel initProducer(IotDataBridgeRabbitMQConfig config) throws Exception { | 50 | + protected Channel initProducer(IotDataSinkRabbitMQConfig config) throws Exception { |
| 51 | // 1. 创建连接工厂 | 51 | // 1. 创建连接工厂 |
| 52 | ConnectionFactory factory = new ConnectionFactory(); | 52 | ConnectionFactory factory = new ConnectionFactory(); |
| 53 | factory.setHost(config.getHost()); | 53 | factory.setHost(config.getHost()); |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/IotRedisStreamDataBridgeExecute.java
| 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; | 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeRedisStreamConfig; | 4 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataSinkRedisStreamConfig; |
| 5 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | 5 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; | 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; |
| 7 | import lombok.extern.slf4j.Slf4j; | 7 | import lombok.extern.slf4j.Slf4j; |
| @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; | @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; | ||
| 25 | @Component | 25 | @Component |
| 26 | @Slf4j | 26 | @Slf4j |
| 27 | public class IotRedisStreamDataBridgeExecute extends | 27 | public class IotRedisStreamDataBridgeExecute extends |
| 28 | - AbstractCacheableDataBridgeExecute<IotDataBridgeRedisStreamConfig, RedisTemplate<String, Object>> { | 28 | + AbstractCacheableDataBridgeExecute<IotDataSinkRedisStreamConfig, RedisTemplate<String, Object>> { |
| 29 | 29 | ||
| 30 | @Override | 30 | @Override |
| 31 | public Integer getType() { | 31 | public Integer getType() { |
| @@ -33,7 +33,7 @@ public class IotRedisStreamDataBridgeExecute extends | @@ -33,7 +33,7 @@ public class IotRedisStreamDataBridgeExecute extends | ||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | @Override | 35 | @Override |
| 36 | - public void execute0(IotDeviceMessage message, IotDataBridgeRedisStreamConfig config) throws Exception { | 36 | + public void execute0(IotDeviceMessage message, IotDataSinkRedisStreamConfig config) throws Exception { |
| 37 | // 1. 获取 RedisTemplate | 37 | // 1. 获取 RedisTemplate |
| 38 | RedisTemplate<String, Object> redisTemplate = getProducer(config); | 38 | RedisTemplate<String, Object> redisTemplate = getProducer(config); |
| 39 | 39 | ||
| @@ -45,7 +45,7 @@ public class IotRedisStreamDataBridgeExecute extends | @@ -45,7 +45,7 @@ public class IotRedisStreamDataBridgeExecute extends | ||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | @Override | 47 | @Override |
| 48 | - protected RedisTemplate<String, Object> initProducer(IotDataBridgeRedisStreamConfig config) { | 48 | + protected RedisTemplate<String, Object> initProducer(IotDataSinkRedisStreamConfig config) { |
| 49 | // 1.1 创建 Redisson 配置 | 49 | // 1.1 创建 Redisson 配置 |
| 50 | Config redissonConfig = new Config(); | 50 | Config redissonConfig = new Config(); |
| 51 | SingleServerConfig serverConfig = redissonConfig.useSingleServer() | 51 | SingleServerConfig serverConfig = redissonConfig.useSingleServer() |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/IotRocketMQDataBridgeExecute.java
| 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; | 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataBridgeRocketMQConfig; | 3 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataSinkRocketMQConfig; |
| 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; | 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataSinkTypeEnum; |
| 6 | import lombok.extern.slf4j.Slf4j; | 6 | import lombok.extern.slf4j.Slf4j; |
| @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | ||
| 21 | @Component | 21 | @Component |
| 22 | @Slf4j | 22 | @Slf4j |
| 23 | public class IotRocketMQDataBridgeExecute extends | 23 | public class IotRocketMQDataBridgeExecute extends |
| 24 | - AbstractCacheableDataBridgeExecute<IotDataBridgeRocketMQConfig, DefaultMQProducer> { | 24 | + AbstractCacheableDataBridgeExecute<IotDataSinkRocketMQConfig, DefaultMQProducer> { |
| 25 | 25 | ||
| 26 | @Override | 26 | @Override |
| 27 | public Integer getType() { | 27 | public Integer getType() { |
| @@ -29,7 +29,7 @@ public class IotRocketMQDataBridgeExecute extends | @@ -29,7 +29,7 @@ public class IotRocketMQDataBridgeExecute extends | ||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | @Override | 31 | @Override |
| 32 | - public void execute0(IotDeviceMessage message, IotDataBridgeRocketMQConfig config) throws Exception { | 32 | + public void execute0(IotDeviceMessage message, IotDataSinkRocketMQConfig config) throws Exception { |
| 33 | // 1. 获取或创建 Producer | 33 | // 1. 获取或创建 Producer |
| 34 | DefaultMQProducer producer = getProducer(config); | 34 | DefaultMQProducer producer = getProducer(config); |
| 35 | 35 | ||
| @@ -50,7 +50,7 @@ public class IotRocketMQDataBridgeExecute extends | @@ -50,7 +50,7 @@ public class IotRocketMQDataBridgeExecute extends | ||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | @Override | 52 | @Override |
| 53 | - protected DefaultMQProducer initProducer(IotDataBridgeRocketMQConfig config) throws Exception { | 53 | + protected DefaultMQProducer initProducer(IotDataSinkRocketMQConfig config) throws Exception { |
| 54 | DefaultMQProducer producer = new DefaultMQProducer(config.getGroup()); | 54 | DefaultMQProducer producer = new DefaultMQProducer(config.getGroup()); |
| 55 | producer.setNamesrvAddr(config.getNameServer()); | 55 | producer.setNamesrvAddr(config.getNameServer()); |
| 56 | producer.start(); | 56 | producer.start(); |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/rule/action/databridge/IotDataBridgeExecuteTest.java
| @@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.iot.service.rule.action.databridge; | @@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.iot.service.rule.action.databridge; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | 3 | import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; |
| 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; | 4 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 5 | -import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataSinkDO; | ||
| 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.*; | 5 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.*; |
| 6 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataSinkDO; | ||
| 7 | import cn.iocoder.yudao.module.iot.service.rule.data.action.*; | 7 | import cn.iocoder.yudao.module.iot.service.rule.data.action.*; |
| 8 | import lombok.extern.slf4j.Slf4j; | 8 | import lombok.extern.slf4j.Slf4j; |
| 9 | import org.junit.jupiter.api.BeforeEach; | 9 | import org.junit.jupiter.api.BeforeEach; |
| @@ -54,7 +54,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | @@ -54,7 +54,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | ||
| 54 | IotKafkaMQDataBridgeExecute action = new IotKafkaMQDataBridgeExecute(); | 54 | IotKafkaMQDataBridgeExecute action = new IotKafkaMQDataBridgeExecute(); |
| 55 | 55 | ||
| 56 | // 2. 创建配置 | 56 | // 2. 创建配置 |
| 57 | - IotDataBridgeKafkaMQConfig config = new IotDataBridgeKafkaMQConfig() | 57 | + IotDataSinkKafkaConfig config = new IotDataSinkKafkaConfig() |
| 58 | .setBootstrapServers("127.0.0.1:9092") | 58 | .setBootstrapServers("127.0.0.1:9092") |
| 59 | .setTopic("test-topic") | 59 | .setTopic("test-topic") |
| 60 | .setSsl(false) | 60 | .setSsl(false) |
| @@ -71,7 +71,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | @@ -71,7 +71,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | ||
| 71 | IotRabbitMQDataBridgeExecute action = new IotRabbitMQDataBridgeExecute(); | 71 | IotRabbitMQDataBridgeExecute action = new IotRabbitMQDataBridgeExecute(); |
| 72 | 72 | ||
| 73 | // 2. 创建配置 | 73 | // 2. 创建配置 |
| 74 | - IotDataBridgeRabbitMQConfig config = new IotDataBridgeRabbitMQConfig() | 74 | + IotDataSinkRabbitMQConfig config = new IotDataSinkRabbitMQConfig() |
| 75 | .setHost("localhost") | 75 | .setHost("localhost") |
| 76 | .setPort(5672) | 76 | .setPort(5672) |
| 77 | .setVirtualHost("/") | 77 | .setVirtualHost("/") |
| @@ -91,7 +91,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | @@ -91,7 +91,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | ||
| 91 | IotRedisStreamDataBridgeExecute action = new IotRedisStreamDataBridgeExecute(); | 91 | IotRedisStreamDataBridgeExecute action = new IotRedisStreamDataBridgeExecute(); |
| 92 | 92 | ||
| 93 | // 2. 创建配置 | 93 | // 2. 创建配置 |
| 94 | - IotDataBridgeRedisStreamConfig config = new IotDataBridgeRedisStreamConfig() | 94 | + IotDataSinkRedisStreamConfig config = new IotDataSinkRedisStreamConfig() |
| 95 | .setHost("127.0.0.1") | 95 | .setHost("127.0.0.1") |
| 96 | .setPort(6379) | 96 | .setPort(6379) |
| 97 | .setDatabase(0) | 97 | .setDatabase(0) |
| @@ -108,7 +108,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | @@ -108,7 +108,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | ||
| 108 | IotRocketMQDataBridgeExecute action = new IotRocketMQDataBridgeExecute(); | 108 | IotRocketMQDataBridgeExecute action = new IotRocketMQDataBridgeExecute(); |
| 109 | 109 | ||
| 110 | // 2. 创建配置 | 110 | // 2. 创建配置 |
| 111 | - IotDataBridgeRocketMQConfig config = new IotDataBridgeRocketMQConfig() | 111 | + IotDataSinkRocketMQConfig config = new IotDataSinkRocketMQConfig() |
| 112 | .setNameServer("127.0.0.1:9876") | 112 | .setNameServer("127.0.0.1:9876") |
| 113 | .setGroup("test-group") | 113 | .setGroup("test-group") |
| 114 | .setTopic("test-topic") | 114 | .setTopic("test-topic") |
| @@ -125,7 +125,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | @@ -125,7 +125,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | ||
| 125 | .thenReturn(new ResponseEntity<>("Success", HttpStatus.OK)); | 125 | .thenReturn(new ResponseEntity<>("Success", HttpStatus.OK)); |
| 126 | 126 | ||
| 127 | // 2. 创建配置 | 127 | // 2. 创建配置 |
| 128 | - IotDataBridgeHttpConfig config = new IotDataBridgeHttpConfig() | 128 | + IotDataSinkHttpConfig config = new IotDataSinkHttpConfig() |
| 129 | .setUrl("https://doc.iocoder.cn/").setMethod(HttpMethod.GET.name()); | 129 | .setUrl("https://doc.iocoder.cn/").setMethod(HttpMethod.GET.name()); |
| 130 | 130 | ||
| 131 | // 3. 执行测试 | 131 | // 3. 执行测试 |
| @@ -142,7 +142,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | @@ -142,7 +142,7 @@ public class IotDataBridgeExecuteTest extends BaseMockitoUnitTest { | ||
| 142 | * @param type MQ 类型 | 142 | * @param type MQ 类型 |
| 143 | * @throws Exception 如果执行过程中发生异常 | 143 | * @throws Exception 如果执行过程中发生异常 |
| 144 | */ | 144 | */ |
| 145 | - private void executeAndVerifyCache(IotDataBridgeExecute<?> action, IotDataBridgeAbstractConfig config, String type) | 145 | + private void executeAndVerifyCache(IotDataBridgeExecute<?> action, IotAbstractDataSinkConfig config, String type) |
| 146 | throws Exception { | 146 | throws Exception { |
| 147 | log.info("[test{}DataBridge][第一次执行,应该会创建新的 producer]", type); | 147 | log.info("[test{}DataBridge][第一次执行,应该会创建新的 producer]", type); |
| 148 | action.execute(message, new IotDataSinkDO().setType(action.getType()).setConfig(config)); | 148 | action.execute(message, new IotDataSinkDO().setType(action.getType()).setConfig(config)); |