Pārlūkot izejas kodu

!25 openapi模块接口更新推送
Merge pull request !25 from sawyer/dev-V0.4.5

花木水之间 1 gadu atpakaļ
vecāks
revīzija
0ee18ff030
16 mainītis faili ar 379 papildinājumiem un 159 dzēšanām
  1. 245 135
      data/init/sys_role_menu.json
  2. 35 0
      iot-common/iot-common-dao/iot-common-model/src/main/java/cc/iotkit/model/device/message/DevicePropertyCache.java
  3. 6 0
      iot-common/iot-common-dao/iot-common-model/src/main/java/cc/iotkit/model/product/ThingModel.java
  4. 4 1
      iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/DevicePropertyDataImpl.java
  5. 8 4
      iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/DevicePropertyDataImpl.java
  6. 8 2
      iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java
  7. 2 2
      iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/controller/IotContributorController.java
  8. 7 1
      iot-module/iot-openapi/pom.xml
  9. 1 1
      iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/bo/device/OpenapiSetDeviceServicePropertyBo.java
  10. 3 4
      iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/vo/OpenDevicePropertyVo.java
  11. 37 0
      iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/vo/OpenPropertyVo.java
  12. 1 1
      iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/OpenDeviceService.java
  13. 0 2
      iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenBaseServiceImpl.java
  14. 19 6
      iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenDeviceServiceImpl.java
  15. 3 0
      iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java
  16. BIN
      微信图片_20230710205406.jpg

+ 245 - 135
data/init/sys_role_menu.json

