Commit 03462a103ca452f4a40261fe48f026cc68e30be0

Authored by 芋道源码
Committed by Gitee
2 parents 5264de07 03d4f60e

!1211 [feat]:模拟设备加入 spring event

Merge pull request !1211 from alwayssuper/feature/iot
Showing 25 changed files with 381 additions and 101 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ErrorCodeConstants.java
... ... @@ -30,6 +30,7 @@ public interface ErrorCodeConstants {
30 30 ErrorCode DEVICE_GATEWAY_NOT_EXISTS = new ErrorCode(1_050_003_004, "网关设备不存在");
31 31 ErrorCode DEVICE_NOT_GATEWAY = new ErrorCode(1_050_003_005, "设备不是网关设备");
32 32 ErrorCode DEVICE_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_050_003_006, "导入设备数据不能为空!");
  33 + ErrorCode DEVICE_DATA_CONTENT_JSON_PARSE_ERROR = new ErrorCode(1_050_003_007, "导入设备数据格式错误!");
33 34  
34 35 // ========== 产品分类 1-050-004-000 ==========
35 36 ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_050_004_000, "产品分类不存在");
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceDataController.java
... ... @@ -3,6 +3,7 @@ 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;
6 7 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.*;
7 8 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
8 9 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO;
... ... @@ -55,9 +56,9 @@ public class IotDeviceDataController {
55 56 @PostMapping("/simulator")
56 57 @Operation(summary = "模拟设备")
57 58 public CommonResult<Boolean> simulatorDevice(@Valid @RequestBody IotDeviceDataSimulatorSaveReqVO simulatorReqVO) {
58   - //TODO:先生成一下设备日志 后续完善模拟设备代码逻辑
  59 + //TODO:先使用 IotDeviceDataSimulatorSaveReqVO 另外content里数据类型的效验前端也没做,后端应该要要效验一下,这块后续看看怎么安排
59 60 // TODO @super:应该 deviceDataService 里面有个 simulatorDevice,然后里面去 insert 日志!
60   - iotDeviceLogDataService.createDeviceLog(simulatorReqVO);
  61 + deviceDataService.simulatorSend(simulatorReqVO);
61 62 return success(true);
62 63 }
63 64  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/deviceData/IotDeviceDataSimulatorSaveReqVO.java
... ... @@ -14,16 +14,18 @@ public class IotDeviceDataSimulatorSaveReqVO {
14 14 private String id;
15 15  
16 16 // TODO @super:不用传递 productKey,因为 deviceKey 可以推导出来
17   - @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "product123")
18   - @NotEmpty(message = "产品ID不能为空")
  17 + // TODO 讨论: 日志记录的时候要记录一下productKey,目前是前端已经有productKey了,所以前端传入,如果不传入的话,后端要根据deviceKey查询productKey,感觉直传是不是效率高一些
  18 + @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "product123")
  19 + @NotEmpty(message = "产品标识不能为空")
19 20 private String productKey;
20 21  
21 22 // TODO @super:中文写作规范,中英文之间,要有空格。例如说,设备 ID。ps:这里应该是设备标识
22   - @Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123")
23   - @NotEmpty(message = "设备ID不能为空")
  23 + @Schema(description = "设备标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123")
  24 + @NotEmpty(message = "设备标识不能为空")
24 25 private String deviceKey;
25 26  
26 27 // TODO @super:type、subType,是不是不用传递,因为模拟只有属性???
  28 + // TODO 讨论: 不只模拟属性
