Commit 916024b8914482eb6b4e32f52e75b4193aa4e108

Authored by YunaiV
1 parent a152f6d9

【功能新增】IoT:验证通过独立、内嵌模式的调用

Showing 17 changed files with 270 additions and 39 deletions
plugins/yudao-module-iot-http-plugin-2.2.0-snapshot.jar 0 → 100644
No preview for this file type
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/RpcConstants.java 0 → 100644
  1 +package cn.iocoder.yudao.framework.common.enums;
  2 +
  3 +/**
  4 + * RPC 相关的枚举
  5 + *
  6 + * 虽然放在 yudao-spring-boot-starter-rpc 会相对合适,但是每个 API 模块需要使用到,所以暂时只好放在此处
  7 + *
  8 + * @author 芋道源码
  9 + */
  10 +public class RpcConstants {
  11 +
  12 + /**
  13 + * RPC API 的前缀
  14 + */
  15 + public static final String RPC_API_PREFIX = "/rpc-api";
  16 +
  17 +}
... ...
yudao-module-iot/yudao-module-iot-api/pom.xml
... ... @@ -21,6 +21,14 @@
21 21 <groupId>cn.iocoder.boot</groupId>
22 22 <artifactId>yudao-common</artifactId>
23 23 </dependency>
  24 +
  25 + <!-- Web 相关 -->
  26 + <dependency>
  27 + <groupId>org.springframework</groupId>
  28 + <artifactId>spring-web</artifactId>
  29 + <scope>provided</scope> <!-- 设置为 provided,只有工具类需要使用到 -->
  30 + </dependency>
  31 +
24 32 <!-- PF4J -->
25 33 <!-- TODO 芋艿:这个依赖,要不要放在 api 包 -->
26 34 <dependency>
... ...
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/DeviceDataApi.java
1 1 package cn.iocoder.yudao.module.iot.api.device;
2 2  
3   -import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceEventReportReqDTO;
  5 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
  6 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceStatusUpdateReqDTO;
  7 +import cn.iocoder.yudao.module.iot.enums.ApiConstants;
  8 +import jakarta.annotation.security.PermitAll;
4 9 import jakarta.validation.Valid;
  10 +import org.springframework.web.bind.annotation.PostMapping;
  11 +import org.springframework.web.bind.annotation.PutMapping;
  12 +import org.springframework.web.bind.annotation.RequestBody;
5 13  
  14 +// TODO 芋艿:名字可能看情况改下
6 15 /**
7 16 * 设备数据 API
8 17 *
... ... @@ -10,11 +19,35 @@ import jakarta.validation.Valid;
10 19 */
11 20 public interface DeviceDataApi {
12 21  
  22 + // TODO @芋艿:可能会调整
  23 + String PREFIX = ApiConstants.PREFIX + "/device-data";
  24 +
  25 + /**
  26 + * 更新设备状态
  27 + *
  28 + * @param updateReqDTO 更新请求
  29 + */
  30 + @PutMapping(PREFIX + "/update-status")
  31 + @PermitAll // TODO 芋艿:后续看看怎么优化下
  32 + CommonResult<Boolean> updateDeviceStatus(@Valid @RequestBody IotDeviceStatusUpdateReqDTO updateReqDTO);
  33 +
13 34 /**
14   - * 保存设备数据
  35 + * 上报设备事件数据
15 36 *
16   - * @param createDTO 设备数据
  37 + * @param reportReqDTO 设备事件
17 38 */
18   - void saveDeviceData(@Valid DeviceDataCreateReqDTO createDTO);
  39 + @PostMapping(PREFIX + "/report-event")
  40 + @PermitAll // TODO 芋艿:后续看看怎么优化下
  41 + CommonResult<Boolean> reportDeviceEventData(@Valid @RequestBody IotDeviceEventReportReqDTO reportReqDTO);
  42 +
  43 + /**
  44 + * 上报设备属性数据
  45 + *
  46 + * @param reportReqDTO 设备数据
  47 + */
  48 + @PostMapping(PREFIX + "/report-property")
  49 + @PermitAll // TODO 芋艿:后续看看怎么优化下
  50 + CommonResult<Boolean> reportDevicePropertyData(@Valid @RequestBody IotDevicePropertyReportReqDTO reportReqDTO);
  51 +
19 52  
20 53 }
21 54 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/IotDeviceEventReportReqDTO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.api.device.dto;
  2 +
  3 +import jakarta.validation.constraints.NotEmpty;
  4 +import lombok.AllArgsConstructor;
  5 +import lombok.Builder;
  6 +import lombok.Data;
  7 +import lombok.NoArgsConstructor;
  8 +
  9 +import java.util.Map;
  10 +
  11 +/**
  12 + * IoT 设备【事件】数据上报 Request DTO
  13 + */
  14 +@Data
  15 +@NoArgsConstructor
  16 +@AllArgsConstructor
  17 +@Builder
  18 +public class IotDeviceEventReportReqDTO {
  19 +
  20 + // TODO 芋艿:要不要 id
  21 + // TODO 芋艿:要不要 time
  22 +
  23 + /**
  24 + * 产品标识
  25 + */
  26 + @NotEmpty(message = "产品标识不能为空")
  27 + private String productKey;
  28 + /**
  29 + * 设备名称
  30 + */
  31 + @NotEmpty(message = "设备名称不能为空")
  32 + private String deviceName;
  33 +
  34 + /**
  35 + * 事件标识
  36 + */
  37 + @NotEmpty(message = "事件标识不能为空")
  38 + private String identifier;
  39 + /**
  40 + * 事件参数
  41 + */
  42 + @NotEmpty(message = "事件参数不能为空")
  43 + private Map<String, Object> params;
  44 +
  45 +}
