Zimo 1 hari lalu
induk
melakukan
f0dfa16119
100 mengubah file dengan 551 tambahan dan 3368 penghapusan
  1. 44 0
      yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/MapUtils.java
  2. 90 1
      yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java
  3. 15 5
      yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/config/YudaoRedisMQConsumerAutoConfiguration.java
  4. 6 7
      yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisPendingMessageResendJob.java
  5. 72 0
      yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisStreamMessageCleanupJob.java
  6. 6 0
      yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/stream/AbstractRedisStreamMessageListener.java
  7. 4 5
      yudao-module-iot/pom.xml
  8. 0 53
      yudao-module-iot/yudao-module-iot-api/pom.xml
  9. 0 94
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/IotDeviceUpstreamApi.java
  10. 0 22
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceConfigSetReqDTO.java
  11. 0 31
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceDownstreamAbstractReqDTO.java
  12. 0 66
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceOtaUpgradeReqDTO.java
  13. 0 24
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDevicePropertyGetReqDTO.java
  14. 0 22
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDevicePropertySetReqDTO.java
  15. 0 26
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceServiceInvokeReqDTO.java
  16. 0 35
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceEmqxAuthReqDTO.java
  17. 0 26
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceEventReportReqDTO.java
  18. 0 35
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceOtaProgressReqDTO.java
  19. 0 21
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceOtaPullReqDTO.java
  20. 0 21
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceOtaReportReqDTO.java
  21. 0 22
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDevicePropertyReportReqDTO.java
  22. 0 12
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceRegisterReqDTO.java
  23. 0 43
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceRegisterSubReqDTO.java
  24. 0 24
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceStateUpdateReqDTO.java
  25. 0 44
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceTopologyAddReqDTO.java
  26. 0 45
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceUpstreamAbstractReqDTO.java
  27. 0 45
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotPluginInstanceHeartbeatReqDTO.java
  28. 0 4
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/package-info.java
  29. 0 6
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java
  30. 0 16
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ApiConstants.java
  31. 0 22
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/DictTypeConstants.java
  32. 0 75
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ErrorCodeConstants.java
  33. 0 44
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/device/IotDeviceMessageIdentifierEnum.java
  34. 0 37
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/device/IotDeviceMessageTypeEnum.java
  35. 0 42
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/device/IotDeviceStateEnum.java
  36. 0 38
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeRecordStatusEnum.java
  37. 0 33
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeTaskScopeEnum.java
  38. 0 35
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeTaskStatusEnum.java
  39. 0 37
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginDeployTypeEnum.java
  40. 0 37
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginStatusEnum.java
  41. 0 37
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginTypeEnum.java
  42. 0 38
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java
  43. 0 39
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java
  44. 0 59
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java
  45. 0 37
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java
  46. 0 40
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java
  47. 0 37
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java
  48. 0 31
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotAlertConfigReceiveTypeEnum.java
  49. 0 30
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotDataBridgeDirectionEnum.java
  50. 0 42
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotDataBridgeTypeEnum.java
  51. 0 31
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneActionTypeEnum.java
  52. 0 64
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneTriggerConditionParameterOperatorEnum.java
  53. 0 30
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneTriggerTypeEnum.java
  54. 0 37
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotDataSpecsDataTypeEnum.java
  55. 0 30
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelAccessModeEnum.java
  56. 0 31
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelParamDirectionEnum.java
  57. 0 30
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelServiceCallTypeEnum.java
  58. 0 31
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelServiceEventTypeEnum.java
  59. 0 38
      yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelTypeEnum.java
  60. 28 47
      yudao-module-iot/yudao-module-iot-biz/pom.xml
  61. 0 61
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/ScriptTest.java
  62. 0 78
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/api/device/IoTDeviceUpstreamApiImpl.java
  63. 1 3
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java
  64. 0 75
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.http
  65. 110 44
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java
  66. 0 40
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceLogController.java
  67. 37 43
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDevicePropertyController.java
  68. 7 7
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/NewIotDeviceGroupController.java
  69. 0 31
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceDownstreamReqVO.java
  70. 0 31
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceUpstreamReqVO.java
  71. 0 23
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDeviceLogPageReqVO.java
  72. 0 36
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDeviceLogRespVO.java
  73. 0 35
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDevicePropertyHistoryPageReqVO.java
  74. 0 20
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDevicePropertyRespVO.java
  75. 1 3
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceImportExcelVO.java
  76. 0 25
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceMqttConnectionParamsRespVO.java
  77. 4 1
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDevicePageReqVO.java
  78. 12 10
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceRespVO.java
  79. 13 5
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceSaveReqVO.java
  80. 15 3
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/IotOtaFirmwareController.java
  81. 0 75
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/IotOtaUpgradeRecordController.java
  82. 0 65
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/IotOtaUpgradeTaskController.java
  83. 7 14
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwareCreateReqVO.java
  84. 10 7
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwarePageReqVO.java
  85. 29 65
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwareRespVO.java
  86. 2 7
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwareUpdateReqVO.java
  87. 0 33
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/record/IotOtaUpgradeRecordPageReqVO.java
  88. 0 109
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/record/IotOtaUpgradeRecordRespVO.java
  89. 0 28
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/task/IotOtaUpgradeTaskPageReqVO.java
  90. 0 84
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/task/IotOtaUpgradeTaskRespVO.java
  91. 0 63
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/task/IotOtaUpgradeTaskSaveReqVO.java
  92. 0 87
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/PluginConfigController.java
  93. 0 20
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigImportReqVO.java
  94. 0 20
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigPageReqVO.java
  95. 0 54
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigRespVO.java
  96. 0 56
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigSaveReqVO.java
  97. 0 19
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigStatusReqVO.java
  98. 0 35
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/instance/PluginInstancePageReqVO.java
  99. 0 34
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/instance/PluginInstanceRespVO.java
  100. 38 5
      yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/IotProductController.java

+ 44 - 0
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/MapUtils.java

@@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.core.KeyValue;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -65,4 +66,47 @@ public class MapUtils {
         return map;
     }
 
+    /**
+     * 从 Map 中获取 BigDecimal 值
+     *
+     * @param map Map 数据源
+     * @param key 键名
+     * @return BigDecimal 值,解析失败或值为 null 时返回 null
+     */
+    public static BigDecimal getBigDecimal(Map<String, ?> map, String key) {
+        return getBigDecimal(map, key, null);
+    }
+
+    /**
+     * 从 Map 中获取 BigDecimal 值
+     *
+     * @param map          Map 数据源
+     * @param key          键名
+     * @param defaultValue 默认值
+     * @return BigDecimal 值,解析失败或值为 null 时返回默认值
+     */
+    public static BigDecimal getBigDecimal(Map<String, ?> map, String key, BigDecimal defaultValue) {
+        if (map == null) {
+            return defaultValue;
+        }
+        Object value = map.get(key);
+        if (value == null) {
+            return defaultValue;
+        }
+        if (value instanceof BigDecimal) {
+            return (BigDecimal) value;
+        }
+        if (value instanceof Number) {
+            return BigDecimal.valueOf(((Number) value).doubleValue());
+        }
+        if (value instanceof String) {
+            try {
+                return new BigDecimal((String) value);
+            } catch (NumberFormatException e) {
+                return defaultValue;
+            }
+        }
+        return defaultValue;
+    }
+
 }

+ 90 - 1
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java

