diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceRespVO.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceRespVO.java index cc45c0280f..8404ca9224 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceRespVO.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceRespVO.java @@ -83,6 +83,9 @@ public class IotDeviceRespVO { @ExcelProperty("认证类型(如一机一密、动态注册)") private String authType; + @Schema(description = "设备配置", example = "{\"abc\": \"efg\"}") + private String config; + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("创建时间") private LocalDateTime createTime; diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceSaveReqVO.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceSaveReqVO.java index 7bf0f33ee9..b9ea9b99fa 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceSaveReqVO.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceSaveReqVO.java @@ -38,4 +38,7 @@ public class IotDeviceSaveReqVO { @Schema(description = "网关设备 ID", example = "16380") private Long gatewayId; + @Schema(description = "设备配置", example = "{\"abc\": \"efg\"}") + private String config; + } \ No newline at end of file diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDevicePropertyMapper.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDevicePropertyMapper.java index 955b384780..37a72e4b02 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDevicePropertyMapper.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/IotDevicePropertyMapper.java @@ -32,7 +32,6 @@ public interface IotDevicePropertyMapper { default void alterProductPropertySTable(String productKey, List oldFields, List newFields) { - // TODO @芋艿:需要处理 device_key,重新发布的时候 oldFields.removeIf(field -> StrUtil.equalsAny(field.getField(), TDengineTableField.FIELD_TS, "report_time", "device_key")); List addFields = newFields.stream().filter( // 新增的字段 diff --git a/yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/src/main/java/cn/iocoder/yudao/module/iot/plugin/emqx/upstream/router/IotDeviceWebhookVertxHandler.java b/yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/src/main/java/cn/iocoder/yudao/module/iot/plugin/emqx/upstream/router/IotDeviceWebhookVertxHandler.java index a2499826fd..31679fe056 100644 --- a/yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/src/main/java/cn/iocoder/yudao/module/iot/plugin/emqx/upstream/router/IotDeviceWebhookVertxHandler.java +++ b/yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/src/main/java/cn/iocoder/yudao/module/iot/plugin/emqx/upstream/router/IotDeviceWebhookVertxHandler.java @@ -17,9 +17,8 @@ import java.util.Collections; /** * IoT Emqx Webhook 事件处理的 Vert.x Handler - * EMQX - * Webhook + * + * EMQXWebhook * * @author haohao */ @@ -69,12 +68,11 @@ public class IotDeviceWebhookVertxHandler implements Handler { * @param username 用户名 */ private void handleClientConnected(String clientId, String username) { + // 解析产品标识和设备名称 if (StrUtil.isEmpty(username) || "undefined".equals(username)) { log.warn("[handleClientConnected][客户端连接事件,但用户名为空] clientId={}", clientId); return; } - - // 解析产品标识和设备名称 String[] parts = parseUsername(username); if (parts == null) { return; @@ -87,7 +85,6 @@ public class IotDeviceWebhookVertxHandler implements Handler { updateReqDTO.setState(IotDeviceStateEnum.ONLINE.getState()); updateReqDTO.setProcessId(IotPluginCommonUtils.getProcessId()); updateReqDTO.setReportTime(LocalDateTime.now()); - CommonResult result = deviceUpstreamApi.updateDeviceState(updateReqDTO); if (result.getCode() != 0 || !result.getData()) { log.error("[handleClientConnected][更新设备状态为在线失败] clientId={}, username={}, code={}, msg={}", @@ -104,12 +101,11 @@ public class IotDeviceWebhookVertxHandler implements Handler { * @param username 用户名 */ private void handleClientDisconnected(String clientId, String username) { + // 解析产品标识和设备名称 if (StrUtil.isEmpty(username) || "undefined".equals(username)) { log.warn("[handleClientDisconnected][客户端断开连接事件,但用户名为空] clientId={}", clientId); return; } - - // 解析产品标识和设备名称 String[] parts = parseUsername(username); if (parts == null) { return; @@ -122,7 +118,6 @@ public class IotDeviceWebhookVertxHandler implements Handler { offlineReqDTO.setState(IotDeviceStateEnum.OFFLINE.getState()); offlineReqDTO.setProcessId(IotPluginCommonUtils.getProcessId()); offlineReqDTO.setReportTime(LocalDateTime.now()); - CommonResult offlineResult = deviceUpstreamApi.updateDeviceState(offlineReqDTO); if (offlineResult.getCode() != 0 || !offlineResult.getData()) { log.error("[handleClientDisconnected][更新设备状态为离线失败] clientId={}, username={}, code={}, msg={}", @@ -136,19 +131,18 @@ public class IotDeviceWebhookVertxHandler implements Handler { * 解析用户名,格式为 deviceName&productKey * * @param username 用户名 - * @return 解析结果,[0]为deviceName,[1]为productKey,解析失败返回null + * @return 解析结果,[0] 为 deviceName,[1] 为productKey,解析失败返回 null */ private String[] parseUsername(String username) { if (StrUtil.isEmpty(username)) { return null; } - String[] parts = username.split("&"); if (parts.length != 2) { - log.warn("[parseUsername][用户名格式不正确,无法解析产品标识和设备名称] username={}", username); + log.warn("[parseUsername][用户名格式({})不正确,无法解析产品标识和设备名称]", username); return null; } - return parts; } + } \ No newline at end of file diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index 492e31db56..17403fef85 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -46,11 +46,11 @@ - - - - - + + cn.iocoder.boot + yudao-module-bpm-biz + ${revision} +