@@ -1,412 +1,522 @@
  [
-
     {
-      "id": 429541652308037,
-      "menuId": 1,
+      "id": 445326475956293,
+      "menuId": 2200,
       "roleId": 2
     },
     {
-      "id": 429541652308038,
-      "menuId": 100,
+      "id": 445326475956294,
+      "menuId": 2201,
       "roleId": 2
     },
     {
-      "id": 429541652308039,
-      "menuId": 101,
+      "id": 445326475956295,
+      "menuId": 2205,
       "roleId": 2
     },
     {
-      "id": 429541652308040,
-      "menuId": 102,
+      "id": 445326475956296,
+      "menuId": 2206,
       "roleId": 2
     },
     {
-      "id": 429541652308041,
-      "menuId": 103,
+      "id": 445326475956297,
+      "menuId": 2207,
       "roleId": 2
     },
     {
-      "id": 429541652308042,
-      "menuId": 104,
+      "id": 445326475956298,
+      "menuId": 2225,
       "roleId": 2
     },
     {
-      "id": 429541652308043,
-      "menuId": 105,
+      "id": 445326475956299,
+      "menuId": 2208,
       "roleId": 2
     },
     {
-      "id": 429541652308044,
-      "menuId": 106,
+      "id": 445326475956300,
+      "menuId": 2209,
       "roleId": 2
     },
     {
-      "id": 429541652308045,
-      "menuId": 107,
+      "id": 445326475956301,
+      "menuId": 2210,
       "roleId": 2
     },
     {
-      "id": 429541652308046,
-      "menuId": 108,
+      "id": 445326475956302,
+      "menuId": 2211,
       "roleId": 2
     },
     {
-      "id": 429541652308047,
-      "menuId": 500,
+      "id": 445326475956303,
+      "menuId": 2212,
       "roleId": 2
     },
     {
-      "id": 429541652308048,
-      "menuId": 501,
+      "id": 445326475956304,
+      "menuId": 2213,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956305,
+      "menuId": 2218,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956306,
+      "menuId": 2219,
       "roleId": 2
     },
     {
-      "id": 429541652308049,
+      "id": 445326475956307,
+      "menuId": 2221,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956308,
+      "menuId": 2223,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956309,
+      "menuId": 2,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956310,
+      "menuId": 109,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956311,
+      "menuId": 1,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956312,
+      "menuId": 100,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956313,
       "menuId": 1001,
       "roleId": 2
     },
     {
-      "id": 429541652308050,
+      "id": 445326475956314,
       "menuId": 1002,
       "roleId": 2
     },
     {
-      "id": 429541652308051,
+      "id": 445326475956315,
       "menuId": 1005,
       "roleId": 2
     },
     {
-      "id": 429541652312133,
+      "id": 445326475956316,
+      "menuId": 101,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956317,
       "menuId": 1008,
       "roleId": 2
     },
     {
-      "id": 429541652312134,
+      "id": 445326475956318,
       "menuId": 1009,
       "roleId": 2
     },
     {
-      "id": 429541652312135,
+      "id": 445326475956319,
+      "menuId": 102,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956320,
       "menuId": 1013,
       "roleId": 2
     },
     {
-      "id": 429541652312136,
+      "id": 445326475956321,
       "menuId": 1014,
       "roleId": 2
     },
     {
-      "id": 429541652312137,
+      "id": 445326475956322,
+      "menuId": 103,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956323,
       "menuId": 1017,
       "roleId": 2
     },
     {
-      "id": 429541652312138,
+      "id": 445326475956324,
       "menuId": 1018,
       "roleId": 2
     },
     {
-      "id": 429541652312139,
+      "id": 445326475956325,
+      "menuId": 104,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956326,
       "menuId": 1021,
       "roleId": 2
     },
     {
-      "id": 429541652312140,
+      "id": 445326475956327,
       "menuId": 1022,
       "roleId": 2
     },
     {
-      "id": 429541652312141,
+      "id": 445326475956328,
       "menuId": 1023,
       "roleId": 2
     },
     {
-      "id": 429541652312142,
+      "id": 445326475956329,
+      "menuId": 105,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956330,
       "menuId": 1026,
       "roleId": 2
     },
     {
-      "id": 429541652312143,
+      "id": 445326475956331,
       "menuId": 1027,
       "roleId": 2
     },
     {
-      "id": 429541652312144,
+      "id": 445326475956332,
+      "menuId": 106,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956333,
       "menuId": 1031,
       "roleId": 2
     },
     {
-      "id": 429541652312145,
+      "id": 445326475956334,
       "menuId": 1032,
       "roleId": 2
     },
     {
-      "id": 429541652312146,
+      "id": 445326475956335,
       "menuId": 1035,
       "roleId": 2
     },
     {
-      "id": 429541652312147,
+      "id": 445326475956336,
+      "menuId": 107,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956337,
       "menuId": 1036,
       "roleId": 2
     },
     {
-      "id": 429541652312148,
+      "id": 445326475956338,
       "menuId": 1037,
       "roleId": 2
     },
     {
-      "id": 429541652312149,
+      "id": 445326475956339,
+      "menuId": 108,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956340,
+      "menuId": 500,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956341,
       "menuId": 1040,
       "roleId": 2
     },
     {
-      "id": 429541652312150,
+      "id": 445326475956342,
       "menuId": 1042,
       "roleId": 2
     },
     {
-      "id": 429541652312151,
+      "id": 445326475956343,
+      "menuId": 501,
+      "roleId": 2
+    },
+    {
+      "id": 445326475956344,
       "menuId": 1043,
       "roleId": 2
     },
     {
-      "id": 429541652312152,
+      "id": 445326475956345,
       "menuId": 1045,
       "roleId": 2
     },
     {
-      "id": 429541652312153,
+      "id": 445326475956346,
       "menuId": 118,
       "roleId": 2
     },
     {
-      "id": 429541652312154,
+      "id": 445326475956347,
       "menuId": 1600,
       "roleId": 2
     },
     {
-      "id": 429541652312155,
+      "id": 445326475956348,
       "menuId": 1601,
       "roleId": 2
     },
     {
-      "id": 429541652312156,
+      "id": 445326475956349,
       "menuId": 1602,
       "roleId": 2
     },
     {
-      "id": 429541652312157,
+      "id": 445326475956350,
       "menuId": 1603,
       "roleId": 2
     },
     {
-      "id": 429541652312158,
+      "id": 445326475956351,
       "menuId": 1604,
       "roleId": 2
     },
     {
-      "id": 429541652312159,
+      "id": 445326475960389,
       "menuId": 1605,
       "roleId": 2
     },
     {
-      "id": 429541652312160,
-      "menuId": 2200,
+      "id": 445326475960390,
+      "menuId": 441851175424069,
       "roleId": 2
     },
     {
-      "id": 429541652312161,
-      "menuId": 2201,
+      "id": 445326475960391,
+      "menuId": 2214,
       "roleId": 2
     },
     {
-      "id": 429541652312162,
-      "menuId": 2214,
+      "id": 445326475960392,
+      "menuId": 441853056651333,
       "roleId": 2
     },
     {
-      "id": 429541652312163,
-      "menuId": 2205,
+      "id": 445326475960393,
+      "menuId": 441853220675653,
       "roleId": 2
     },
     {
-      "id": 429541652312164,
-      "menuId": 2206,
+      "id": 445326475960394,
+      "menuId": 441862877970501,
       "roleId": 2
     },
     {
-      "id": 429541652312165,
-      "menuId": 2207,
+      "id": 445326475960395,
+      "menuId": 441869217525829,
       "roleId": 2
     },
     {
-      "id": 429541652312166,
-      "menuId": 2215,
+      "id": 445326475960396,
+      "menuId": 441869327724613,
       "roleId": 2
     },
     {
-      "id": 429541652312167,
-      "menuId": 2208,
+      "id": 445326475960397,
+      "menuId": 441869649666117,
       "roleId": 2
     },
     {
-      "id": 429541652312168,
-      "menuId": 2209,
+      "id": 445326475960398,
+      "menuId": 441869802405957,
       "roleId": 2
     },
     {
-      "id": 429541652312169,
-      "menuId": 2210,
+      "id": 445326475960399,
+      "menuId": 441870007808069,
       "roleId": 2
     },
     {
-      "id": 429541652312170,
-      "menuId": 2211,
+      "id": 445326475960400,
+      "menuId": 441870091001925,
       "roleId": 2
     },
     {
-      "id": 429541652312171,
-      "menuId": 2212,
+      "id": 445326475960401,
+      "menuId": 441870607315013,
       "roleId": 2
     },
     {
-      "id": 429541652312172,
-      "menuId": 2213,
+      "id": 445326475960402,
+      "menuId": 441870717771845,
       "roleId": 2
     },
     {
-      "id": 429541652312173,
-      "menuId": 2216,
+      "id": 445326475960403,
+      "menuId": 441870780928069,
       "roleId": 2
     },
     {
-      "id": 429541652312174,
-      "menuId": 2217,
+      "id": 445326475960404,
+      "menuId": 2215,
       "roleId": 2
     },
     {
-      "id": 429541652312175,
-      "menuId": 2218,
+      "id": 445326475960405,
+      "menuId": 2224,
       "roleId": 2
     },
     {
-      "id": 429541652312176,
-      "menuId": 2219,
+      "id": 445326475960406,
+      "menuId": 442149490409541,
       "roleId": 2
     },
     {
-      "id": 429541652312177,
-      "menuId": 2220,
+      "id": 445326475960407,
+      "menuId": 442149580529733,
       "roleId": 2
     },
     {
-      "id": 429541652312178,
-      "menuId": 2221,
+      "id": 445326475960408,
+      "menuId": 442149811572805,
       "roleId": 2
     },
     {
-      "id": 429541652312179,
-      "menuId": 2222,
+      "id": 445326475960409,
+      "menuId": 442127879118917,
       "roleId": 2
     },
     {
-      "id": 429541652312180,
-      "menuId": 2223,
+      "id": 445326475960410,
+      "menuId": 442127985041477,
       "roleId": 2
     },
     {
-      "id": 429541652312181,
-      "menuId": 2,
+      "id": 445326475960411,
+      "menuId": 442127357415493,
       "roleId": 2
     },
     {
-      "id": 429541652312182,
-      "menuId": 109,
+      "id": 445326475960412,
+      "menuId": 442127596064837,
       "roleId": 2
     },
     {
-      "id": 429541652312183,
-      "menuId": 1046,
+      "id": 445326475960413,
+      "menuId": 442128593006661,
       "roleId": 2
     },
     {
-      "id": 429541652312184,
-      "menuId": 1047,
+      "id": 445326475960414,
+      "menuId": 442129175347269,
       "roleId": 2
     },
     {
-      "id": 429541652312185,
-      "menuId": 1048,
+      "id": 445326475960415,
+      "menuId": 2216,
       "roleId": 2
     },
     {
-      "id": 429541652312186,
-      "menuId": 113,
+      "id": 445326475960416,
+      "menuId": 2217,
       "roleId": 2
     },
     {
-      "id": 429541652312187,
-      "menuId": 117,
+      "id": 445326475960417,
+      "menuId": 442130419388485,
       "roleId": 2
     },
     {
-      "id": 429541652312188,
-      "menuId": 120,
+      "id": 445326475960418,
+      "menuId": 442143693541445,
       "roleId": 2
     },
     {
-      "id": 429541652312189,
-      "menuId": 3,
+      "id": 445326475960419,
+      "menuId": 2220,
+      "roleId": 2
+    },
+    {
+      "id": 445326475960420,
+      "menuId": 2222,
+      "roleId": 2
+    },
+    {
+      "id": 445326475960421,
+      "menuId": 442131294584901,
+      "roleId": 2
+    },
+    {
+      "id": 445326475960422,
+      "menuId": 442130860195909,
+      "roleId": 2
+    },
+    {
+      "id": 445326475960423,
+      "menuId": 442130932109381,
       "roleId": 2
     },
     {
-      "id": 429541652312190,
-      "menuId": 114,
+      "id": 445326475960424,
+      "menuId": 1046,
       "roleId": 2
     },
     {
-      "id": 429541652312191,
+      "id": 445326475960425,
+      "menuId": 3,
+      "roleId": 2
+    },
+    {
+      "id": 445326475960426,
       "menuId": 115,
       "roleId": 2
     },
     {
-      "id": 429541652316229,
+      "id": 445326475960427,
       "menuId": 1055,
       "roleId": 2
     },
     {
-      "id": 429541652316230,
+      "id": 445326475964485,
       "menuId": 1056,
       "roleId": 2
     },
     {
-      "id": 429541652316231,
+      "id": 445326475964486,
       "menuId": 1058,
       "roleId": 2
     },
     {
-      "id": 429541652316232,
+      "id": 445326475964487,
       "menuId": 1057,
       "roleId": 2
     },
     {
-      "id": 429541652316233,
+      "id": 445326475964488,
       "menuId": 1059,
       "roleId": 2
     },
     {
-      "id": 429541652316234,
+      "id": 445326475964489,
       "menuId": 1060,
       "roleId": 2
-    },  {
-   "id": 2023070901,
-   "menuId": 2224,
-   "roleId": 2
- },
-   {
-     "id": 2023071901,
-     "menuId": 2225,
-     "roleId": 2
-   }
- ]
+    },
+    {
+      "id": 445326475964490,
+      "menuId": 4,
+      "roleId": 2
+    }
+  ]