27 29 @Schema(description = "消息/日志类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "property")
28 30 @NotEmpty(message = "消息类型不能为空")
29 31 private String type;
... ... @@ -36,7 +38,6 @@ public class IotDeviceDataSimulatorSaveReqVO {
36 38 @NotEmpty(message = "数据内容不能为空")
37 39 private String content;
38 40  
39   - // TODO @芋艿:需要讨论下,reportTime 到底以那个为准!
40 41 @Schema(description = "上报时间", requiredMode = Schema.RequiredMode.REQUIRED)
41 42 private Long reportTime;
42 43  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceLogDO.java
1 1 package cn.iocoder.yudao.module.iot.dal.dataobject.device;
2 2  
  3 +import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
3 4 import lombok.AllArgsConstructor;
4 5 import lombok.Builder;
5 6 import lombok.Data;
... ... @@ -27,12 +28,16 @@ public class IotDeviceLogDO {
27 28 // TODO @super:关联要 @下
28 29 /**
29 30 * 产品标识
  31 + * <p>
  32 + * 关联 {@link IotProductDO#getProductKey()}
30 33 */
31 34 private String productKey;
32 35  
33 36 // TODO @super:关联要 @下
34 37 /**
35 38 * 设备标识
  39 + * <p>
  40 + * 关联 {@link IotDeviceDO#getDeviceKey()}}
36 41 */
37 42 private String deviceKey;
38 43  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/SelectVisualDO.java
... ... @@ -19,6 +19,9 @@ public class SelectVisualDO {
19 19 */
20 20 private String tableName;
21 21  
  22 +
  23 + private String deviceKey;
  24 +
22 25 /**
23 26 * 属性
24 27 */
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/TdTableDO.java
... ... @@ -33,6 +33,10 @@ public class TdTableDO {
33 33 */
34 34 private String tableName;
35 35  
  36 + private String productKey;
  37 +
  38 + private String deviceKey;
  39 +
36 40 /**
37 41 * COLUMN 字段
38 42 */
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDeviceLogDataMapper.java
... ... @@ -21,20 +21,25 @@ public interface IotDeviceLogDataMapper {
21 21  
22 22 /**
23 23 * 创建设备日志超级表
24   - *
25   - * 注意:初始化时只需创建一次
  24 + * 初始化只创建一次
26 25 */
27 26 void createDeviceLogSTable();
28 27  
29   - // TODO @super:是不是删除哈
30   - /**
31   - * 创建设备日志子表
32   - *
33   - * @param deviceKey 设备标识
34   - */
35   - void createDeviceLogTable(@Param("deviceKey") String deviceKey);
36 28  
37 29 // TODO @super:单个参数,不用加 @Param
  30 + //讨论:艿菇这里有些特殊情况,我也学习了一下这块知识:
  31 + // 如果使用的是Java 8及以上版本,并且编译器保留了参数名(通过编译器选项-parameters启用),则可以去掉@Param注解。MyBatis会自动使用参数的实际名称
  32 + // 但在TDengine中 @Param去掉后TDengine会报错,以下是大模型的回答:
  33 + // 不用加 @Param在普通的 MySQL 场景下是正确的 - 对于 MyBatis,当方法只有一个参数时,确实可以不用添加 @Param 注解。
  34 + //但是在 TDengine 的场景下,情况不同:
  35 + //TDengine 的特殊性:
  36 + //TDengine 使用特殊的 SQL 语法
  37 + //需要处理超级表(STable)和子表的概念
  38 + //参数绑定的方式与普通 MySQL 不同
  39 + //为什么这里必须要 @Param:
  40 + //XML 中使用了 ${log.deviceKey} 这样的参数引用方式
  41 + //需要在 SQL 中动态构建表名(device_log_${log.deviceKey})
  42 + //没有 @Param("log") 的话,MyBatis 无法正确解析参数
38 43 /**
39 44 * 插入设备日志数据
40 45 *
... ... @@ -60,4 +65,18 @@ public interface IotDeviceLogDataMapper {
60 65 */
61 66 Long selectCount(@Param("reqVO") IotDeviceLogPageReqVO reqVO);
62 67  
  68 + /**
  69 + * 查询设备日志表是否存在
  70 + *
  71 + * @return 不存在返回null
  72 + */
  73 + Object checkDeviceLogSTableExists();
  74 +
  75 + /**
  76 + * 检查设备日志子表是否存在
  77 + *
  78 + * @param deviceKey 设备标识
  79 + * @return 不存在返回null
  80 + */
  81 + Object checkDeviceLogTableExists(@Param("deviceKey") String deviceKey);
63 82 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDevicePropertyDataMapper.java
... ... @@ -2,6 +2,9 @@ package cn.iocoder.yudao.module.iot.dal.tdengine;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.util.ObjectUtil;
  5 +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
  6 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO;
  7 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO;
5 8 import cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField;
6 9 import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS;
7 10 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
... ... @@ -10,6 +13,7 @@ import org.apache.ibatis.annotations.Param;
10 13  
11 14 import java.util.ArrayList;
12 15 import java.util.List;
  16 +import java.util.Map;
13 17 import java.util.stream.Collectors;
14 18  
15 19 @Mapper
... ... @@ -74,4 +78,43 @@ public interface IotDevicePropertyDataMapper {
74 78 void alterProductPropertySTableDropField(@Param("productKey") String productKey,
75 79 @Param("field") TDengineTableField field);
76 80  
  81 + //TODO:先参考一下老逻辑,后续改进
  82 + /**
  83 + * 插入数据 - 指定列插入数据
  84 + *
  85 + * @param table 数据
  86 + * productKey 产品 key
  87 + * deviceKey 设备 key
  88 + * columns 列
  89 + */
  90 + void insertDevicePropertyData(TdTableDO table);
  91 +
  92 + //TODO:先参考一下老逻辑,后续改进
  93 + /**
  94 + * 查看超级表 - 获取超级表的结构信息
  95 + * SQL:DESCRIBE [db_name.]stb_name;
  96 + *
  97 + * @param superTable 超级表信息
  98 + * productKey 产品 key
  99 + */
  100 + List<Map<String, Object>> describeSuperTable(TdTableDO superTable);
  101 +
  102 + /**
  103 + * 获取历史数据列表
  104 + *
  105 + * @param selectVisualDO 查询条件
  106 + * @return 历史数据列表
  107 + */
  108 + @TenantIgnore
  109 + List<Map<String, Object>> selectHistoryDataList(SelectVisualDO selectVisualDO);
  110 +
  111 + /**
  112 + * 获取历史数据条数
  113 + *
  114 + * @param selectVisualDO 查询条件
  115 + * @return 数据条数
  116 + */
  117 + @TenantIgnore
  118 + Long selectHistoryCount(SelectVisualDO selectVisualDO);
  119 +
77 120 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/TdThingModelMessageMapper.java deleted
1   -package cn.iocoder.yudao.module.iot.dal.tdengine;
2   -
3   -import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS;
4   -import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
5   -import org.apache.ibatis.annotations.Mapper;
6   -import org.apache.ibatis.annotations.Param;
7   -
8   -/**
9   - * 处理 TD 中物模型消息日志的操作
10   - */
11   -@Mapper
12   -@Deprecated // TODO super:什么时候,删除下哈。
13   -@TDengineDS
14   -@InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错
15   -public interface TdThingModelMessageMapper {
16   -
17   - /**
18   - * 创建物模型消息日志超级表超级表
19   - *
20   - */
21   -
22   - void createSuperTable(@Param("productKey") String productKey);
23   -
24   - /**
25   - * 创建子表
26   - *
27   - */
28   -
29   - void createTableWithTag(@Param("productKey") String productKey,@Param("deviceKey") String deviceKey);
30   -
31   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/tdengine/config/TDengineTableInitConfiguration.java
... ... @@ -25,18 +25,13 @@ public class TDengineTableInitConfiguration implements ApplicationRunner {
25 25 public void run(ApplicationArguments args) {
26 26 try {
27 27 // 初始化设备日志表
28   - deviceLogService.initTDengineSTable();
  28 + deviceLogService.defineDeviceLog();
29 29 // TODO @super:这个日志,是不是不用打,不然重复啦!!!
30   - log.info("[run]初始化 设备日志表 TDengine 表结构成功");
31 30 } catch (Exception ex) {
32 31 // TODO @super:初始化失败,打印 error 日志,退出系统。。不然跑起来,就初始啦!!!
33   - if (ex.getMessage().contains("Table already exists")) {
34   - log.info("TDengine 设备日志超级表已存在,跳过创建");
35   - return;
36   - } else{
37   - log.error("初始化 设备日志表 TDengine 表结构失败", ex);
38   - }
39   - throw ex;
  32 + // 初始化失败时打印错误日志并退出系统
  33 + log.error("[TDengine] 初始化设备日志表结构失败,系统无法正常运行,即将退出", ex);
  34 + System.exit(1);
40 35 }
41 36 }
42 37  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/consumer/deviceconsumer/DeviceConsumer.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.mq.consumer.deviceconsumer;
  2 +
  3 +
  4 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
  5 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
  6 +import cn.iocoder.yudao.module.iot.service.device.IotDeviceLogDataService;
  7 +import cn.iocoder.yudao.module.iot.service.device.IotDevicePropertyDataService;
  8 +import lombok.extern.slf4j.Slf4j;
  9 +import org.springframework.context.event.EventListener;
  10 +import org.springframework.scheduling.annotation.Async;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import javax.annotation.Resource;
  14 +
  15 +/**
  16 + * 针对 {@link ThingModelMessage} 的消费者
  17 + *
  18 + * @author alwayssuper
  19 + */
  20 +@Component
  21 +@Slf4j
  22 +public class DeviceConsumer {
  23 + @Resource
  24 + private IotDeviceLogDataService iotDeviceLogDataService;
  25 + @Resource
  26 + private IotDevicePropertyDataService deviceDataService;
  27 +
  28 + // TODO @芋艿:这块先用ThingModelMessage,后续看看用啥替代
  29 + @EventListener
  30 + @Async
  31 + public void onMessage(ThingModelMessage message) {
  32 + log.info("[onMessage][消息内容({})]", message);
  33 + //TODO:数据插入这块整体写的比较混乱,整体借鉴了浩浩哥之前写的逻辑,目前是通过模拟设备科插入数据了,但之前的逻辑有大量弃用的部分,后续看看怎么完善
  34 +
  35 + // 设备数据记录
  36 + deviceDataService.saveDeviceDataTest(message);
  37 + // 设备日志记录
  38 + iotDeviceLogDataService.saveDeviceLog(message);
  39 + }
  40 +
  41 +}
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/consumer/simulatesend/SimulateSendConsumer.java deleted
1   -package cn.iocoder.yudao.module.iot.mq.consumer.simulatesend;
2   -
3   -/**
4   - * TODO @alwayssuper:记得实现,还有类注释哈
5   - *
6   - * @author alwayssuper
7   - * @since 2024/12/20 8:04
8   - */
9   -public class SimulateSendConsumer {
10   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/message/package-info.java 0 → 100644
  1 +/**
  2 + * 消息队列的消息
  3 + */
  4 +package cn.iocoder.yudao.module.iot.mq.message;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/producer/simulatesend/SimulateSendProducer.java
1 1 package cn.iocoder.yudao.module.iot.mq.producer.simulatesend;
2 2  
  3 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
3 4 import jakarta.annotation.Resource;
4 5 import lombok.extern.slf4j.Slf4j;
5 6 import org.springframework.context.ApplicationContext;
... ... @@ -19,4 +20,12 @@ public class SimulateSendProducer {
19 20 @Resource
20 21 private ApplicationContext applicationContext;
21 22  
  23 + /**
  24 + * 发送 {@link ThingModelMessage} 消息
  25 + *
  26 + * @param thingModelMessage 物模型消息
  27 + */
  28 + public void sendSimulateMessage(ThingModelMessage thingModelMessage) {
  29 + applicationContext.publishEvent(thingModelMessage);
  30 + }
22 31 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceLogDataService.java
... ... @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataSimulatorSaveReqVO;
5 5 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO;
6 6 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO;
  7 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
7 8  
8 9 /**
9 10 * IoT 设备日志数据 Service 接口
... ... @@ -17,7 +18,7 @@ public interface IotDeviceLogDataService {
17 18 *
18 19 *系统启动时,会自动初始化一次
19 20 */
20   - void initTDengineSTable();
  21 + void defineDeviceLog();
21 22  
22 23 /**
23 24 * 插入设备日志
... ... @@ -36,4 +37,11 @@ public interface IotDeviceLogDataService {
36 37 */
37 38 PageResult<IotDeviceLogDO> getDeviceLogPage(IotDeviceLogPageReqVO pageReqVO);
38 39  
  40 + /**
  41 + * 插入设备日志
  42 + *
  43 + * @param msg 设备数据
  44 + */
  45 + void saveDeviceLog(ThingModelMessage msg);
  46 +
39 47 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceLogDataServiceImpl.java
1 1 package cn.iocoder.yudao.module.iot.service.device;
2 2  
  3 +import cn.hutool.json.JSONUtil;
3 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
5 6 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataSimulatorSaveReqVO;
6 7 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceLogPageReqVO;
7 8 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO;
  9 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
8 10 import cn.iocoder.yudao.module.iot.dal.tdengine.IotDeviceLogDataMapper;
9 11 import jakarta.annotation.Resource;
10 12 import lombok.extern.slf4j.Slf4j;
11 13 import org.springframework.stereotype.Service;
12 14 import org.springframework.validation.annotation.Validated;
13 15  
  16 +import java.util.Date;
14 17 import java.util.List;
15 18  
16 19 /**
... ... @@ -28,9 +31,24 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{
28 31  
29 32 // TODO @super:方法名。defineDeviceLog。。未来,有可能别人使用别的记录日志,例如说 es 之类的。
30 33 @Override
31   - public void initTDengineSTable() {
  34 + public void defineDeviceLog() {
32 35 // TODO @super:改成不存在才创建。
33   - iotDeviceLogDataMapper.createDeviceLogSTable();
  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] 设备日志超级表已存在,跳过创建");
  51 + }
34 52 }
35 53  
36 54 @Override
... ... @@ -40,18 +58,24 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{
40 58  
41 59 // 2. 处理时间字段
42 60 // TODO @super:一次性的字段,不用单独给个变量
43   - long currentTime = System.currentTimeMillis();
  61 +// long currentTime = System.currentTimeMillis();
44 62 // 2.1 设置时序时间为当前时间
45   - iotDeviceLogDO.setTs(currentTime); // TODO @super:TS在SQL中直接NOW 咱们的TS数据获取是走哪一种;走 now()
  63 +// iotDeviceLogDO.setTs(currentTime); // TODO @super:TS在SQL中直接NOW 咱们的TS数据获取是走哪一种;走 now()
46 64  
47 65 // 3. 插入数据
48 66 // TODO @super:不要直接调用对方的 IotDeviceLogDataMapper,通过 service 哈!
  67 + // 讨论:艿菇 这就是iotDeviceLogDataService的Impl
49 68 iotDeviceLogDataMapper.insert(iotDeviceLogDO);
50 69 }
51 70  
52 71 // TODO @super:在 iotDeviceLogDataService 写
  72 + // 讨论:艿菇 这就是iotDeviceLogDataService的Impl
53 73 @Override
54 74 public PageResult<IotDeviceLogDO> getDeviceLogPage(IotDeviceLogPageReqVO pageReqVO) {
  75 + // 当设备日志表未创建时,查询会出现报错
  76 + if(iotDeviceLogDataMapper.checkDeviceLogTableExists(pageReqVO.getDeviceKey())==null){
  77 + return null;
  78 + }
55 79 // 查询数据
56 80 List<IotDeviceLogDO> list = iotDeviceLogDataMapper.selectPage(pageReqVO);
57 81 Long total = iotDeviceLogDataMapper.selectCount(pageReqVO);
... ... @@ -59,4 +83,21 @@ public class IotDeviceLogDataServiceImpl implements IotDeviceLogDataService{
59 83 return new PageResult<>(list, total);
60 84 }
61 85  
  86 + @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()) // 上报时间
  97 + .build();
  98 +
  99 + // 2. 插入设备日志
  100 + iotDeviceLogDataMapper.insert(iotDeviceLogDO);
  101 + }
  102 +
62 103 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataService.java
... ... @@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.iot.service.device;
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
5 5 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataSimulatorSaveReqVO;
6 7 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
  8 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
7 9 import jakarta.validation.Valid;
8 10  
9 11 import java.util.List;
... ... @@ -30,6 +32,22 @@ public interface IotDevicePropertyDataService {
30 32 */
31 33 void saveDeviceData(IotDevicePropertyReportReqDTO createDTO);
32 34  
  35 +
  36 + /**
  37 + * 保存设备数据
  38 + *
  39 + * @param thingModelMessage 设备数据
  40 + */
  41 + void saveDeviceDataTest(ThingModelMessage thingModelMessage);
  42 +
  43 + /**
  44 + * 模拟设备
  45 + *
  46 + * @param simulatorReqVO 设备数据
  47 + */
  48 +
  49 + void simulatorSend(IotDeviceDataSimulatorSaveReqVO simulatorReqVO);
  50 +
33 51 /**
34 52 * 获得设备属性最新数据
35 53 *
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataServiceImpl.java
... ... @@ -3,11 +3,14 @@ package cn.iocoder.yudao.module.iot.service.device;
3 3 import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.date.DateUtil;
5 5 import cn.hutool.core.map.MapUtil;
  6 +import cn.hutool.core.util.IdUtil;
6 7 import cn.hutool.core.util.StrUtil;
7 8 import cn.hutool.json.JSONObject;
  9 +import cn.hutool.json.JSONUtil;
8 10 import cn.iocoder.yudao.framework.common.pojo.PageResult;
9 11 import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
10 12 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO;
  13 +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataSimulatorSaveReqVO;
11 14 import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType.ThingModelDateOrTextDataSpecs;
12 15 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
13 16 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
... ... @@ -22,6 +25,7 @@ import cn.iocoder.yudao.module.iot.enums.IotConstants;
22 25 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotDataSpecsDataTypeEnum;
23 26 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum;
24 27 import cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField;
  28 +import cn.iocoder.yudao.module.iot.mq.producer.simulatesend.SimulateSendProducer;
25 29 import cn.iocoder.yudao.module.iot.service.product.IotProductService;
26 30 import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService;
27 31 import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService;
... ... @@ -37,8 +41,10 @@ import java.util.HashMap;
37 41 import java.util.List;
38 42 import java.util.Map;
39 43  
  44 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
40 45 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
41 46 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
  47 +import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DEVICE_DATA_CONTENT_JSON_PARSE_ERROR;
42 48  
43 49 /**
44 50 * IoT 设备【属性】数据 Service 实现类
... ... @@ -77,6 +83,9 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe
77 83 private IotProductService productService;
78 84  
79 85 @Resource
  86 + private SimulateSendProducer simulateSendProducer;
  87 +
  88 + @Resource
80 89 private TdEngineDMLMapper tdEngineDMLMapper;
81 90  
82 91 @Resource
... ... @@ -150,6 +159,45 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe
150 159 thingModelMessageService.saveThingModelMessage(device, thingModelMessage);
151 160 }
152 161  
  162 + //TODO:后续捋一捋这块逻辑,先借鉴一下目前的代码
  163 + @Override
  164 + public void saveDeviceDataTest(ThingModelMessage thingModelMessage) {
  165 + // 1. 根据产品 key 和设备名称,获得设备信息
  166 + IotDeviceDO device = deviceService.getDeviceByProductKeyAndDeviceName(thingModelMessage.getProductKey(), thingModelMessage.getDeviceName());
  167 + // 2. 保存数据
  168 + thingModelMessageService.saveThingModelMessage(device, thingModelMessage);
  169 + }
  170 +
  171 + //TODO: copy 了 saveDeviceData 的逻辑,后续看看这块怎么优化
  172 + @Override
  173 + public void simulatorSend(IotDeviceDataSimulatorSaveReqVO simulatorReqVO) {
  174 + // 1. 根据设备 key ,获得设备信息
  175 + IotDeviceDO device = deviceService.getDeviceByDeviceKey(simulatorReqVO.getDeviceKey());
  176 +
  177 + // 2. 解析 content 为 JSON 对象
  178 + JSONObject contentJson;
  179 + try {
  180 + contentJson = JSONUtil.parseObj(simulatorReqVO.getContent());
  181 + } catch (Exception e) {
  182 + throw exception(DEVICE_DATA_CONTENT_JSON_PARSE_ERROR);
  183 + }
  184 +
  185 + // 3. 构建物模型消息
  186 + ThingModelMessage thingModelMessage = ThingModelMessage.builder()
  187 + .id(IdUtil.fastSimpleUUID()) // TODO:后续优化
  188 + .sys(null)// TODO:这块先写死,后续优化
  189 + .method("thing.event.property.post") // TODO:这块先写死,后续优化
  190 + .params(contentJson) // 将 content 作为 params
  191 + .time(simulatorReqVO.getReportTime()) // 使用上报时间
  192 + .productKey(simulatorReqVO.getProductKey())
  193 + .deviceName(device.getDeviceName())
  194 + .deviceKey(device.getDeviceKey())
  195 + .build();
  196 +
  197 + // 4. 发送模拟消息
  198 + simulateSendProducer.sendSimulateMessage(thingModelMessage);
  199 + }
  200 +
153 201 @Override
154 202 public List<IotDeviceDataDO> getLatestDeviceProperties(@Valid IotDeviceDataPageReqVO deviceDataReqVO) {
155 203 List<IotDeviceDataDO> list = new ArrayList<>();
... ... @@ -196,6 +244,7 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe
196 244 SelectVisualDO selectVisualDO = new SelectVisualDO();
197 245 selectVisualDO.setDataBaseName(getDatabaseName());
198 246 selectVisualDO.setTableName(getDeviceTableName(device.getProductKey(), device.getDeviceName()));
  247 + selectVisualDO.setDeviceKey(device.getDeviceKey());
199 248 selectVisualDO.setFieldName(deviceDataReqVO.getIdentifier());
200 249 selectVisualDO.setStartTime(DateUtil.date(deviceDataReqVO.getTimes()[0].atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()).getTime());
201 250 selectVisualDO.setEndTime(DateUtil.date(deviceDataReqVO.getTimes()[1].atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()).getTime());
... ... @@ -203,8 +252,8 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe
203 252 params.put("rows", deviceDataReqVO.getPageSize());
204 253 params.put("page", (deviceDataReqVO.getPageNo() - 1) * deviceDataReqVO.getPageSize());
205 254 selectVisualDO.setParams(params);
206   - pageResult.setList(tdEngineDMLMapper.selectHistoryDataList(selectVisualDO));
207   - pageResult.setTotal(tdEngineDMLMapper.selectHistoryCount(selectVisualDO));
  255 + pageResult.setList(devicePropertyDataMapper.selectHistoryDataList(selectVisualDO));
  256 + pageResult.setTotal(devicePropertyDataMapper.selectHistoryCount(selectVisualDO));
208 257 return pageResult;
209 258 }
210 259  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceService.java
... ... @@ -72,6 +72,15 @@ public interface IotDeviceService {
72 72 */
73 73 IotDeviceDO getDevice(Long id);
74 74  
  75 +
  76 + /**
  77 + * 根据设备 key 获得设备
  78 + *
  79 + * @param deviceKey 编号
  80 + * @return IoT 设备
  81 + */
  82 + IotDeviceDO getDeviceByDeviceKey(String deviceKey);
  83 +
75 84 /**
76 85 * ��得设备分页
77 86 *
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceServiceImpl.java
... ... @@ -198,6 +198,11 @@ public class IotDeviceServiceImpl implements IotDeviceService {
198 198 }
199 199  
200 200 @Override
  201 + public IotDeviceDO getDeviceByDeviceKey(String deviceKey) {
  202 + return deviceMapper.selectByDeviceKey(deviceKey);
  203 + }
  204 +
  205 + @Override
201 206 public PageResult<IotDeviceDO> getDevicePage(IotDevicePageReqVO pageReqVO) {
202 207 return deviceMapper.selectPage(pageReqVO);
203 208 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
... ... @@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO;
13 13 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
14 14 import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO;
15 15 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO;
  16 +import cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyDataMapper;
16 17 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper;
17 18 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;
18 19 import cn.iocoder.yudao.module.iot.enums.IotConstants;
... ... @@ -62,6 +63,9 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
62 63 private TdEngineDMLMapper tdEngineDMLMapper;
63 64  
64 65 @Resource
  66 + private IotDevicePropertyDataMapper iotDevicePropertyDataMapper;
  67 +
  68 + @Resource
65 69 private DeviceDataRedisDAO deviceDataRedisDAO;
66 70  
67 71 // TODO @haohao:这个方法,可以考虑加下 1. 2. 3. 更有层次感
... ... @@ -71,7 +75,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
71 75 // 1. 判断设备状态,如果为未激活状态,创建数据表并更新设备状态
72 76 if (IotDeviceStatusEnum.INACTIVE.getStatus().equals(device.getStatus())) {
73 77 // 1.1 创建设备表
74   - createDeviceTable(device.getDeviceType(), device.getProductKey(), device.getDeviceName(), device.getDeviceKey());
  78 +// createDeviceTable(device.getDeviceType(), device.getProductKey(), device.getDeviceName(), device.getDeviceKey());
75 79 iotDeviceService.updateDeviceStatus(new IotDeviceStatusUpdateReqVO()
76 80 .setId(device.getId()).setStatus(IotDeviceStatusEnum.ONLINE.getStatus()));
77 81 }
... ... @@ -85,14 +89,20 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
85 89  
86 90 // 3. 过滤并收集有效的属性字段,缓存设备属性
87 91 List<TdFieldDO> schemaFieldValues = filterAndCollectValidFields(params, thingModelList, device, thingModelMessage.getTime());
88   - if (schemaFieldValues.size() == 1) { // 仅有时间字段,无需保存
  92 + if (schemaFieldValues.size() == 0) { // 没有字段,无需保存
89 93 return;
90 94 }
91 95  
92 96 // 4. 构建并保存设备属性数据
93   - tdEngineDMLMapper.insertData(TdTableDO.builder()
94   - .dataBaseName(getDatabaseName())
95   - .tableName(getDeviceTableName(device.getProductKey(), device.getDeviceName()))
  97 +// tdEngineDMLMapper.insertData(TdTableDO.builder()
  98 +// .dataBaseName(getDatabaseName())
  99 +// .tableName(getDeviceTableName(device.getProductKey(), device.getDeviceName()))
  100 +// .columns(schemaFieldValues)
  101 +// .build());
  102 + // TODO:复用了旧逻辑,先过渡一下
  103 + iotDevicePropertyDataMapper.insertDevicePropertyData(TdTableDO.builder()
  104 + .productKey(device.getProductKey())
  105 + .deviceKey(device.getDeviceKey())
96 106 .columns(schemaFieldValues)
97 107 .build());
98 108 }
... ... @@ -145,7 +155,8 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
145 155  
146 156 // 3. 过滤并收集有效的属性字段
147 157 List<TdFieldDO> schemaFieldValues = new ArrayList<>();
148   - schemaFieldValues.add(new TdFieldDO(TIME, time));
  158 + //TODO:新版本是使用ts字段
  159 +// schemaFieldValues.add(new TdFieldDO(TIME, time));
149 160 params.forEach((key, val) -> {
150 161 if (propertyIdentifiers.contains(key)) {
151 162 schemaFieldValues.add(new TdFieldDO(key.toLowerCase(), val));
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDeviceLogDataMapper.xml
... ... @@ -6,13 +6,13 @@
6 6  
7 7 <!-- 创建设备日志超级表 初始化只创建一次-->
8 8 <update id="createDeviceLogSTable">
9   - CREATE STABLE device_log (
  9 + CREATE STABLE IF NOT EXISTS device_log (
10 10 ts TIMESTAMP,
11 11 id NCHAR(50),
12 12 product_key NCHAR(50),
13 13 type NCHAR(50),
14 14 <!-- TODO @super:下划线 sub_type -->
15   - subType NCHAR(50),
  15 + sub_type NCHAR(50),
16 16 content NCHAR(1024),
17 17 report_time TIMESTAMP
18 18 ) TAGS (
... ... @@ -31,7 +31,7 @@
31 31 USING device_log
32 32 TAGS ('${log.deviceKey}')
33 33 VALUES (
34   - #{log.ts},
  34 + NOW,
35 35 #{log.id},
36 36 #{log.productKey},
37 37 #{log.type},
... ... @@ -75,4 +75,15 @@
75 75 </where>
76 76 </select>
77 77  
  78 + <!-- 检查设备日志超级表是否存在 -->
  79 + <select id="checkDeviceLogSTableExists" resultType="Object">
  80 + SHOW STABLES LIKE 'device_log'
  81 + </select>
  82 +
  83 + <!-- 检查设备日志子表是否存在 -->
  84 + <select id="checkDeviceLogTableExists" resultType="Object">
  85 + SHOW TABLES LIKE 'device_log_${deviceKey}'
  86 + </select>
  87 +
  88 +
78 89 </mapper>
79 90 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDevicePropertyDataMapper.xml
... ... @@ -42,4 +42,46 @@
42 42 DROP COLUMN ${field.field}
43 43 </update>
44 44  
  45 + <insert id="insertDevicePropertyData">
  46 + INSERT INTO device_property_${deviceKey}
  47 + USING product_property_${productKey}
  48 + TAGS ('${deviceKey}')
  49 + (ts
  50 + <foreach item="item" collection="columns" separator=",">
  51 + ,${item.fieldName}
  52 + </foreach>
  53 + )
  54 + VALUES
  55 + (NOW
  56 + <foreach item="item" collection="columns" separator=",">
  57 + ,#{item.fieldValue}
  58 + </foreach>
  59 + )
  60 + </insert>
  61 +
  62 + <!-- 描述超级表结构 -->
  63 + <select id="describeSuperTable" resultType="java.util.Map">
  64 + DESCRIBE product_property_${productKey}
  65 + </select>
  66 +
  67 + <!-- 获取历史数据 -->
  68 + <select id="selectHistoryDataList" resultType="java.util.Map"
  69 + parameterType="cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO">
  70 + SELECT ${fieldName} AS data, ts AS time
  71 + FROM device_property_${deviceKey}
  72 + WHERE ts BETWEEN #{startTime} AND #{endTime}
  73 + AND ${fieldName} IS NOT NULL
  74 + ORDER BY ts DESC
  75 + LIMIT #{params.rows} OFFSET #{params.page}
  76 + </select>
  77 +
  78 + <!-- 统计历史数据总数 -->
  79 + <select id="selectHistoryCount" resultType="java.lang.Long"
  80 + parameterType="cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO">
  81 + SELECT COUNT(*)
  82 + FROM device_property_${deviceKey}
  83 + WHERE ts BETWEEN #{startTime} AND #{endTime}
  84 + AND ${fieldName} IS NOT NULL
  85 + </select>
  86 +
45 87 </mapper>
46 88 \ 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://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
  48 + url: jdbc:mysql://chaojiniu.top:23306/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: root
57   - password: 123456
  56 + username: ruoyi-vue-pro
  57 + password: ruoyi-@h2ju02hebp
58 58 # username: sa # SQL Server 连接的示例
59 59 # password: Yudao@2024 # SQL Server 连接的示例
60 60 # username: SYSDBA # DM 连接的示例
... ... @@ -63,12 +63,12 @@ spring:
63 63 # password: Yudao@2024 # OpenGauss 连接的示例
64 64 slave: # 模拟从库,可根据自己需要修改
65 65 lazy: true # 开启懒加载,保证启动速度
66   - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
67   - username: root
68   - password: 123456
  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 69 tdengine: # IOT 数据库
70 70 # lazy: true # 开启懒加载,保证启动速度
71   - url: jdbc:TAOS-RS://127.0.0.1:6041/ruoyi_vue_pro
  71 + url: jdbc:TAOS-RS://chaojiniu.top:6041/ruoyi_vue_pro
72 72 driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
73 73 username: root
74 74 password: taosdata
... ... @@ -78,10 +78,10 @@ spring:
78 78 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
79 79 data:
80 80 redis:
81   - host: 400-infra.server.iocoder.cn # 地址
  81 + host: chaojiniu.top # 地址
82 82 port: 6379 # 端口
83   - database: 1 # 数据库索引
84   - # password: 123456 # 密码,建议生产环境开启
  83 + database: 15 # 数据库索引
  84 + password: fsknKD7UvQYZsyf2hXXn # 密码,建议生产环境开启
85 85  
86 86 --- #################### 定时任务相关配置 ####################
87 87  
... ... @@ -183,10 +183,8 @@ logging:
183 183 cn.iocoder.yudao.module.crm.dal.mysql: debug
184 184 cn.iocoder.yudao.module.erp.dal.mysql: debug
185 185 cn.iocoder.yudao.module.iot.dal.mysql: debug
186   - cn.iocoder.yudao.module.iot.dal.tdengine: DEBUG
187 186 cn.iocoder.yudao.module.ai.dal.mysql: debug
188 187 org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示
189   - com.taosdata: DEBUG # TDengine 的日志级别
190 188  
191 189 debug: false
192 190  
... ... @@ -269,11 +267,11 @@ justauth:
269 267 iot:
270 268 emq:
271 269 # 账号
272   - username: root
  270 + username: haohao
273 271 # 密码
274   - password: 123456
  272 + password: ahh@123456
275 273 # 主机地址
276   - hostUrl: tcp://127.0.0.1:1883
  274 + hostUrl: tcp://chaojiniu.top:1883
277 275 # 客户端Id,不能相同,采用随机数 ${random.value}
278 276 client-id: ${random.int}
279 277 # 默认主题
... ... @@ -285,9 +283,9 @@ iot:
285 283  
286 284 # MQTT-RPC 配置
287 285 mqtt:
288   - broker: tcp://127.0.0.1:1883
289   - username: root
290   - password: 123456
  286 + broker: tcp://chaojiniu.top:1883
  287 + username: haohao
  288 + password: ahh@123456
291 289 clientId: mqtt-rpc-server-${random.int}
292 290 requestTopic: rpc/request
293 291 responseTopicPrefix: rpc/response/
... ...
yudao-server/src/main/resources/application.yaml
... ... @@ -328,4 +328,7 @@ yudao:
328 328 key: pLXUGAwK5305
329 329 customer: E77DF18BE109F454A5CD319E44BF5177
330 330  
331   -debug: false
332 331 \ No newline at end of file
  332 +debug: false
  333 +# 插件配置
  334 +pf4j:
  335 + pluginsDir: /Users/anhaohao/code/gitee/ruoyi-vue-pro/plugins # 插件目录
333 336 \ No newline at end of file
... ...