Explorar el Código

Merge remote-tracking branch 'openiita-dev/dev-V0.4.5' into dev-V0.4.5

dsy hace 2 años
padre
commit
67ab77a4ee

+ 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) {

+ 1 - 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>
 

+ 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