@@ -3,18 +3,23 @@ package cn.iocoder.yudao.framework.common.util.json;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
+import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeDeserializer;
+import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeSerializer;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.module.SimpleModule;
 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import lombok.Getter;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -26,13 +31,18 @@ import java.util.List;
 @Slf4j
 public class JsonUtils {
 
+    @Getter
     private static ObjectMapper objectMapper = new ObjectMapper();
 
     static {
         objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // 忽略 null 值
-        objectMapper.registerModules(new JavaTimeModule()); // 解决 LocalDateTime 的序列化
+        // 解决 LocalDateTime 的序列化
+        SimpleModule simpleModule = new JavaTimeModule()
+                .addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE)
+                .addDeserializer(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE);
+        objectMapper.registerModules(simpleModule);
     }
 
     /**
@@ -99,6 +109,18 @@ public class JsonUtils {
         }
     }
 
+    public static <T> T parseObject(byte[] text, Type type) {
+        if (ArrayUtil.isEmpty(text)) {
+            return null;
+        }
+        try {
+            return objectMapper.readValue(text, objectMapper.getTypeFactory().constructType(type));
+        } catch (IOException e) {
+            log.error("json parse err,json:{}", text, e);
+            throw new RuntimeException(e);
+        }
+    }
+
     /**
      * 将字符串解析成指定类型的对象
      * 使用 {@link #parseObject(String, Class)} 时,在@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) 的场景下,
@@ -151,6 +173,24 @@ public class JsonUtils {
         }
     }
 
+    /**
+     * 解析 JSON 字符串成指定类型的对象,如果解析失败,则返回 null
+     *
+     * @param text 字符串
+     * @param clazz 类型
+     * @return 指定类型的对象
+     */
+    public static <T> T parseObjectQuietly(String text, Class<T> clazz) {
+        if (StrUtil.isEmpty(text)) {
+            return null;
+        }
+        try {
+            return objectMapper.readValue(text, clazz);
+        } catch (IOException e) {
+            return null;
+        }
+    }
+
     public static <T> List<T> parseArray(String text, Class<T> clazz) {
         if (StrUtil.isEmpty(text)) {
             return new ArrayList<>();
@@ -207,4 +247,53 @@ public class JsonUtils {
         return JSONUtil.isTypeJSONObject(str);
     }
 
+    /**
+     * 将 Object 转换为目标类型
+     * <p>
+     * 避免先转 jsonString 再 parseObject 的性能损耗
+     *
+     * @param obj   源对象(可以是 Map、POJO 等)
+     * @param clazz 目标类型
+     * @return 转换后的对象
+     */
+    public static <T> T convertObject(Object obj, Class<T> clazz) {
+        if (obj == null) {
+            return null;
+        }
+        if (clazz.isInstance(obj)) {
+            return clazz.cast(obj);
+        }
+        return objectMapper.convertValue(obj, clazz);
+    }
+
+    /**
+     * 将 Object 转换为目标类型(支持泛型)
+     *
+     * @param obj           源对象
+     * @param typeReference 目标类型引用
+     * @return 转换后的对象
+     */
+    public static <T> T convertObject(Object obj, TypeReference<T> typeReference) {
+        if (obj == null) {
+            return null;
+        }
+        return objectMapper.convertValue(obj, typeReference);
+    }
+
+    /**
+     * 将 Object 转换为 List 类型
+     * <p>
+     * 避免先转 jsonString 再 parseArray 的性能损耗
+     *
+     * @param obj   源对象(可以是 List、数组等)
+     * @param clazz 目标元素类型
+     * @return 转换后的 List
+     */
+    public static <T> List<T> convertList(Object obj, Class<T> clazz) {
+        if (obj == null) {
+            return new ArrayList<>();
+        }
+        return objectMapper.convertValue(obj, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
+    }
+
 }

+ 15 - 5
yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/config/YudaoRedisMQConsumerAutoConfiguration.java

@@ -6,12 +6,12 @@ import cn.hutool.system.SystemUtil;
 import cn.iocoder.yudao.framework.common.enums.DocumentEnum;
 import cn.iocoder.yudao.framework.mq.redis.core.RedisMQTemplate;
 import cn.iocoder.yudao.framework.mq.redis.core.job.RedisPendingMessageResendJob;
+import cn.iocoder.yudao.framework.mq.redis.core.job.RedisStreamMessageCleanupJob;
 import cn.iocoder.yudao.framework.mq.redis.core.pubsub.AbstractRedisChannelMessageListener;
 import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
 import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
 import lombok.extern.slf4j.Slf4j;
 import org.redisson.api.RedissonClient;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.AutoConfiguration;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.context.annotation.Bean;
@@ -68,9 +68,19 @@ public class YudaoRedisMQConsumerAutoConfiguration {
     @ConditionalOnBean(AbstractRedisStreamMessageListener.class) // 只有 AbstractStreamMessageListener 存在的时候,才需要注册 Redis pubsub 监听
     public RedisPendingMessageResendJob redisPendingMessageResendJob(List<AbstractRedisStreamMessageListener<?>> listeners,
                                                                      RedisMQTemplate redisTemplate,
-                                                                     @Value("${spring.application.name}") String groupName,
                                                                      RedissonClient redissonClient) {
-        return new RedisPendingMessageResendJob(listeners, redisTemplate, groupName, redissonClient);
+        return new RedisPendingMessageResendJob(listeners, redisTemplate, redissonClient);
+    }
+
+    /**
+     * 创建 Redis Stream 消息清理任务
+     */
+    @Bean
+    @ConditionalOnBean(AbstractRedisStreamMessageListener.class)
+    public RedisStreamMessageCleanupJob redisStreamMessageCleanupJob(List<AbstractRedisStreamMessageListener<?>> listeners,
+                                                                     RedisMQTemplate redisTemplate,
+                                                                     RedissonClient redissonClient) {
+        return new RedisStreamMessageCleanupJob(listeners, redisTemplate, redissonClient);
     }
 
     /**
@@ -129,14 +139,14 @@ public class YudaoRedisMQConsumerAutoConfiguration {
      *
      * @return 消费者名字
      */
-    private static String buildConsumerName() {
+    public static String buildConsumerName() {
         return String.format("%s@%d", SystemUtil.getHostInfo().getAddress(), SystemUtil.getCurrentPID());
     }
 
     /**
      * 校验 Redis 版本号,是否满足最低的版本号要求!
      */
-    private static void checkRedisVersion(RedisTemplate<String, ?> redisTemplate) {
+    public static void checkRedisVersion(RedisTemplate<String, ?> redisTemplate) {
         // 获得 Redis 版本
         Properties info = redisTemplate.execute((RedisCallback<Properties>) RedisServerCommands::info);
         String version = MapUtil.getStr(info, "redis_version");

+ 6 - 7
yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisPendingMessageResendJob.java

@@ -23,23 +23,22 @@ import java.util.Objects;
 @AllArgsConstructor
 public class RedisPendingMessageResendJob {
 
-    private static final String LOCK_KEY = "redis:pending:msg:lock";
+    private static final String LOCK_KEY = "redis:stream:pending-message-resend:lock";
 
     /**
      * 消息超时时间,默认 5 分钟
      *
      * 1. 超时的消息才会被重新投递
-     * 2. 由于定时任务 1 分钟一次,消息超时后不会被立即重投,极端情况下消息5分钟过期后,再等 1 分钟才会被扫瞄到
+     * 2. 由于定时任务 1 分钟一次,消息超时后不会被立即重投,极端情况下消息 5 分钟过期后,再等 1 分钟才会被扫瞄到
      */
     private static final int EXPIRE_TIME = 5 * 60;
 
     private final List<AbstractRedisStreamMessageListener<?>> listeners;
     private final RedisMQTemplate redisTemplate;
-    private final String groupName;
     private final RedissonClient redissonClient;
 
     /**
-     * 一分钟执行一次,这里选择每分钟的35秒执行,是为了避免整点任务过多的问题
+     * 一分钟执行一次,这里选择每分钟的 35 秒执行,是为了避免整点任务过多的问题
      */
     @Scheduled(cron = "35 * * * * ?")
     public void messageResend() {
@@ -64,13 +63,13 @@ public class RedisPendingMessageResendJob {
     private void execute() {
         StreamOperations<String, Object, Object> ops = redisTemplate.getRedisTemplate().opsForStream();
         listeners.forEach(listener -> {
-            PendingMessagesSummary pendingMessagesSummary = Objects.requireNonNull(ops.pending(listener.getStreamKey(), groupName));
+            PendingMessagesSummary pendingMessagesSummary = Objects.requireNonNull(ops.pending(listener.getStreamKey(), listener.getGroup()));
             // 每个消费者的 pending 队列消息数量
             Map<String, Long> pendingMessagesPerConsumer = pendingMessagesSummary.getPendingMessagesPerConsumer();
             pendingMessagesPerConsumer.forEach((consumerName, pendingMessageCount) -> {
                 log.info("[processPendingMessage][消费者({}) 消息数量({})]", consumerName, pendingMessageCount);
                 // 每个消费者的 pending消息的详情信息
-                PendingMessages pendingMessages = ops.pending(listener.getStreamKey(), Consumer.from(groupName, consumerName), Range.unbounded(), pendingMessageCount);
+                PendingMessages pendingMessages = ops.pending(listener.getStreamKey(), Consumer.from(listener.getGroup(), consumerName), Range.unbounded(), pendingMessageCount);
                 if (pendingMessages.isEmpty()) {
                     return;
                 }
@@ -91,7 +90,7 @@ public class RedisPendingMessageResendJob {
                             .ofObject(records.get(0).getValue()) // 设置内容
                             .withStreamKey(listener.getStreamKey()));
                     // ack 消息消费完成
-                    redisTemplate.getRedisTemplate().opsForStream().acknowledge(groupName, records.get(0));
+                    redisTemplate.getRedisTemplate().opsForStream().acknowledge(listener.getGroup(), records.get(0));
                     log.info("[processPendingMessage][消息({})重新投递成功]", records.get(0).getId());
                 });
             });

+ 72 - 0
yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/job/RedisStreamMessageCleanupJob.java

@@ -0,0 +1,72 @@
+package cn.iocoder.yudao.framework.mq.redis.core.job;
+
+import cn.iocoder.yudao.framework.mq.redis.core.RedisMQTemplate;
+import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
+import org.springframework.data.redis.core.StreamOperations;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import java.util.List;
+
+/**
+ * Redis Stream 消息清理任务
+ * 用于定期清理已消费的消息,防止内存占用过大
+ *
+ * @see <a href="https://www.cnblogs.com/nanxiang/p/16179519.html">记一次 redis stream 数据类型内存不释放问题</a>
+ *
+ * @author 芋道源码
+ */
+@Slf4j
+@AllArgsConstructor
+public class RedisStreamMessageCleanupJob {
+
+    private static final String LOCK_KEY = "redis:stream:message-cleanup:lock";
+
+    /**
+     * 保留的消息数量,默认保留最近 10000 条消息
+     */
+    private static final long MAX_COUNT = 10000;
+
+    private final List<AbstractRedisStreamMessageListener<?>> listeners;
+    private final RedisMQTemplate redisTemplate;
+    private final RedissonClient redissonClient;
+
+    /**
+     * 每小时执行一次清理任务
+     */
+    @Scheduled(cron = "0 0 * * * ?")
+    public void cleanup() {
+        RLock lock = redissonClient.getLock(LOCK_KEY);
+        // 尝试加锁
+        if (lock.tryLock()) {
+            try {
+                execute();
+            } catch (Exception ex) {
+                log.error("[cleanup][执行异常]", ex);
+            } finally {
+                lock.unlock();
+            }
+        }
+    }
+
+    /**
+     * 执行清理逻辑
+     */
+    private void execute() {
+        StreamOperations<String, Object, Object> ops = redisTemplate.getRedisTemplate().opsForStream();
+        listeners.forEach(listener -> {
+            try {
+                // 使用 XTRIM 命令清理消息,只保留最近的 MAX_LEN 条消息
+                Long trimCount = ops.trim(listener.getStreamKey(), MAX_COUNT, true);
+                if (trimCount != null && trimCount > 0) {
+                    log.info("[execute][Stream({}) 清理消息数量({})]", listener.getStreamKey(), trimCount);
+                }
+            } catch (Exception ex) {
+                log.error("[execute][Stream({}) 清理异常]", listener.getStreamKey(), ex);
+            }
+        });
+    }
+}

+ 6 - 0
yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/stream/AbstractRedisStreamMessageListener.java

@@ -53,6 +53,12 @@ public abstract class AbstractRedisStreamMessageListener<T extends AbstractRedis
         this.streamKey = messageType.getDeclaredConstructor().newInstance().getStreamKey();
     }
 
+    protected AbstractRedisStreamMessageListener(String streamKey, String group) {
+        this.messageType = null;
+        this.streamKey = streamKey;
+        this.group = group;
+    }
+
     @Override
     public void onMessage(ObjectRecord<String, String> message) {
         // 消费消息

+ 4 - 5
yudao-module-iot/pom.xml

@@ -1,16 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xmlns="http://maven.apache.org/POM/4.0.0"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <artifactId>yudao</artifactId>
         <groupId>cn.iocoder.boot</groupId>
         <version>${revision}</version>
     </parent>
     <modules>
-        <module>yudao-module-iot-api</module>
         <module>yudao-module-iot-biz</module>
-        <module>yudao-module-iot-plugins</module>
+        <module>yudao-module-iot-core</module>
+        <module>yudao-module-iot-gateway</module>
     </modules>
     <modelVersion>4.0.0</modelVersion>
 
@@ -20,7 +19,7 @@
     <name>${project.artifactId}</name>
     <description>
         物联网模块
-        <!-- TODO 芋艿:需要补充下说明! -->
+                <!-- TODO 芋艿:需要补充下说明! -->
     </description>
 
 </project>

+ 0 - 53
yudao-module-iot/yudao-module-iot-api/pom.xml

@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>yudao-module-iot</artifactId>
-        <groupId>cn.iocoder.boot</groupId>
-        <version>${revision}</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>yudao-module-iot-api</artifactId>
-    <packaging>jar</packaging>
-
-    <name>${project.artifactId}</name>
-    <!-- TODO 芋艿:需要在整理下,特别是 PF4J -->
-    <description>
-        物联网 模块 API,暴露给其它模块调用
-    </description>
-
-    <dependencies>
-        <dependency>
-            <groupId>cn.iocoder.boot</groupId>
-            <artifactId>yudao-common</artifactId>
-        </dependency>
-
-        <!-- Web 相关 -->
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-web</artifactId>
-            <scope>provided</scope> <!-- 设置为 provided,只有工具类需要使用到 -->
-        </dependency>
-
-        <!-- 工具类相关 -->
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-databind</artifactId>
-            <scope>provided</scope> <!-- 设置为 provided,只有工具类需要使用到 -->
-        </dependency>
-
-        <dependency>
-            <groupId>org.pf4j</groupId> <!-- PF4J:内置插件机制 -->
-            <artifactId>pf4j-spring</artifactId>
-        </dependency>
-
-        <!-- 参数校验 -->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-validation</artifactId>
-            <optional>true</optional>
-        </dependency>
-    </dependencies>
-
-</project>

+ 0 - 94
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/IotDeviceUpstreamApi.java

@@ -1,94 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.*;
-import cn.iocoder.yudao.module.iot.enums.ApiConstants;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-
-import javax.validation.Valid;
-
-/**
- * 设备数据 Upstream 上行 API
- *
- * 目的:设备 -> 插件 -> 服务端
- *
- * @author haohao
- */
-public interface IotDeviceUpstreamApi {
-
-    String PREFIX = ApiConstants.PREFIX + "/device/upstream";
-
-    // ========== 设备相关 ==========
-
-    /**
-     * 更新设备状态
-     *
-     * @param updateReqDTO 更新设备状态 DTO
-     */
-    @PostMapping(PREFIX + "/update-state")
-    CommonResult<Boolean> updateDeviceState(@Valid @RequestBody IotDeviceStateUpdateReqDTO updateReqDTO);
-
-    /**
-     * 上报设备属性数据
-     *
-     * @param reportReqDTO 上报设备属性数据 DTO
-     */
-    @PostMapping(PREFIX + "/report-property")
-    CommonResult<Boolean> reportDeviceProperty(@Valid @RequestBody IotDevicePropertyReportReqDTO reportReqDTO);
-
-    /**
-     * 上报设备事件数据
-     *
-     * @param reportReqDTO 设备事件
-     */
-    @PostMapping(PREFIX + "/report-event")
-    CommonResult<Boolean> reportDeviceEvent(@Valid @RequestBody IotDeviceEventReportReqDTO reportReqDTO);
-
-    // TODO @芋艿:这个需要 plugins 接入下
-    /**
-     * 注册设备
-     *
-     * @param registerReqDTO 注册设备 DTO
-     */
-    @PostMapping(PREFIX + "/register")
-    CommonResult<Boolean> registerDevice(@Valid @RequestBody IotDeviceRegisterReqDTO registerReqDTO);
-
-    // TODO @芋艿:这个需要 plugins 接入下
-    /**
-     * 注册子设备
-     *
-     * @param registerReqDTO 注册子设备 DTO
-     */
-    @PostMapping(PREFIX + "/register-sub")
-    CommonResult<Boolean> registerSubDevice(@Valid @RequestBody IotDeviceRegisterSubReqDTO registerReqDTO);
-
-    // TODO @芋艿:这个需要 plugins 接入下
-    /**
-     * 注册设备拓扑
-     *
-     * @param addReqDTO 注册设备拓扑 DTO
-     */
-    @PostMapping(PREFIX + "/add-topology")
-    CommonResult<Boolean> addDeviceTopology(@Valid @RequestBody IotDeviceTopologyAddReqDTO addReqDTO);
-
-    // TODO @芋艿:考虑 http 认证
-    /**
-     * 认证 Emqx 连接
-     *
-     * @param authReqDTO 认证 Emqx 连接 DTO
-     */
-    @PostMapping(PREFIX + "/authenticate-emqx-connection")
-    CommonResult<Boolean> authenticateEmqxConnection(@Valid @RequestBody IotDeviceEmqxAuthReqDTO authReqDTO);
-
-    // ========== 插件相关 ==========
-
-    /**
-     * 心跳插件实例
-     *
-     * @param heartbeatReqDTO 心跳插件实例 DTO
-     */
-    @PostMapping(PREFIX + "/heartbeat-plugin-instance")
-    CommonResult<Boolean> heartbeatPluginInstance(@Valid @RequestBody IotPluginInstanceHeartbeatReqDTO heartbeatReqDTO);
-
-}

+ 0 - 22
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceConfigSetReqDTO.java

@@ -1,22 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.downstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-import java.util.Map;
-
-/**
- * IoT 设备【配置】设置 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceConfigSetReqDTO extends IotDeviceDownstreamAbstractReqDTO {
-
-    /**
-     * 配置
-     */
-    @NotNull(message = "配置不能为空")
-    private Map<String, Object> config;
-
-}

+ 0 - 31
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceDownstreamAbstractReqDTO.java

@@ -1,31 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.downstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-
-/**
- * IoT 设备下行的抽象 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public abstract class IotDeviceDownstreamAbstractReqDTO {
-
-    /**
-     * 请求编号
-     */
-    private String requestId;
-
-    /**
-     * 产品标识
-     */
-    @NotEmpty(message = "产品标识不能为空")
-    private String productKey;
-    /**
-     * 设备名称
-     */
-    @NotEmpty(message = "设备名称不能为空")
-    private String deviceName;
-
-}

+ 0 - 66
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceOtaUpgradeReqDTO.java

@@ -1,66 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.downstream;
-
-import cn.hutool.core.map.MapUtil;
-import lombok.Data;
-
-import java.util.Map;
-
-/**
- * IoT 设备【OTA】升级下发 Request DTO(更新固件消息)
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceOtaUpgradeReqDTO extends IotDeviceDownstreamAbstractReqDTO {
-
-    /**
-     * 固件编号
-     */
-    private Long firmwareId;
-    /**
-     * 固件版本
-     */
-    private String version;
-
-    /**
-     * 签名方式
-     *
-     * 例如说:MD5、SHA256
-     */
-    private String signMethod;
-    /**
-     * 固件文件签名
-     */
-    private String fileSign;
-    /**
-     * 固件文件大小
-     */
-    private Long fileSize;
-    /**
-     * 固件文件 URL
-     */
-    private String fileUrl;
-
-    /**
-     * 自定义信息,建议使用 JSON 格式
-     */
-    private String information;
-
-    public static IotDeviceOtaUpgradeReqDTO build(Map<?, ?> map) {
-        return new IotDeviceOtaUpgradeReqDTO()
-                .setFirmwareId(MapUtil.getLong(map, "firmwareId")).setVersion((String) map.get("version"))
-                .setSignMethod((String) map.get("signMethod")).setFileSign((String) map.get("fileSign"))
-                .setFileSize(MapUtil.getLong(map, "fileSize")).setFileUrl((String) map.get("fileUrl"))
-                .setInformation((String) map.get("information"));
-    }
-
-    public static Map<?, ?> build(IotDeviceOtaUpgradeReqDTO dto) {
-        return MapUtil.builder()
-                .put("firmwareId", dto.getFirmwareId()).put("version", dto.getVersion())
-                .put("signMethod", dto.getSignMethod()).put("fileSign", dto.getFileSign())
-                .put("fileSize", dto.getFileSize()).put("fileUrl", dto.getFileUrl())
-                .put("information", dto.getInformation())
-                .build();
-    }
-
-}

+ 0 - 24
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDevicePropertyGetReqDTO.java

@@ -1,24 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.downstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.util.List;
-
-// TODO @芋艿:从 server => plugin => device 是否有必要?从阿里云 iot 来看,没有这个功能?!
-// TODO @芋艿:是不是改成 read 更好?在看看阿里云的 topic 设计
-/**
- * IoT 设备【属性】获取 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDevicePropertyGetReqDTO extends IotDeviceDownstreamAbstractReqDTO {
-
-    /**
-     * 属性标识数组
-     */
-    @NotEmpty(message = "属性标识数组不能为空")
-    private List<String> identifiers;
-
-}

+ 0 - 22
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDevicePropertySetReqDTO.java

@@ -1,22 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.downstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.util.Map;
-
-/**
- * IoT 设备【属性】设置 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDevicePropertySetReqDTO extends IotDeviceDownstreamAbstractReqDTO {
-
-    /**
-     * 属性参数
-     */
-    @NotEmpty(message = "属性参数不能为空")
-    private Map<String, Object> properties;
-
-}

+ 0 - 26
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/downstream/IotDeviceServiceInvokeReqDTO.java

@@ -1,26 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.downstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.util.Map;
-
-/**
- * IoT 设备【服务】调用 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceServiceInvokeReqDTO extends IotDeviceDownstreamAbstractReqDTO {
-
-    /**
-     * 服务标识
-     */
-    @NotEmpty(message = "服务标识不能为空")
-    private String identifier;
-    /**
-     * 调用参数
-     */
-    private Map<String, Object> params;
-
-}

+ 0 - 35
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceEmqxAuthReqDTO.java

@@ -1,35 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-
-// TODO @芋艿:要不要继承 IotDeviceUpstreamAbstractReqDTO
-// TODO @芋艿:@haohao:后续其它认证的设计
-/**
- * IoT 认证 Emqx 连接 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceEmqxAuthReqDTO {
-
-    /**
-     * 客户端 ID
-     */
-    @NotEmpty(message = "客户端 ID 不能为空")
-    private String clientId;
-
-    /**
-     * 用户名
-     */
-    @NotEmpty(message = "用户名不能为空")
-    private String username;
-
-    /**
-     * 密码
-     */
-    @NotEmpty(message = "密码不能为空")
-    private String password;
-
-}

+ 0 - 26
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceEventReportReqDTO.java

@@ -1,26 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.util.Map;
-
-/**
- * IoT 设备【事件】上报 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceEventReportReqDTO extends IotDeviceUpstreamAbstractReqDTO {
-
-    /**
-     * 事件标识
-     */
-    @NotEmpty(message = "事件标识不能为空")
-    private String identifier;
-    /**
-     * 事件参数
-     */
-    private Map<String, Object> params;
-
-}

+ 0 - 35
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceOtaProgressReqDTO.java

@@ -1,35 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-// TODO @芋艿:待实现:/ota/${productKey}/${deviceName}/progress
-/**
- * IoT 设备【OTA】升级进度 Request DTO(上报更新固件进度)
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceOtaProgressReqDTO extends IotDeviceUpstreamAbstractReqDTO {
-
-    /**
-     * 固件编号
-     */
-    private Long firmwareId;
-
-    /**
-     * 升级状态
-     *
-     * 枚举 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeRecordStatusEnum}
-     */
-    private Integer status;
-    /**
-     * 升级进度,百分比
-     */
-    private Integer progress;
-
-    /**
-     * 升级进度描述
-     */
-    private String description;
-
-}

+ 0 - 21
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceOtaPullReqDTO.java

@@ -1,21 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-// TODO @芋艿:待实现:/ota/${productKey}/${deviceName}/pull
-/**
- * IoT 设备【OTA】升级下拉 Request DTO(拉取固件更新)
- *
- * @author 芋道源码
- */
-public class IotDeviceOtaPullReqDTO {
-
-    /**
-     * 固件编号
-     */
-    private Long firmwareId;
-
-    /**
-     * 固件版本
-     */
-    private String version;
-
-}

+ 0 - 21
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceOtaReportReqDTO.java

@@ -1,21 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-// TODO @芋艿:待实现:/ota/${productKey}/${deviceName}/report
-/**
- * IoT 设备【OTA】上报 Request DTO(上报固件版本)
- *
- * @author 芋道源码
- */
-public class IotDeviceOtaReportReqDTO {
-
-    /**
-     * 固件编号
-     */
-    private Long firmwareId;
-
-    /**
-     * 固件版本
-     */
-    private String version;
-
-}

+ 0 - 22
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDevicePropertyReportReqDTO.java

@@ -1,22 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.util.Map;
-
-/**
- * IoT 设备【属性】上报 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDevicePropertyReportReqDTO extends IotDeviceUpstreamAbstractReqDTO {
-
-    /**
-     * 属性参数
-     */
-    @NotEmpty(message = "属性参数不能为空")
-    private Map<String, Object> properties;
-
-}

+ 0 - 12
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceRegisterReqDTO.java

@@ -1,12 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-/**
- * IoT 设备【注册】自己 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceRegisterReqDTO extends IotDeviceUpstreamAbstractReqDTO {
-}

+ 0 - 43
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceRegisterSubReqDTO.java

@@ -1,43 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.util.List;
-
-/**
- * IoT 设备【注册】子设备 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceRegisterSubReqDTO extends IotDeviceUpstreamAbstractReqDTO {
-
-    // TODO @芋艿:看看要不要优化命名
-    /**
-     * 子设备数组
-     */
-    @NotEmpty(message = "子设备不能为空")
-    private List<Device> params;
-
-    /**
-     * 设备信息
-     */
-    @Data
-    public static class Device {
-
-        /**
-         * 产品标识
-         */
-        @NotEmpty(message = "产品标识不能为空")
-        private String productKey;
-
-        /**
-         * 设备名称
-         */
-        @NotEmpty(message = "设备名称不能为空")
-        private String deviceName;
-
-    }
-
-}

+ 0 - 24
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceStateUpdateReqDTO.java

@@ -1,24 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStateEnum;
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * IoT 设备【状态】更新 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotDeviceStateUpdateReqDTO extends IotDeviceUpstreamAbstractReqDTO {
-
-    /**
-     * 设备状态
-     */
-    @NotNull(message = "设备状态不能为空")
-    @InEnum(IotDeviceStateEnum.class) // 只使用:在线、离线
-    private Integer state;
-
-}

+ 0 - 44
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceTopologyAddReqDTO.java

@@ -1,44 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.util.List;
-
-// TODO @芋艿:要写清楚,是来自设备网关,还是设备。
-/**
- * IoT 设备【拓扑】添加 Request DTO
- */
-@Data
-public class IotDeviceTopologyAddReqDTO extends IotDeviceUpstreamAbstractReqDTO {
-
-    // TODO @芋艿:看看要不要优化命名
-    /**
-     * 子设备数组
-     */
-    @NotEmpty(message = "子设备不能为空")
-    private List<IotDeviceRegisterSubReqDTO.Device> params;
-
-    /**
-     * 设备信息
-     */
-    @Data
-    public static class Device {
-
-        /**
-         * 产品标识
-         */
-        @NotEmpty(message = "产品标识不能为空")
-        private String productKey;
-
-        /**
-         * 设备名称
-         */
-        @NotEmpty(message = "设备名称不能为空")
-        private String deviceName;
-
-        // TODO @芋艿:阿里云还有 sign 签名
-
-    }
-
-}

+ 0 - 45
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotDeviceUpstreamAbstractReqDTO.java