... ...
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/DeviceDataCreateReqDTO.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/IotDevicePropertyReportReqDTO.java
1 1 package cn.iocoder.yudao.module.iot.api.device.dto;
2 2  
  3 +import jakarta.validation.constraints.NotEmpty;
3 4 import lombok.AllArgsConstructor;
4 5 import lombok.Builder;
5 6 import lombok.Data;
6 7 import lombok.NoArgsConstructor;
7   -import jakarta.validation.constraints.NotNull;
8 8  
  9 +import java.util.Map;
  10 +
  11 +/**
  12 + * IoT 设备【属性】数据上报 Request DTO
  13 + */
9 14 @Data
10 15 @NoArgsConstructor
11 16 @AllArgsConstructor
12 17 @Builder
13   -public class DeviceDataCreateReqDTO {
  18 +public class IotDevicePropertyReportReqDTO {
  19 +
  20 + // TODO 芋艿:要不要 id
  21 + // TODO 芋艿:要不要 time
14 22  
15 23 /**
16 24 * 产品标识
17 25 */
18   - @NotNull(message = "产品标识不能为空")
  26 + @NotEmpty(message = "产品标识不能为空")
19 27 private String productKey;
20 28 /**
21 29 * 设备名称
22 30 */
23   - @NotNull(message = "设备名称不能为空")
  31 + @NotEmpty(message = "设备名称不能为空")
24 32 private String deviceName;
25 33 /**
26   - * 消息
  34 + * 属性参数
27 35 */
28   - @NotNull(message = "消息不能为空")
29   - private String message;
  36 + @NotEmpty(message = "属性参数不能为空")
  37 + private Map<String, Object> params;
30 38  
31 39 }
32 40 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/IotDeviceStatusUpdateReqDTO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.api.device.dto;
  2 +
  3 +import cn.iocoder.yudao.framework.common.validation.InEnum;
  4 +import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum;
  5 +import jakarta.validation.constraints.NotEmpty;
  6 +import lombok.AllArgsConstructor;
  7 +import lombok.Builder;
  8 +import lombok.Data;
  9 +import lombok.NoArgsConstructor;
  10 +
  11 +/**
  12 + * IoT 设备状态更新 Request DTO
  13 + */
  14 +@Data
  15 +@NoArgsConstructor
  16 +@AllArgsConstructor
  17 +@Builder
  18 +public class IotDeviceStatusUpdateReqDTO {
  19 +
  20 + // TODO 芋艿:要不要 id
  21 + // TODO 芋艿:要不要 time
  22 +
  23 + /**
  24 + * 产品标识
  25 + */
  26 + @NotEmpty(message = "产品标识不能为空")
  27 + private String productKey;
  28 + /**
  29 + * 设备名称
  30 + */
  31 + @NotEmpty(message = "设备名称不能为空")
  32 + private String deviceName;
  33 + /**
  34 + * 设备状态
  35 + */
  36 + @NotEmpty(message = "设备状态不能为空")
  37 + @InEnum(IotDeviceStatusEnum.class) // 只使用:在线、离线
  38 + private Integer status;
  39 +
  40 +}
... ...
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ApiConstants.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.enums;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.RpcConstants;
  4 +
  5 +/**
  6 + * API 相关的枚举
  7 + *
  8 + * @author 芋道源码
  9 + */
  10 +public class ApiConstants {
  11 +
  12 + public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/iot";
  13 +
  14 + public static final String VERSION = "1.0.0";
  15 +
  16 +}
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/api/device/DeviceDataApiImpl.java
1 1 package cn.iocoder.yudao.module.iot.api.device;
2 2  
3   -import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceEventReportReqDTO;
  5 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
  6 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceStatusUpdateReqDTO;
4 7 import cn.iocoder.yudao.module.iot.service.device.IotDevicePropertyDataService;
5   -import org.springframework.stereotype.Service;
6 8 import org.springframework.validation.annotation.Validated;
  9 +import org.springframework.web.bind.annotation.RestController;
7 10  
8 11 import javax.annotation.Resource;
9 12  
  13 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  14 +
10 15 /**
11 16 * 设备数据 API 实现类
12 17 */
13   -@Service
  18 +@RestController
14 19 @Validated
15 20 public class DeviceDataApiImpl implements DeviceDataApi {
16 21  
... ... @@ -18,8 +23,19 @@ public class DeviceDataApiImpl implements DeviceDataApi {
18 23 private IotDevicePropertyDataService deviceDataService;
19 24  
20 25 @Override
21   - public void saveDeviceData(DeviceDataCreateReqDTO createDTO) {
22   - deviceDataService.saveDeviceData(createDTO);
  26 + public CommonResult<Boolean> updateDeviceStatus(IotDeviceStatusUpdateReqDTO updateReqDTO) {
  27 + return success(true);
  28 + }
  29 +
  30 + @Override
  31 + public CommonResult<Boolean> reportDeviceEventData(IotDeviceEventReportReqDTO reportReqDTO) {
  32 + return success(true);
  33 + }
  34 +
  35 + @Override
  36 + public CommonResult<Boolean> reportDevicePropertyData(IotDevicePropertyReportReqDTO reportReqDTO) {
  37 + deviceDataService.saveDeviceData(reportReqDTO);
  38 + return success(true);
23 39 }
24 40  
25 41 }
26 42 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxServiceImpl.java
1 1 package cn.iocoder.yudao.module.iot.emq.service;
2 2  
3   -import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
  3 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
4 4 import cn.iocoder.yudao.module.iot.service.device.IotDevicePropertyDataService;
5 5 import jakarta.annotation.Resource;
6 6 import lombok.extern.slf4j.Slf4j;
... ... @@ -34,10 +34,10 @@ public class EmqxServiceImpl implements EmqxService {
34 34 String productKey = topic.split("/")[2];
35 35 String deviceName = topic.split("/")[3];
36 36 String message = new String(mqttMessage.getPayload());
37   - DeviceDataCreateReqDTO createDTO = DeviceDataCreateReqDTO.builder()
  37 + IotDevicePropertyReportReqDTO createDTO = IotDevicePropertyReportReqDTO.builder()
38 38 .productKey(productKey)
39 39 .deviceName(deviceName)
40   - .message(message)
  40 +// .properties(message) // TODO 芋艿:临时去掉,看看
41 41 .build();
42 42 iotDeviceDataService.saveDeviceData(createDTO);
43 43 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/plugin/UnifiedConfiguration.java
... ... @@ -7,8 +7,6 @@ import org.springframework.beans.factory.annotation.Value;
7 7 import org.springframework.context.annotation.Bean;
8 8 import org.springframework.context.annotation.Configuration;
9 9  
10   -import java.nio.file.Paths;
11   -
12 10 // TODO @芋艿:需要 review 下
13 11 @Slf4j
14 12 @Configuration
... ... @@ -21,8 +19,8 @@ public class UnifiedConfiguration {
21 19 // @DependsOn("deviceDataApiImpl")
22 20 public SpringPluginManager pluginManager() {
23 21 log.info("[init][实例化 SpringPluginManager]");
24   - SpringPluginManager springPluginManager = new SpringPluginManager(Paths.get(pluginsDir)) {
25   -// SpringPluginManager springPluginManager = new SpringPluginManager() {
  22 +// SpringPluginManager springPluginManager = new SpringPluginManager(Paths.get(pluginsDir)) {
  23 + SpringPluginManager springPluginManager = new SpringPluginManager() {
26 24  
27 25 @Override
28 26 public void startPlugins() {
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataService.java
1 1 package cn.iocoder.yudao.module.iot.service.device;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
  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 6 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
7 7 import jakarta.validation.Valid;
... ... @@ -28,7 +28,7 @@ public interface IotDevicePropertyDataService {
28 28 *
29 29 * @param createDTO 设备数据
30 30 */
31   - void saveDeviceData(DeviceDataCreateReqDTO createDTO);
  31 + void saveDeviceData(IotDevicePropertyReportReqDTO createDTO);
32 32  
33 33 /**
34 34 * 获得设备属性最新数据
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataServiceImpl.java
... ... @@ -6,7 +6,7 @@ import cn.hutool.core.map.MapUtil;
6 6 import cn.hutool.core.util.StrUtil;
7 7 import cn.hutool.json.JSONObject;
8 8 import cn.iocoder.yudao.framework.common.pojo.PageResult;
9   -import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
  9 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
10 10 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO;
11 11 import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType.ThingModelDateOrTextDataSpecs;
12 12 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
... ... @@ -130,11 +130,12 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe
130 130 }
131 131  
132 132 @Override
133   - public void saveDeviceData(DeviceDataCreateReqDTO createDTO) {
  133 + public void saveDeviceData(IotDevicePropertyReportReqDTO createDTO) {
  134 + // TODO 芋艿:这块需要实现
134 135 // 1. 根据产品 key 和设备名称,获得设备信息
135 136 IotDeviceDO device = deviceService.getDeviceByProductKeyAndDeviceName(createDTO.getProductKey(), createDTO.getDeviceName());
136 137 // 2. 解析消息,保存数据
137   - JSONObject jsonObject = new JSONObject(createDTO.getMessage());
  138 + JSONObject jsonObject = new JSONObject(createDTO.getParams());
138 139 log.info("[saveDeviceData][productKey({}) deviceName({}) data({})]", createDTO.getProductKey(), createDTO.getDeviceName(), jsonObject);
139 140 ThingModelMessage thingModelMessage = ThingModelMessage.builder()
140 141 .id(jsonObject.getStr("id"))
... ...
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/pom.xml
... ... @@ -124,7 +124,7 @@
124 124 <!-- 其他依赖项 -->
125 125 <dependency>
126 126 <groupId>org.springframework.boot</groupId>
127   - <artifactId>spring-boot-starter</artifactId>
  127 + <artifactId>spring-boot-starter-web</artifactId>
128 128 </dependency>
129 129 <!-- PF4J Spring 集成 -->
130 130 <dependency>
... ...
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/HttpPluginSpringbootApplication.java
1 1 package cn.iocoder.yudao.module.iot;
2 2  
3 3 import org.springframework.boot.SpringApplication;
  4 +import org.springframework.boot.WebApplicationType;
4 5 import org.springframework.boot.autoconfigure.SpringBootApplication;
5 6  
  7 +// TODO @haohao:建议包名:cn.iocoder.yudao.module.iot.plugin.${pluginName},例如说 http。然后子包如下:
  8 +// config:方配置类,以及 HttpVertxPlugin 初始化
  9 +// service:放 HttpVertxHandler 逻辑;
6 10 @SpringBootApplication
7 11 public class HttpPluginSpringbootApplication {
8 12  
9 13 public static void main(String[] args) {
10   - SpringApplication.run(HttpPluginSpringbootApplication.class, args);
  14 +// SpringApplication.run(HttpPluginSpringbootApplication.class, args);
  15 + SpringApplication application = new SpringApplication(HttpPluginSpringbootApplication.class);
  16 + application.setWebApplicationType(WebApplicationType.NONE);
  17 + application.run(args);
11 18 }
12 19  
13   -}
14 20 \ No newline at end of file
  21 +}
  22 +
  23 +// TODO @haohao:如下是 sdk 的包:cn.iocoder.yudao.module.iot.plugin.sdk
  24 +// 1. api 包:实现 DeviceDataApi 接口,通过 resttemplate 调用
  25 +// 2. config 包:初始化 DeviceDataApi 等等
  26 +
  27 +// 3. 其中 resttemplate 调用的后端地址,通过每个服务的 application.yaml 进行注入。
15 28 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/config/TestConfiguration.java
1 1 package cn.iocoder.yudao.module.iot.config;
2 2  
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
3 4 import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
4   -import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
  5 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceEventReportReqDTO;
  6 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
  7 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceStatusUpdateReqDTO;
5 8 import org.pf4j.DefaultPluginManager;
6 9 import org.pf4j.PluginWrapper;
  10 +import org.springframework.boot.web.client.RestTemplateBuilder;
7 11 import org.springframework.context.annotation.Bean;
8 12 import org.springframework.context.annotation.Configuration;
  13 +import org.springframework.web.client.RestTemplate;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
9 16  
10 17 // TODO 芋艿:临时实现;
11 18 @Configuration
12 19 public class TestConfiguration {
13 20  
  21 +// @Resource
  22 +// private RestTemplate restTemplate;
  23 +
  24 + // TODO 芋艿:这里,后续看看怎么创建好点
  25 + @Bean
  26 + public RestTemplate restTemplate() {
  27 + return new RestTemplateBuilder().build();
  28 + }
  29 +
14 30 @Bean
15   - public DeviceDataApi deviceDataApi() {
  31 + public DeviceDataApi deviceDataApi(RestTemplate restTemplate) {
16 32 return new DeviceDataApi() {
17 33  
18 34 @Override
19   - public void saveDeviceData(DeviceDataCreateReqDTO createDTO) {
20   - System.out.println("saveDeviceData");
  35 + public CommonResult<Boolean> updateDeviceStatus(IotDeviceStatusUpdateReqDTO updateReqDTO) {
  36 + // TODO haohao:待实现
  37 + return null;
  38 + }
  39 +
  40 + @Override
  41 + public CommonResult<Boolean> reportDeviceEventData(IotDeviceEventReportReqDTO reportReqDTO) {
  42 + // TODO haohao:待实现
  43 + return null;
  44 + }
  45 +
  46 + @Override
  47 + public CommonResult<Boolean> reportDevicePropertyData(IotDevicePropertyReportReqDTO reportReqDTO) {
  48 + // TODO haohao:待完整实现
  49 + String url = "http://127.0.0.1:48080/rpc-api/iot/device-data/report-property";
  50 + try {
  51 + restTemplate.postForObject(url, reportReqDTO, CommonResult.class);
  52 + return success(true);
  53 + } catch (Exception e) {
  54 + e.printStackTrace();
  55 + return CommonResult.error(400, "error");
  56 + }
21 57 }
22 58  
23 59 };
... ...
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/service/HttpVertxHandler.java
... ... @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.service;
3 3 import cn.hutool.json.JSONObject;
4 4 import cn.hutool.json.JSONUtil;
5 5 import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi;
6   -import cn.iocoder.yudao.module.iot.api.device.dto.DeviceDataCreateReqDTO;
  6 +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO;
7 7 import io.vertx.core.Handler;
8 8 import io.vertx.ext.web.RequestBody;
9 9 import io.vertx.ext.web.RoutingContext;
... ... @@ -46,12 +46,12 @@ public class HttpVertxHandler implements Handler&lt;RoutingContext&gt; {
46 46  
47 47 try {
48 48 // 调用主程序的接口保存数据
49   - DeviceDataCreateReqDTO createDTO = DeviceDataCreateReqDTO.builder()
  49 + IotDevicePropertyReportReqDTO createDTO = IotDevicePropertyReportReqDTO.builder()
50 50 .productKey(productKey)
51 51 .deviceName(deviceName)
52   - .message(jsonData.toString())
  52 + .params(jsonData) // TODO 芋艿:这块要优化
53 53 .build();
54   - deviceDataApi.saveDeviceData(createDTO);
  54 + deviceDataApi.reportDevicePropertyData(createDTO);
55 55  
56 56 // 构造成功响应内容
57 57 JSONObject successRes = createResponseJson(
... ...