+ 35 - 0
iot-common/iot-common-dao/iot-common-model/src/main/java/cc/iotkit/model/device/message/DevicePropertyCache.java

@@ -0,0 +1,35 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.model.device.message;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Map;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class DevicePropertyCache {
+
+
+    // 属性值
+    private Object value;
+
+    // 属性值时间: 设备上报时间
+    private Long occurred;
+
+
+    public Map<String, Object> toMap() {
+        return Map.of("value", value, "occurred", occurred);
+    }
+
+}

+ 6 - 0
iot-common/iot-common-dao/iot-common-model/src/main/java/cc/iotkit/model/product/ThingModel.java

@@ -62,6 +62,12 @@ public class ThingModel extends TenantModel implements Id<Long>, Serializable {
         private DataType dataType;
         private String name;
         private String accessMode = "rw";
+
+        // 描述
+        private String description;
+
+        // 单位
+        private String unit;
     }
 
     @Data

+ 4 - 1
iot-common/iot-common-dao/iot-temporal-serviceImpl-es/src/main/java/cc/iotkit/temporal/es/service/DevicePropertyDataImpl.java

@@ -13,6 +13,7 @@ import cc.iotkit.common.utils.MapstructUtils;
 import cc.iotkit.data.manager.IDeviceInfoData;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.device.message.DeviceProperty;