@@ -1,45 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeSerializer;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import java.time.LocalDateTime;
-
-/**
- * IoT 设备上行的抽象 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public abstract class IotDeviceUpstreamAbstractReqDTO {
-
-    /**
-     * 请求编号
-     */
-    private String requestId;
-
-    /**
-     * 插件实例的进程编号
-     */
-    private String processId;
-
-    /**
-     * 产品标识
-     */
-    @NotEmpty(message = "产品标识不能为空")
-    private String productKey;
-    /**
-     * 设备名称
-     */
-    @NotEmpty(message = "设备名称不能为空")
-    private String deviceName;
-
-    /**
-     * 上报时间
-     */
-    @JsonSerialize(using = TimestampLocalDateTimeSerializer.class) // 解决 iot plugins 序列化 LocalDateTime 是数组,导致无法解析的问题
-    private LocalDateTime reportTime;
-
-}

+ 0 - 45
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/control/upstream/IotPluginInstanceHeartbeatReqDTO.java

@@ -1,45 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-
-/**
- * IoT 插件实例心跳 Request DTO
- *
- * @author 芋道源码
- */
-@Data
-public class IotPluginInstanceHeartbeatReqDTO {
-
-    /**
-     * 请求编号
-     */
-    @NotEmpty(message = "请求编号不能为空")
-    private String processId;
-
-    /**
-     * 插件包标识符
-     */
-    @NotEmpty(message = "插件包标识符不能为空")
-    private String pluginKey;
-
-    /**
-     * 插件实例所在 IP
-     */
-    @NotEmpty(message = "插件实例所在 IP 不能为空")
-    private String hostIp;
-    /**
-     * 插件实例的进程编号
-     */
-    @NotNull(message = "插件实例的进程编号不能为空")
-    private Integer downstreamPort;
-
-    /**
-     * 是否在线
-     */
-    @NotNull(message = "是否在线不能为空")
-    private Boolean online;
-
-}

+ 0 - 4
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/device/dto/package-info.java

@@ -1,4 +0,0 @@
-/**
- * TODO 芋艿:占位
- */
-package cn.iocoder.yudao.module.iot.api.device.dto;

+ 0 - 6
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java

@@ -1,6 +0,0 @@
-/**
- * 占位
- *
- * TODO 芋艿:后续删除
- */
-package cn.iocoder.yudao.module.iot.api;

+ 0 - 16
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ApiConstants.java

@@ -1,16 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums;
-
-import cn.iocoder.yudao.framework.common.enums.RpcConstants;
-
-/**
- * API 相关的枚举
- *
- * @author 芋道源码
- */
-public class ApiConstants {
-
-    public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/iot";
-
-    public static final String VERSION = "1.0.0";
-
-}

+ 0 - 22
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/DictTypeConstants.java

@@ -1,22 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums;
-
-/**
- * IoT 字典类型的枚举类
- *
- * @author 芋道源码
- */
-public class DictTypeConstants {
-
-    public static final String PRODUCT_STATUS = "iot_product_status";
-    public static final String PRODUCT_DEVICE_TYPE = "iot_product_device_type";
-    public static final String NET_TYPE = "iot_net_type";
-    public static final String PROTOCOL_TYPE = "iot_protocol_type";
-    public static final String DATA_FORMAT = "iot_data_format";
-    public static final String VALIDATE_TYPE = "iot_validate_type";
-
-    public static final String DEVICE_STATE = "iot_device_state";
-    
-    public static final String IOT_DATA_BRIDGE_DIRECTION_ENUM = "iot_data_bridge_direction_enum";
-    public static final String IOT_DATA_BRIDGE_TYPE_ENUM = "iot_data_bridge_type_enum";
-
-}

+ 0 - 75
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ErrorCodeConstants.java

@@ -1,75 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums;
-
-import cn.iocoder.yudao.framework.common.exception.ErrorCode;
-
-/**
- * iot 错误码枚举类
- * <p>
- * iot 系统,使用 1-050-000-000 段
- */
-public interface ErrorCodeConstants {
-
-    // ========== 产品相关 1-050-001-000 ============
-    ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_050_001_000, "产品不存在");
-    ErrorCode PRODUCT_KEY_EXISTS = new ErrorCode(1_050_001_001, "产品标识已经存在");
-    ErrorCode PRODUCT_STATUS_NOT_DELETE = new ErrorCode(1_050_001_002, "产品状是发布状态,不允许删除");
-    ErrorCode PRODUCT_STATUS_NOT_ALLOW_THING_MODEL = new ErrorCode(1_050_001_003, "产品状是发布状态,不允许操作物模型");
-
-    // ========== 产品物模型 1-050-002-000 ============
-    ErrorCode THING_MODEL_NOT_EXISTS = new ErrorCode(1_050_002_000, "产品物模型不存在");
-    ErrorCode THING_MODEL_EXISTS_BY_PRODUCT_KEY = new ErrorCode(1_050_002_001, "ProductKey 对应的产品物模型已存在");
-    ErrorCode THING_MODEL_IDENTIFIER_EXISTS = new ErrorCode(1_050_002_002, "存在重复的功能标识符。");
-    ErrorCode THING_MODEL_NAME_EXISTS = new ErrorCode(1_050_002_003, "存在重复的功能名称。");
-    ErrorCode THING_MODEL_IDENTIFIER_INVALID = new ErrorCode(1_050_002_003, "产品物模型标识无效");
-
-    // ========== 设备 1-050-003-000 ============
-    ErrorCode DEVICE_NOT_EXISTS = new ErrorCode(1_050_003_000, "设备不存在");
-    ErrorCode DEVICE_NAME_EXISTS = new ErrorCode(1_050_003_001, "设备名称在同一产品下必须唯一");
-    ErrorCode DEVICE_HAS_CHILDREN = new ErrorCode(1_050_003_002, "有子设备,不允许删除");
-    ErrorCode DEVICE_KEY_EXISTS = new ErrorCode(1_050_003_003, "设备标识已经存在");
-    ErrorCode DEVICE_GATEWAY_NOT_EXISTS = new ErrorCode(1_050_003_004, "网关设备不存在");
-    ErrorCode DEVICE_NOT_GATEWAY = new ErrorCode(1_050_003_005, "设备不是网关设备");
-    ErrorCode DEVICE_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_050_003_006, "导入设备数据不能为空!");
-    ErrorCode DEVICE_DOWNSTREAM_FAILED = new ErrorCode(1_050_003_007, "执行失败,原因:{}");
-
-    // ========== 产品分类 1-050-004-000 ==========
-    ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_050_004_000, "产品分类不存在");
-
-    // ========== 设备分组 1-050-005-000 ==========
-    ErrorCode DEVICE_GROUP_NOT_EXISTS = new ErrorCode(1_050_005_000, "设备分组不存在");
-    ErrorCode DEVICE_GROUP_DELETE_FAIL_DEVICE_EXISTS = new ErrorCode(1_050_005_001, "设备分组下存在设备,不允许删除");
-
-    // ========== 插件配置 1-050-006-000 ==========
-    ErrorCode PLUGIN_CONFIG_NOT_EXISTS = new ErrorCode(1_050_006_000, "插件配置不存在");
-    ErrorCode PLUGIN_INSTALL_FAILED = new ErrorCode(1_050_006_001, "插件安装失败");
-    ErrorCode PLUGIN_INSTALL_FAILED_FILE_NAME_NOT_MATCH = new ErrorCode(1_050_006_002, "插件安装失败,文件名与原插件id不匹配");
-    ErrorCode PLUGIN_CONFIG_DELETE_FAILED_RUNNING = new ErrorCode(1_050_006_003, "请先停止插件");
-    ErrorCode PLUGIN_STATUS_INVALID = new ErrorCode(1_050_006_004, "插件状态无效");
-    ErrorCode PLUGIN_CONFIG_KEY_DUPLICATE = new ErrorCode(1_050_006_005, "插件标识已存在");
-    ErrorCode PLUGIN_START_FAILED = new ErrorCode(1_050_006_006, "插件启动失败");
-    ErrorCode PLUGIN_STOP_FAILED = new ErrorCode(1_050_006_007, "插件停止失败");
-
-    // ========== 插件实例 1-050-007-000 ==========
-
-    // ========== 固件相关 1-050-008-000 ==========
-
-    ErrorCode OTA_FIRMWARE_NOT_EXISTS = new ErrorCode(1_050_008_000, "固件信息不存在");
-    ErrorCode OTA_FIRMWARE_PRODUCT_VERSION_DUPLICATE = new ErrorCode(1_050_008_001, "产品版本号重复");
-
-    ErrorCode OTA_UPGRADE_TASK_NOT_EXISTS = new ErrorCode(1_050_008_100, "升级任务不存在");
-    ErrorCode OTA_UPGRADE_TASK_NAME_DUPLICATE = new ErrorCode(1_050_008_101, "升级任务名称重复");
-    ErrorCode OTA_UPGRADE_TASK_DEVICE_IDS_EMPTY = new ErrorCode(1_050_008_102, "设备编号列表不能为空");
-    ErrorCode OTA_UPGRADE_TASK_DEVICE_LIST_EMPTY = new ErrorCode(1_050_008_103, "设备列表不能为空");
-    ErrorCode OTA_UPGRADE_TASK_CANNOT_CANCEL = new ErrorCode(1_050_008_104, "升级任务不能取消");
-
-    ErrorCode OTA_UPGRADE_RECORD_NOT_EXISTS = new ErrorCode(1_050_008_200, "升级记录不存在");
-    ErrorCode OTA_UPGRADE_RECORD_DUPLICATE = new ErrorCode(1_050_008_201, "升级记录重复");
-    ErrorCode OTA_UPGRADE_RECORD_CANNOT_RETRY = new ErrorCode(1_050_008_202, "升级记录不能重试");
-
-    // ========== MQTT 通信相关 1-050-009-000 ==========
-    ErrorCode MQTT_TOPIC_ILLEGAL = new ErrorCode(1_050_009_000, "topic illegal");
-
-    // ========== IoT 数据桥梁 1-050-010-000 ==========
-    ErrorCode DATA_BRIDGE_NOT_EXISTS = new ErrorCode(1_050_010_000, "IoT 数据桥梁不存在");
-
-}

+ 0 - 44
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/device/IotDeviceMessageIdentifierEnum.java

@@ -1,44 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.device;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-// TODO @芋艿:需要添加对应的 DTO,以及上下行的链路,网关、网关服务、设备等
-/**
- * IoT 设备消息标识符枚举
- */
-@Getter
-@RequiredArgsConstructor
-public enum IotDeviceMessageIdentifierEnum {
-
-    PROPERTY_GET("get"), // 下行 TODO 芋艿:【讨论】貌似这个“上行”更合理?device 主动拉取配置。和 IotDevicePropertyGetReqDTO 一样的配置
-    PROPERTY_SET("set"), // 下行
-    PROPERTY_REPORT("report"), // 上行
-
-    STATE_ONLINE("online"), // 上行
-    STATE_OFFLINE("offline"), // 上行
-
-    CONFIG_GET("get"), // 上行 TODO 芋艿:【讨论】暂时没有上行的场景
-    CONFIG_SET("set"), // 下行
-
-    SERVICE_INVOKE("${identifier}"), // 下行
-    SERVICE_REPLY_SUFFIX("_reply"), // 芋艿:TODO 芋艿:【讨论】上行 or 下行
-
-    OTA_UPGRADE("upgrade"), // 下行
-    OTA_PULL("pull"), // 上行
-    OTA_PROGRESS("progress"), // 上行
-    OTA_REPORT("report"), // 上行
-
-    REGISTER_REGISTER("register"), // 上行
-    REGISTER_REGISTER_SUB("register_sub"), // 上行
-    REGISTER_UNREGISTER_SUB("unregister_sub"), // 下行
-
-    TOPOLOGY_ADD("topology_add"), // 下行;
-    ;
-
-    /**
-     * 标志符
-     */
-    private final String identifier;
-
-}

+ 0 - 37
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/device/IotDeviceMessageTypeEnum.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.device;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 设备消息类型枚举
- */
-@Getter
-@RequiredArgsConstructor
-public enum IotDeviceMessageTypeEnum implements ArrayValuable<String> {
-
-    STATE("state"), // 设备状态
-    PROPERTY("property"), // 设备属性:可参考 https://help.aliyun.com/zh/iot/user-guide/device-properties-events-and-services 设备属性、事件、服务
-    EVENT("event"), // 设备事件:可参考 https://help.aliyun.com/zh/iot/user-guide/device-properties-events-and-services 设备属性、事件、服务
-    SERVICE("service"), // 设备服务:可参考 https://help.aliyun.com/zh/iot/user-guide/device-properties-events-and-services 设备属性、事件、服务
-    CONFIG("config"), // 设备配置:可参考 https://help.aliyun.com/zh/iot/user-guide/remote-configuration-1 远程配置
-    OTA("ota"), // 设备 OTA:可参考 https://help.aliyun.com/zh/iot/user-guide/ota-update OTA 升级
-    REGISTER("register"), // 设备注册:可参考 https://help.aliyun.com/zh/iot/user-guide/register-devices 设备身份注册
-    TOPOLOGY("topology"),; // 设备拓扑:可参考 https://help.aliyun.com/zh/iot/user-guide/manage-topological-relationships 设备拓扑
-
-    public static final String[] ARRAYS = Arrays.stream(values()).map(IotDeviceMessageTypeEnum::getType).toArray(String[]::new);
-
-    /**
-     * 属性
-     */
-    private final String type;
-
-    @Override
-    public String[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 42
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/device/IotDeviceStateEnum.java

@@ -1,42 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.device;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 设备状态枚举
- *
- * @author haohao
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotDeviceStateEnum implements ArrayValuable<Integer> {
-
-    INACTIVE(0, "未激活"),
-    ONLINE(1, "在线"),
-    OFFLINE(2, "离线");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotDeviceStateEnum::getState).toArray(Integer[]::new);
-
-    /**
-     * 状态
-     */
-    private final Integer state;
-    /**
-     * 状态名
-     */
-    private final String name;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-    public static boolean isOnline(Integer state) {
-        return ONLINE.getState().equals(state);
-    }
-
-}

+ 0 - 38
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeRecordStatusEnum.java

@@ -1,38 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.ota;
-
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT OTA 升级记录的范围枚举
- *
- * @author haohao
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotOtaUpgradeRecordStatusEnum implements ArrayValuable<Integer> {
-
-    PENDING(0), // 待推送
-    PUSHED(10), // 已推送
-    UPGRADING(20), // 升级中
-    SUCCESS(30), // 升级成功
-    FAILURE(40), // 升级失败
-    CANCELED(50),; // 已取消
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotOtaUpgradeRecordStatusEnum::getStatus).toArray(Integer[]::new);
-
-    /**
-     * 范围
-     */
-    private final Integer status;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 33
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeTaskScopeEnum.java

@@ -1,33 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.ota;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT OTA 升级任务的范围枚举
- *
- * @author haohao
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotOtaUpgradeTaskScopeEnum implements ArrayValuable<Integer> {
-
-    ALL(1), // 全部设备:只包括当前产品下的设备,不包括未来创建的设备
-    SELECT(2); // 指定设备
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotOtaUpgradeTaskScopeEnum::getScope).toArray(Integer[]::new);
-
-    /**
-     * 范围
-     */
-    private final Integer scope;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 35
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeTaskStatusEnum.java

@@ -1,35 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.ota;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT OTA 升级任务的范围枚举
- *
- * @author haohao
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotOtaUpgradeTaskStatusEnum implements ArrayValuable<Integer> {
-
-    IN_PROGRESS(10), // 进行中:升级中
-    COMPLETED(20), // 已完成:已结束,全部升级完成
-    INCOMPLETE(21), // 未完成:已结束,部分升级完成
-    CANCELED(30),; // 已取消:一般是主动取消任务
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotOtaUpgradeTaskStatusEnum::getStatus).toArray(Integer[]::new);
-
-    /**
-     * 范围
-     */
-    private final Integer status;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 37
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginDeployTypeEnum.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.plugin;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 部署方式枚举
- *
- * @author haohao
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotPluginDeployTypeEnum implements ArrayValuable<Integer> {
-
-    JAR(0, "JAR 部署"),
-    STANDALONE(1, "独立部署");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotPluginDeployTypeEnum::getDeployType).toArray(Integer[]::new);
-
-    /**
-     * 部署方式
-     */
-    private final Integer deployType;
-    /**
-     * 部署方式名
-     */
-    private final String name;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 37
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginStatusEnum.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.plugin;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 插件状态枚举
- *
- * @author haohao
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotPluginStatusEnum implements ArrayValuable<Integer> {
-
-    STOPPED(0, "停止"),
-    RUNNING(1, "运行");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotPluginStatusEnum::getStatus).toArray(Integer[]::new);
-
-    /**
-     * 状态
-     */
-    private final Integer status;
-    /**
-     * 状态名
-     */
-    private final String name;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 37
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginTypeEnum.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.plugin;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 插件类型枚举
- *
- * @author haohao
- */
-@AllArgsConstructor
-@Getter
-public enum IotPluginTypeEnum implements ArrayValuable<Integer> {
-
-    NORMAL(0, "普通插件"),
-    DEVICE(1, "设备插件");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotPluginTypeEnum::getType).toArray(Integer[]::new);
-
-    /**
-     * 类型
-     */
-    private final Integer type;
-    /**
-     * 类型名
-     */
-    private final String name;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 38
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java

@@ -1,38 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.product;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * 产品数据格式枚举类
- *
- * @author ahh
- * @see <a href="https://help.aliyun.com/zh/iot/user-guide/message-parsing">阿里云 - 什么是消息解析</a>
- */
-@AllArgsConstructor
-@Getter
-public enum IotDataFormatEnum implements ArrayValuable<Integer> {
-
-    JSON(0, "标准数据格式(JSON)"),
-    CUSTOMIZE(1, "透传/自定义");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotDataFormatEnum::getType).toArray(Integer[]::new);
-
-    /**
-     * 类型
-     */
-    private final Integer type;
-    /**
-     * 描述
-     */
-    private final String description;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 39
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java

@@ -1,39 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.product;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 联网方式枚举类
- *
- * @author ahh
- */
-@AllArgsConstructor
-@Getter
-public enum IotNetTypeEnum implements ArrayValuable<Integer> {
-
-    WIFI(0, "Wi-Fi"),
-    CELLULAR(1, "Cellular"),
-    ETHERNET(2, "Ethernet"),
-    OTHER(3, "其他");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotNetTypeEnum::getType).toArray(Integer[]::new);
-
-    /**
-     * 类型
-     */
-    private final Integer type;
-    /**
-     * 描述
-     */
-    private final String description;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 59
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java

@@ -1,59 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.product;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 产品的设备类型
- *
- * @author ahh
- */
-@AllArgsConstructor
-@Getter
-public enum IotProductDeviceTypeEnum implements ArrayValuable<Integer> {
-
-    DIRECT(0, "直连设备"),
-    GATEWAY_SUB(1, "网关子设备"),
-    GATEWAY(2, "网关设备");
-
-    /**
-     * 类型
-     */
-    private final Integer type;
-
-    /**
-     * 描述
-     */
-    private final String description;
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotProductDeviceTypeEnum::getType).toArray(Integer[]::new);
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-    /**
-     * 判断是否是网关
-     *
-     * @param type 类型
-     * @return 是否是网关
-     */
-    public static boolean isGateway(Integer type) {
-        return GATEWAY.getType().equals(type);
-    }
-
-    /**
-     * 判断是否是网关子设备
-     *
-     * @param type 类型
-     * @return 是否是网关子设备
-     */
-    public static boolean isGatewaySub(Integer type) {
-        return GATEWAY_SUB.getType().equals(type);
-    }
-
-}

