Commit 269dec1b2e04552dfc5ad7820a81a174e1ccfef2
1 parent
03462a10
【代码评审】IoT:模拟设备数据
Showing
13 changed files
with
66 additions
and
142 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 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO; | |
| 7 | 6 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.*; |
| 8 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO; |
| 9 | 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO; |
| ... | ... | @@ -52,7 +51,7 @@ public class IotDeviceDataController { |
| 52 | 51 | return success(BeanUtils.toBean(list, IotTimeDataRespVO.class)); |
| 53 | 52 | } |
| 54 | 53 | |
| 55 | - // TODO:数据权限 | |
| 54 | + // TODO:功能权限 | |
| 56 | 55 | @PostMapping("/simulator") |
| 57 | 56 | @Operation(summary = "模拟设备") |
| 58 | 57 | public CommonResult<Boolean> simulatorDevice(@Valid @RequestBody IotDeviceDataSimulatorSaveReqVO simulatorReqVO) { |
| ... | ... | @@ -62,7 +61,7 @@ public class IotDeviceDataController { |
| 62 | 61 | return success(true); |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | - // TODO:数据权限 | |
| 64 | + // TODO:功能权限 | |
| 66 | 65 | @GetMapping("/log/page") |
| 67 | 66 | @Operation(summary = "获得设备日志分页") |
| 68 | 67 | public CommonResult<PageResult<IotDeviceLogRespVO>> getDeviceLogPage(@Valid IotDeviceLogPageReqVO pageReqVO) { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/deviceData/IotDeviceDataSimulatorSaveReqVO.java
| ... | ... | @@ -19,7 +19,6 @@ public class IotDeviceDataSimulatorSaveReqVO { |
| 19 | 19 | @NotEmpty(message = "产品标识不能为空") |
| 20 | 20 | private String productKey; |
| 21 | 21 | |
| 22 | - // TODO @super:中文写作规范,中英文之间,要有空格。例如说,设备 ID。ps:这里应该是设备标识 | |
| 23 | 22 | @Schema(description = "设备标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123") |
| 24 | 23 | @NotEmpty(message = "设备标识不能为空") |
| 25 | 24 | private String deviceKey; |
| ... | ... | @@ -38,6 +37,7 @@ public class IotDeviceDataSimulatorSaveReqVO { |
| 38 | 37 | @NotEmpty(message = "数据内容不能为空") |
| 39 | 38 | private String content; |
| 40 | 39 | |
| 40 | + // TODO @芋艿:需要讨论下,reportTime 到底以那个为准! | |
| 41 | 41 | @Schema(description = "上报时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 42 | 42 | private Long reportTime; |
| 43 | 43 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceLogDO.java
| ... | ... | @@ -25,7 +25,6 @@ public class IotDeviceLogDO { |
| 25 | 25 | */ |
| 26 | 26 | private String id; |
| 27 | 27 | |
| 28 | - // TODO @super:关联要 @下 | |
| 29 | 28 | /** |
| 30 | 29 | * 产品标识 |
| 31 | 30 | * <p> |
| ... | ... | @@ -33,7 +32,6 @@ public class IotDeviceLogDO { |
| 33 | 32 | */ |
| 34 | 33 | private String productKey; |
| 35 | 34 | |
| 36 | - // TODO @super:关联要 @下 | |
| 37 | 35 | /** |
| 38 | 36 | * 设备标识 |
| 39 | 37 | * <p> | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDeviceLogDataMapper.java
| ... | ... | @@ -10,9 +10,7 @@ import org.apache.ibatis.annotations.Param; |
| 10 | 10 | import java.util.List; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * IOT 设备日志数据 Mapper 接口 | |
| 14 | - * | |
| 15 | - * 基于 TDengine 实现设备日志的存储 | |
| 13 | + * 设备日志 {@link IotDeviceLogDO} Mapper 接口 | |
| 16 | 14 | */ |
| 17 | 15 | @Mapper |
| 18 | 16 | @TDengineDS |
| ... | ... | @@ -21,12 +19,11 @@ public interface IotDeviceLogDataMapper { |
| 21 | 19 | |
| 22 | 20 | /** |
| 23 | 21 | * 创建设备日志超级表 |
| 24 | - * 初始化只创建一次 | |
| 25 | 22 | */ |
| 26 | 23 | void createDeviceLogSTable(); |
| 27 | 24 | |
| 28 | - | |
| 29 | 25 | // TODO @super:单个参数,不用加 @Param |
| 26 | + // TODO @芋艿:在瞅瞅 | |
| 30 | 27 | //讨论:艿菇这里有些特殊情况,我也学习了一下这块知识: |
| 31 | 28 | // 如果使用的是Java 8及以上版本,并且编译器保留了参数名(通过编译器选项-parameters启用),则可以去掉@Param注解。MyBatis会自动使用参数的实际名称 |
| 32 | 29 | // 但在TDengine中 @Param去掉后TDengine会报错,以下是大模型的回答: |
| ... | ... | @@ -65,18 +62,12 @@ public interface IotDeviceLogDataMapper { |
| 65 | 62 | */ |
| 66 | 63 | Long selectCount(@Param("reqVO") IotDeviceLogPageReqVO reqVO); |
| 67 | 64 | |
| 65 | + // TODO @芋艿:这个方法名,后续看看叫啥好 | |
| 68 | 66 | /** |
| 69 | 67 | * 查询设备日志表是否存在 |
| 70 | 68 | * |
| 71 | - * @return 不存在返回null | |
| 69 | + * @return 不存在返回 null | |
| 72 | 70 | */ |
| 73 | 71 | Object checkDeviceLogSTableExists(); |
| 74 | 72 | |
| 75 | - /** | |
| 76 | - * 检查设备日志子表是否存在 | |
| 77 | - * | |
| 78 | - * @param deviceKey 设备标识 | |
| 79 | - * @return 不存在返回null | |
| 80 | - */ | |
| 81 | - Object checkDeviceLogTableExists(@Param("deviceKey") String deviceKey); | |
| 82 | 73 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/tdengine/config/TDengineTableInitConfiguration.java
| ... | ... | @@ -6,17 +6,15 @@ import lombok.extern.slf4j.Slf4j; |
| 6 | 6 | import org.springframework.boot.ApplicationArguments; |
| 7 | 7 | import org.springframework.boot.ApplicationRunner; |
| 8 | 8 | import org.springframework.context.annotation.Configuration; |
| 9 | -import org.springframework.core.annotation.Order; | |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * TDengine 表初始化的 Configuration |
| 13 | 12 | * |
| 14 | 13 | * @author alwayssuper |
| 15 | 14 | */ |
| 15 | +@Configuration | |
| 16 | 16 | @Slf4j |
| 17 | 17 | @RequiredArgsConstructor |
| 18 | -@Configuration | |
| 19 | -@Order | |
| 20 | 18 | public class TDengineTableInitConfiguration implements ApplicationRunner { |
| 21 | 19 | |
| 22 | 20 | private final IotDeviceLogDataService deviceLogService; |
| ... | ... | @@ -26,9 +24,7 @@ public class TDengineTableInitConfiguration implements ApplicationRunner { |
| 26 | 24 | try { |
| 27 | 25 | // 初始化设备日志表 |
| 28 | 26 | deviceLogService.defineDeviceLog(); |
| 29 | - // TODO @super:这个日志,是不是不用打,不然重复啦!!! | |
| 30 | 27 | } catch (Exception ex) { |
| 31 | - // TODO @super:初始化失败,打印 error 日志,退出系统。。不然跑起来,就初始啦!!! | |
| 32 | 28 | // 初始化失败时打印错误日志并退出系统 |
| 33 | 29 | log.error("[TDengine] 初始化设备日志表结构失败,系统无法正常运行,即将退出", ex); |
| 34 | 30 | System.exit(1); | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/consumer/deviceconsumer/DeviceConsumer.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.mq.consumer.deviceconsumer; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO; | |
| 5 | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; |
| 6 | 5 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceLogDataService; |
| 7 | 6 | import cn.iocoder.yudao.module.iot.service.device.IotDevicePropertyDataService; |
| ... | ... | @@ -20,8 +19,9 @@ import javax.annotation.Resource; |
| 20 | 19 | @Component |
| 21 | 20 | @Slf4j |
| 22 | 21 | public class DeviceConsumer { |
| 22 | + | |
| 23 | 23 | @Resource |
| 24 | - private IotDeviceLogDataService iotDeviceLogDataService; | |
| 24 | + private IotDeviceLogDataService deviceLogDataService; | |
| 25 | 25 | @Resource |
| 26 | 26 | private IotDevicePropertyDataService deviceDataService; |
| 27 | 27 | |
| ... | ... | @@ -35,7 +35,7 @@ public class DeviceConsumer { |
| 35 | 35 | // 设备数据记录 |
| 36 | 36 | deviceDataService.saveDeviceDataTest(message); |
| 37 | 37 | // 设备日志记录 |
| 38 | - iotDeviceLogDataService.saveDeviceLog(message); | |
| 38 | + deviceLogDataService.saveDeviceLog(message); | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/producer/simulatesend/SimulateSendProducer.java
| ... | ... | @@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j; |
| 6 | 6 | import org.springframework.context.ApplicationContext; |
| 7 | 7 | import org.springframework.stereotype.Component; |
| 8 | 8 | |
| 9 | -// TODO @alwayssuper:是不是还没用起来哈?Producer 最好属于某个模块; | |
| 9 | +// TODO @芋艿:@alwayssuper:是不是还没用起来哈?Producer 最好属于某个模块; | |
| 10 | 10 | /** |
| 11 | 11 | * SimulateSend 模拟设备上报的 Producer |
| 12 | 12 | * |
| ... | ... | @@ -28,4 +28,5 @@ public class SimulateSendProducer { |
| 28 | 28 | public void sendSimulateMessage(ThingModelMessage thingModelMessage) { |
| 29 | 29 | applicationContext.publishEvent(thingModelMessage); |
| 30 | 30 | } |
| 31 | + | |
| 31 | 32 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceLogDataService.java
| ... | ... | @@ -16,7 +16,7 @@ public interface IotDeviceLogDataService { |
| 16 | 16 | /** |
| 17 | 17 | * 初始化 TDengine 超级表 |
| 18 | 18 | * |
| 19 | - *系统启动时,会自动初始化一次 | |
| 19 | + * 系统启动时,会自动初始化一次 | |
| 20 | 20 | */ |
| 21 | 21 | void defineDeviceLog(); |
| 22 | 22 | |
| ... | ... | @@ -40,8 +40,8 @@ public interface IotDeviceLogDataService { |
| 40 | 40 | /** |
| 41 | 41 | * 插入设备日志 |
| 42 | 42 | * |
| 43 | - * @param msg 设备数据 | |
| 43 | + * @param message 设备数据 | |
| 44 | 44 | */ |
| 45 | - void saveDeviceLog(ThingModelMessage msg); | |
| 45 | + void saveDeviceLog(ThingModelMessage message); | |
| 46 | 46 | |
| 47 | 47 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceLogDataServiceImpl.java
| ... | ... | @@ -13,7 +13,6 @@ import lombok.extern.slf4j.Slf4j; |
| 13 | 13 | import org.springframework.stereotype.Service; |
| 14 | 14 | import org.springframework.validation.annotation.Validated; |
| 15 | 15 | |
| 16 | -import java.util.Date; | |
| 17 | 16 | import java.util.List; |
| 18 | 17 | |
| 19 | 18 | /** |
| ... | ... | @@ -27,28 +26,18 @@ import java.util.List; |
| 27 | 26 | public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{ |
| 28 | 27 | |
| 29 | 28 | @Resource |
| 30 | - private IotDeviceLogDataMapper iotDeviceLogDataMapper; | |
| 29 | + private IotDeviceLogDataMapper deviceLogDataMapper; | |
| 31 | 30 | |
| 32 | - // TODO @super:方法名。defineDeviceLog。。未来,有可能别人使用别的记录日志,例如说 es 之类的。 | |
| 33 | 31 | @Override |
| 34 | 32 | public void defineDeviceLog() { |
| 35 | - // TODO @super:改成不存在才创建。 | |
| 36 | -// try { | |
| 37 | -// // 创建超级表(使用 IF NOT EXISTS 语句避免重复创建错误) | |
| 38 | -// iotDeviceLogDataMapper.createDeviceLogSTable(); | |
| 39 | -// } catch (Exception e) { | |
| 40 | -// if (e.getMessage().contains("already exists")) { | |
| 41 | -// log.info("[TDengine] 设备日志超级表已存在,跳过创建"); | |
| 42 | -// return; | |
| 43 | -// } | |
| 44 | -// throw e; | |
| 45 | -// } | |
| 46 | - if(iotDeviceLogDataMapper.checkDeviceLogSTableExists()==null){ | |
| 47 | - log.info("[TDengine] 设备日志超级表不存在,开始创建"); | |
| 48 | - iotDeviceLogDataMapper.createDeviceLogSTable(); | |
| 49 | - }else{ | |
| 50 | - log.info("[TDengine] 设备日志超级表已存在,跳过创建"); | |
| 33 | + if (deviceLogDataMapper.checkDeviceLogSTableExists() != null) { | |
| 34 | + log.info("[defineDeviceLog][设备日志超级表已存在,跳过创建]"); | |
| 35 | + return; | |
| 51 | 36 | } |
| 37 | + | |
| 38 | + log.info("[defineDeviceLog][设备日志超级表不存在,开始创建]"); | |
| 39 | + deviceLogDataMapper.createDeviceLogSTable(); | |
| 40 | + log.info("[defineDeviceLog][设备日志超级表不存在,创建完成]"); | |
| 52 | 41 | } |
| 53 | 42 | |
| 54 | 43 | @Override |
| ... | ... | @@ -57,47 +46,32 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{ |
| 57 | 46 | IotDeviceLogDO iotDeviceLogDO = BeanUtils.toBean(simulatorReqVO, IotDeviceLogDO.class); |
| 58 | 47 | |
| 59 | 48 | // 2. 处理时间字段 |
| 60 | - // TODO @super:一次性的字段,不用单独给个变量 | |
| 61 | -// long currentTime = System.currentTimeMillis(); | |
| 62 | - // 2.1 设置时序时间为当前时间 | |
| 63 | 49 | // iotDeviceLogDO.setTs(currentTime); // TODO @super:TS在SQL中直接NOW 咱们的TS数据获取是走哪一种;走 now() |
| 64 | 50 | |
| 65 | 51 | // 3. 插入数据 |
| 66 | - // TODO @super:不要直接调用对方的 IotDeviceLogDataMapper,通过 service 哈! | |
| 67 | - // 讨论:艿菇 这就是iotDeviceLogDataService的Impl | |
| 68 | - iotDeviceLogDataMapper.insert(iotDeviceLogDO); | |
| 52 | + deviceLogDataMapper.insert(iotDeviceLogDO); | |
| 69 | 53 | } |
| 70 | 54 | |
| 71 | - // TODO @super:在 iotDeviceLogDataService 写 | |
| 72 | - // 讨论:艿菇 这就是iotDeviceLogDataService的Impl | |
| 73 | 55 | @Override |
| 74 | 56 | public PageResult<IotDeviceLogDO> getDeviceLogPage(IotDeviceLogPageReqVO pageReqVO) { |
| 75 | - // 当设备日志表未创建时,查询会出现报错 | |
| 76 | - if(iotDeviceLogDataMapper.checkDeviceLogTableExists(pageReqVO.getDeviceKey())==null){ | |
| 77 | - return null; | |
| 78 | - } | |
| 79 | - // 查询数据 | |
| 80 | - List<IotDeviceLogDO> list = iotDeviceLogDataMapper.selectPage(pageReqVO); | |
| 81 | - Long total = iotDeviceLogDataMapper.selectCount(pageReqVO); | |
| 82 | - // 构造分页结果 | |
| 57 | + // TODO @芋艿:增加一个表不存在的 try catch | |
| 58 | + List<IotDeviceLogDO> list = deviceLogDataMapper.selectPage(pageReqVO); | |
| 59 | + Long total = deviceLogDataMapper.selectCount(pageReqVO); | |
| 83 | 60 | return new PageResult<>(list, total); |
| 84 | 61 | } |
| 85 | 62 | |
| 86 | 63 | @Override |
| 87 | - public void saveDeviceLog(ThingModelMessage msg) { | |
| 88 | - // 1. 构建设备日志对象 | |
| 89 | - IotDeviceLogDO iotDeviceLogDO = IotDeviceLogDO.builder() | |
| 90 | - .id(msg.getId()) // 消息ID | |
| 91 | - .deviceKey(msg.getDeviceKey()) // 设备标识 | |
| 92 | - .productKey(msg.getProductKey()) // 产品标识 | |
| 93 | - .type(msg.getMethod()) // 消息类型,使用method作为类型 | |
| 94 | - .subType("property") // TODO:这块先写死,后续优化 | |
| 95 | - .content(JSONUtil.toJsonStr(msg)) // TODO:后续优化 | |
| 96 | - .reportTime(msg.getTime()) // 上报时间 | |
| 64 | + public void saveDeviceLog(ThingModelMessage message) { | |
| 65 | + IotDeviceLogDO log = IotDeviceLogDO.builder() | |
| 66 | + .id(message.getId()) | |
| 67 | + .deviceKey(message.getDeviceKey()) | |
| 68 | + .productKey(message.getProductKey()) | |
| 69 | + .type(message.getMethod()) // 消息类型,使用method作为类型 TODO 芋艿:在看看 | |
| 70 | + .subType("property") // TODO 芋艿:这块先写死,后续优化 | |
| 71 | + .content(JSONUtil.toJsonStr(message)) // TODO 芋艿:后续优化 | |
| 72 | + .reportTime(message.getTime()) // 上报时间 TODO 芋艿:在想想时间 | |
| 97 | 73 | .build(); |
| 98 | - | |
| 99 | - // 2. 插入设备日志 | |
| 100 | - iotDeviceLogDataMapper.insert(iotDeviceLogDO); | |
| 74 | + deviceLogDataMapper.insert(log); | |
| 101 | 75 | } |
| 102 | 76 | |
| 103 | 77 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataService.java
| ... | ... | @@ -32,7 +32,6 @@ public interface IotDevicePropertyDataService { |
| 32 | 32 | */ |
| 33 | 33 | void saveDeviceData(IotDevicePropertyReportReqDTO createDTO); |
| 34 | 34 | |
| 35 | - | |
| 36 | 35 | /** |
| 37 | 36 | * 保存设备数据 |
| 38 | 37 | * |
| ... | ... | @@ -45,7 +44,6 @@ public interface IotDevicePropertyDataService { |
| 45 | 44 | * |
| 46 | 45 | * @param simulatorReqVO 设备数据 |
| 47 | 46 | */ |
| 48 | - | |
| 49 | 47 | void simulatorSend(IotDeviceDataSimulatorSaveReqVO simulatorReqVO); |
| 50 | 48 | |
| 51 | 49 | /** | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataServiceImpl.java
| ... | ... | @@ -159,7 +159,7 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe |
| 159 | 159 | thingModelMessageService.saveThingModelMessage(device, thingModelMessage); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - //TODO:后续捋一捋这块逻辑,先借鉴一下目前的代码 | |
| 162 | + //TODO @芋艿:后续捋一捋这块逻辑,先借鉴一下目前的代码 | |
| 163 | 163 | @Override |
| 164 | 164 | public void saveDeviceDataTest(ThingModelMessage thingModelMessage) { |
| 165 | 165 | // 1. 根据产品 key 和设备名称,获得设备信息 |
| ... | ... | @@ -168,7 +168,7 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe |
| 168 | 168 | thingModelMessageService.saveThingModelMessage(device, thingModelMessage); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - //TODO: copy 了 saveDeviceData 的逻辑,后续看看这块怎么优化 | |
| 171 | + //TODO @芋艿:copy 了 saveDeviceData 的逻辑,后续看看这块怎么优化 | |
| 172 | 172 | @Override |
| 173 | 173 | public void simulatorSend(IotDeviceDataSimulatorSaveReqVO simulatorReqVO) { |
| 174 | 174 | // 1. 根据设备 key ,获得设备信息 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDeviceLogDataMapper.xml
| ... | ... | @@ -4,28 +4,20 @@ |
| 4 | 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 5 | 5 | <mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.IotDeviceLogDataMapper"> |
| 6 | 6 | |
| 7 | - <!-- 创建设备日志超级表 初始化只创建一次--> | |
| 8 | 7 | <update id="createDeviceLogSTable"> |
| 9 | 8 | CREATE STABLE IF NOT EXISTS device_log ( |
| 10 | - ts TIMESTAMP, | |
| 11 | - id NCHAR(50), | |
| 12 | - product_key NCHAR(50), | |
| 13 | - type NCHAR(50), | |
| 14 | - <!-- TODO @super:下划线 sub_type --> | |
| 15 | - sub_type NCHAR(50), | |
| 16 | - content NCHAR(1024), | |
| 17 | - report_time TIMESTAMP | |
| 9 | + ts TIMESTAMP, | |
| 10 | + id NCHAR(50), | |
| 11 | + product_key NCHAR(50), | |
| 12 | + type NCHAR(50), | |
| 13 | + sub_type NCHAR(50), | |
| 14 | + content NCHAR(1024), | |
| 15 | + report_time TIMESTAMP | |
| 18 | 16 | ) TAGS ( |
| 19 | 17 | device_key NCHAR(50) |
| 20 | 18 | ) |
| 21 | 19 | </update> |
| 22 | 20 | |
| 23 | - <!-- 创建设备日志子表 讨论:TDengine 在子表不存在的情况下 可在数据插入时 自动建表 要不要去掉创建子表的逻辑 由第一次插入数据时自动创建--> | |
| 24 | - <update id="createDeviceLogTable"> | |
| 25 | - CREATE TABLE device_log_${deviceKey} USING device_log TAGS('${deviceKey}') | |
| 26 | - </update> | |
| 27 | - | |
| 28 | - <!-- 插入设备日志数据 在子表不存在的情况下 可在数据插入时 自动建表 --> | |
| 29 | 21 | <insert id="insert"> |
| 30 | 22 | INSERT INTO device_log_${log.deviceKey} (ts, id, product_key, type, subType, content, report_time) |
| 31 | 23 | USING device_log |
| ... | ... | @@ -42,7 +34,7 @@ |
| 42 | 34 | </insert> |
| 43 | 35 | |
| 44 | 36 | <select id="selectPage" resultType="cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO"> |
| 45 | - SELECT ts, id, device_key, product_key, type, subType, content, report_time | |
| 37 | + SELECT ts, id, device_key, product_key, type, sub_type, content, report_time | |
| 46 | 38 | FROM device_log_${reqVO.deviceKey} |
| 47 | 39 | <where> |
| 48 | 40 | <if test="reqVO.type != null and reqVO.type != ''"> |
| ... | ... | @@ -75,15 +67,12 @@ |
| 75 | 67 | </where> |
| 76 | 68 | </select> |
| 77 | 69 | |
| 78 | - <!-- 检查设备日志超级表是否存在 --> | |
| 79 | 70 | <select id="checkDeviceLogSTableExists" resultType="Object"> |
| 80 | 71 | SHOW STABLES LIKE 'device_log' |
| 81 | 72 | </select> |
| 82 | 73 | |
| 83 | - <!-- 检查设备日志子表是否存在 --> | |
| 84 | 74 | <select id="checkDeviceLogTableExists" resultType="Object"> |
| 85 | 75 | SHOW TABLES LIKE 'device_log_${deviceKey}' |
| 86 | 76 | </select> |
| 87 | 77 | |
| 88 | - | |
| 89 | 78 | </mapper> |
| 90 | 79 | \ No newline at end of file | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -45,7 +45,7 @@ spring: |
| 45 | 45 | primary: master |
| 46 | 46 | datasource: |
| 47 | 47 | master: |
| 48 | - url: jdbc:mysql://chaojiniu.top:23306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 48 | + url: jdbc:mysql://127.0.0.1:3307/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 49 | 49 | # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 |
| 50 | 50 | # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 |
| 51 | 51 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| ... | ... | @@ -53,8 +53,8 @@ spring: |
| 53 | 53 | # url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 |
| 54 | 54 | # url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例 |
| 55 | 55 | # url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例 |
| 56 | - username: ruoyi-vue-pro | |
| 57 | - password: ruoyi-@h2ju02hebp | |
| 56 | + username: root | |
| 57 | + password: ahh@123456 | |
| 58 | 58 | # username: sa # SQL Server 连接的示例 |
| 59 | 59 | # password: Yudao@2024 # SQL Server 连接的示例 |
| 60 | 60 | # username: SYSDBA # DM 连接的示例 |
| ... | ... | @@ -63,25 +63,17 @@ spring: |
| 63 | 63 | # password: Yudao@2024 # OpenGauss 连接的示例 |
| 64 | 64 | slave: # 模拟从库,可根据自己需要修改 |
| 65 | 65 | lazy: true # 开启懒加载,保证启动速度 |
| 66 | - url: jdbc:mysql://chaojiniu.top:23306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true | |
| 67 | - username: ruoyi-vue-pro | |
| 68 | - password: ruoyi-@h2ju02hebp | |
| 69 | - tdengine: # IOT 数据库 | |
| 70 | -# lazy: true # 开启懒加载,保证启动速度 | |
| 71 | - url: jdbc:TAOS-RS://chaojiniu.top:6041/ruoyi_vue_pro | |
| 72 | - driver-class-name: com.taosdata.jdbc.rs.RestfulDriver | |
| 66 | + url: jdbc:mysql://127.0.0.1:3307/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true | |
| 73 | 67 | username: root |
| 74 | - password: taosdata | |
| 75 | - druid: | |
| 76 | - validation-query: SELECT SERVER_STATUS() # TDengine 数据源的有效性检查 SQL | |
| 68 | + password: ahh@123456 | |
| 77 | 69 | |
| 78 | 70 | # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 |
| 79 | 71 | data: |
| 80 | 72 | redis: |
| 81 | - host: chaojiniu.top # 地址 | |
| 73 | + host: 127.0.0.1 # 地址 | |
| 82 | 74 | port: 6379 # 端口 |
| 83 | - database: 15 # 数据库索引 | |
| 84 | - password: fsknKD7UvQYZsyf2hXXn # 密码,建议生产环境开启 | |
| 75 | + database: 0 # 数据库索引 | |
| 76 | +# password: dev # 密码,建议生产环境开启 | |
| 85 | 77 | |
| 86 | 78 | --- #################### 定时任务相关配置 #################### |
| 87 | 79 | |
| ... | ... | @@ -191,12 +183,12 @@ debug: false |
| 191 | 183 | --- #################### 微信公众号、小程序相关配置 #################### |
| 192 | 184 | wx: |
| 193 | 185 | mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 |
| 194 | -# app-id: wx041349c6f39b268b # 测试号(牛希尧提供的) | |
| 195 | -# secret: 5abee519483bc9f8cb37ce280e814bd0 | |
| 186 | + # app-id: wx041349c6f39b268b # 测试号(牛希尧提供的) | |
| 187 | + # secret: 5abee519483bc9f8cb37ce280e814bd0 | |
| 196 | 188 | app-id: wx5b23ba7a5589ecbb # 测试号(自己的) |
| 197 | 189 | secret: 2a7b3b20c537e52e74afd395eb85f61f |
| 198 | -# app-id: wxa69ab825b163be19 # 测试号(Kongdy 提供的) | |
| 199 | -# secret: bd4f9fab889591b62aeac0d7b8d8b4a0 | |
| 190 | + # app-id: wxa69ab825b163be19 # 测试号(Kongdy 提供的) | |
| 191 | + # secret: bd4f9fab889591b62aeac0d7b8d8b4a0 | |
| 200 | 192 | # 存储配置,解决 AccessToken 的跨节点的共享 |
| 201 | 193 | config-storage: |
| 202 | 194 | type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 |
| ... | ... | @@ -205,10 +197,10 @@ wx: |
| 205 | 197 | miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档 |
| 206 | 198 | # appid: wx62056c0d5e8db250 # 测试号(牛希尧提供的) |
| 207 | 199 | # secret: 333ae72f41552af1e998fe1f54e1584a |
| 208 | -# appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 | |
| 209 | -# secret: 6f270509224a7ae1296bbf1c8cb97aed | |
| 210 | -# appid: wxc4598c446f8a9cb3 # 测试号(Kongdy 提供的) | |
| 211 | -# secret: 4a1a04e07f6a4a0751b39c3064a92c8b | |
| 200 | + # appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 | |
| 201 | + # secret: 6f270509224a7ae1296bbf1c8cb97aed | |
| 202 | + # appid: wxc4598c446f8a9cb3 # 测试号(Kongdy 提供的) | |
| 203 | + # secret: 4a1a04e07f6a4a0751b39c3064a92c8b | |
| 212 | 204 | appid: wx66186af0759f47c9 # 测试号(puhui 提供的) |
| 213 | 205 | secret: 3218bcbd112cbc614c7264ceb20144ac |
| 214 | 206 | config-storage: |
| ... | ... | @@ -267,7 +259,7 @@ justauth: |
| 267 | 259 | iot: |
| 268 | 260 | emq: |
| 269 | 261 | # 账号 |
| 270 | - username: haohao | |
| 262 | + username: anhaohao | |
| 271 | 263 | # 密码 |
| 272 | 264 | password: ahh@123456 |
| 273 | 265 | # 主机地址 |
| ... | ... | @@ -279,18 +271,4 @@ iot: |
| 279 | 271 | # 保持连接 |
| 280 | 272 | keepalive: 60 |
| 281 | 273 | # 清除会话(设置为false,断开连接,重连后使用原来的会话 保留订阅的主题,能接收离线期间的消息) |
| 282 | - clearSession: true | |
| 283 | - | |
| 284 | -# MQTT-RPC 配置 | |
| 285 | -mqtt: | |
| 286 | - broker: tcp://chaojiniu.top:1883 | |
| 287 | - username: haohao | |
| 288 | - password: ahh@123456 | |
| 289 | - clientId: mqtt-rpc-server-${random.int} | |
| 290 | - requestTopic: rpc/request | |
| 291 | - responseTopicPrefix: rpc/response/ | |
| 292 | - | |
| 293 | - | |
| 294 | -# 插件配置 | |
| 295 | -pf4j: | |
| 296 | - pluginsDir: /Users/anhaohao/code/gitee/ruoyi-vue-pro/plugins # 插件目录 | |
| 297 | 274 | \ No newline at end of file |
| 275 | + clearSession: true | |
| 298 | 276 | \ No newline at end of file | ... | ... |