+import cc.iotkit.model.device.message.DevicePropertyCache;
 import cc.iotkit.temporal.IDevicePropertyData;
 import cc.iotkit.temporal.es.document.DocDeviceProperty;
 import org.elasticsearch.index.query.QueryBuilders;
@@ -63,9 +64,11 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
     @Override
     public void addProperties(String deviceId, Map<String, Object> properties, long time) {
         properties.forEach((key, val) -> {
+            DevicePropertyCache propertyCache = (DevicePropertyCache) val;
             String index = getIndex(deviceId, key);
+            long occurred =  Objects.nonNull( propertyCache.getOccurred() )? propertyCache.getOccurred() : time;
             template.save(
-                    new DocDeviceProperty(UUID.randomUUID().toString(), deviceId, key, val, time),
+                    new DocDeviceProperty(UUID.randomUUID().toString(), deviceId, key, propertyCache.getValue(), occurred),
                     IndexCoordinates.of(index)
             );
         });

+ 8 - 4
iot-common/iot-common-dao/iot-temproal-serviceImpl-td/src/main/java/cc/iotkit/temporal/td/service/DevicePropertyDataImpl.java

@@ -12,6 +12,7 @@ package cc.iotkit.temporal.td.service;
 import cc.iotkit.data.manager.IDeviceInfoData;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.device.message.DeviceProperty;
+import cc.iotkit.model.device.message.DevicePropertyCache;
 import cc.iotkit.temporal.IDevicePropertyData;
 import cc.iotkit.temporal.td.config.Constants;
 import cc.iotkit.temporal.td.dao.TdTemplate;
@@ -22,9 +23,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -65,10 +64,15 @@ public class DevicePropertyDataImpl implements IDevicePropertyData {
         if (device == null) {
             return;
         }
+        Map<String, Object> propertiesMap = new HashMap<>();
+        properties.forEach((key, val) -> {
+            DevicePropertyCache propertyCache = (DevicePropertyCache) val;
+            propertiesMap.put(key, propertyCache.getValue());
+        });
         //获取设备旧属性
         Map<String, Object> oldProperties = deviceInfoData.getProperties(deviceId);
         //用新属性覆盖
-        oldProperties.putAll(properties);
+        oldProperties.putAll(propertiesMap);
 
         StringBuilder sbFieldNames = new StringBuilder();
         StringBuilder sbFieldPlaces = new StringBuilder();

+ 8 - 2
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java

@@ -15,6 +15,7 @@ import cc.iotkit.common.utils.StringUtils;
 import cc.iotkit.data.manager.IDeviceInfoData;
 import cc.iotkit.data.manager.IThingModelData;
 import cc.iotkit.model.device.DeviceInfo;
+import cc.iotkit.model.device.message.DevicePropertyCache;
 import cc.iotkit.model.device.message.ThingModelMessage;
 import cc.iotkit.model.product.ThingModel;
 import cc.iotkit.mq.ConsumerHandler;
@@ -78,10 +79,14 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
                 ThingModel.Property::getIdentifier, ThingModel.Property::getDataType));
 
         Map<String, Object> addProperties = new HashMap<>();