+ 0 - 37
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.product;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 产品的状态枚举类
- *
- * @author ahh
- */
-@AllArgsConstructor
-@Getter
-public enum IotProductStatusEnum implements ArrayValuable<Integer> {
-
-    UNPUBLISHED(0, "开发中"),
-    PUBLISHED(1, "已发布");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotProductStatusEnum::getStatus).toArray(Integer[]::new);
-
-    /**
-     * 类型
-     */
-    private final Integer status;
-    /**
-     * 描述
-     */
-    private final String description;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 40
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java

@@ -1,40 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.product;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 接入网关协议枚举类
- *
- * @author ahh
- */
-@AllArgsConstructor
-@Getter
-public enum IotProtocolTypeEnum implements ArrayValuable<Integer> {
-
-    CUSTOM(0, "自定义"),
-    MODBUS(1, "Modbus"),
-    OPC_UA(2, "OPC UA"),
-    ZIGBEE(3, "ZigBee"),
-    BLE(4, "BLE");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotProtocolTypeEnum::getType).toArray(Integer[]::new);
-
-    /**
-     * 类型
-     */
-    private final Integer type;
-    /**
-     * 描述
-     */
-    private final String description;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 37
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.product;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 数据校验级别枚举类
- *
- * @author ahh
- */
-@AllArgsConstructor
-@Getter
-public enum IotValidateTypeEnum implements ArrayValuable<Integer> {
-
-    WEAK(0, "弱校验"),
-    NONE(1, "免校验");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotValidateTypeEnum::getType).toArray(Integer[]::new);
-
-    /**
-     * 类型
-     */
-    private final Integer type;
-    /**
-     * 描述
-     */
-    private final String description;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 31
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotAlertConfigReceiveTypeEnum.java

@@ -1,31 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.rule;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 告警配置的接收方式枚举
- *
- * @author 芋道源码
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotAlertConfigReceiveTypeEnum implements ArrayValuable<Integer> {
-
-    SMS(1), // 短信
-    MAIL(2), // 邮箱
-    NOTIFY(3); // 通知
-
-    private final Integer type;
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotAlertConfigReceiveTypeEnum::getType).toArray(Integer[]::new);
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 30
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotDataBridgeDirectionEnum.java

@@ -1,30 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.rule;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 数据桥接的方向枚举
- *
- * @author 芋道源码
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotDataBridgeDirectionEnum implements ArrayValuable<Integer> {
-
-    INPUT(1), // 输入
-    OUTPUT(2); // 输出
-
-    private final Integer type;
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotDataBridgeDirectionEnum::getType).toArray(Integer[]::new);
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 42
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotDataBridgeTypeEnum.java

@@ -1,42 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.rule;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 数据桥接的类型枚举
- *
- * @author 芋道源码
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotDataBridgeTypeEnum implements ArrayValuable<Integer> {
-
-    HTTP(1, "HTTP"),
-    TCP(2, "TCP"),
-    WEBSOCKET(3, "WEBSOCKET"),
-
-    MQTT(10, "MQTT"),
-
-    DATABASE(20, "DATABASE"),
-    REDIS_STREAM(21, "REDIS_STREAM"),
-
-    ROCKETMQ(30, "ROCKETMQ"),
-    RABBITMQ(31, "RABBITMQ"),
-    KAFKA(32, "KAFKA");
-
-    private final Integer type;
-
-    private final String name;
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotDataBridgeTypeEnum::getType).toArray(Integer[]::new);
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 31
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneActionTypeEnum.java

@@ -1,31 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.rule;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 规则场景的触发类型枚举
- *
- * 设备触发,定时触发
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotRuleSceneActionTypeEnum implements ArrayValuable<Integer> {
-
-    DEVICE_CONTROL(1), // 设备执行
-    ALERT(2), // 告警执行
-    DATA_BRIDGE(3); // 桥接执行
-
-    private final Integer type;
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneActionTypeEnum::getType).toArray(Integer[]::new);
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 64
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneTriggerConditionParameterOperatorEnum.java

