Commit deab8c1cc6bb7864d9c40e0c369f649f6f9bfa41
1 parent
16120820
【代码评审】IoT:设备日志 TDengine 表与模拟设备
Showing
18 changed files
with
89 additions
and
86 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceDataController.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.iot.controller.admin.device; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.iot.controller.admin.device; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.IotDeviceSaveReqVO; | ||
| 7 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.*; | 6 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.*; |
| 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO; | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO; |
| 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; | 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; |
| @@ -13,7 +12,6 @@ import io.swagger.v3.oas.annotations.Operation; | @@ -13,7 +12,6 @@ import io.swagger.v3.oas.annotations.Operation; | ||
| 13 | import io.swagger.v3.oas.annotations.tags.Tag; | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 14 | import jakarta.annotation.Resource; | 13 | import jakarta.annotation.Resource; |
| 15 | import jakarta.validation.Valid; | 14 | import jakarta.validation.Valid; |
| 16 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 17 | import org.springframework.validation.annotation.Validated; | 15 | import org.springframework.validation.annotation.Validated; |
| 18 | import org.springframework.web.bind.annotation.*; | 16 | import org.springframework.web.bind.annotation.*; |
| 19 | 17 | ||
| @@ -34,7 +32,7 @@ public class IotDeviceDataController { | @@ -34,7 +32,7 @@ public class IotDeviceDataController { | ||
| 34 | @Resource | 32 | @Resource |
| 35 | private IotDeviceLogDataService iotDeviceLogDataService; | 33 | private IotDeviceLogDataService iotDeviceLogDataService; |
| 36 | 34 | ||
| 37 | - @Resource | 35 | + @Resource // TODO @super:service 之间,不用空行;原因是,这样更简洁;空行,主要是为了“间隔”,提升可读性 |
| 38 | private IotDeviceLogDataService deviceLogDataService; | 36 | private IotDeviceLogDataService deviceLogDataService; |
| 39 | 37 | ||
| 40 | // TODO @浩浩:这里的 /latest-list,包括方法名。 | 38 | // TODO @浩浩:这里的 /latest-list,包括方法名。 |
| @@ -52,14 +50,17 @@ public class IotDeviceDataController { | @@ -52,14 +50,17 @@ public class IotDeviceDataController { | ||
| 52 | PageResult<Map<String, Object>> list = deviceDataService.getHistoryDeviceProperties(deviceDataReqVO); | 50 | PageResult<Map<String, Object>> list = deviceDataService.getHistoryDeviceProperties(deviceDataReqVO); |
| 53 | return success(BeanUtils.toBean(list, IotTimeDataRespVO.class)); | 51 | return success(BeanUtils.toBean(list, IotTimeDataRespVO.class)); |
| 54 | } | 52 | } |
| 53 | + | ||
| 55 | // TODO:数据权限 | 54 | // TODO:数据权限 |
| 56 | @PostMapping("/simulator") | 55 | @PostMapping("/simulator") |
| 57 | @Operation(summary = "模拟设备") | 56 | @Operation(summary = "模拟设备") |
| 58 | public CommonResult<Boolean> simulatorDevice(@Valid @RequestBody IotDeviceDataSimulatorSaveReqVO simulatorReqVO) { | 57 | public CommonResult<Boolean> simulatorDevice(@Valid @RequestBody IotDeviceDataSimulatorSaveReqVO simulatorReqVO) { |
| 59 | //TODO:先生成一下设备日志 后续完善模拟设备代码逻辑 | 58 | //TODO:先生成一下设备日志 后续完善模拟设备代码逻辑 |
| 59 | + // TODO @super:应该 deviceDataService 里面有个 simulatorDevice,然后里面去 insert 日志! | ||
| 60 | iotDeviceLogDataService.createDeviceLog(simulatorReqVO); | 60 | iotDeviceLogDataService.createDeviceLog(simulatorReqVO); |
| 61 | return success(true); | 61 | return success(true); |
| 62 | } | 62 | } |
| 63 | + | ||
| 63 | // TODO:数据权限 | 64 | // TODO:数据权限 |
| 64 | @GetMapping("/log/page") | 65 | @GetMapping("/log/page") |
| 65 | @Operation(summary = "获得设备日志分页") | 66 | @Operation(summary = "获得设备日志分页") |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceSaveReqVO.java
| @@ -14,7 +14,7 @@ public class IotDeviceSaveReqVO { | @@ -14,7 +14,7 @@ public class IotDeviceSaveReqVO { | ||
| 14 | private Long id; | 14 | private Long id; |
| 15 | 15 | ||
| 16 | @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.AUTO, example = "177") | 16 | @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.AUTO, example = "177") |
| 17 | - @Size(max = 50, message = "设备编号长度不能超过50个字符") | 17 | + @Size(max = 50, message = "设备编号长度不能超过 50 个字符") |
| 18 | private String deviceKey; | 18 | private String deviceKey; |
| 19 | 19 | ||
| 20 | @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | 20 | @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/deviceData/IotDeviceDataSimulatorSaveReqVO.java
| @@ -3,27 +3,27 @@ package cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData; | @@ -3,27 +3,27 @@ package cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import jakarta.validation.constraints.NotEmpty; | 4 | import jakarta.validation.constraints.NotEmpty; |
| 5 | import lombok.Data; | 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 | 6 | ||
| 7 | +// TODO super: SaveReqVO => ReqVO | ||
| 12 | @Schema(description = "管理后台 - IoT 模拟设备数据 Request VO") | 8 | @Schema(description = "管理后台 - IoT 模拟设备数据 Request VO") |
| 13 | @Data | 9 | @Data |
| 14 | public class IotDeviceDataSimulatorSaveReqVO { | 10 | public class IotDeviceDataSimulatorSaveReqVO { |
| 15 | 11 | ||
| 16 | - @Schema(description = "消息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "msg123") | 12 | + // TODO @super:感觉后端随机更合适? |
| 13 | + @Schema(description = "消息 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "msg123") | ||
| 17 | private String id; | 14 | private String id; |
| 18 | 15 | ||
| 16 | + // TODO @super:不用传递 productKey,因为 deviceKey 可以推导出来 | ||
| 19 | @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "product123") | 17 | @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "product123") |
| 20 | @NotEmpty(message = "产品ID不能为空") | 18 | @NotEmpty(message = "产品ID不能为空") |
| 21 | private String productKey; | 19 | private String productKey; |
| 22 | 20 | ||
| 21 | + // TODO @super:中文写作规范,中英文之间,要有空格。例如说,设备 ID。ps:这里应该是设备标识 | ||
| 23 | @Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123") | 22 | @Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123") |
| 24 | @NotEmpty(message = "设备ID不能为空") | 23 | @NotEmpty(message = "设备ID不能为空") |
| 25 | private String deviceKey; | 24 | private String deviceKey; |
| 26 | 25 | ||
| 26 | + // TODO @super:type、subType,是不是不用传递,因为模拟只有属性??? | ||
| 27 | @Schema(description = "消息/日志类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "property") | 27 | @Schema(description = "消息/日志类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "property") |
| 28 | @NotEmpty(message = "消息类型不能为空") | 28 | @NotEmpty(message = "消息类型不能为空") |
| 29 | private String type; | 29 | private String type; |
| @@ -36,6 +36,7 @@ public class IotDeviceDataSimulatorSaveReqVO { | @@ -36,6 +36,7 @@ public class IotDeviceDataSimulatorSaveReqVO { | ||
| 36 | @NotEmpty(message = "数据内容不能为空") | 36 | @NotEmpty(message = "数据内容不能为空") |
| 37 | private String content; | 37 | private String content; |
| 38 | 38 | ||
| 39 | + // TODO @芋艿:需要讨论下,reportTime 到底以那个为准! | ||
| 39 | @Schema(description = "上报时间", requiredMode = Schema.RequiredMode.REQUIRED) | 40 | @Schema(description = "上报时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 40 | private Long reportTime; | 41 | private Long reportTime; |
| 41 | 42 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/deviceData/IotDeviceLogPageReqVO.java
| @@ -18,13 +18,16 @@ public class IotDeviceLogPageReqVO extends PageParam { | @@ -18,13 +18,16 @@ public class IotDeviceLogPageReqVO extends PageParam { | ||
| 18 | @NotEmpty(message = "设备标识不能为空") | 18 | @NotEmpty(message = "设备标识不能为空") |
| 19 | private String deviceKey; | 19 | private String deviceKey; |
| 20 | 20 | ||
| 21 | + // TODO @super:对应的枚举类 | ||
| 21 | @Schema(description = "消息类型", example = "property") | 22 | @Schema(description = "消息类型", example = "property") |
| 22 | private String type; | 23 | private String type; |
| 23 | 24 | ||
| 24 | @Schema(description = "标识符", example = "temperature") | 25 | @Schema(description = "标识符", example = "temperature") |
| 26 | + // TODO @super:对应的枚举类 | ||
| 25 | private String subType; | 27 | private String subType; |
| 26 | 28 | ||
| 27 | @Schema(description = "创建时间") | 29 | @Schema(description = "创建时间") |
| 28 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 30 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 29 | private LocalDateTime[] createTime; | 31 | private LocalDateTime[] createTime; |
| 30 | -} | ||
| 31 | \ No newline at end of file | 32 | \ No newline at end of file |
| 33 | + | ||
| 34 | +} | ||
| 32 | \ No newline at end of file | 35 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/deviceData/IotDeviceLogRespVO.java
| @@ -11,8 +11,10 @@ public class IotDeviceLogRespVO { | @@ -11,8 +11,10 @@ public class IotDeviceLogRespVO { | ||
| 11 | 11 | ||
| 12 | @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 12 | @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 13 | private String id; | 13 | private String id; |
| 14 | + | ||
| 14 | @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "product123") | 15 | @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "product123") |
| 15 | private String productKey; | 16 | private String productKey; |
| 17 | + | ||
| 16 | @Schema(description = "设备标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123") | 18 | @Schema(description = "设备标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123") |
| 17 | private String deviceKey; | 19 | private String deviceKey; |
| 18 | 20 | ||
| @@ -30,4 +32,5 @@ public class IotDeviceLogRespVO { | @@ -30,4 +32,5 @@ public class IotDeviceLogRespVO { | ||
| 30 | 32 | ||
| 31 | @Schema(description = "记录时间戳", requiredMode = Schema.RequiredMode.REQUIRED) | 33 | @Schema(description = "记录时间戳", requiredMode = Schema.RequiredMode.REQUIRED) |
| 32 | private LocalDateTime ts; | 34 | private LocalDateTime ts; |
| 33 | -} | ||
| 34 | \ No newline at end of file | 35 | \ No newline at end of file |
| 36 | + | ||
| 37 | +} | ||
| 35 | \ No newline at end of file | 38 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/IotThingModelController.java
| @@ -74,6 +74,7 @@ public class IotThingModelController { | @@ -74,6 +74,7 @@ public class IotThingModelController { | ||
| 74 | return success(IotThingModelConvert.INSTANCE.convertList(list)); | 74 | return success(IotThingModelConvert.INSTANCE.convertList(list)); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | + // TODO @puhui @super:getThingModelListByProductId 和 getThingModelListByProductId 可以融合么? | ||
| 77 | @GetMapping("/list") | 78 | @GetMapping("/list") |
| 78 | @Operation(summary = "获得产品物模型列表") | 79 | @Operation(summary = "获得产品物模型列表") |
| 79 | @PreAuthorize("@ss.hasPermission('iot:thing-model:query')") | 80 | @PreAuthorize("@ss.hasPermission('iot:thing-model:query')") |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/vo/IotThingModelListReqVO.java
| @@ -6,11 +6,10 @@ import io.swagger.v3.oas.annotations.media.Schema; | @@ -6,11 +6,10 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | import jakarta.validation.constraints.NotNull; | 6 | import jakarta.validation.constraints.NotNull; |
| 7 | import lombok.Data; | 7 | import lombok.Data; |
| 8 | 8 | ||
| 9 | - | ||
| 10 | - | ||
| 11 | @Schema(description = "管理后台 - IoT 产品物模型List Request VO") | 9 | @Schema(description = "管理后台 - IoT 产品物模型List Request VO") |
| 12 | @Data | 10 | @Data |
| 13 | public class IotThingModelListReqVO { | 11 | public class IotThingModelListReqVO { |
| 12 | + | ||
| 14 | @Schema(description = "功能标识") | 13 | @Schema(description = "功能标识") |
| 15 | private String identifier; | 14 | private String identifier; |
| 16 | 15 | ||
| @@ -21,7 +20,8 @@ public class IotThingModelListReqVO { | @@ -21,7 +20,8 @@ public class IotThingModelListReqVO { | ||
| 21 | @InEnum(IotThingModelTypeEnum.class) | 20 | @InEnum(IotThingModelTypeEnum.class) |
| 22 | private Integer type; | 21 | private Integer type; |
| 23 | 22 | ||
| 24 | - @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 25 | - @NotNull(message = "产品ID不能为空") | 23 | + @Schema(description = "产品 ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| 24 | + @NotNull(message = "产品 ID 不能为空") | ||
| 26 | private Long productId; | 25 | private Long productId; |
| 26 | + | ||
| 27 | } | 27 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceLogDO.java
| 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.device; | 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.device; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.date.DateTime; | ||
| 4 | import lombok.AllArgsConstructor; | 3 | import lombok.AllArgsConstructor; |
| 5 | import lombok.Builder; | 4 | import lombok.Builder; |
| 6 | import lombok.Data; | 5 | import lombok.Data; |
| 7 | import lombok.NoArgsConstructor; | 6 | import lombok.NoArgsConstructor; |
| 8 | 7 | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | /** | 8 | /** |
| 12 | * IoT 设备日志数据 DO | 9 | * IoT 设备日志数据 DO |
| 13 | * | 10 | * |
| 11 | + * 目前使用 TDengine 存储 | ||
| 12 | + * | ||
| 14 | * @author alwayssuper | 13 | * @author alwayssuper |
| 15 | */ | 14 | */ |
| 16 | @Data | 15 | @Data |
| @@ -18,33 +17,41 @@ import java.time.LocalDateTime; | @@ -18,33 +17,41 @@ import java.time.LocalDateTime; | ||
| 18 | @NoArgsConstructor | 17 | @NoArgsConstructor |
| 19 | @AllArgsConstructor | 18 | @AllArgsConstructor |
| 20 | public class IotDeviceLogDO { | 19 | public class IotDeviceLogDO { |
| 20 | + | ||
| 21 | + // TODO @芋艿:消息 ID 的生成逻辑 | ||
| 21 | /** | 22 | /** |
| 22 | - * 消息ID | 23 | + * 消息 ID |
| 23 | */ | 24 | */ |
| 24 | private String id; | 25 | private String id; |
| 25 | 26 | ||
| 27 | + // TODO @super:关联要 @下 | ||
| 26 | /** | 28 | /** |
| 27 | - * 产品ID | 29 | + * 产品标识 |
| 28 | */ | 30 | */ |
| 29 | private String productKey; | 31 | private String productKey; |
| 30 | 32 | ||
| 33 | + // TODO @super:关联要 @下 | ||
| 31 | /** | 34 | /** |
| 32 | - * 设备ID | 35 | + * 设备标识 |
| 33 | */ | 36 | */ |
| 34 | private String deviceKey; | 37 | private String deviceKey; |
| 35 | 38 | ||
| 39 | + // TODO @super:枚举类 | ||
| 36 | /** | 40 | /** |
| 37 | - * 消息/日志类型 | 41 | + * 日志类型 |
| 38 | */ | 42 | */ |
| 39 | private String type; | 43 | private String type; |
| 40 | 44 | ||
| 45 | + // TODO @super:枚举类 | ||
| 41 | /** | 46 | /** |
| 42 | * 标识符:用于标识具体的属性、事件或服务 | 47 | * 标识符:用于标识具体的属性、事件或服务 |
| 43 | */ | 48 | */ |
| 44 | private String subType; | 49 | private String subType; |
| 45 | 50 | ||
| 46 | /** | 51 | /** |
| 47 | - * 数据内容:存储具体的消息数据内容,通常是JSON格式 | 52 | + * 数据内容 |
| 53 | + * | ||
| 54 | + * 存储具体的消息数据内容,通常是 JSON 格式 | ||
| 48 | */ | 55 | */ |
| 49 | private String content; | 56 | private String content; |
| 50 | 57 | ||
| @@ -58,5 +65,4 @@ public class IotDeviceLogDO { | @@ -58,5 +65,4 @@ public class IotDeviceLogDO { | ||
| 58 | */ | 65 | */ |
| 59 | private Long ts; | 66 | private Long ts; |
| 60 | 67 | ||
| 61 | - | ||
| 62 | } | 68 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/ThingModelMessageDO.java
| @@ -6,7 +6,7 @@ import lombok.Data; | @@ -6,7 +6,7 @@ import lombok.Data; | ||
| 6 | import lombok.NoArgsConstructor; | 6 | import lombok.NoArgsConstructor; |
| 7 | 7 | ||
| 8 | // TODO @芋艿:纠结下字段 | 8 | // TODO @芋艿:纠结下字段 |
| 9 | -@Deprecated | 9 | +@Deprecated // TODO @super:看看啥时候删除下哈。 |
| 10 | /** | 10 | /** |
| 11 | * TD 物模型消息日志的数据库 | 11 | * TD 物模型消息日志的数据库 |
| 12 | */ | 12 | */ |
| @@ -25,7 +25,7 @@ public class ThingModelMessageDO { | @@ -25,7 +25,7 @@ public class ThingModelMessageDO { | ||
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | * 系统扩展参数 | 27 | * 系统扩展参数 |
| 28 | - * | 28 | + * |
| 29 | * 例如:设备状态、系统时间、固件版本等系统级信息 | 29 | * 例如:设备状态、系统时间、固件版本等系统级信息 |
| 30 | */ | 30 | */ |
| 31 | private Object system; | 31 | private Object system; |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDeviceLogDataMapper.java
| 1 | package cn.iocoder.yudao.module.iot.dal.tdengine; | 1 | package cn.iocoder.yudao.module.iot.dal.tdengine; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO; | 3 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO; |
| 5 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; |
| 6 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS; | 5 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS; |
| @@ -12,7 +11,7 @@ import java.util.List; | @@ -12,7 +11,7 @@ import java.util.List; | ||
| 12 | 11 | ||
| 13 | /** | 12 | /** |
| 14 | * IOT 设备日志数据 Mapper 接口 | 13 | * IOT 设备日志数据 Mapper 接口 |
| 15 | - * | 14 | + * |
| 16 | * 基于 TDengine 实现设备日志的存储 | 15 | * 基于 TDengine 实现设备日志的存储 |
| 17 | */ | 16 | */ |
| 18 | @Mapper | 17 | @Mapper |
| @@ -22,11 +21,12 @@ public interface IotDeviceLogDataMapper { | @@ -22,11 +21,12 @@ public interface IotDeviceLogDataMapper { | ||
| 22 | 21 | ||
| 23 | /** | 22 | /** |
| 24 | * 创建设备日志超级表 | 23 | * 创建设备日志超级表 |
| 25 | - * | 24 | + * |
| 26 | * 注意:初始化时只需创建一次 | 25 | * 注意:初始化时只需创建一次 |
| 27 | */ | 26 | */ |
| 28 | void createDeviceLogSTable(); | 27 | void createDeviceLogSTable(); |
| 29 | 28 | ||
| 29 | + // TODO @super:是不是删除哈 | ||
| 30 | /** | 30 | /** |
| 31 | * 创建设备日志子表 | 31 | * 创建设备日志子表 |
| 32 | * | 32 | * |
| @@ -34,11 +34,12 @@ public interface IotDeviceLogDataMapper { | @@ -34,11 +34,12 @@ public interface IotDeviceLogDataMapper { | ||
| 34 | */ | 34 | */ |
| 35 | void createDeviceLogTable(@Param("deviceKey") String deviceKey); | 35 | void createDeviceLogTable(@Param("deviceKey") String deviceKey); |
| 36 | 36 | ||
| 37 | + // TODO @super:单个参数,不用加 @Param | ||
| 37 | /** | 38 | /** |
| 38 | * 插入设备日志数据 | 39 | * 插入设备日志数据 |
| 39 | - * | 40 | + * |
| 40 | * 如果子表不存在,会自动创建子表 | 41 | * 如果子表不存在,会自动创建子表 |
| 41 | - * | 42 | + * |
| 42 | * @param log 设备日志数据 | 43 | * @param log 设备日志数据 |
| 43 | */ | 44 | */ |
| 44 | void insert(@Param("log") IotDeviceLogDO log); | 45 | void insert(@Param("log") IotDeviceLogDO log); |
| @@ -58,4 +59,5 @@ public interface IotDeviceLogDataMapper { | @@ -58,4 +59,5 @@ public interface IotDeviceLogDataMapper { | ||
| 58 | * @return 日志总数 | 59 | * @return 日志总数 |
| 59 | */ | 60 | */ |
| 60 | Long selectCount(@Param("reqVO") IotDeviceLogPageReqVO reqVO); | 61 | Long selectCount(@Param("reqVO") IotDeviceLogPageReqVO reqVO); |
| 62 | + | ||
| 61 | } | 63 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/TdThingModelMessageMapper.java
| 1 | package cn.iocoder.yudao.module.iot.dal.tdengine; | 1 | package cn.iocoder.yudao.module.iot.dal.tdengine; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; | ||
| 4 | -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; | ||
| 5 | -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessageDO; | ||
| 6 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS; | 3 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS; |
| 7 | -import com.baomidou.dynamic.datasource.annotation.DS; | ||
| 8 | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; | 4 | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 5 | import org.apache.ibatis.annotations.Mapper; |
| 10 | import org.apache.ibatis.annotations.Param; | 6 | import org.apache.ibatis.annotations.Param; |
| @@ -13,7 +9,7 @@ import org.apache.ibatis.annotations.Param; | @@ -13,7 +9,7 @@ import org.apache.ibatis.annotations.Param; | ||
| 13 | * 处理 TD 中物模型消息日志的操作 | 9 | * 处理 TD 中物模型消息日志的操作 |
| 14 | */ | 10 | */ |
| 15 | @Mapper | 11 | @Mapper |
| 16 | -@Deprecated | 12 | +@Deprecated // TODO super:什么时候,删除下哈。 |
| 17 | @TDengineDS | 13 | @TDengineDS |
| 18 | @InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错 | 14 | @InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错 |
| 19 | public interface TdThingModelMessageMapper { | 15 | public interface TdThingModelMessageMapper { |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/tdengine/config/TDengineTableInitConfiguration.java
| @@ -16,7 +16,7 @@ import org.springframework.core.annotation.Order; | @@ -16,7 +16,7 @@ import org.springframework.core.annotation.Order; | ||
| 16 | @Slf4j | 16 | @Slf4j |
| 17 | @RequiredArgsConstructor | 17 | @RequiredArgsConstructor |
| 18 | @Configuration | 18 | @Configuration |
| 19 | -@Order(Integer.MAX_VALUE) // 保证在最后执行 | 19 | +@Order |
| 20 | public class TDengineTableInitConfiguration implements ApplicationRunner { | 20 | public class TDengineTableInitConfiguration implements ApplicationRunner { |
| 21 | 21 | ||
| 22 | private final IotDeviceLogDataService deviceLogService; | 22 | private final IotDeviceLogDataService deviceLogService; |
| @@ -26,15 +26,18 @@ public class TDengineTableInitConfiguration implements ApplicationRunner { | @@ -26,15 +26,18 @@ public class TDengineTableInitConfiguration implements ApplicationRunner { | ||
| 26 | try { | 26 | try { |
| 27 | // 初始化设备日志表 | 27 | // 初始化设备日志表 |
| 28 | deviceLogService.initTDengineSTable(); | 28 | deviceLogService.initTDengineSTable(); |
| 29 | - log.info("初始化 设备日志表 TDengine 表结构成功"); | 29 | + // TODO @super:这个日志,是不是不用打,不然重复啦!!! |
| 30 | + log.info("[run]初始化 设备日志表 TDengine 表结构成功"); | ||
| 30 | } catch (Exception ex) { | 31 | } catch (Exception ex) { |
| 32 | + // TODO @super:初始化失败,打印 error 日志,退出系统。。不然跑起来,就初始啦!!! | ||
| 31 | if (ex.getMessage().contains("Table already exists")) { | 33 | if (ex.getMessage().contains("Table already exists")) { |
| 32 | log.info("TDengine 设备日志超级表已存在,跳过创建"); | 34 | log.info("TDengine 设备日志超级表已存在,跳过创建"); |
| 33 | return; | 35 | return; |
| 34 | - }else{ | 36 | + } else{ |
| 35 | log.error("初始化 设备日志表 TDengine 表结构失败", ex); | 37 | log.error("初始化 设备日志表 TDengine 表结构失败", ex); |
| 36 | } | 38 | } |
| 37 | throw ex; | 39 | throw ex; |
| 38 | } | 40 | } |
| 39 | } | 41 | } |
| 42 | + | ||
| 40 | } | 43 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceLogDataService.java
| @@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDevi | @@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDevi | ||
| 5 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO; | 5 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO; |
| 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; |
| 7 | 7 | ||
| 8 | - | ||
| 9 | /** | 8 | /** |
| 10 | * IoT 设备日志数据 Service 接口 | 9 | * IoT 设备日志数据 Service 接口 |
| 11 | * | 10 | * |
| @@ -15,7 +14,7 @@ public interface IotDeviceLogDataService { | @@ -15,7 +14,7 @@ public interface IotDeviceLogDataService { | ||
| 15 | 14 | ||
| 16 | /** | 15 | /** |
| 17 | * 初始化 TDengine 超级表 | 16 | * 初始化 TDengine 超级表 |
| 18 | - * | 17 | + * |
| 19 | *系统启动时,会自动初始化一次 | 18 | *系统启动时,会自动初始化一次 |
| 20 | */ | 19 | */ |
| 21 | void initTDengineSTable(); | 20 | void initTDengineSTable(); |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceLogDataServiceImpl.java
| 1 | package cn.iocoder.yudao.module.iot.service.device; | 1 | package cn.iocoder.yudao.module.iot.service.device; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.date.DateTime; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataSimulatorSaveReqVO; | 5 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataSimulatorSaveReqVO; |
| @@ -12,8 +11,6 @@ import lombok.extern.slf4j.Slf4j; | @@ -12,8 +11,6 @@ import lombok.extern.slf4j.Slf4j; | ||
| 12 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 13 | import org.springframework.validation.annotation.Validated; | 12 | import org.springframework.validation.annotation.Validated; |
| 14 | 13 | ||
| 15 | -import java.time.LocalDateTime; | ||
| 16 | -import java.time.ZoneId; | ||
| 17 | import java.util.List; | 14 | import java.util.List; |
| 18 | 15 | ||
| 19 | /** | 16 | /** |
| @@ -29,34 +26,30 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{ | @@ -29,34 +26,30 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{ | ||
| 29 | @Resource | 26 | @Resource |
| 30 | private IotDeviceLogDataMapper iotDeviceLogDataMapper; | 27 | private IotDeviceLogDataMapper iotDeviceLogDataMapper; |
| 31 | 28 | ||
| 32 | - | 29 | + // TODO @super:方法名。defineDeviceLog。。未来,有可能别人使用别的记录日志,例如说 es 之类的。 |
| 33 | @Override | 30 | @Override |
| 34 | public void initTDengineSTable() { | 31 | public void initTDengineSTable() { |
| 35 | - try { | ||
| 36 | - // 创建设备日志超级表 | ||
| 37 | - iotDeviceLogDataMapper.createDeviceLogSTable(); | ||
| 38 | - log.info("创建设备日志超级表成功"); | ||
| 39 | - } catch (Exception ex) { | ||
| 40 | - throw ex; | ||
| 41 | - } | 32 | + // TODO @super:改成不存在才创建。 |
| 33 | + iotDeviceLogDataMapper.createDeviceLogSTable(); | ||
| 42 | } | 34 | } |
| 43 | 35 | ||
| 44 | @Override | 36 | @Override |
| 45 | public void createDeviceLog(IotDeviceDataSimulatorSaveReqVO simulatorReqVO) { | 37 | public void createDeviceLog(IotDeviceDataSimulatorSaveReqVO simulatorReqVO) { |
| 46 | - //TODO:讨论一下,iotkit这块TS和上报时间都是外部传入的 但是看TDengine文档 他是建议对TS在SQL中直接NOW 咱们的TS数据获取是走哪一种 | ||
| 47 | - | ||
| 48 | // 1. 转换请求对象为 DO | 38 | // 1. 转换请求对象为 DO |
| 49 | IotDeviceLogDO iotDeviceLogDO = BeanUtils.toBean(simulatorReqVO, IotDeviceLogDO.class); | 39 | IotDeviceLogDO iotDeviceLogDO = BeanUtils.toBean(simulatorReqVO, IotDeviceLogDO.class); |
| 50 | - | 40 | + |
| 51 | // 2. 处理时间字段 | 41 | // 2. 处理时间字段 |
| 42 | + // TODO @super:一次性的字段,不用单独给个变量 | ||
| 52 | long currentTime = System.currentTimeMillis(); | 43 | long currentTime = System.currentTimeMillis(); |
| 53 | // 2.1 设置时序时间为当前时间 | 44 | // 2.1 设置时序时间为当前时间 |
| 54 | - iotDeviceLogDO.setTs(currentTime); | 45 | + iotDeviceLogDO.setTs(currentTime); // TODO @super:TS在SQL中直接NOW 咱们的TS数据获取是走哪一种;走 now() |
| 55 | 46 | ||
| 56 | // 3. 插入数据 | 47 | // 3. 插入数据 |
| 48 | + // TODO @super:不要直接调用对方的 IotDeviceLogDataMapper,通过 service 哈! | ||
| 57 | iotDeviceLogDataMapper.insert(iotDeviceLogDO); | 49 | iotDeviceLogDataMapper.insert(iotDeviceLogDO); |
| 58 | } | 50 | } |
| 59 | 51 | ||
| 52 | + // TODO @super:在 iotDeviceLogDataService 写 | ||
| 60 | @Override | 53 | @Override |
| 61 | public PageResult<IotDeviceLogDO> getDeviceLogPage(IotDeviceLogPageReqVO pageReqVO) { | 54 | public PageResult<IotDeviceLogDO> getDeviceLogPage(IotDeviceLogPageReqVO pageReqVO) { |
| 62 | // 查询数据 | 55 | // 查询数据 |
| @@ -65,4 +58,5 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{ | @@ -65,4 +58,5 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{ | ||
| 65 | // 构造分页结果 | 58 | // 构造分页结果 |
| 66 | return new PageResult<>(list, total); | 59 | return new PageResult<>(list, total); |
| 67 | } | 60 | } |
| 61 | + | ||
| 68 | } | 62 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataServiceImpl.java
| @@ -18,7 +18,6 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | @@ -18,7 +18,6 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | ||
| 18 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; | 18 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; |
| 19 | import cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyDataMapper; | 19 | import cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyDataMapper; |
| 20 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; | 20 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; |
| 21 | -import cn.iocoder.yudao.module.iot.dal.tdengine.TdThingModelMessageMapper; | ||
| 22 | import cn.iocoder.yudao.module.iot.enums.IotConstants; | 21 | import cn.iocoder.yudao.module.iot.enums.IotConstants; |
| 23 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotDataSpecsDataTypeEnum; | 22 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotDataSpecsDataTypeEnum; |
| 24 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | 23 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; |
| @@ -111,7 +110,6 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe | @@ -111,7 +110,6 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe | ||
| 111 | return; | 110 | return; |
| 112 | } | 111 | } |
| 113 | newFields.add(0, new TDengineTableField(TDengineTableField.FIELD_TS, TDengineTableField.TYPE_TIMESTAMP)); | 112 | newFields.add(0, new TDengineTableField(TDengineTableField.FIELD_TS, TDengineTableField.TYPE_TIMESTAMP)); |
| 114 | - // 2.1.1 创建产品超级表 | ||
| 115 | devicePropertyDataMapper.createProductPropertySTable(product.getProductKey(), newFields); | 113 | devicePropertyDataMapper.createProductPropertySTable(product.getProductKey(), newFields); |
| 116 | return; | 114 | return; |
| 117 | } | 115 | } |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/IotProductServiceImpl.java
| @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; | ||
| 9 | import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper; | 9 | import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper; |
| 10 | import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; | 10 | import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; |
| 11 | import cn.iocoder.yudao.module.iot.service.device.IotDevicePropertyDataService; | 11 | import cn.iocoder.yudao.module.iot.service.device.IotDevicePropertyDataService; |
| 12 | -import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService; | ||
| 13 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; | 12 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| 14 | import jakarta.annotation.Resource; | 13 | import jakarta.annotation.Resource; |
| 15 | import org.springframework.context.annotation.Lazy; | 14 | import org.springframework.context.annotation.Lazy; |
| @@ -116,14 +115,15 @@ public class IotProductServiceImpl implements IotProductService { | @@ -116,14 +115,15 @@ public class IotProductServiceImpl implements IotProductService { | ||
| 116 | public void updateProductStatus(Long id, Integer status) { | 115 | public void updateProductStatus(Long id, Integer status) { |
| 117 | // 1. 校验存在 | 116 | // 1. 校验存在 |
| 118 | validateProductExists(id); | 117 | validateProductExists(id); |
| 119 | - // 2. 更新 | ||
| 120 | - IotProductDO updateObj = IotProductDO.builder().id(id).status(status).build(); | ||
| 121 | - // 3. 产品是发布状态 | 118 | + |
| 119 | + // 2. 产品是发布状态 | ||
| 122 | if (Objects.equals(status, IotProductStatusEnum.PUBLISHED.getStatus())) { | 120 | if (Objects.equals(status, IotProductStatusEnum.PUBLISHED.getStatus())) { |
| 123 | - // 3.1 创建产品超级表数据模型 | 121 | + // 创建产品超级表数据模型 |
| 124 | devicePropertyDataService.defineDevicePropertyData(id); | 122 | devicePropertyDataService.defineDevicePropertyData(id); |
| 125 | - | ||
| 126 | } | 123 | } |
| 124 | + | ||
| 125 | + // 3. 更新 | ||
| 126 | + IotProductDO updateObj = IotProductDO.builder().id(id).status(status).build(); | ||
| 127 | productMapper.updateById(updateObj); | 127 | productMapper.updateById(updateObj); |
| 128 | } | 128 | } |
| 129 | 129 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
| @@ -7,20 +7,20 @@ import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; | @@ -7,20 +7,20 @@ import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; | ||
| 7 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.IotDeviceStatusUpdateReqVO; | 7 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.IotDeviceStatusUpdateReqVO; |
| 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; | 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO; | 9 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO; |
| 10 | -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.*; | 10 | +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser; |
| 11 | +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO; | ||
| 12 | +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO; | ||
| 13 | +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; | ||
| 11 | import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | 14 | import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; |
| 12 | -import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; | ||
| 13 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; | 15 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; |
| 14 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; | 16 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; |
| 15 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; | 17 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; |
| 16 | -import cn.iocoder.yudao.module.iot.dal.tdengine.TdThingModelMessageMapper; | ||
| 17 | import cn.iocoder.yudao.module.iot.enums.IotConstants; | 18 | import cn.iocoder.yudao.module.iot.enums.IotConstants; |
| 18 | import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum; | 19 | import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum; |
| 19 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | 20 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; |
| 20 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; | 21 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| 21 | -import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService; | ||
| 22 | import cn.iocoder.yudao.module.iot.service.product.IotProductService; | 22 | import cn.iocoder.yudao.module.iot.service.product.IotProductService; |
| 23 | -import cn.iocoder.yudao.module.iot.util.IotTdDatabaseUtils; | 23 | +import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService; |
| 24 | import jakarta.annotation.Resource; | 24 | import jakarta.annotation.Resource; |
| 25 | import lombok.extern.slf4j.Slf4j; | 25 | import lombok.extern.slf4j.Slf4j; |
| 26 | import org.springframework.beans.factory.annotation.Value; | 26 | import org.springframework.beans.factory.annotation.Value; |
| @@ -62,12 +62,8 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ | @@ -62,12 +62,8 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ | ||
| 62 | private TdEngineDMLMapper tdEngineDMLMapper; | 62 | private TdEngineDMLMapper tdEngineDMLMapper; |
| 63 | 63 | ||
| 64 | @Resource | 64 | @Resource |
| 65 | - private TdThingModelMessageMapper tdThingModelMessageMapper; | ||
| 66 | - | ||
| 67 | - @Resource | ||
| 68 | private DeviceDataRedisDAO deviceDataRedisDAO; | 65 | private DeviceDataRedisDAO deviceDataRedisDAO; |
| 69 | - | ||
| 70 | - | 66 | + |
| 71 | // TODO @haohao:这个方法,可以考虑加下 1. 2. 3. 更有层次感 | 67 | // TODO @haohao:这个方法,可以考虑加下 1. 2. 3. 更有层次感 |
| 72 | @Override | 68 | @Override |
| 73 | @TenantIgnore | 69 | @TenantIgnore |
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDeviceLogDataMapper.xml
| @@ -7,19 +7,19 @@ | @@ -7,19 +7,19 @@ | ||
| 7 | <!-- 创建设备日志超级表 初始化只创建一次--> | 7 | <!-- 创建设备日志超级表 初始化只创建一次--> |
| 8 | <update id="createDeviceLogSTable"> | 8 | <update id="createDeviceLogSTable"> |
| 9 | CREATE STABLE device_log ( | 9 | CREATE STABLE device_log ( |
| 10 | - ts TIMESTAMP, | ||
| 11 | - id NCHAR(50), | ||
| 12 | - product_key NCHAR(50), | ||
| 13 | - type NCHAR(50), | ||
| 14 | - subType NCHAR(50), | ||
| 15 | - content NCHAR(1024), | ||
| 16 | - report_time TIMESTAMP | ||
| 17 | - )TAGS ( | ||
| 18 | - device_key NCHAR(50) | ||
| 19 | - ) | 10 | + ts TIMESTAMP, |
| 11 | + id NCHAR(50), | ||
| 12 | + product_key NCHAR(50), | ||
| 13 | + type NCHAR(50), | ||
| 14 | + <!-- TODO @super:下划线 sub_type --> | ||
| 15 | + subType NCHAR(50), | ||
| 16 | + content NCHAR(1024), | ||
| 17 | + report_time TIMESTAMP | ||
| 18 | + ) TAGS ( | ||
| 19 | + device_key NCHAR(50) | ||
| 20 | + ) | ||
| 20 | </update> | 21 | </update> |
| 21 | 22 | ||
| 22 | - | ||
| 23 | <!-- 创建设备日志子表 讨论:TDengine 在子表不存在的情况下 可在数据插入时 自动建表 要不要去掉创建子表的逻辑 由第一次插入数据时自动创建--> | 23 | <!-- 创建设备日志子表 讨论:TDengine 在子表不存在的情况下 可在数据插入时 自动建表 要不要去掉创建子表的逻辑 由第一次插入数据时自动创建--> |
| 24 | <update id="createDeviceLogTable"> | 24 | <update id="createDeviceLogTable"> |
| 25 | CREATE TABLE device_log_${deviceKey} USING device_log TAGS('${deviceKey}') | 25 | CREATE TABLE device_log_${deviceKey} USING device_log TAGS('${deviceKey}') |