+        Long occurred = msg.getOccurred();
         //删除非属性字段
         properties.forEach((key,val)->{
             if (thingModelProperties.containsKey(key)) {
-                addProperties.put(key,val);
+                DevicePropertyCache propertyCache = new DevicePropertyCache();
+                propertyCache.setValue(val);
+                propertyCache.setOccurred(occurred);
+                addProperties.put(key,propertyCache);
                 handleLocate(deviceInfo,val,thingModelProperties.get(key));
             }
         });
@@ -91,12 +96,13 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
 
         //保存属性记录
         try {
-            devicePropertyData.addProperties(deviceId, addProperties, msg.getOccurred());
+            devicePropertyData.addProperties(deviceId, addProperties, occurred);
         } catch (Throwable e) {
             log.warn("save property data error", e);
         }
     }
 
+
     private  void handleLocate(DeviceInfo deviceInfo,Object data,ThingModel.DataType dataType){
         if("position".equals(dataType.getType())){//如果是定位属性需要做一些处理
             Object specs = dataType.getSpecs();

+ 2 - 2
iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/controller/IotContributorController.java

@@ -40,7 +40,7 @@ public class IotContributorController extends BaseController {
     /**
      * 查询贡献者列表
      */
-    @SaCheckPermission("contribution:contributor:list")
+//    @SaCheckPermission("contribution:contributor:list")
     @PostMapping("/list")
     @ApiOperation("查询贡献者列表")
     public Paging<IotContributorVo> list( PageRequest<IotContributorBo> pageQuery) {
@@ -63,7 +63,7 @@ public class IotContributorController extends BaseController {
      * 获取贡献者详细信息
      *
      */
-    @SaCheckPermission("contribution:contributor:query")
+//    @SaCheckPermission("contribution:contributor:query")
     @PostMapping("/getDetail")
     @ApiOperation("获取贡献者详细信息")
     public IotContributorVo getDetail(@Validated @RequestBody Request<Long> request) {

+ 7 - 1
iot-module/iot-openapi/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-module</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.4.5-SNAPSHOT</version>
+        <version>${revision}</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -104,6 +104,12 @@
             <artifactId>mapstruct-plus-spring-boot-starter</artifactId>
             <version>${mapstruct-plus.version}</version>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.83</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <properties>

+ 1 - 1
iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/bo/device/OpenapiSetDeviceServicePropertyBo.java

@@ -29,5 +29,5 @@ public class OpenapiSetDeviceServicePropertyBo {
     private String productKey;
 
     @ApiModelProperty(value="参数")
-    private Map<String, Object> args;
+    private String args;
 }

+ 3 - 4
iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/vo/OpenDevicePropertyVo.java

@@ -1,14 +1,13 @@
 package cc.iotkit.openapi.dto.vo;
 
-import cc.iotkit.model.product.ProductModel;
 import cc.iotkit.model.product.ThingModel;
 import io.github.linpeilie.annotations.AutoMapper;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
+
 
 @ApiModel(value = "OpenDevicePropertyVo")
 @Data
@@ -16,7 +15,7 @@ import java.util.Map;
 public class OpenDevicePropertyVo {
 
     @ApiModelProperty(value="设备属性")
-    private Map<String, Object> property = new HashMap<>();
+    private List<OpenPropertyVo> property;
 
     @ApiModelProperty(value = "主键")
     private String id;

+ 37 - 0
iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/vo/OpenPropertyVo.java

@@ -0,0 +1,37 @@
+package cc.iotkit.openapi.dto.vo;
+
+import cc.iotkit.model.product.ThingModel;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@ApiModel(value = "OpenPropertyVo")
+@Data
+public class OpenPropertyVo {
+    private String identifier;
+    private ThingModel.DataType dataType;
+    private String name;
+    private String accessMode = "rw";
+
+    // 描述
+    private String description;
+
+    // 单位
+    private String unit;
+
+    private String time;
+
+    private String value;
+
+    public OpenPropertyVo() {
+    }
+
+    public OpenPropertyVo(String identifier, ThingModel.DataType dataType, String name, String accessMode, String description, String unit) {
+        this.identifier = identifier;
+        this.dataType = dataType;
+        this.name = name;
+        this.accessMode = accessMode;
+        this.description = description;
+        this.unit = unit;
+    }
+}

+ 1 - 1
iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/OpenDeviceService.java

@@ -22,7 +22,7 @@ public interface OpenDeviceService {
     /**
      * 设备属性设置
      */
-    String setProperty(String productKey, String deviceName, Map<String, Object> properties);
+    String setProperty(String productKey, String deviceName, String properties);
 
     OpenDevicePropertyVo getDevicePropertyStatus(OpenapiDeviceBo data);
 }

+ 0 - 2
iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenBaseServiceImpl.java

@@ -52,8 +52,6 @@ public class OpenBaseServiceImpl implements OpenBaseService {
 
         // 校验租户
         checkTenant(bo.getTenantId());
-        System.out.println("boAppid + password + boTimeStamp = " + boAppid + password + boTimeStamp);
-        System.out.println("boIdentifier = " + boIdentifier);
         if (!CodecUtil.md5Str(boAppid + password + boTimeStamp).equals(boIdentifier)){
             throw new BizException(ErrCode.IDENTIFIER_ERROR);
         }

+ 19 - 6
iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenDeviceServiceImpl.java

@@ -15,16 +15,19 @@ import cc.iotkit.model.product.Product;
 import cc.iotkit.model.product.ThingModel;
 import cc.iotkit.openapi.dto.bo.device.OpenapiDeviceBo;
 import cc.iotkit.openapi.dto.vo.OpenDevicePropertyVo;
+import cc.iotkit.openapi.dto.vo.OpenPropertyVo;
 import cc.iotkit.openapi.service.OpenDeviceService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
-import static cc.iotkit.common.enums.ErrCode.DEVICE_NOT_FOUND;
-import static cc.iotkit.common.enums.ErrCode.DEVICE_OFFLINE;
 
 @Service
 public class OpenDeviceServiceImpl implements OpenDeviceService {
@@ -102,9 +105,9 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
     }
 
     @Override
-    public String setProperty(String productKey, String deviceName, Map<String, Object> args) {
+    public String setProperty(String productKey, String deviceName, String args) {
         DeviceInfo deviceRepetition = deviceInfoData.findByProductKeyAndDeviceName(productKey, deviceName);
-        return deviceService.setProperty(deviceRepetition.getDeviceId(), args, true);
+        return deviceService.setProperty(deviceRepetition.getDeviceId(), JSON.parseObject(args,Map.class), true);
     }
 
     @Override
@@ -112,11 +115,21 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
         ThingModel thingModel = thingModelData.findByProductKey(bo.getProductKey());
         OpenDevicePropertyVo propertyVo = MapstructUtils.convert(thingModel, OpenDevicePropertyVo.class);
         DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(bo.getProductKey(), bo.getDeviceName());
+        List<OpenPropertyVo> openPropertyVos = new ArrayList<>();
         if (propertyVo != null){
-            propertyVo.setProperty(deviceInfoData.getProperties(deviceInfo.getDeviceId()));
+            Map<String, Object> properties = deviceInfoData.getProperties(deviceInfo.getDeviceId());
+            for (ThingModel.Property property : propertyVo.getModel().getProperties()) {
+                OpenPropertyVo openPropertyVo = new OpenPropertyVo(property.getIdentifier(), property.getDataType(), property.getName(), property.getAccessMode(), property.getDescription(), property.getUnit());
+                Map<String,Object> map = (Map<String, Object>) properties.get(openPropertyVo.getIdentifier());
+                if (map != null){
+                    openPropertyVo.setTime(String.valueOf(map.get("occurred")));
+                    openPropertyVo.setValue(String.valueOf(map.get("value")));
+                }
+                openPropertyVos.add(openPropertyVo);
+            }
+            propertyVo.setProperty(openPropertyVos);
         }
         return propertyVo;
     }
 
-
 }

+ 3 - 0
iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java

@@ -415,6 +415,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
                 return;
             }
             LoginUser loginUser = LoginHelper.getLoginUser(token);
+            if(Objects.isNull(loginUser)||CollUtil.isEmpty(loginUser.getRoles())){
+                return;
+            }
             if (loginUser.getRoles().stream().anyMatch(r -> r.getId().equals(roleId))) {
                 StpUtil.logoutByTokenValue(token);
             }

BIN
微信图片_20230710205406.jpg