@@ -1,64 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.rule;
-
-import cn.hutool.core.util.ArrayUtil;
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 场景触发条件参数的操作符枚举
- *
- * @author 芋道源码
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotRuleSceneTriggerConditionParameterOperatorEnum implements ArrayValuable<String> {
-
-    EQUALS("=", "#source == #value"),
-    NOT_EQUALS("!=", "!(#source == #value)"),
-
-    GREATER_THAN(">", "#source > #value"),
-    GREATER_THAN_OR_EQUALS(">=", "#source >= #value"),
-
-    LESS_THAN("<", "#source < #value"),
-    LESS_THAN_OR_EQUALS("<=", "#source <= #value"),
-
-    IN("in", "#values.contains(#source)"),
-    NOT_IN("not in", "!(#values.contains(#source))"),
-
-    BETWEEN("between", "(#source >= #values.get(0)) && (#source <= #values.get(1))"),
-    NOT_BETWEEN("not between", "(#source < #values.get(0)) || (#source > #values.get(1))"),
-
-    LIKE("like", "#source.contains(#value)"), // 字符串匹配
-    NOT_NULL("not null", "#source != null && #source.length() > 0"); // 非空
-
-    private final String operator;
-    private final String springExpression;
-
-    public static final String[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneTriggerConditionParameterOperatorEnum::getOperator).toArray(String[]::new);
-
-    /**
-     * Spring 表达式 - 原始值
-     */
-    public static final String SPRING_EXPRESSION_SOURCE = "source";
-    /**
-     * Spring 表达式 - 目标值
-     */
-    public static final String SPRING_EXPRESSION_VALUE = "value";
-    /**
-     * Spring 表达式 - 目标值数组
-     */
-    public static final String SPRING_EXPRESSION_VALUE_List = "values";
-
-    public static IotRuleSceneTriggerConditionParameterOperatorEnum operatorOf(String operator) {
-        return ArrayUtil.firstMatch(item -> item.getOperator().equals(operator), values());
-    }
-
-    @Override
-    public String[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 30
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/rule/IotRuleSceneTriggerTypeEnum.java

@@ -1,30 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.rule;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-
-/**
- * IoT 场景流转的触发类型枚举
- *
- * @author 芋道源码
- */
-@RequiredArgsConstructor
-@Getter
-public enum IotRuleSceneTriggerTypeEnum implements ArrayValuable<Integer> {
-
-    DEVICE(1), // 设备触发
-    TIMER(2); // 定时触发
-
-    private final Integer type;
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotRuleSceneTriggerTypeEnum::getType).toArray(Integer[]::new);
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 37
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotDataSpecsDataTypeEnum.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.thingmodel;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 数据定义的数据类型枚举类
- *
- * @author 芋道源码
- */
-@AllArgsConstructor
-@Getter
-public enum IotDataSpecsDataTypeEnum implements ArrayValuable<String> {
-
-    INT("int"),
-    FLOAT("float"),
-    DOUBLE("double"),
-    ENUM("enum"),
-    BOOL("bool"),
-    TEXT("text"),
-    DATE("date"),
-    STRUCT("struct"),
-    ARRAY("array");
-
-    public static final String[] ARRAYS = Arrays.stream(values()).map(IotDataSpecsDataTypeEnum::getDataType).toArray(String[]::new);
-
-    private final String dataType;
-
-    @Override
-    public String[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 30
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelAccessModeEnum.java

@@ -1,30 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.thingmodel;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 产品物模型属性读取类型枚举
- *
- * @author ahh
- */
-@AllArgsConstructor
-@Getter
-public enum IotThingModelAccessModeEnum implements ArrayValuable<String> {
-
-    READ_ONLY("r"),
-    READ_WRITE("rw");
-
-    public static final String[] ARRAYS = Arrays.stream(values()).map(IotThingModelAccessModeEnum::getMode).toArray(String[]::new);
-
-    private final String mode;
-
-    @Override
-    public String[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 31
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelParamDirectionEnum.java

@@ -1,31 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.thingmodel;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-
-/**
- * IoT 产品物模型参数是输入参数还是输出参数枚举
- *
- * @author HUIHUI
- */
-@AllArgsConstructor
-@Getter
-public enum IotThingModelParamDirectionEnum implements ArrayValuable<String> {
-
-    INPUT("input"), // 输入参数
-    OUTPUT("output"); // 输出参数
-
-    public static final String[] ARRAYS = Arrays.stream(values()).map(IotThingModelParamDirectionEnum::getDirection).toArray(String[]::new);
-
-    private final String direction;
-
-    @Override
-    public String[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 30
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelServiceCallTypeEnum.java

@@ -1,30 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.thingmodel;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 产品物模型服务调用方式枚举
- *
- * @author HUIHUI
- */
-@AllArgsConstructor
-@Getter
-public enum IotThingModelServiceCallTypeEnum implements ArrayValuable<String> {
-
-    ASYNC("async"), // 异步调用
-    SYNC("sync"); // 同步调用
-
-    public static final String[] ARRAYS = Arrays.stream(values()).map(IotThingModelServiceCallTypeEnum::getType).toArray(String[]::new);
-
-    private final String type;
-
-    @Override
-    public String[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 31
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelServiceEventTypeEnum.java

@@ -1,31 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.thingmodel;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 产品物模型事件类型枚举
- *
- * @author HUIHUI
- */
-@AllArgsConstructor
-@Getter
-public enum IotThingModelServiceEventTypeEnum implements ArrayValuable<String> {
-
-    INFO("info"), // 信息
-    ALERT("alert"), // 告警
-    ERROR("error"); // 故障
-
-    public static final String[] ARRAYS = Arrays.stream(values()).map(IotThingModelServiceEventTypeEnum::getType).toArray(String[]::new);
-
-    private final String type;
-
-    @Override
-    public String[] array() {
-        return ARRAYS;
-    }
-
-}

+ 0 - 38
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelTypeEnum.java

@@ -1,38 +0,0 @@
-package cn.iocoder.yudao.module.iot.enums.thingmodel;
-
-import cn.iocoder.yudao.framework.common.core.ArrayValuable;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-import java.util.Arrays;
-
-/**
- * IoT 产品功能(物模型)类型枚举类
- *
- * @author ahh
- */
-@AllArgsConstructor
-@Getter
-public enum IotThingModelTypeEnum implements ArrayValuable<Integer> {
-
-    PROPERTY(1, "属性"),
-    SERVICE(2, "服务"),
-    EVENT(3, "事件");
-
-    public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotThingModelTypeEnum::getType).toArray(Integer[]::new);
-
-    /**
-     * 类型
-     */
-    private final Integer type;
-    /**
-     * 描述
-     */
-    private final String description;
-
-    @Override
-    public Integer[] array() {
-        return ARRAYS;
-    }
-
-}

+ 28 - 47
yudao-module-iot/yudao-module-iot-biz/pom.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <artifactId>yudao-module-iot</artifactId>
         <groupId>cn.iocoder.boot</groupId>
@@ -15,13 +14,18 @@
     <name>${project.artifactId}</name>
     <description>
         物联网 模块,主要实现 产品管理、设备管理、协议管理等功能。
-        <!-- TODO 芋艿:后续补充下 -->
+                <!-- TODO 芋艿:后续补充下 -->
     </description>
 
     <dependencies>
         <dependency>
             <groupId>cn.iocoder.boot</groupId>
-            <artifactId>yudao-module-iot-api</artifactId>
+            <artifactId>yudao-module-system</artifactId>
+            <version>${revision}</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-module-iot-core</artifactId>
             <version>${revision}</version>
         </dependency>
 
@@ -69,11 +73,30 @@
             <artifactId>yudao-spring-boot-starter-excel</artifactId>
         </dependency>
 
+        <!-- OkHttp -->
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>mockwebserver</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- MQTT -->
+        <dependency>
+            <groupId>org.eclipse.paho</groupId>
+            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+            <optional>true</optional>
+        </dependency>
+
         <!-- 消息队列相关 -->
+        <!-- TODO @芋艿:临时打开 -->
         <dependency>
             <groupId>org.apache.rocketmq</groupId>
             <artifactId>rocketmq-spring-boot-starter</artifactId>
-            <optional>true</optional>
+<!--            <optional>true</optional>-->
         </dependency>
         <dependency>
             <groupId>org.springframework.kafka</groupId>
@@ -85,48 +108,6 @@
             <artifactId>spring-boot-starter-amqp</artifactId>
             <optional>true</optional>
         </dependency>
-
-        <dependency>
-            <groupId>org.pf4j</groupId>  <!-- PF4J:内置插件机制 -->
-            <artifactId>pf4j-spring</artifactId>
-        </dependency>
-
-        <!-- TODO @芋艿:bom 管理 -->
-        <dependency>
-            <groupId>org.apache.groovy</groupId>
-            <artifactId>groovy-all</artifactId>
-            <version>4.0.25</version>
-            <type>pom</type>
-        </dependency>
-
-        <!-- TODO @芋艿:bom 管理 TODO @芋艿:不支持 jdk8 -->
-<!--        <dependency>-->
-<!--            <groupId>org.graalvm.js</groupId>-->
-<!--            <artifactId>js</artifactId>-->
-<!--            <version>24.1.2</version>-->
-<!--            <type>pom</type>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.graalvm.js</groupId>-->
-<!--            <artifactId>js-scriptengine</artifactId>-->
-<!--            <version>24.1.2</version>-->
-<!--        </dependency>-->
-
-        <!-- TODO @芋艿:合理注释 -->
-        <!-- IoT 数据桥梁的执行器所需消息队列。如果您只需要使用 rocketmq 那么则注释掉其它消息队列即可 -->
-        <!--        <dependency>-->
-        <!--            <groupId>org.apache.rocketmq</groupId>-->
-        <!--            <artifactId>rocketmq-spring-boot-starter</artifactId>-->
-        <!--        </dependency>-->
-        <!--        <dependency>-->
-        <!--            <groupId>org.springframework.kafka</groupId>-->
-        <!--            <artifactId>spring-kafka</artifactId>-->
-        <!--        </dependency>-->
-        <!--        <dependency>-->
-        <!--            <groupId>org.springframework.boot</groupId>-->
-        <!--            <artifactId>spring-boot-starter-amqp</artifactId>-->
-        <!--        </dependency>-->
-
     </dependencies>
 
 </project>

+ 0 - 61
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/ScriptTest.java

@@ -1,61 +0,0 @@
-package cn.iocoder.yudao.module.iot;
-
-import cn.hutool.script.ScriptUtil;
-import javax.script.Bindings;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-
-/**
- * TODO 芋艿:测试脚本的接入
- */
-public class ScriptTest {
-
-    public static void main2(String[] args) {
-        // 创建一个 Groovy 脚本引擎
-        ScriptEngine engine = ScriptUtil.createGroovyEngine();
-
-        // 创建绑定参数
-        Bindings bindings = engine.createBindings();
-        bindings.put("name", "Alice");
-        bindings.put("age", 30);
-
-        // 定义一个稍微复杂的 Groovy 脚本
-        String script = "def greeting = 'Hello, ' + name + '!';\n" +
-                "def ageInFiveYears = age + 5;\n" +
-                "def message = greeting + ' In five years, you will be ' + ageInFiveYears + ' years old.';\n" +
-                "return message.toUpperCase();\n";
-
-        try {
-            // 执行脚本并获取结果
-            Object result = engine.eval(script, bindings);
-            System.out.println(result); // 输出: HELLO, ALICE! IN FIVE YEARS, YOU WILL BE 35 YEARS OLD.
-        } catch (ScriptException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void main(String[] args) {
-        // 创建一个 JavaScript 脚本引擎
-        ScriptEngine jsEngine = ScriptUtil.createJsEngine();
-
-        // 创建绑定参数
-        Bindings jsBindings = jsEngine.createBindings();
-        jsBindings.put("name", "Bob");
-        jsBindings.put("age", 25);
-
-        // 定义一个简单的 JavaScript 脚本
-        String jsScript = "var greeting = 'Hello, ' + name + '!';\n" +
-                "var ageInTenYears = age + 10;\n" +
-                "var message = greeting + ' In ten years, you will be ' + ageInTenYears + ' years old.';\n" +
-                "message.toUpperCase();\n";
-
-        try {
-            // 执行脚本并获取结果
-            Object jsResult = jsEngine.eval(jsScript, jsBindings);
-            System.out.println(jsResult); // 输出: HELLO, BOB! IN TEN YEARS, YOU WILL BE 35 YEARS OLD.
-        } catch (ScriptException e) {
-            e.printStackTrace();
-        }
-    }
-
-}

+ 0 - 78
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/api/device/IoTDeviceUpstreamApiImpl.java

@@ -1,78 +0,0 @@
-package cn.iocoder.yudao.module.iot.api.device;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.*;
-import cn.iocoder.yudao.module.iot.service.device.control.IotDeviceUpstreamService;
-import cn.iocoder.yudao.module.iot.service.plugin.IotPluginInstanceService;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-
-/**
- * * 设备数据 Upstream 上行 API 实现类
- */
-@RestController
-@Validated
-public class IoTDeviceUpstreamApiImpl implements IotDeviceUpstreamApi {
-
-    @Resource
-    private IotDeviceUpstreamService deviceUpstreamService;
-    @Resource
-    private IotPluginInstanceService pluginInstanceService;
-
-    // ========== 设备相关 ==========
-
-    @Override
-    public CommonResult<Boolean> updateDeviceState(IotDeviceStateUpdateReqDTO updateReqDTO) {
-        deviceUpstreamService.updateDeviceState(updateReqDTO);
-        return success(true);
-    }
-
-    @Override
-    public CommonResult<Boolean> reportDeviceProperty(IotDevicePropertyReportReqDTO reportReqDTO) {
-        deviceUpstreamService.reportDeviceProperty(reportReqDTO);
-        return success(true);
-    }
-
-    @Override
-    public CommonResult<Boolean> reportDeviceEvent(IotDeviceEventReportReqDTO reportReqDTO) {
-        deviceUpstreamService.reportDeviceEvent(reportReqDTO);
-        return success(true);
-    }
-
-    @Override
-    public CommonResult<Boolean> registerDevice(IotDeviceRegisterReqDTO registerReqDTO) {
-        deviceUpstreamService.registerDevice(registerReqDTO);
-        return success(true);
-    }
-
-    @Override
-    public CommonResult<Boolean> registerSubDevice(IotDeviceRegisterSubReqDTO registerReqDTO) {
-        deviceUpstreamService.registerSubDevice(registerReqDTO);
-        return success(true);
-    }
-
-    @Override
-    public CommonResult<Boolean> addDeviceTopology(IotDeviceTopologyAddReqDTO addReqDTO) {
-        deviceUpstreamService.addDeviceTopology(addReqDTO);
-        return success(true);
-    }
-
-    @Override
-    public CommonResult<Boolean> authenticateEmqxConnection(IotDeviceEmqxAuthReqDTO authReqDTO) {
-        boolean result = deviceUpstreamService.authenticateEmqxConnection(authReqDTO);
-        return success(result);
-    }
-
-    // ========== 插件相关 ==========
-
-    @Override
-    public CommonResult<Boolean> heartbeatPluginInstance(IotPluginInstanceHeartbeatReqDTO heartbeatReqDTO) {
-        pluginInstanceService.heartbeatPluginInstance(heartbeatReqDTO);
-        return success(true);
-    }
-
-}

+ 1 - 3
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java

@@ -1,6 +1,4 @@
 /**
- * 占位
- *
- * TODO 芋艿:后续删除
+ * iot API 包,定义并实现提供给其它模块的 API
  */
 package cn.iocoder.yudao.module.iot.api;

+ 0 - 75
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.http

@@ -1,75 +0,0 @@
-### 请求 /iot/device/downstream 接口(服务调用) => 成功
-POST {{baseUrl}}/iot/device/downstream
-Content-Type: application/json
-tenant-id: {{adminTenentId}}
-Authorization: Bearer {{token}}
-
-{
-  "id": 25,
-  "type": "service",
-  "identifier": "temperature",
-  "data": {
-    "xx": "yy"
-  }
-}
-
-### 请求 /iot/device/downstream 接口(属性设置) => 成功
-POST {{baseUrl}}/iot/device/downstream
-Content-Type: application/json
-tenant-id: {{adminTenentId}}
-Authorization: Bearer {{token}}
-
-{
-  "id": 25,
-  "type": "property",
-  "identifier": "set",
-  "data": {
-    "xx": "yy"
-  }
-}
-
-### 请求 /iot/device/downstream 接口(属性获取) => 成功
-POST {{baseUrl}}/iot/device/downstream
-Content-Type: application/json
-tenant-id: {{adminTenentId}}
-Authorization: Bearer {{token}}
-
-{
-  "id": 25,
-  "type": "property",
-  "identifier": "get",
-  "data": ["xx", "yy"]
-}
-
-### 请求 /iot/device/downstream 接口(配置设置) => 成功
-POST {{baseUrl}}/iot/device/downstream
-Content-Type: application/json
-tenant-id: {{adminTenentId}}
-Authorization: Bearer {{token}}
-
-{
-  "id": 25,
-  "type": "config",
-  "identifier": "set"
-}
-
-### 请求 /iot/device/downstream 接口(OTA 升级) => 成功
-POST {{baseUrl}}/iot/device/downstream
-Content-Type: application/json
-tenant-id: {{adminTenentId}}
-Authorization: Bearer {{token}}
-
-{
-  "id": 25,
-  "type": "ota",
-  "identifier": "upgrade",
-  "data": {
-    "firmwareId": 1,
-    "version": "1.0.0",
-    "signMethod": "MD5",
-    "fileSign": "d41d8cd98f00b204e9800998ecf8427e",
-    "fileSize": 1024,
-    "fileUrl": "http://example.com/firmware.bin",
-    "information": "{\"desc\":\"升级到最新版本\"}"
-  }
-}

+ 110 - 44
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java

@@ -1,20 +1,21 @@
 package cn.iocoder.yudao.module.iot.controller.admin.device;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
-import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceDownstreamReqVO;
-import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceUpstreamReqVO;
 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.*;
-import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
+import cn.iocoder.yudao.module.iot.dal.dataobject.device.NewIotDeviceDO;
+import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
-import cn.iocoder.yudao.module.iot.service.device.control.IotDeviceDownstreamService;
-import cn.iocoder.yudao.module.iot.service.device.control.IotDeviceUpstreamService;
+import cn.iocoder.yudao.module.iot.service.product.IotProductService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -25,13 +26,12 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
 
 @Tag(name = "管理后台 - IoT 设备")
 @RestController
@@ -42,9 +42,7 @@ public class IotDeviceController {
     @Resource
     private IotDeviceService deviceService;
     @Resource
-    private IotDeviceUpstreamService deviceUpstreamService;
-    @Resource
-    private IotDeviceDownstreamService deviceDownstreamService;
+    private IotProductService productService;
 
     @PostMapping("/create")
     @Operation(summary = "创建设备")
@@ -53,6 +51,7 @@ public class IotDeviceController {
         return success(deviceService.createDevice(createReqVO));
     }
 
+
     @PutMapping("/update")
     @Operation(summary = "更新设备")
     @PreAuthorize("@ss.hasPermission('iot:device:update')")
@@ -61,7 +60,57 @@ public class IotDeviceController {
         return success(true);
     }
 
-    // TODO @芋艿:参考阿里云:1)绑定网关;2)解绑网关
+    @PutMapping("/bind-gateway")
+    @Operation(summary = "绑定子设备到网关")
+    @PreAuthorize("@ss.hasPermission('iot:device:update')")
+    public CommonResult<Boolean> bindDeviceGateway(@Valid @RequestBody IotDeviceBindGatewayReqVO reqVO) {
+        deviceService.bindDeviceGateway(reqVO.getSubIds(), reqVO.getGatewayId());
+        return success(true);
+    }
+
+    @PutMapping("/unbind-gateway")
+    @Operation(summary = "解绑子设备与网关")
+    @PreAuthorize("@ss.hasPermission('iot:device:update')")
+    public CommonResult<Boolean> unbindDeviceGateway(@Valid @RequestBody IotDeviceUnbindGatewayReqVO reqVO) {
+        deviceService.unbindDeviceGateway(reqVO.getSubIds(), reqVO.getGatewayId());
+        return success(true);
+    }
+
+    @GetMapping("/sub-device-list")
+    @Operation(summary = "获取网关的子设备列表")
+    @Parameter(name = "gatewayId", description = "网关设备编号", required = true, example = "1")
+    @PreAuthorize("@ss.hasPermission('iot:device:query')")
+    public CommonResult<List<IotDeviceRespVO>> getSubDeviceList(@RequestParam("gatewayId") Long gatewayId) {
+        List<NewIotDeviceDO> list = deviceService.getDeviceListByGatewayId(gatewayId);
+        if (CollUtil.isEmpty(list)) {
+            return success(Collections.emptyList());
+        }
+
+        // 补充产品名称
+        Map<Long, IotProductDO> productMap = convertMap(productService.getProductList(), IotProductDO::getId);
+        return success(convertList(list, device -> {
+            IotDeviceRespVO respVO = BeanUtils.toBean(device, IotDeviceRespVO.class);
+            MapUtils.findAndThen(productMap, device.getProductId(),
+                    product -> respVO.setProductName(product.getName()));
+            return respVO;
+        }));
+    }
+
+    @GetMapping("/unbound-sub-device-page")
+    @Operation(summary = "获取未绑定网关的子设备分页")
+    @PreAuthorize("@ss.hasPermission('iot:device:query')")
+    public CommonResult<PageResult<IotDeviceRespVO>> getUnboundSubDevicePage(@Valid IotDevicePageReqVO pageReqVO) {
+        PageResult<NewIotDeviceDO> pageResult = deviceService.getUnboundSubDevicePage(pageReqVO);
+        if (CollUtil.isEmpty(pageResult.getList())) {
+            return success(PageResult.empty());
+        }
+
+        // 补充产品名称
+        Map<Long, IotProductDO> productMap = convertMap(productService.getProductList(), IotProductDO::getId);
+        PageResult<IotDeviceRespVO> result = BeanUtils.toBean(pageResult, IotDeviceRespVO.class, device ->
+                MapUtils.findAndThen(productMap, device.getProductId(), product -> device.setProductName(product.getName())));
+        return success(result);
+    }
 
     @PutMapping("/update-group")
     @Operation(summary = "更新设备分组")
@@ -94,7 +143,7 @@ public class IotDeviceController {
     @Parameter(name = "id", description = "编号", required = true, example = "1024")
     @PreAuthorize("@ss.hasPermission('iot:device:query')")
     public CommonResult<IotDeviceRespVO> getDevice(@RequestParam("id") Long id) {
-        IotDeviceDO device = deviceService.getDevice(id);
+        NewIotDeviceDO device = deviceService.getDevice(id);
         return success(BeanUtils.toBean(device, IotDeviceRespVO.class));
     }
 
@@ -102,7 +151,7 @@ public class IotDeviceController {
     @Operation(summary = "获得设备分页")
     @PreAuthorize("@ss.hasPermission('iot:device:query')")
     public CommonResult<PageResult<IotDeviceRespVO>> getDevicePage(@Valid IotDevicePageReqVO pageReqVO) {
-        PageResult<IotDeviceDO> pageResult = deviceService.getDevicePage(pageReqVO);
+        PageResult<NewIotDeviceDO> pageResult = deviceService.getDevicePage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class));
     }
 
@@ -111,7 +160,7 @@ public class IotDeviceController {
     @PreAuthorize("@ss.hasPermission('iot:device:export')")
     @ApiAccessLog(operateType = EXPORT)
     public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO,
-            HttpServletResponse response) throws IOException {
+                                  HttpServletResponse response) throws IOException {
         exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
         CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO);
         // 导出 Excel
@@ -129,12 +178,37 @@ public class IotDeviceController {
 
     @GetMapping("/simple-list")
     @Operation(summary = "获取设备的精简信息列表", description = "主要用于前端的下拉选项")
-    @Parameter(name = "deviceType", description = "设备类型", example = "1")
-    public CommonResult<List<IotDeviceRespVO>> getSimpleDeviceList(
-            @RequestParam(value = "deviceType", required = false) Integer deviceType) {
-        List<IotDeviceDO> list = deviceService.getDeviceListByDeviceType(deviceType);
-        return success(convertList(list, device ->  // 只返回 id、name 字段
-                new IotDeviceRespVO().setId(device.getId()).setDeviceName(device.getDeviceName())));
+    @Parameters({
+            @Parameter(name = "deviceType", description = "设备类型", example = "1"),
+            @Parameter(name = "productId", description = "产品编号", example = "1024")
+    })
+    public CommonResult<List<IotDeviceRespVO>> getDeviceSimpleList(
+            @RequestParam(value = "deviceType", required = false) Integer deviceType,
+            @RequestParam(value = "productId", required = false) Long productId) {
+        List<NewIotDeviceDO> list = deviceService.getDeviceListByCondition(deviceType, productId);
+        return success(convertList(list, device ->  // 只返回 id、name、productId 字段
+                new IotDeviceRespVO().setId(device.getId()).setDeviceName(device.getDeviceName())
+                        .setProductId(device.getProductId()).setState(device.getState())));
+    }
+
+    @GetMapping("/location-list")
+    @Operation(summary = "获取设备位置列表", description = "获取有经纬度信息的设备列表,用于地图展示")
+    @PreAuthorize("@ss.hasPermission('iot:device:query')")
+    public CommonResult<List<IotDeviceRespVO>> getDeviceLocationList() {
+        // 1. 获取有位置信息的设备列表
+        List<NewIotDeviceDO> devices = deviceService.getDeviceListByHasLocation();
+        if (CollUtil.isEmpty(devices)) {
+            return success(Collections.emptyList());
+        }
+
+        // 2. 转换并返回
+        Map<Long, IotProductDO> productMap = convertMap(productService.getProductList(), IotProductDO::getId);
+        return success(convertList(devices, device -> {
+            IotDeviceRespVO respVO = BeanUtils.toBean(device, IotDeviceRespVO.class);
+            MapUtils.findAndThen(productMap, device.getProductId(),
+                    product -> respVO.setProductName(product.getName()));
+            return respVO;
+        }));
     }
 
     @PostMapping("/import")
@@ -155,34 +229,26 @@ public class IotDeviceController {
         List<IotDeviceImportExcelVO> list = Arrays.asList(
                 IotDeviceImportExcelVO.builder().deviceName("温度传感器001").parentDeviceName("gateway110")
                         .productKey("1de24640dfe").groupNames("灰度分组,生产分组").build(),
-                IotDeviceImportExcelVO.builder().deviceName("biubiu")
-                        .productKey("YzvHxd4r67sT4s2B").groupNames("").build());
+                IotDeviceImportExcelVO.builder().deviceName("biubiu").productKey("YzvHxd4r67sT4s2B")
+                        .groupNames("").build());
         // 输出
         ExcelUtils.write(response, "设备导入模板.xls", "数据", IotDeviceImportExcelVO.class, list);
     }
 
-    @PostMapping("/upstream")
-    @Operation(summary = "设备上行", description = "可用于设备模拟")
-    @PreAuthorize("@ss.hasPermission('iot:device:upstream')")
-    public CommonResult<Boolean> upstreamDevice(@Valid @RequestBody IotDeviceUpstreamReqVO upstreamReqVO) {
-        deviceUpstreamService.upstreamDevice(upstreamReqVO);
-        return success(true);
+    @GetMapping("/get-auth-info")
+    @Operation(summary = "获得设备连接信息")
+    @PreAuthorize("@ss.hasPermission('iot:device:auth-info')")
+    public CommonResult<IotDeviceAuthInfoRespVO> getDeviceAuthInfo(@RequestParam("id") Long id) {
+        return success(deviceService.getDeviceAuthInfo(id));
     }
 
-    @PostMapping("/downstream")
-    @Operation(summary = "设备下行", description = "可用于设备模拟")
-    @PreAuthorize("@ss.hasPermission('iot:device:downstream')")
-    public CommonResult<Boolean> downstreamDevice(@Valid @RequestBody IotDeviceDownstreamReqVO downstreamReqVO) {
-        deviceDownstreamService.downstreamDevice(downstreamReqVO);
-        return success(true);
-    }
-
-    // TODO @haohao:是不是默认详情接口,不返回 secret,然后这个接口,用于统一返回。然后接口名可以更通用一点。
-    @GetMapping("/mqtt-connection-params")
-    @Operation(summary = "获取 MQTT 连接参数")
-    @PreAuthorize("@ss.hasPermission('iot:device:mqtt-connection-params')")
-    public CommonResult<IotDeviceMqttConnectionParamsRespVO> getMqttConnectionParams(@RequestParam("deviceId") Long deviceId) {
-        return success(deviceService.getMqttConnectionParams(deviceId));
+    // TODO @haohao:可以使用 @RequestParam("productKey") String productKey, @RequestParam("deviceNames") List<String> deviceNames 来接收哇?
+    @GetMapping("/list-by-product-key-and-names")
+    @Operation(summary = "通过产品标识和设备名称列表获取设备")
+    @PreAuthorize("@ss.hasPermission('iot:device:query')")
+    public CommonResult<List<IotDeviceRespVO>> getDevicesByProductKeyAndNames(@Valid IotDeviceByProductKeyAndNamesReqVO reqVO) {
+        List<NewIotDeviceDO> devices = deviceService.getDeviceListByProductKeyAndNames(reqVO.getProductKey(), reqVO.getDeviceNames());
+        return success(BeanUtils.toBean(devices, IotDeviceRespVO.class));
     }
 
-}
+}

+ 0 - 40
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceLogController.java

@@ -1,40 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDeviceLogPageReqVO;
-import cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDeviceLogRespVO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO;
-import cn.iocoder.yudao.module.iot.service.device.data.IotDeviceLogService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "管理后台 - IoT 设备日志")
-@RestController
-@RequestMapping("/iot/device/log")
-@Validated
-public class IotDeviceLogController {
-
-    @Resource
-    private IotDeviceLogService deviceLogService;
-
-    @GetMapping("/page")
-    @Operation(summary = "获得设备日志分页")
-    @PreAuthorize("@ss.hasPermission('iot:device:log-query')")
-    public CommonResult<PageResult<IotDeviceLogRespVO>> getDeviceLogPage(@Valid IotDeviceLogPageReqVO pageReqVO) {
-        PageResult<IotDeviceLogDO> pageResult = deviceLogService.getDeviceLogPage(pageReqVO);
-        return success(BeanUtils.toBean(pageResult, IotDeviceLogRespVO.class));
-    }
-
-}

+ 37 - 43
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDevicePropertyController.java

@@ -1,22 +1,21 @@
 package cn.iocoder.yudao.module.iot.controller.admin.device;
 
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.LocalDateTimeUtil;
 import cn.hutool.core.lang.Assert;
-import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDevicePropertyHistoryPageReqVO;
-import cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDevicePropertyRespVO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
+import cn.iocoder.yudao.module.iot.controller.admin.device.vo.property.IotDevicePropertyDetailRespVO;
+import cn.iocoder.yudao.module.iot.controller.admin.device.vo.property.IotDevicePropertyHistoryListReqVO;
+import cn.iocoder.yudao.module.iot.controller.admin.device.vo.property.IotDevicePropertyRespVO;
+import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.model.ThingModelProperty;
+import cn.iocoder.yudao.module.iot.dal.dataobject.device.NewIotDeviceDO;
 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDevicePropertyDO;
 import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO;
+import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum;
 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
-import cn.iocoder.yudao.module.iot.service.device.data.IotDevicePropertyService;
+import cn.iocoder.yudao.module.iot.service.device.property.IotDevicePropertyService;
 import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.Parameters;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -46,50 +45,45 @@ public class IotDevicePropertyController {
     @Resource
     private IotDeviceService deviceService;
 
-    @GetMapping("/latest")
+    @GetMapping("/get-latest")
     @Operation(summary = "获取设备属性最新属性")
-    @Parameters({
-            @Parameter(name = "deviceId", description = "设备编号", required = true),
-            @Parameter(name = "identifier", description = "标识符"),
-            @Parameter(name = "name", description = "名称")
-    })
+    @Parameter(name = "deviceId", description = "设备编号", required = true)
     @PreAuthorize("@ss.hasPermission('iot:device:property-query')")
-    public CommonResult<List<IotDevicePropertyRespVO>> getLatestDeviceProperties(
-            @RequestParam("deviceId") Long deviceId,
-            @RequestParam(value = "identifier", required = false) String identifier,
-            @RequestParam(value = "name", required = false) String name) {
+    public CommonResult<List<IotDevicePropertyDetailRespVO>> getLatestDeviceProperties(
+            @RequestParam("deviceId") Long deviceId) {
+        // 1.1 获取设备信息
+        NewIotDeviceDO device = deviceService.getDevice(deviceId);
+        Assert.notNull(device, "设备不存在");
+        // 1.2 获取设备最新属性
         Map<String, IotDevicePropertyDO> properties = devicePropertyService.getLatestDeviceProperties(deviceId);
+        // 1.3 根据 productId + type 查询属性类型的物模型
+        List<IotThingModelDO> thingModels = thingModelService.getThingModelListByProductIdAndType(
+                device.getProductId(), IotThingModelTypeEnum.PROPERTY.getType());
 
-        // 拼接数据
-        IotDeviceDO device = deviceService.getDevice(deviceId);
-        Assert.notNull(device, "设备不存在");
-        List<IotThingModelDO> thingModels = thingModelService.getThingModelListByProductId(device.getProductId());
-        return success(convertList(properties.entrySet(), entry -> {
-            IotThingModelDO thingModel = CollUtil.findOne(thingModels,
-                    item -> item.getIdentifier().equals(entry.getKey()));
-            if (thingModel == null || thingModel.getProperty() == null) {
-                return null;
-            }
-            if (StrUtil.isNotEmpty(identifier) && !StrUtil.contains(thingModel.getIdentifier(), identifier)) {
-                return null;
-            }
-            if (StrUtil.isNotEmpty(name) && !StrUtil.contains(thingModel.getName(), name)) {
-                return null;
+        // 2. 基于 thingModels 遍历,拼接 properties
+        return success(convertList(thingModels, thingModel -> {
+            ThingModelProperty thingModelProperty = thingModel.getProperty();
+            Assert.notNull(thingModelProperty, "属性不能为空");
+            IotDevicePropertyDetailRespVO result = new IotDevicePropertyDetailRespVO()
+                    .setName(thingModel.getName()).setDataType(thingModelProperty.getDataType())
+                    .setDataSpecs(thingModelProperty.getDataSpecs())
+                    .setDataSpecsList(thingModelProperty.getDataSpecsList());
+            result.setIdentifier(thingModel.getIdentifier());
+            IotDevicePropertyDO property = properties.get(thingModel.getIdentifier());
+            if (property != null) {
+                result.setValue(property.getValue())
+                        .setUpdateTime(LocalDateTimeUtil.toEpochMilli(property.getUpdateTime()));
             }
-            // 构建对象
-            IotDevicePropertyDO property = entry.getValue();
-            return new IotDevicePropertyRespVO().setProperty(thingModel.getProperty())
-                    .setValue(property.getValue()).setUpdateTime(LocalDateTimeUtil.toEpochMilli(property.getUpdateTime()));
+            return result;
         }));
     }
 
-    @GetMapping("/history-page")
-    @Operation(summary = "获取设备属性历史数据")
+    @GetMapping("/history-list")
+    @Operation(summary = "获取设备属性历史数据列表")
     @PreAuthorize("@ss.hasPermission('iot:device:property-query')")
-    public CommonResult<PageResult<IotDevicePropertyRespVO>> getHistoryDevicePropertyPage(
-            @Valid IotDevicePropertyHistoryPageReqVO pageReqVO) {
-        Assert.notEmpty(pageReqVO.getIdentifier(), "标识符不能为空");
-        return success(devicePropertyService.getHistoryDevicePropertyPage(pageReqVO));
+    public CommonResult<List<IotDevicePropertyRespVO>> getHistoryDevicePropertyList(
+            @Valid IotDevicePropertyHistoryListReqVO listReqVO) {
+        return success(devicePropertyService.getHistoryDevicePropertyList(listReqVO));
     }
 
 }

+ 7 - 7
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceGroupController.java → yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/NewIotDeviceGroupController.java

@@ -7,8 +7,8 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.group.IotDeviceGroupPageReqVO;
 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.group.IotDeviceGroupRespVO;
 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.group.IotDeviceGroupSaveReqVO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceGroupDO;
-import cn.iocoder.yudao.module.iot.service.device.IotDeviceGroupService;
+import cn.iocoder.yudao.module.iot.dal.dataobject.device.NewIotDeviceGroupDO;
+import cn.iocoder.yudao.module.iot.service.device.NewIotDeviceGroupService;
 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -28,10 +28,10 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
 @RestController
 @RequestMapping("/iot/device-group")
 @Validated
-public class IotDeviceGroupController {
+public class NewIotDeviceGroupController {
 
     @Resource
-    private IotDeviceGroupService deviceGroupService;
+    private NewIotDeviceGroupService deviceGroupService;
     @Resource
     private IotDeviceService deviceService;
 
@@ -64,7 +64,7 @@ public class IotDeviceGroupController {
     @Parameter(name = "id", description = "编号", required = true, example = "1024")
     @PreAuthorize("@ss.hasPermission('iot:device-group:query')")
     public CommonResult<IotDeviceGroupRespVO> getDeviceGroup(@RequestParam("id") Long id) {
-        IotDeviceGroupDO deviceGroup = deviceGroupService.getDeviceGroup(id);
+        NewIotDeviceGroupDO deviceGroup = deviceGroupService.getDeviceGroup(id);
         return success(BeanUtils.toBean(deviceGroup, IotDeviceGroupRespVO.class));
     }
 
@@ -72,7 +72,7 @@ public class IotDeviceGroupController {
     @Operation(summary = "获得设备分组分页")
     @PreAuthorize("@ss.hasPermission('iot:device-group:query')")
     public CommonResult<PageResult<IotDeviceGroupRespVO>> getDeviceGroupPage(@Valid IotDeviceGroupPageReqVO pageReqVO) {
-        PageResult<IotDeviceGroupDO> pageResult = deviceGroupService.getDeviceGroupPage(pageReqVO);
+        PageResult<NewIotDeviceGroupDO> pageResult = deviceGroupService.getDeviceGroupPage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, IotDeviceGroupRespVO.class,
                 group -> group.setDeviceCount(deviceService.getDeviceCountByGroupId(group.getId()))));
     }
@@ -80,7 +80,7 @@ public class IotDeviceGroupController {
     @GetMapping("/simple-list")
     @Operation(summary = "获取设备分组的精简信息列表", description = "只包含被开启的分组,主要用于前端的下拉选项")
     public CommonResult<List<IotDeviceGroupRespVO>> getSimpleDeviceGroupList() {
-        List<IotDeviceGroupDO> list = deviceGroupService.getDeviceGroupListByStatus(CommonStatusEnum.ENABLE.getStatus());
+        List<NewIotDeviceGroupDO> list = deviceGroupService.getDeviceGroupListByStatus(CommonStatusEnum.ENABLE.getStatus());
         return success(convertList(list, group -> // 只返回 id、name 字段
                 new IotDeviceGroupRespVO().setId(group.getId()).setName(group.getName())));
     }

+ 0 - 31
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceDownstreamReqVO.java

@@ -1,31 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device.vo.control;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.enums.device.IotDeviceMessageTypeEnum;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-
-@Schema(description = "管理后台 - IoT 设备下行 Request VO") // 服务调用、属性设置、属性获取等
-@Data
-public class IotDeviceDownstreamReqVO {
-
-    @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
-    @NotNull(message = "设备编号不能为空")
-    private Long id;
-
-    @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "property")
-    @NotEmpty(message = "消息类型不能为空")
-    @InEnum(IotDeviceMessageTypeEnum.class)
-    private String type;
-
-    @Schema(description = "标识符", requiredMode = Schema.RequiredMode.REQUIRED, example = "report")
-    @NotEmpty(message = "标识符不能为空")
-    private String identifier; // 参见 IotDeviceMessageIdentifierEnum 枚举类
-
-    @Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
-    private Object data; // 例如说:服务调用的 params、属性设置的 properties
-
-}

+ 0 - 31
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceUpstreamReqVO.java

@@ -1,31 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device.vo.control;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.enums.device.IotDeviceMessageTypeEnum;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-
-@Schema(description = "管理后台 - IoT 设备上行 Request VO") // 属性上报、事件上报、状态变更等
-@Data
-public class IotDeviceUpstreamReqVO {
-
-    @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
-    @NotNull(message = "设备编号不能为空")
-    private Long id;
-
-    @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "property")
-    @NotEmpty(message = "消息类型不能为空")
-    @InEnum(IotDeviceMessageTypeEnum.class)
-    private String type;
-
-    @Schema(description = "标识符", requiredMode = Schema.RequiredMode.REQUIRED, example = "report")
-    @NotEmpty(message = "标识符不能为空")
-    private String identifier; // 参见 IotDeviceMessageIdentifierEnum 枚举类
-
-    @Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
-    private Object data; // 例如说:属性上报的 properties、事件上报的 params
-
-}

+ 0 - 23
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDeviceLogPageReqVO.java

@@ -1,23 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device.vo.data;
-
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-
-@Schema(description = "管理后台 - IoT 设备日志分页查询 Request VO")
-@Data
-public class IotDeviceLogPageReqVO extends PageParam {
-
-    @Schema(description = "设备标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123")
-    @NotEmpty(message = "设备标识不能为空")
-    private String deviceKey;
-
-    @Schema(description = "消息类型", example = "property")
-    private String type; // 参见 IotDeviceMessageTypeEnum 枚举,精准匹配
-
-    @Schema(description = "标识符", example = "temperature")
-    private String identifier; // 参见 IotDeviceMessageIdentifierEnum 枚举,模糊匹配
-
-}

+ 0 - 36
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDeviceLogRespVO.java

@@ -1,36 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device.vo.data;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.time.LocalDateTime;
-
-@Schema(description = "管理后台 - IoT 设备日志 Response VO")
-@Data
-public class IotDeviceLogRespVO {
-
-    @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
-    private String id;
-
-    @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "product123")
-    private String productKey;
-
-    @Schema(description = "设备标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "device123")
-    private String deviceKey;
-
-    @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "property")
-    private String type;
-
-    @Schema(description = "标识符", requiredMode = Schema.RequiredMode.REQUIRED, example = "temperature")
-    private String identifier;
-
-    @Schema(description = "日志内容", requiredMode = Schema.RequiredMode.REQUIRED)
-    private String content;
-
-    @Schema(description = "上报时间", requiredMode = Schema.RequiredMode.REQUIRED)
-    private LocalDateTime reportTime;
-
-    @Schema(description = "记录时间戳", requiredMode = Schema.RequiredMode.REQUIRED)
-    private LocalDateTime ts;
-
-}

+ 0 - 35
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDevicePropertyHistoryPageReqVO.java

@@ -1,35 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device.vo.data;
-
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import java.time.LocalDateTime;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-@Schema(description = "管理后台 - IoT 设备属性历史分页 Request VO")
-@Data
-public class IotDevicePropertyHistoryPageReqVO extends PageParam {
-
-    @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
-    @NotNull(message = "设备编号不能为空")
-    private Long deviceId;
-
-    @Schema(description = "设备 Key", hidden = true)
-    private String deviceKey; // 非前端传递,后端自己查询设置
-
-    @Schema(description = "属性标识符", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotEmpty(message = "属性标识符不能为空")
-    private String identifier;
-
-    @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    @Size(min = 2, max = 2, message = "请选择时间范围")
-    private LocalDateTime[] times;
-
-}

+ 0 - 20
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/data/IotDevicePropertyRespVO.java

@@ -1,20 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device.vo.data;
-
-import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelProperty;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-@Schema(description = "管理后台 - IoT 设备属性 Response VO")
-@Data
-public class IotDevicePropertyRespVO {
-
-    @Schema(description = "属性定义", requiredMode = Schema.RequiredMode.REQUIRED)
-    private ThingModelProperty property;
-
-    @Schema(description = "最新值", requiredMode = Schema.RequiredMode.REQUIRED)
-    private Object value;
-
-    @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
-    private Long updateTime; // 由于从 TDengine 查询出来的是 Long 类型,所以这里也使用 Long 类型
-
-}

+ 1 - 3
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceImportExcelVO.java

@@ -6,7 +6,6 @@ import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
-import lombok.experimental.Accessors;
 
 import javax.validation.constraints.NotEmpty;
 
@@ -17,7 +16,6 @@ import javax.validation.constraints.NotEmpty;
 @Builder
 @AllArgsConstructor
 @NoArgsConstructor
-@Accessors(chain = false) // 设置 chain = false,避免设备导入有问题
 public class IotDeviceImportExcelVO {
 
     @ExcelProperty("设备名称")
@@ -35,4 +33,4 @@ public class IotDeviceImportExcelVO {
     @ExcelProperty("设备分组")
     private String groupNames;
 
-}
+}

+ 0 - 25
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceMqttConnectionParamsRespVO.java

@@ -1,25 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
-
-import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
-import com.alibaba.excel.annotation.ExcelProperty;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-@Schema(description = "管理后台 - IoT 设备 MQTT 连接参数 Response VO")
-@Data
-@ExcelIgnoreUnannotated
-public class IotDeviceMqttConnectionParamsRespVO {
-
-    @Schema(description = "MQTT 客户端 ID", example = "24602")
-    @ExcelProperty("MQTT 客户端 ID")
-    private String mqttClientId;
-
-    @Schema(description = "MQTT 用户名", example = "芋艿")
-    @ExcelProperty("MQTT 用户名")
-    private String mqttUsername;
-
-    @Schema(description = "MQTT 密码")
-    @ExcelProperty("MQTT 密码")
-    private String mqttPassword;
-
-}

+ 4 - 1
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDevicePageReqVO.java

@@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
 
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStateEnum;
+import cn.iocoder.yudao.module.iot.core.enums.device.IotDeviceStateEnum;
 import cn.iocoder.yudao.module.iot.enums.product.IotProductDeviceTypeEnum;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -31,4 +31,7 @@ public class IotDevicePageReqVO extends PageParam {
     @Schema(description = "设备分组编号", example = "1024")
     private Long groupId;
 
+    @Schema(description = "网关设备 ID", example = "16380")
+    private Long gatewayId;
+
 }

+ 12 - 10
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceRespVO.java

@@ -1,12 +1,13 @@
 package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
 
-import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
-import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.Set;
 
@@ -20,10 +21,6 @@ public class IotDeviceRespVO {
     @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
     private Long id;
 
-    @Schema(description = "设备唯一标识符", requiredMode = Schema.RequiredMode.REQUIRED)
-    @ExcelProperty("设备唯一标识符")
-    private String deviceKey;
-
     @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
     @ExcelProperty("设备名称")
     private String deviceName;
@@ -47,6 +44,9 @@ public class IotDeviceRespVO {
     @ExcelProperty("产品编号")
     private Long productId;
 
+    @Schema(description = "产品名称", example = "温湿度传感器")
+    private String productName; // 只有部分接口返回,例如 getDeviceLocationList
+
     @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("产品 Key")
     private String productKey;
@@ -79,13 +79,15 @@ public class IotDeviceRespVO {
     @ExcelProperty("设备密钥")
     private String deviceSecret;
 
-    @Schema(description = "认证类型(如一机一密、动态注册)", example = "2")
-    @ExcelProperty("认证类型(如一机一密、动态注册)")
-    private String authType;
-
     @Schema(description = "设备配置", example = "{\"abc\": \"efg\"}")
     private String config;
 
+    @Schema(description = "设备位置的纬度", example = "45.000000")
+    private BigDecimal latitude;
+
+    @Schema(description = "设备位置的经度", example = "45.000000")
+    private BigDecimal longitude;
+
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;

+ 13 - 5
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceSaveReqVO.java

@@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import javax.validation.constraints.Size;
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+import java.math.BigDecimal;
 import java.util.Set;
 
 @Schema(description = "管理后台 - IoT 设备新增/修改 Request VO")
@@ -13,10 +15,6 @@ public class IotDeviceSaveReqVO {
     @Schema(description = "设备编号", example = "177")
     private Long id;
 
-    @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.AUTO, example = "177")
-    @Size(max = 50, message = "设备编号长度不能超过 50 个字符")
-    private String deviceKey;
-
     @Schema(description = "设备名称", requiredMode = Schema.RequiredMode.AUTO, example = "王五")
     private String deviceName;
 
@@ -41,4 +39,14 @@ public class IotDeviceSaveReqVO {
     @Schema(description = "设备配置", example = "{\"abc\": \"efg\"}")
     private String config;
 
+    @Schema(description = "设备位置的纬度", example = "39.915")
+    @DecimalMin(value = "-90", message = "纬度范围为 -90 到 90")
+    @DecimalMax(value = "90", message = "纬度范围为 -90 到 90")
+    private BigDecimal latitude;
+
+    @Schema(description = "设备位置的经度", example = "116.404")
+    @DecimalMin(value = "-180", message = "经度范围为 -180 到 180")
+    @DecimalMax(value = "180", message = "经度范围为 -180 到 180")
+    private BigDecimal longitude;
+
 }

+ 15 - 3
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/IotOtaFirmwareController.java

@@ -8,7 +8,9 @@ import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwa
 import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareRespVO;
 import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareUpdateReqVO;
 import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
+import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
 import cn.iocoder.yudao.module.iot.service.ota.IotOtaFirmwareService;
+import cn.iocoder.yudao.module.iot.service.product.IotProductService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -22,12 +24,14 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
 @Tag(name = "管理后台 - IoT OTA 固件")
 @RestController
-@RequestMapping("/iot/ota-firmware")
+@RequestMapping("/iot/ota/firmware")
 @Validated
 public class IotOtaFirmwareController {
 
     @Resource
     private IotOtaFirmwareService otaFirmwareService;
+    @Resource
+    private IotProductService productService;
 
     @PostMapping("/create")
     @Operation(summary = "创建 OTA 固件")
@@ -48,8 +52,16 @@ public class IotOtaFirmwareController {
     @Operation(summary = "获得 OTA 固件")
     @PreAuthorize("@ss.hasPermission('iot:ota-firmware:query')")
     public CommonResult<IotOtaFirmwareRespVO> getOtaFirmware(@RequestParam("id") Long id) {
-        IotOtaFirmwareDO otaFirmware = otaFirmwareService.getOtaFirmware(id);
-        return success(BeanUtils.toBean(otaFirmware, IotOtaFirmwareRespVO.class));
+        IotOtaFirmwareDO firmware = otaFirmwareService.getOtaFirmware(id);
+        if (firmware == null) {
+            return success(null);
+        }
+        return success(BeanUtils.toBean(firmware, IotOtaFirmwareRespVO.class, o -> {
+            IotProductDO product = productService.getProduct(firmware.getProductId());
+            if (product != null) {
+                o.setProductName(product.getName());
+            }
+        }));
     }
 
     @GetMapping("/page")

+ 0 - 75
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/IotOtaUpgradeRecordController.java

@@ -1,75 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.ota;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.record.IotOtaUpgradeRecordPageReqVO;
-import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.record.IotOtaUpgradeRecordRespVO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaUpgradeRecordDO;
-import cn.iocoder.yudao.module.iot.service.ota.IotOtaUpgradeRecordService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.Map;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "管理后台 - IoT OTA 升级记录")
-@RestController
-@RequestMapping("/iot/ota-upgrade-record")
-@Validated
-public class IotOtaUpgradeRecordController {
-
-    @Resource
-    private IotOtaUpgradeRecordService upgradeRecordService;
-
-    @GetMapping("/get-statistics")
-    @Operation(summary = "固件升级设备统计")
-    @PreAuthorize("@ss.hasPermission('iot:ota-upgrade-record:query')")
-    @Parameter(name = "firmwareId", description = "固件编号", required = true, example = "1024")
-    public CommonResult<Map<Integer, Long>> getOtaUpgradeRecordStatistics(@RequestParam(value = "firmwareId") Long firmwareId) {
-        return success(upgradeRecordService.getOtaUpgradeRecordStatistics(firmwareId));
-    }
-
-    @GetMapping("/get-count")
-    @Operation(summary = "获得升级记录分页 tab 数量")
-    @PreAuthorize("@ss.hasPermission('iot:ota-upgrade-record:query')")
-    public CommonResult<Map<Integer, Long>> getOtaUpgradeRecordCount(
-            @Valid IotOtaUpgradeRecordPageReqVO pageReqVO) {
-        return success(upgradeRecordService.getOtaUpgradeRecordCount(pageReqVO));
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得升级记录分页")
-    @PreAuthorize("@ss.hasPermission('iot:ota-upgrade-record:query')")
-    public CommonResult<PageResult<IotOtaUpgradeRecordRespVO>> getUpgradeRecordPage(
-            @Valid IotOtaUpgradeRecordPageReqVO pageReqVO) {
-        PageResult<IotOtaUpgradeRecordDO> pageResult = upgradeRecordService.getUpgradeRecordPage(pageReqVO);
-        return success(BeanUtils.toBean(pageResult, IotOtaUpgradeRecordRespVO.class));
-    }
-
-    @GetMapping("/get")
-    @Operation(summary = "获得升级记录")
-    @PreAuthorize("@ss.hasPermission('iot:ota-upgrade-record:query')")
-    @Parameter(name = "id", description = "升级记录编号", required = true, example = "1024")
-    public CommonResult<IotOtaUpgradeRecordRespVO> getUpgradeRecord(@RequestParam("id") Long id) {
-        IotOtaUpgradeRecordDO upgradeRecord = upgradeRecordService.getUpgradeRecord(id);
-        return success(BeanUtils.toBean(upgradeRecord, IotOtaUpgradeRecordRespVO.class));
-    }
-
-    @PutMapping("/retry")
-    @Operation(summary = "重试升级记录")
-    @PreAuthorize("@ss.hasPermission('iot:ota-upgrade-record:retry')")
-    @Parameter(name = "id", description = "升级记录编号", required = true, example = "1024")
-    public CommonResult<Boolean> retryUpgradeRecord(@RequestParam("id") Long id) {
-        upgradeRecordService.retryUpgradeRecord(id);
-        return success(true);
-    }
-
-}

+ 0 - 65
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/IotOtaUpgradeTaskController.java

@@ -1,65 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.ota;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.task.IotOtaUpgradeTaskPageReqVO;
-import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.task.IotOtaUpgradeTaskRespVO;
-import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.task.IotOtaUpgradeTaskSaveReqVO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaUpgradeTaskDO;
-import cn.iocoder.yudao.module.iot.service.ota.IotOtaUpgradeTaskService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "管理后台 - IoT OTA 升级任务")
-@RestController
-@RequestMapping("/iot/ota-upgrade-task")
-@Validated
-public class IotOtaUpgradeTaskController {
-
-    @Resource
-    private IotOtaUpgradeTaskService upgradeTaskService;
-
-    @PostMapping("/create")
-    @Operation(summary = "创建升级任务")
-    @PreAuthorize(value = "@ss.hasPermission('iot:ota-upgrade-task:create')")
-    public CommonResult<Long> createUpgradeTask(@Valid @RequestBody IotOtaUpgradeTaskSaveReqVO createReqVO) {
-        return success(upgradeTaskService.createUpgradeTask(createReqVO));
-    }
-
-    @PostMapping("/cancel")
-    @Operation(summary = "取消升级任务")
-    @Parameter(name = "id", description = "升级任务编号", required = true)
-    @PreAuthorize(value = "@ss.hasPermission('iot:ota-upgrade-task:cancel')")
-    public CommonResult<Boolean> cancelUpgradeTask(@RequestParam("id") Long id) {
-        upgradeTaskService.cancelUpgradeTask(id);
-        return success(true);
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得升级任务分页")
-    @PreAuthorize(value = "@ss.hasPermission('iot:ota-upgrade-task:query')")
-    public CommonResult<PageResult<IotOtaUpgradeTaskRespVO>> getUpgradeTaskPage(@Valid IotOtaUpgradeTaskPageReqVO pageReqVO) {
-        PageResult<IotOtaUpgradeTaskDO> pageResult = upgradeTaskService.getUpgradeTaskPage(pageReqVO);
-        return success(BeanUtils.toBean(pageResult, IotOtaUpgradeTaskRespVO.class));
-    }
-
-    @GetMapping("/get")
-    @Operation(summary = "获得升级任务")
-    @Parameter(name = "id", description = "升级任务编号", required = true, example = "1024")
-    @PreAuthorize(value = "@ss.hasPermission('iot:ota-upgrade-task:query')")
-    public CommonResult<IotOtaUpgradeTaskRespVO> getUpgradeTask(@RequestParam("id") Long id) {
-        IotOtaUpgradeTaskDO upgradeTask = upgradeTaskService.getUpgradeTask(id);
-        return success(BeanUtils.toBean(upgradeTask, IotOtaUpgradeTaskRespVO.class));
-    }
-
-}

+ 7 - 14
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwareCreateReqVO.java

@@ -2,40 +2,33 @@ package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
+import org.hibernate.validator.constraints.URL;
 
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
-
 @Schema(description = "管理后台 - IoT OTA 固件创建 Request VO")
 @Data
 public class IotOtaFirmwareCreateReqVO {
 
-    @Schema(description = "固件名称", requiredMode = REQUIRED, example = "智能开关固件")
+    @Schema(description = "固件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "智能开关固件")
     @NotEmpty(message = "固件名称不能为空")
     private String name;
 
     @Schema(description = "固件描述", example = "某品牌型号固件,测试用")
     private String description;
 
-    @Schema(description = "版本号", requiredMode = REQUIRED, example = "1.0.0")
+    @Schema(description = "版本号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0.0")
     @NotEmpty(message = "版本号不能为空")
     private String version;
 
-    @Schema(description = "产品编号", requiredMode = REQUIRED, example = "1024")
+    @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
     @NotNull(message = "产品编号不能为空")
-    private String productId;
-
-    @Schema(description = "签名方式", example = "MD5")
-    // TODO @li:是不是必传哈
-    private String signMethod;
+    private Long productId;
 
-    @Schema(description = "固件文件 URL", requiredMode = REQUIRED, example = "https://www.iocoder.cn/yudao-firmware.zip")
+    @Schema(description = "固件文件 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.zip")
     @NotEmpty(message = "固件文件 URL 不能为空")
+    @URL(message = "固件文件 URL 格式错误")
     private String fileUrl;
 
-    @Schema(description = "自定义信息,建议使用 JSON 格式", example = "{\"key1\":\"value1\",\"key2\":\"value2\"}")
-    private String information;
-
 }

+ 10 - 7
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwarePageReqVO.java

@@ -3,21 +3,24 @@ package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 
-@Data
 @Schema(description = "管理后台 - IoT OTA 固件分页 Request VO")
+@Data
 public class IotOtaFirmwarePageReqVO extends PageParam {
 
-    /**
-     * 固件名称
-     */
     @Schema(description = "固件名称", example = "智能开关固件")
     private String name;
 
-    /**
-     * 产品标识
-     */
     @Schema(description = "产品标识", example = "1024")
     private String productId;
 
+    @Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
 }

+ 29 - 65
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwareRespVO.java

@@ -1,85 +1,49 @@
 package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware;
 
-import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
-import com.fhs.core.trans.anno.Trans;
-import com.fhs.core.trans.constant.TransType;
 import com.fhs.core.trans.vo.VO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
+import java.time.LocalDateTime;
 
-@Data
 @Schema(description = "管理后台 - IoT OTA 固件 Response VO")
+@Data
 public class IotOtaFirmwareRespVO implements VO {
 
-    /**
-     * 固件编号
-     */
-    @Schema(description = "固件编号", requiredMode = REQUIRED, example = "1024")
+    @Schema(description = "固件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
     private Long id;
-    /**
-     * 固件名称
-     */
-    @Schema(description = "固件名称", requiredMode = REQUIRED, example = "OTA固件")
+
+    @Schema(description = "固件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "OTA 固件")
     private String name;
-    /**
-     * 固件描述
-     */
+
     @Schema(description = "固件描述")
     private String description;
-    /**
-     * 版本号
-     */
-    @Schema(description = "版本号", requiredMode = REQUIRED, example = "1.0.0")
+
+    @Schema(description = "版本号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0.0")
     private String version;
 
-    /**
-     * 产品编号
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getId()}
-     */
-    @Schema(description = "产品编号", requiredMode = REQUIRED, example = "1024")
-    @Trans(type = TransType.SIMPLE, target = IotProductDO.class, fields = {"name"}, refs = {"productName"})
-    private String productId;
-    /**
-     * 产品标识
-     * <p>
-     * 冗余 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getProductKey()}
-     */
-    @Schema(description = "产品标识", requiredMode = REQUIRED, example = "iot-product-key")
-    private String productKey;
-    /**
-     * 产品名称
-     */
-    @Schema(description = "产品名称", requiredMode = REQUIRED, example = "OTA产品")
+    @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
+    private Long productId;
+
+    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "智能设备")
     private String productName;
-    /**
-     * 签名方式
-     * <p>
-     * 例如说:MD5、SHA256
-     */
-    @Schema(description = "签名方式", example = "MD5")
-    private String signMethod;
-    /**
-     * 固件文件签名
-     */
-    @Schema(description = "固件文件签名", example = "1024")
-    private String fileSign;
-    /**
-     * 固件文件大小
-     */
-    @Schema(description = "固件文件大小", requiredMode = REQUIRED, example = "1024")
-    private Long fileSize;
-    /**
-     * 固件文件 URL
-     */
-    @Schema(description = "固件文件 URL", requiredMode = REQUIRED, example = "https://www.iocoder.cn")
+
+    @Schema(description = "固件文件 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/firmware.bin")
     private String fileUrl;
-    /**
-     * 自定义信息,建议使用 JSON 格式
-     */
-    @Schema(description = "自定义信息,建议使用 JSON 格式")
-    private String information;
+
+    @Schema(description = "固件文件大小", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
+    private Long fileSize;
+
+    @Schema(description = "固件文件签名算法", example = "MD5")
+    private String fileDigestAlgorithm;
+
+    @Schema(description = "固件文件签名结果", example = "d41d8cd98f00b204e9800998ecf8427e")
+    private String fileDigestValue;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    private LocalDateTime createTime;
+
+    @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    private LocalDateTime updateTime;
 
 }

+ 2 - 7
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/firmware/IotOtaFirmwareUpdateReqVO.java

@@ -3,22 +3,17 @@ package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
-
 @Schema(description = "管理后台 - IoT OTA 固件更新 Request VO")
 @Data
 public class IotOtaFirmwareUpdateReqVO {
 
-    @Schema(description = "固件编号", requiredMode = REQUIRED, example = "1024")
+    @Schema(description = "固件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
     @NotNull(message = "固件编号不能为空")
     private Long id;
 
-    // TODO @li:name 是不是可以飞必传哈
-    @Schema(description = "固件名称", requiredMode = REQUIRED, example = "智能开关固件")
-    @NotEmpty(message = "固件名称不能为空")
+    @Schema(description = "固件名称", example = "智能开关固件")
     private String name;
 
     @Schema(description = "固件描述", example = "某品牌型号固件,测试用")

+ 0 - 33
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/record/IotOtaUpgradeRecordPageReqVO.java

@@ -1,33 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.record;
-
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
-
-@Data
-@Schema(description = "管理后台 - IoT OTA 升级记录分页 Request VO")
-public class IotOtaUpgradeRecordPageReqVO extends PageParam {
-
-    // TODO @li:已经有注解,不用重复注释
-    /**
-     * 升级任务编号字段。
-     * <p>
-     * 该字段用于标识升级任务的唯一编号,不能为空。
-     */
-    @Schema(description = "升级任务编号", requiredMode = REQUIRED, example = "1024")
-    @NotNull(message = "升级任务编号不能为空")
-    private Long taskId;
-
-    /**
-     * 设备标识字段。
-     * <p>
-     * 该字段用于标识设备的名称,通常用于区分不同的设备。
-     */
-    @Schema(description = "设备标识", requiredMode = REQUIRED, example = "摄像头A1-1")
-    private String deviceName;
-
-}

+ 0 - 109
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/record/IotOtaUpgradeRecordRespVO.java

@@ -1,109 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.record;
-
-import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaUpgradeTaskDO;
-import com.fhs.core.trans.anno.Trans;
-import com.fhs.core.trans.constant.TransType;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.time.LocalDateTime;
-
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
-
-@Data
-@Schema(description = "管理后台 - IoT OTA 升级记录 Response VO")
-public class IotOtaUpgradeRecordRespVO {
-
-    /**
-     * 升级记录编号
-     */
-    @Schema(description = "升级记录编号", requiredMode = REQUIRED, example = "1024")
-    private Long id;
-    /**
-     * 固件编号
-     * <p>
-     * 关联 {@link IotOtaFirmwareDO#getId()}
-     */
-    @Schema(description = "固件编号", requiredMode = REQUIRED, example = "1024")
-    @Trans(type = TransType.SIMPLE, target = IotOtaFirmwareDO.class, fields = {"version"}, refs = {"firmwareVersion"})
-    private Long firmwareId;
-    /**
-     * 固件版本
-     */
-    @Schema(description = "固件版本", requiredMode = REQUIRED, example = "v1.0.0")
-    private String firmwareVersion;
-    /**
-     * 任务编号
-     * <p>
-     * 关联 {@link IotOtaUpgradeTaskDO#getId()}
-     */
-    @Schema(description = "任务编号", requiredMode = REQUIRED, example = "1024")
-    private Long taskId;
-    /**
-     * 产品标识
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getId()}
-     */
-    @Schema(description = "产品标识", requiredMode = REQUIRED, example = "iot")
-    private String productKey;
-    /**
-     * 设备名称
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO#getId()}
-     */
-    @Schema(description = "设备名称", requiredMode = REQUIRED, example = "iot")
-    private String deviceName;
-    /**
-     * 设备编号
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO#getId()}
-     */
-    @Schema(description = "设备编号", requiredMode = REQUIRED, example = "1024")
-    private String deviceId;
-    /**
-     * 来源的固件编号
-     * <p>
-     * 关联 {@link IotDeviceDO#getFirmwareId()}
-     */
-    @Schema(description = "来源的固件编号", requiredMode = REQUIRED, example = "1024")
-    @Trans(type = TransType.SIMPLE, target = IotOtaFirmwareDO.class, fields = {"version"}, refs = {"fromFirmwareVersion"})
-    private Long fromFirmwareId;
-    /**
-     * 来源的固件版本
-     */
-    @Schema(description = "来源的固件版本", requiredMode = REQUIRED, example = "v1.0.0")
-    private String fromFirmwareVersion;
-    /**
-     * 升级状态
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeRecordStatusEnum}
-     */
-    @Schema(description = "升级状态", requiredMode = REQUIRED, allowableValues = {"0", "10", "20", "30", "40", "50"})
-    private Integer status;
-    /**
-     * 升级进度,百分比
-     */
-    @Schema(description = "升级进度,百分比", requiredMode = REQUIRED, example = "10")
-    private Integer progress;
-    /**
-     * 升级进度描述
-     * <p>
-     * 注意,只记录设备最后一次的升级进度描述
-     * 如果想看历史记录,可以查看 {@link cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO} 设备日志
-     */
-    @Schema(description = "升级进度描述", requiredMode = REQUIRED, example = "10")
-    private String description;
-    /**
-     * 升级开始时间
-     */
-    @Schema(description = "升级开始时间", requiredMode = REQUIRED, example = "2022-07-08 07:30:00")
-    private LocalDateTime startTime;
-    /**
-     * 升级结束时间
-     */
-    @Schema(description = "升级结束时间", requiredMode = REQUIRED, example = "2022-07-08 07:30:00")
-    private LocalDateTime endTime;
-
-}

+ 0 - 28
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/task/IotOtaUpgradeTaskPageReqVO.java

@@ -1,28 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.task;
-
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
-
-@Data
-@Schema(description = "管理后台 - IoT OTA 升级任务分页 Request VO")
-public class IotOtaUpgradeTaskPageReqVO extends PageParam {
-
-    /**
-     * 任务名称字段,用于描述任务的名称
-     */
-    @Schema(description = "任务名称", example = "升级任务")
-    private String name;
-
-    /**
-     * 固件编号字段,用于唯一标识固件,不能为空
-     */
-    @NotNull(message = "固件编号不能为空")
-    @Schema(description = "固件编号", requiredMode = REQUIRED, example = "1024")
-    private Long firmwareId;
-
-}

+ 0 - 84
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/task/IotOtaUpgradeTaskRespVO.java

@@ -1,84 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.task;
-
-import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
-import com.fhs.core.trans.vo.VO;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.time.LocalDateTime;
-import java.util.List;
-
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
-
-@Data
-@Schema(description = "管理后台 - IoT OTA 升级任务 Response VO")
-public class IotOtaUpgradeTaskRespVO implements VO {
-
-    /**
-     * 任务编号
-     */
-    @Schema(description = "任务编号", requiredMode = REQUIRED, example = "1024")
-    private Long id;
-    /**
-     * 任务名称
-     */
-    @Schema(description = "任务名称", requiredMode = REQUIRED, example = "升级任务")
-    private String name;
-    /**
-     * 任务描述
-     */
-    @Schema(description = "任务描述", example = "升级任务")
-    private String description;
-    /**
-     * 固件编号
-     * <p>
-     * 关联 {@link IotOtaFirmwareDO#getId()}
-     */
-    @Schema(description = "固件编号", requiredMode = REQUIRED, example = "1024")
-    private Long firmwareId;
-    /**
-     * 任务状态
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeTaskStatusEnum}
-     */
-    @Schema(description = "任务状态", requiredMode = REQUIRED, allowableValues = {"10", "20", "21", "30"})
-    private Integer status;
-    /**
-     * 任务状态名称
-     */
-    @Schema(description = "任务状态名称", requiredMode = REQUIRED, example = "进行中")
-    private String statusName;
-    /**
-     * 升级范围
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeTaskScopeEnum}
-     */
-    @Schema(description = "升级范围", requiredMode = REQUIRED, allowableValues = {"1", "2"})
-    private Integer scope;
-    /**
-     * 设备数量
-     */
-    @Schema(description = "设备数量", requiredMode = REQUIRED, example = "1024")
-    private Long deviceCount;
-    /**
-     * 选中的设备编号数组
-     * <p>
-     * 关联 {@link IotDeviceDO#getId()}
-     */
-    @Schema(description = "选中的设备编号数组", example = "1024")
-    private List<Long> deviceIds;
-    /**
-     * 选中的设备名字数组
-     * <p>
-     * 关联 {@link IotDeviceDO#getDeviceName()}
-     */
-    @Schema(description = "选中的设备名字数组", example = "1024")
-    private List<String> deviceNames;
-    /**
-     * 创建时间
-     */
-    @Schema(description = "创建时间", requiredMode = REQUIRED, example = "2022-07-08 07:30:00")
-    private LocalDateTime createTime;
-
-}

+ 0 - 63
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/ota/vo/upgrade/task/IotOtaUpgradeTaskSaveReqVO.java

@@ -1,63 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.upgrade.task;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
-import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
-import cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeTaskScopeEnum;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import java.util.List;
-
-import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
-
-@Data
-@Schema(description = "管理后台 - IoT OTA 升级任务创建/修改 Request VO")
-public class IotOtaUpgradeTaskSaveReqVO {
-
-    // TODO @li:已经有注解,不用重复注释
-    // TODO @li: @Schema 写在参数校验前面。先有定义;其他的,也检查下;
-
-    /**
-     * 任务名称
-     */
-    @NotEmpty(message = "任务名称不能为空")
-    @Schema(description = "任务名称", requiredMode = REQUIRED, example = "升级任务")
-    private String name;
-
-    /**
-     * 任务描述
-     */
-    @Schema(description = "任务描述", example = "升级任务")
-    private String description;
-
-    /**
-     * 固件编号
-     * <p>
-     * 关联 {@link IotOtaFirmwareDO#getId()}
-     */
-    @NotNull(message = "固件编号不能为空")
-    @Schema(description = "固件编号", requiredMode = REQUIRED, example = "1024")
-    private Long firmwareId;
-
-    /**
-     * 升级范围
-     * <p>
-     * 关联 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeTaskScopeEnum}
-     */
-    @NotNull(message = "升级范围不能为空")
-    @InEnum(value = IotOtaUpgradeTaskScopeEnum.class)
-    @Schema(description = "升级范围", requiredMode = REQUIRED, example = "1")
-    private Integer scope;
-
-    /**
-     * 选中的设备编号数组
-     * <p>
-     * 关联 {@link IotDeviceDO#getId()}
-     */
-    @Schema(description = "选中的设备编号数组", requiredMode = REQUIRED, example = "[1,2,3,4]")
-    private List<Long> deviceIds;
-
-}

+ 0 - 87
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/PluginConfigController.java

@@ -1,87 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.config.*;
-import cn.iocoder.yudao.module.iot.dal.dataobject.plugin.IotPluginConfigDO;
-import cn.iocoder.yudao.module.iot.service.plugin.IotPluginConfigService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-
-@Tag(name = "管理后台 - IoT 插件配置")
-@RestController
-@RequestMapping("/iot/plugin-config")
-@Validated
-public class PluginConfigController {
-
-    @Resource
-    private IotPluginConfigService pluginConfigService;
-
-    @PostMapping("/create")
-    @Operation(summary = "创建插件配置")
-    @PreAuthorize("@ss.hasPermission('iot:plugin-config:create')")
-    public CommonResult<Long> createPluginConfig(@Valid @RequestBody PluginConfigSaveReqVO createReqVO) {
-        return success(pluginConfigService.createPluginConfig(createReqVO));
-    }
-
-    @PutMapping("/update")
-    @Operation(summary = "更新插件配置")
-    @PreAuthorize("@ss.hasPermission('iot:plugin-config:update')")
-    public CommonResult<Boolean> updatePluginConfig(@Valid @RequestBody PluginConfigSaveReqVO updateReqVO) {
-        pluginConfigService.updatePluginConfig(updateReqVO);
-        return success(true);
-    }
-
-    @DeleteMapping("/delete")
-    @Operation(summary = "删除插件配置")
-    @Parameter(name = "id", description = "编号", required = true)
-    @PreAuthorize("@ss.hasPermission('iot:plugin-config:delete')")
-    public CommonResult<Boolean> deletePluginConfig(@RequestParam("id") Long id) {
-        pluginConfigService.deletePluginConfig(id);
-        return success(true);
-    }
-
-    @GetMapping("/get")
-    @Operation(summary = "获得插件配置")
-    @Parameter(name = "id", description = "编号", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('iot:plugin-config:query')")
-    public CommonResult<PluginConfigRespVO> getPluginConfig(@RequestParam("id") Long id) {
-        IotPluginConfigDO pluginConfig = pluginConfigService.getPluginConfig(id);
-        return success(BeanUtils.toBean(pluginConfig, PluginConfigRespVO.class));
-    }
-
-    @GetMapping("/page")
-    @Operation(summary = "获得插件配置分页")
-    @PreAuthorize("@ss.hasPermission('iot:plugin-config:query')")
-    public CommonResult<PageResult<PluginConfigRespVO>> getPluginConfigPage(@Valid PluginConfigPageReqVO pageReqVO) {
-        PageResult<IotPluginConfigDO> pageResult = pluginConfigService.getPluginConfigPage(pageReqVO);
-        return success(BeanUtils.toBean(pageResult, PluginConfigRespVO.class));
-    }
-
-    @PostMapping("/upload-file")
-    @Operation(summary = "上传插件文件")
-    @PreAuthorize("@ss.hasPermission('iot:plugin-config:update')")
-    public CommonResult<Boolean> uploadFile(@Valid PluginConfigImportReqVO reqVO) {
-        pluginConfigService.uploadFile(reqVO.getId(), reqVO.getFile());
-        return success(true);
-    }
-
-    @PutMapping("/update-status")
-    @Operation(summary = "修改插件状态")
-    @PreAuthorize("@ss.hasPermission('iot:plugin-config:update')")
-    public CommonResult<Boolean> updatePluginConfigStatus(@Valid @RequestBody PluginConfigStatusReqVO reqVO) {
-        pluginConfigService.updatePluginStatus(reqVO.getId(), reqVO.getStatus());
-        return success(true);
-    }
-
-}

+ 0 - 20
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigImportReqVO.java

@@ -1,20 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.config;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.validation.constraints.NotNull;
-
-@Schema(description = "管理后台 - IoT 插件上传 Request VO")
-@Data
-public class PluginConfigImportReqVO {
-
-    @Schema(description = "主键 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11546")
-    private Long id;
-
-    @Schema(description = "插件文件", requiredMode = Schema.RequiredMode.REQUIRED)
-    @NotNull(message = "插件文件不能为空")
-    private MultipartFile file;
-
-}

+ 0 - 20
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigPageReqVO.java

@@ -1,20 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.config;
-
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginStatusEnum;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-@Schema(description = "管理后台 - IoT 插件配置分页 Request VO")
-@Data
-public class PluginConfigPageReqVO extends PageParam {
-
-    @Schema(description = "插件名称", example = "http")
-    private String name;
-
-    @Schema(description = "状态", example = "1")
-    @InEnum(IotPluginStatusEnum.class)
-    private Integer status;
-
-}

+ 0 - 54
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigRespVO.java

@@ -1,54 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.config;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.time.LocalDateTime;
-
-@Schema(description = "管理后台 - IoT 插件配置 Response VO")
-@Data
-public class PluginConfigRespVO {
-
-    @Schema(description = "主键 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11546")
-    private Long id;
-
-    @Schema(description = "插件包标识符", requiredMode = Schema.RequiredMode.REQUIRED, example = "24627")
-    private String pluginKey;
-
-    @Schema(description = "插件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
-    private String name;
-
-    @Schema(description = "描述", example = "你猜")
-    private String description;
-
-    @Schema(description = "部署方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
-    private Integer deployType;
-
-    @Schema(description = "插件包文件名", requiredMode = Schema.RequiredMode.REQUIRED)
-    private String fileName;
-
-    @Schema(description = "插件版本", requiredMode = Schema.RequiredMode.REQUIRED)
-    private String version;
-
-    @Schema(description = "插件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
-    private Integer type;
-
-    @Schema(description = "设备插件协议类型")
-    private String protocol;
-
-    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
-    private Integer status;
-
-    @Schema(description = "插件配置项描述信息")
-    private String configSchema;
-
-    @Schema(description = "插件配置信息")
-    private String config;
-
-    @Schema(description = "插件脚本")
-    private String script;
-
-    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
-    private LocalDateTime createTime;
-
-}

+ 0 - 56
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigSaveReqVO.java

@@ -1,56 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.config;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginStatusEnum;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-@Schema(description = "管理后台 - IoT 插件配置新增/修改 Request VO")
-@Data
-public class PluginConfigSaveReqVO {
-
-    // TODO @haohao:新增的字段有点多,每个都需要哇?
-
-    // TODO @haohao:一些枚举字段,需要加枚举校验。例如说,deployType、status、type 等
-
-    @Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11546")
-    private Long id;
-
-    @Schema(description = "插件包标识符", requiredMode = Schema.RequiredMode.REQUIRED, example = "24627")
-    private String pluginKey;
-
-    @Schema(description = "插件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
-    private String name;
-
-    @Schema(description = "描述", example = "你猜")
-    private String description;
-
-    @Schema(description = "部署方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
-    private Integer deployType;
-
-    @Schema(description = "插件包文件名", requiredMode = Schema.RequiredMode.REQUIRED)
-    private String fileName;
-
-    @Schema(description = "插件版本", requiredMode = Schema.RequiredMode.REQUIRED)
-    private String version;
-
-    @Schema(description = "插件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
-    private Integer type;
-
-    @Schema(description = "设备插件协议类型")
-    private String protocol;
-
-    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
-    @InEnum(IotPluginStatusEnum.class)
-    private Integer status;
-
-    @Schema(description = "插件配置项描述信息")
-    private String configSchema;
-
-    @Schema(description = "插件配置信息")
-    private String config;
-
-    @Schema(description = "插件脚本")
-    private String script;
-
-}

+ 0 - 19
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/config/PluginConfigStatusReqVO.java

@@ -1,19 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.config;
-
-import cn.iocoder.yudao.framework.common.validation.InEnum;
-import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginStatusEnum;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-@Schema(description = "管理后台 - IoT 插件配置状态 Request VO")
-@Data
-public class PluginConfigStatusReqVO {
-
-    @Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11546")
-    private Long id;
-
-    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
-    @InEnum(IotPluginStatusEnum.class)
-    private Integer status;
-
-}

+ 0 - 35
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/instance/PluginInstancePageReqVO.java

@@ -1,35 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.instance;
-
-import lombok.*;
-import io.swagger.v3.oas.annotations.media.Schema;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import org.springframework.format.annotation.DateTimeFormat;
-import java.time.LocalDateTime;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-// TODO @haohao:后续需要使用下
-@Schema(description = "管理后台 - IoT 插件实例分页 Request VO")
-@Data
-public class PluginInstancePageReqVO extends PageParam {
-
-    @Schema(description = "插件主程序编号", example = "23738")
-    private String mainId;
-
-    @Schema(description = "插件id", example = "26498")
-    private Long pluginId;
-
-    @Schema(description = "插件主程序所在ip")
-    private String ip;
-
-    @Schema(description = "插件主程序端口")
-    private Integer port;
-
-    @Schema(description = "心跳时间,心路时间超过30秒需要剔除")
-    private Long heartbeatAt;
-
-    @Schema(description = "创建时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private LocalDateTime[] createTime;
-
-}

+ 0 - 34
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/instance/PluginInstanceRespVO.java

@@ -1,34 +0,0 @@
-package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.instance;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.time.LocalDateTime;
-
-// TODO @haohao:后续需要使用下
-@Schema(description = "管理后台 - IoT 插件实例 Response VO")
-@Data
-public class PluginInstanceRespVO {
-
-    @Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23864")
-    private Long id;
-
-    @Schema(description = "插件主程序id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23738")
-    private String mainId;
-
-    @Schema(description = "插件id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26498")
-    private Long pluginId;
-
-    @Schema(description = "插件主程序所在ip", requiredMode = Schema.RequiredMode.REQUIRED)
-    private String ip;
-
-    @Schema(description = "插件主程序端口", requiredMode = Schema.RequiredMode.REQUIRED)
-    private Integer port;
-
-    @Schema(description = "心跳时间,心路时间超过30秒需要剔除", requiredMode = Schema.RequiredMode.REQUIRED)
-    private Long heartbeatAt;
-
-    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
-    private LocalDateTime createTime;
-
-}

+ 38 - 5
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/IotProductController.java

@@ -22,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.annotation.security.PermitAll;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
@@ -84,6 +85,27 @@ public class IotProductController {
     @PreAuthorize("@ss.hasPermission('iot:product:query')")
     public CommonResult<IotProductRespVO> getProduct(@RequestParam("id") Long id) {
         IotProductDO product = productService.getProduct(id);
+        if (product == null) {
+            return success(null);
+        }
+        // 拼接数据
+        IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
+        return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
+            if (category != null) {
+                bean.setCategoryName(category.getName());
+            }
+        }));
+    }
+
+    @GetMapping("/get-by-key")
+    @Operation(summary = "通过 ProductKey 获得产品")
+    @Parameter(name = "productKey", description = "产品Key", required = true, example = "abc123")
+    @PreAuthorize("@ss.hasPermission('iot:product:query')")
+    public CommonResult<IotProductRespVO> getProductByKey(@RequestParam("productKey") String productKey) {
+        IotProductDO product = productService.getProductByProductKey(productKey);
+        if (product == null) {
+            return success(null);
+        }
         // 拼接数据
         IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
         return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
@@ -120,13 +142,24 @@ public class IotProductController {
                 result.getData().getList());
     }
 
+    @PostMapping("/sync-property-table")
+    @Operation(summary = "同步产品属性表结构到 TDengine")
+//    @PreAuthorize("@ss.hasPermission('iot:product:update')")
+    @PermitAll
+    public CommonResult<Boolean> syncProductPropertyTable() {
+        productService.syncProductPropertyTable();
+        return success(true);
+    }
+
     @GetMapping("/simple-list")
     @Operation(summary = "获取产品的精简信息列表", description = "主要用于前端的下拉选项")
-    public CommonResult<List<IotProductRespVO>> getSimpleProductList() {
-        List<IotProductDO> list = productService.getProductList();
-        return success(convertList(list, product -> // 只返回 id、name 字段
-                new IotProductRespVO().setId(product.getId()).setName(product.getName())
-                        .setDeviceType(product.getDeviceType())));
+    @Parameter(name = "deviceType", description = "设备类型", example = "1")
+    public CommonResult<List<IotProductRespVO>> getProductSimpleList(
+            @RequestParam(value = "deviceType", required = false) Integer deviceType) {
+        List<IotProductDO> list = productService.getProductList(deviceType);
+        return success(convertList(list, product -> // 只返回 id、name、productKey 字段
+                new IotProductRespVO().setId(product.getId()).setName(product.getName()).setStatus(product.getStatus())
+                        .setDeviceType(product.getDeviceType()).setProductKey(product.getProductKey())));
     }
 
 }

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini