Browse Source

Merge branch 'dev'

xiwa 3 years ago
parent
commit
49c6bb8f91
100 changed files with 4624 additions and 437 deletions
  1. 1 0
      .gitignore
  2. 1 1
      common/pom.xml
  3. 9 0
      common/src/main/java/cc/iotkit/common/ComponentClassLoader.java
  4. 9 0
      common/src/main/java/cc/iotkit/common/Constants.java
  5. 9 0
      common/src/main/java/cc/iotkit/common/exception/BizException.java
  6. 9 0
      common/src/main/java/cc/iotkit/common/exception/NotFoundException.java
  7. 9 0
      common/src/main/java/cc/iotkit/common/exception/OfflineException.java
  8. 9 0
      common/src/main/java/cc/iotkit/common/thing/ThingService.java
  9. 9 0
      common/src/main/java/cc/iotkit/common/utils/CodecUtil.java
  10. 9 0
      common/src/main/java/cc/iotkit/common/utils/DeviceUtil.java
  11. 9 0
      common/src/main/java/cc/iotkit/common/utils/HexUtil.java
  12. 9 0
      common/src/main/java/cc/iotkit/common/utils/JsonUtil.java
  13. 9 1
      common/src/main/java/cc/iotkit/common/utils/ReflectUtil.java
  14. 9 0
      common/src/main/java/cc/iotkit/common/utils/ThreadUtil.java
  15. 9 0
      common/src/main/java/cc/iotkit/common/utils/UniqueIdUtil.java
  16. 5 10
      dao/pom.xml
  17. 11 4
      dao/src/main/java/cc/iotkit/dao/AligenieDeviceRepository.java
  18. 11 4
      dao/src/main/java/cc/iotkit/dao/AligenieProductRepository.java
  19. 18 4
      dao/src/main/java/cc/iotkit/dao/AppDesignRepository.java
  20. 11 4
      dao/src/main/java/cc/iotkit/dao/AppInfoRepository.java
  21. 10 0
      dao/src/main/java/cc/iotkit/dao/CategoryCache.java
  22. 11 5
      dao/src/main/java/cc/iotkit/dao/CategoryRepository.java
  23. 61 0
      dao/src/main/java/cc/iotkit/dao/CommonDao.java
  24. 0 53
      dao/src/main/java/cc/iotkit/dao/DaoTool.java
  25. 12 3
      dao/src/main/java/cc/iotkit/dao/DeviceCache.java
  26. 134 72
      dao/src/main/java/cc/iotkit/dao/DeviceDao.java
  27. 11 4
      dao/src/main/java/cc/iotkit/dao/DeviceGroupRepository.java
  28. 31 0
      dao/src/main/java/cc/iotkit/dao/DeviceInfoRepository.java
  29. 9 0
      dao/src/main/java/cc/iotkit/dao/DevicePropertyDao.java
  30. 9 2
      dao/src/main/java/cc/iotkit/dao/DevicePropertyRepository.java
  31. 9 0
      dao/src/main/java/cc/iotkit/dao/DeviceReportDao.java
  32. 9 2
      dao/src/main/java/cc/iotkit/dao/DeviceReportRepository.java
  33. 0 22
      dao/src/main/java/cc/iotkit/dao/DeviceRepository.java
  34. 15 5
      dao/src/main/java/cc/iotkit/dao/HomeRepository.java
  35. 9 0
      dao/src/main/java/cc/iotkit/dao/OauthClientCache.java
  36. 11 4
      dao/src/main/java/cc/iotkit/dao/OauthClientRepository.java
  37. 9 0
      dao/src/main/java/cc/iotkit/dao/ProductCache.java
  38. 11 4
      dao/src/main/java/cc/iotkit/dao/ProductModelRepository.java
  39. 14 4
      dao/src/main/java/cc/iotkit/dao/ProductRepository.java
  40. 11 4
      dao/src/main/java/cc/iotkit/dao/ProtocolComponentRepository.java
  41. 11 4
      dao/src/main/java/cc/iotkit/dao/ProtocolConverterRepository.java
  42. 0 11
      dao/src/main/java/cc/iotkit/dao/ProtocolGatewayRepository.java
  43. 17 4
      dao/src/main/java/cc/iotkit/dao/RuleInfoRepository.java
  44. 9 2
      dao/src/main/java/cc/iotkit/dao/RuleLogRepository.java
  45. 15 4
      dao/src/main/java/cc/iotkit/dao/SpaceDeviceRepository.java
  46. 13 4
      dao/src/main/java/cc/iotkit/dao/SpaceRepository.java
  47. 16 4
      dao/src/main/java/cc/iotkit/dao/TaskInfoRepository.java
  48. 9 2
      dao/src/main/java/cc/iotkit/dao/TaskLogRepository.java
  49. 9 2
      dao/src/main/java/cc/iotkit/dao/ThingModelMessageRepository.java
  50. 11 4
      dao/src/main/java/cc/iotkit/dao/ThingModelRepository.java
  51. 2 4
      dao/src/main/java/cc/iotkit/dao/ThirdUserSessionRepository.java
  52. 11 4
      dao/src/main/java/cc/iotkit/dao/UserActionLogRepository.java
  53. 11 4
      dao/src/main/java/cc/iotkit/dao/UserInfoRepository.java
  54. 9 2
      dao/src/main/java/cc/iotkit/dao/VirtualDeviceLogRepository.java
  55. 11 4
      dao/src/main/java/cc/iotkit/dao/VirtualDeviceRepository.java
  56. 10 0
      dao/src/main/java/cc/iotkit/dao/config/ElasticsearchConfiguration.java
  57. 0 48
      dao/src/main/java/cc/iotkit/dao/config/RepositoryConfig.java
  58. BIN
      data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/mqtt-component-0.3.0-SNAPSHOT.jar
  59. 42 0
      data/init/category.json
  60. 26 0
      data/init/deviceGroup.json
  61. 1655 0
      data/init/deviceInfo.json
  62. 54 0
      data/init/home.json
  63. 16 0
      data/init/oauthClient.json
  64. 133 0
      data/init/product.json
  65. 11 0
      data/init/productModel.json
  66. 62 0
      data/init/protocolComponent.json
  67. 23 0
      data/init/protocolConverter.json
  68. 95 0
      data/init/ruleInfo.json
  69. 65 0
      data/init/space.json
  70. 101 0
      data/init/spaceDevice.json
  71. 35 0
      data/init/taskInfo.json
  72. 980 0
      data/init/thingModel.json
  73. 124 0
      data/init/userInfo.json
  74. 137 0
      data/init/virtualDevice.json
  75. 2 2
      manager/pom.xml
  76. 9 0
      manager/src/main/java/cc/iotkit/manager/Application.java
  77. 9 0
      manager/src/main/java/cc/iotkit/manager/config/AliyunConfig.java
  78. 9 0
      manager/src/main/java/cc/iotkit/manager/config/CacheConfig.java
  79. 9 0
      manager/src/main/java/cc/iotkit/manager/config/CrossConfig.java
  80. 9 0
      manager/src/main/java/cc/iotkit/manager/config/EmbeddedElasticSearchConfig.java
  81. 3 0
      manager/src/main/java/cc/iotkit/manager/config/SaTokenConfigure.java
  82. 19 6
      manager/src/main/java/cc/iotkit/manager/controller/AppController.java
  83. 29 28
      manager/src/main/java/cc/iotkit/manager/controller/DeviceController.java
  84. 30 14
      manager/src/main/java/cc/iotkit/manager/controller/ProductController.java
  85. 0 2
      manager/src/main/java/cc/iotkit/manager/controller/ProtocolController.java
  86. 22 5
      manager/src/main/java/cc/iotkit/manager/controller/RuleEngineController.java
  87. 20 12
      manager/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java
  88. 12 3
      manager/src/main/java/cc/iotkit/manager/controller/StatsController.java
  89. 9 0
      manager/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java
  90. 11 2
      manager/src/main/java/cc/iotkit/manager/controller/aligenie/AligenieDeviceController.java
  91. 9 0
      manager/src/main/java/cc/iotkit/manager/controller/aligenie/AligenieProductController.java
  92. 14 3
      manager/src/main/java/cc/iotkit/manager/controller/api/AccountController.java
  93. 18 8
      manager/src/main/java/cc/iotkit/manager/controller/api/DeviceController.java
  94. 15 7
      manager/src/main/java/cc/iotkit/manager/controller/api/HomeController.java
  95. 13 1
      manager/src/main/java/cc/iotkit/manager/controller/api/ProductController.java
  96. 33 25
      manager/src/main/java/cc/iotkit/manager/controller/api/SpaceController.java
  97. 9 0
      manager/src/main/java/cc/iotkit/manager/model/aligenie/AligenieProductVo.java
  98. 9 0
      manager/src/main/java/cc/iotkit/manager/model/vo/AppDesignVo.java
  99. 9 0
      manager/src/main/java/cc/iotkit/manager/model/vo/AppPageNode.java
  100. 9 0
      manager/src/main/java/cc/iotkit/manager/model/vo/DeviceLog.java

+ 1 - 0
.gitignore

@@ -26,3 +26,4 @@ target
 *.yml
 log
 data/elasticsearch
+.init

+ 1 - 1
common/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iotkit-parent</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.2.2-SNAPSHOT</version>
+        <version>0.3.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 9 - 0
common/src/main/java/cc/iotkit/common/ComponentClassLoader.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common;
 
 import java.io.File;

+ 9 - 0
common/src/main/java/cc/iotkit/common/Constants.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common;
 
 public interface Constants {

+ 9 - 0
common/src/main/java/cc/iotkit/common/exception/BizException.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.exception;
 
 public class BizException extends RuntimeException{

+ 9 - 0
common/src/main/java/cc/iotkit/common/exception/NotFoundException.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.exception;
 
 

+ 9 - 0
common/src/main/java/cc/iotkit/common/exception/OfflineException.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.exception;
 
 

+ 9 - 0
common/src/main/java/cc/iotkit/common/thing/ThingService.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.thing;
 
 import lombok.AllArgsConstructor;

+ 9 - 0
common/src/main/java/cc/iotkit/common/utils/CodecUtil.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.utils;
 
 import org.apache.commons.codec.binary.Base64;

+ 9 - 0
common/src/main/java/cc/iotkit/common/utils/DeviceUtil.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.utils;
 
 import org.apache.commons.lang3.RandomUtils;

+ 9 - 0
common/src/main/java/cc/iotkit/common/utils/HexUtil.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.utils;
 
 

+ 9 - 0
common/src/main/java/cc/iotkit/common/utils/JsonUtil.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.utils;
 
 import com.fasterxml.jackson.core.type.TypeReference;

+ 9 - 1
common/src/main/java/cc/iotkit/common/utils/ReflectUtil.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.utils;
 
 
@@ -29,5 +38,4 @@ public class ReflectUtil {
         BeanUtils.populate(to, map);
         return to;
     }
-
 }

+ 9 - 0
common/src/main/java/cc/iotkit/common/utils/ThreadUtil.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.utils;
 
 import java.util.concurrent.ScheduledThreadPoolExecutor;

+ 9 - 0
common/src/main/java/cc/iotkit/common/utils/UniqueIdUtil.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.common.utils;
 
 import org.apache.commons.lang3.RandomUtils;

+ 5 - 10
dao/pom.xml

@@ -5,27 +5,22 @@
     <parent>
         <artifactId>iotkit-parent</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.2.2-SNAPSHOT</version>
+        <version>0.3.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>dao</artifactId>
 
-    <properties>
-        <maven.compiler.source>8</maven.compiler.source>
-        <maven.compiler.target>8</maven.compiler.target>
-    </properties>
-
     <dependencies>
 
         <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-mongodb</artifactId>
+            <groupId>jakarta.annotation</groupId>
+            <artifactId>jakarta.annotation-api</artifactId>
         </dependency>
 
         <dependency>
-            <groupId>commons-beanutils</groupId>
-            <artifactId>commons-beanutils</artifactId>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-core</artifactId>
         </dependency>
 
         <dependency>

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/AligenieDeviceRepository.java

@@ -1,13 +1,20 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.aligenie.AligenieDevice;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface AligenieDeviceRepository extends MongoRepository<AligenieDevice, String> {
+public interface AligenieDeviceRepository extends ElasticsearchRepository<AligenieDevice, String> {
 
     void deleteByUid(String uid);
 

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/AligenieProductRepository.java

@@ -1,13 +1,20 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.aligenie.AligenieProduct;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface AligenieProductRepository extends MongoRepository<AligenieProduct, String> {
+public interface AligenieProductRepository extends ElasticsearchRepository<AligenieProduct, String> {
 
     List<AligenieProduct> findByUid(String uid);
 

+ 18 - 4
dao/src/main/java/cc/iotkit/dao/AppDesignRepository.java

@@ -1,9 +1,23 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.product.AppDesign;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
+
+import java.util.List;
+
+public interface AppDesignRepository extends ElasticsearchRepository<AppDesign, String> {
+
+    AppDesign findByProductKey(String productKey);
+
+    List<AppDesign> findByUid(String uid);
 
-@Repository
-public interface AppDesignRepository extends MongoRepository<AppDesign, String> {
 }

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/AppInfoRepository.java

@@ -1,9 +1,16 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.AppInfo;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface AppInfoRepository extends MongoRepository<AppInfo, String> {
+public interface AppInfoRepository extends ElasticsearchRepository<AppInfo, String> {
 }

+ 10 - 0
dao/src/main/java/cc/iotkit/dao/CategoryCache.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.common.Constants;
@@ -8,6 +17,7 @@ import org.springframework.stereotype.Repository;
 
 import javax.annotation.PostConstruct;
 
+
 @Repository
 public class CategoryCache {
 

+ 11 - 5
dao/src/main/java/cc/iotkit/dao/CategoryRepository.java

@@ -1,13 +1,19 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.product.Category;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface CategoryRepository extends MongoRepository<Category, String> {
+public interface CategoryRepository extends ElasticsearchRepository<Category, String> {
 
     int countBy();
 
-
 }

+ 61 - 0
dao/src/main/java/cc/iotkit/dao/CommonDao.java

@@ -0,0 +1,61 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.dao;
+
+import cc.iotkit.model.Paging;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
+import org.springframework.data.elasticsearch.core.SearchHit;
+import org.springframework.data.elasticsearch.core.SearchHits;
+import org.springframework.data.elasticsearch.core.query.Criteria;
+import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
+import org.springframework.data.elasticsearch.core.query.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Repository
+public class CommonDao {
+
+    @Autowired
+    private ElasticsearchRestTemplate elasticsearchRestTemplate;
+
+    /**
+     * 通用按条件分页查找
+     */
+    public <T> Paging<T> pagedFind(Class<T> cls, Criteria condition, Sort.Order order, int size, int page) {
+        Query query = new CriteriaQuery(condition);
+        long total = elasticsearchRestTemplate.count(query, cls);
+        query = query.setPageable(PageRequest.of(page - 1, size, Sort.by(order)));
+        SearchHits<T> searchHits = elasticsearchRestTemplate.search(query, cls);
+        List<T> list = new ArrayList<>();
+        for (SearchHit<T> searchHit : searchHits) {
+            list.add(searchHit.getContent());
+        }
+        return new Paging<>(total, list);
+    }
+
+    /**
+     * 通用按条件查询
+     */
+    public <T> List<T> find(Class<T> cls, Criteria condition) {
+        Query query = new CriteriaQuery(condition);
+        SearchHits<T> searchHits = elasticsearchRestTemplate.search(query, cls);
+        List<T> list = new ArrayList<>();
+        for (SearchHit<T> searchHit : searchHits) {
+            list.add(searchHit.getContent());
+        }
+        return list;
+    }
+
+}

+ 0 - 53
dao/src/main/java/cc/iotkit/dao/DaoTool.java

@@ -1,53 +0,0 @@
-package cc.iotkit.dao;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.SneakyThrows;
-import org.apache.commons.beanutils.BeanMap;
-import org.springframework.data.mongodb.core.query.Update;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class DaoTool {
-
-    public static void update(Update update, List<Prop> props) {
-        for (Prop pro : props) {
-            update.set(pro.getName(), pro.getValue());
-        }
-    }
-
-    public static List<Prop> getProp(String key, Object value) {
-        List<Prop> props = new ArrayList<>();
-        if (value instanceof Map) {
-            Set<Map.Entry<String, Object>> entrySet = ((Map) value).entrySet();
-            for (Map.Entry<String, Object> entry : entrySet) {
-                props.addAll(getProp(key + "." + entry.getKey(), entry.getValue()));
-            }
-        } else if (value != null && !(value instanceof Class)) {
-            props.add(new Prop(key, value));
-        }
-        return props;
-    }
-
-    @SneakyThrows
-    public static <T> Update update(T obj) {
-        Map<Object, Object> pros = new BeanMap(obj);
-        Update update = new Update();
-        for (Map.Entry<Object, Object> entry : pros.entrySet()) {
-            update(update, DaoTool.getProp(entry.getKey().toString(), entry.getValue()));
-        }
-        return update;
-    }
-
-    @Data
-    @AllArgsConstructor
-    @NoArgsConstructor
-    static class Prop {
-        private String name;
-        private Object value;
-    }
-}

+ 12 - 3
dao/src/main/java/cc/iotkit/dao/DeviceCache.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.common.Constants;
@@ -14,7 +23,7 @@ import java.util.List;
 public class DeviceCache {
 
     @Autowired
-    private DeviceRepository deviceRepository;
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private DeviceDao deviceDao;
 
@@ -31,12 +40,12 @@ public class DeviceCache {
 
     @Cacheable(value = Constants.DEVICE_CACHE, key = "#pk+'_'+#dn")
     public DeviceInfo getDeviceInfo(String pk, String dn) {
-        return deviceRepository.findByProductKeyAndDeviceName(pk, dn);
+        return deviceInfoRepository.findByProductKeyAndDeviceName(pk, dn);
     }
 
     @Cacheable(value = Constants.DEVICE_CACHE, key = "#deviceId")
     public DeviceInfo get(String deviceId) {
-        return deviceRepository.findById(deviceId).orElse(null);
+        return deviceInfoRepository.findById(deviceId).orElse(null);
     }
 
     @Cacheable(value = Constants.DEVICE_STATS_CACHE, key = "#uid")

+ 134 - 72
dao/src/main/java/cc/iotkit/dao/DeviceDao.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.Paging;
@@ -5,16 +14,23 @@ import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.product.Category;
 import cc.iotkit.model.product.Product;
 import cc.iotkit.model.stats.DataItem;
+import cn.hutool.core.bean.BeanUtil;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.Pair;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.aggregations.AggregationBuilders;
+import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
+import org.elasticsearch.search.aggregations.bucket.terms.Terms;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.aggregation.*;
-import org.springframework.data.mongodb.core.query.Criteria;
-import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
+import org.springframework.data.elasticsearch.core.ScriptType;
+import org.springframework.data.elasticsearch.core.SearchHit;
+import org.springframework.data.elasticsearch.core.SearchHits;
+import org.springframework.data.elasticsearch.core.clients.elasticsearch7.ElasticsearchAggregations;
+import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
+import org.springframework.data.elasticsearch.core.query.*;
 import org.springframework.stereotype.Repository;
 
 import java.util.ArrayList;
@@ -27,20 +43,25 @@ import java.util.stream.Collectors;
 public class DeviceDao {
 
     @Autowired
-    private MongoTemplate mongoTemplate;
+    private ElasticsearchRestTemplate elasticsearchRestTemplate;
+
+    @Autowired
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private ProductRepository productRepository;
     @Autowired
     private CategoryRepository categoryRepository;
 
     public Paging<DeviceInfo> find(Criteria condition, int size, int page) {
-        Query query = Query.query(condition);
-        return new Paging<>(
-                mongoTemplate.count(query, DeviceInfo.class),
-                mongoTemplate.find(
-                        query.with(PageRequest.of(page - 1, size, Sort.by(Sort.Order.desc("createAt"))))
-                        , DeviceInfo.class)
-        );
+        Query query = new CriteriaQuery(condition);
+        long total = elasticsearchRestTemplate.count(query, DeviceInfo.class);
+        query = query.setPageable(PageRequest.of(page - 1, size, Sort.by(Sort.Order.desc("createAt"))));
+        SearchHits<DeviceInfo> searchHits = elasticsearchRestTemplate.search(query, DeviceInfo.class);
+        List<DeviceInfo> list = new ArrayList<>();
+        for (SearchHit<DeviceInfo> searchHit : searchHits) {
+            list.add(searchHit.getContent());
+        }
+        return new Paging<>(total, list);
     }
 
     /**
@@ -50,80 +71,101 @@ public class DeviceDao {
         if (properties == null) {
             return;
         }
-        Query query = Query.query(new Criteria().and("deviceId").is(deviceId));
-        Update update = new Update();
-        for (String key : properties.keySet()) {
-            update.set("property." + key, properties.get(key));
-        }
-        mongoTemplate.updateFirst(query, update, DeviceInfo.class);
+
+        Map<String, Object> param = new HashMap<>();
+        param.put("property", BeanUtil.beanToMap(properties));
+        param.put("keys", properties.keySet());
+
+        UpdateQuery updateQuery = UpdateQuery.builder(new CriteriaQuery(new Criteria()
+                .and("deviceId").is(deviceId)))
+                .withParams(param)
+                .withScript("for(key in params.keys){ctx._source.property[key]=params.property[key];}")
+                .withScriptType(ScriptType.INLINE)
+                .build();
+        elasticsearchRestTemplate.updateByQuery(updateQuery, IndexCoordinates.of("device_info"));
     }
 
     /**
      * 更新设备标签
      */
     public void updateTag(String deviceId, DeviceInfo.Tag tag) {
-        Query query = Query.query(new Criteria().and("deviceId").is(deviceId));
-        Update update = new Update();
-        update.set("tag." + tag.getId(), tag);
-        mongoTemplate.updateFirst(query, update, DeviceInfo.class);
+        Map<String, Object> param = new HashMap<>();
+        param.put("tag", BeanUtil.beanToMap(tag));
+
+        UpdateQuery updateQuery = UpdateQuery.builder(new CriteriaQuery(new Criteria()
+                .and("deviceId").is(deviceId)))
+                .withParams(param)
+                .withScript(String.format("ctx._source.tag.%s=params.tag", tag.getId()))
+                .withScriptType(ScriptType.INLINE)
+                .build();
+        elasticsearchRestTemplate.updateByQuery(updateQuery, IndexCoordinates.of("device_info"));
     }
 
     /**
      * 设置设备标签值为空
      */
     public void setTagNull(String deviceId, String tagId) {
-        Query query = Query.query(new Criteria().and("deviceId").is(deviceId));
-        Update update = new Update();
-        update.set("tag." + tagId, null);
-        mongoTemplate.updateFirst(query, update, DeviceInfo.class);
+//        Query query = Query.query(new Criteria().and("deviceId").is(deviceId));
+//        Update update = new Update();
+//        update.set("tag." + tagId, null);
+//        mongoTemplate.updateFirst(query, update, DeviceInfo.class);
     }
 
     /**
      * 获取按品类统计的用户设备数
      */
     public List<DataItem> getDeviceStatsByCategory(String uid) {
-        MatchOperation matchOperation;
-        if (StringUtils.isBlank(uid)) {
-            matchOperation = Aggregation.match(new Criteria());
-        } else {
-            matchOperation = Aggregation.match(Criteria.where("uid").is(uid));
+        BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
+        if (StringUtils.isNotBlank(uid)) {
+            queryBuilder =
+                    queryBuilder.must(QueryBuilders.termQuery("uid.keyword", uid));
         }
 
         //先按产品分组统计
-        GroupOperation groupOperation = Aggregation.group("productKey").count().as("total");
-        ProjectionOperation projectionOperation = Aggregation.project("productKey", "uid");
-        Aggregation aggregation = Aggregation.newAggregation(projectionOperation, groupOperation, matchOperation);
-        AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, DeviceInfo.class, Map.class);
-        List<Map> stats = result.getMappedResults();
-
-        //取用户产品列表
-        List<Product> products;
-        if (StringUtils.isBlank(uid)) {
-            products = productRepository.findAll();
-        } else {
+        NativeSearchQuery query = new NativeSearchQueryBuilder()
+                .withQuery(queryBuilder)
+                .withAggregations(
+                        AggregationBuilders.terms("countByPk").field("productKey.keyword")
+                                .size(1000)
+                                .subAggregation(AggregationBuilders.count("count").field("productKey.keyword"))
+                )
+                .build();
+
+        ElasticsearchAggregations result = (ElasticsearchAggregations) elasticsearchRestTemplate
+                .search(query, DeviceInfo.class).getAggregations();
+        ParsedStringTerms terms = result.aggregations().get("countByPk");
+        List<? extends Terms.Bucket> buckets = terms.getBuckets();
+        Map<String, Long> productCount = new HashMap<>();
+        for (Terms.Bucket bucket : buckets) {
+            productCount.put(bucket.getKeyAsString(), bucket.getDocCount());
+        }
+
+        //取用户下产品列表
+        Iterable<Product> products;
+        if (StringUtils.isNotBlank(uid)) {
             products = productRepository.findByUid(uid);
+        } else {
+            products = productRepository.findAll();
         }
         Map<String, String> pkCateMap = new HashMap<>();
         for (Product product : products) {
             pkCateMap.put(product.getId(), product.getCategory());
         }
 
-        //取品类
-        List<Category> categories = categoryRepository.findAll();
+        //取品类列表
         Map<String, String> cateNames = new HashMap<>();
-        for (Category category : categories) {
+        for (Category category : categoryRepository.findAll()) {
             cateNames.put(category.getId(), category.getName());
         }
 
         Map<String, Long> cateStats = new HashMap<>();
-        for (Map stat : stats) {
-            String productKey = stat.get("_id").toString();
-            String cateName = cateNames.get(pkCateMap.get(productKey));
+        productCount.forEach((key, val) -> {
+            String cateName = cateNames.get(pkCateMap.get(key));
             //按品类汇总
             long total = cateStats.getOrDefault(cateName, 0L);
-            total += (Integer) stat.get("total");
+            total += val;
             cateStats.put(cateName, total);
-        }
+        });
 
         List<DataItem> items = new ArrayList<>();
         cateStats.forEach((key, val) -> {
@@ -144,55 +186,75 @@ public class DeviceDao {
      * 根据分组id查询分组下所有设备
      */
     public List<DeviceInfo> findByGroupId(String groupId) {
-        Query query = Query.query(new Criteria().and("group." + groupId).exists(true));
-        return mongoTemplate.find(query, DeviceInfo.class);
+        Query query = new CriteriaQuery(new Criteria().and("group." + groupId).exists());
+        SearchHits<DeviceInfo> searchHits = elasticsearchRestTemplate.search(query, DeviceInfo.class);
+        return searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList());
     }
 
     /**
      * 按分组id统计设备数量
      */
     public long countByGroupId(String groupId) {
-        Query query = Query.query(new Criteria().and("group." + groupId).exists(true));
-        return mongoTemplate.count(query, DeviceInfo.class);
+        Query query = new CriteriaQuery(new Criteria().and("group." + groupId).exists());
+        return elasticsearchRestTemplate.count(query, DeviceInfo.class);
     }
 
     /**
      * 按设备id更新设备分组
      */
     public void updateGroupByDeviceId(String deviceId, DeviceInfo.Group group) {
-        Query query = Query.query(new Criteria().and("deviceId").is(deviceId));
-        Update update = new Update();
-        update.set("group." + group.getId(), group);
-        mongoTemplate.updateFirst(query, update, DeviceInfo.class);
+        Map<String, Object> param = new HashMap<>();
+        param.put("group", BeanUtil.beanToMap(group));
+
+        UpdateQuery updateQuery = UpdateQuery.builder(new CriteriaQuery(new Criteria()
+                .and("deviceId").is(deviceId)))
+                .withParams(param)
+                .withScript(String.format("ctx._source.group.%s=params.group", group.getId()))
+                .withScriptType(ScriptType.INLINE)
+                .build();
+        elasticsearchRestTemplate.updateByQuery(updateQuery, IndexCoordinates.of("device_info"));
     }
 
     /**
      * 按组id更新设备分组
      */
     public void updateGroup(String groupId, DeviceInfo.Group group) {
-        Query query = Query.query(new Criteria().and("group." + groupId).exists(true));
-        Update update = new Update();
-        update.set("group." + group.getId(), group);
-        mongoTemplate.updateMulti(query, update, DeviceInfo.class);
+        Map<String, Object> param = new HashMap<>();
+        param.put("group", BeanUtil.beanToMap(group));
+
+        UpdateQuery updateQuery = UpdateQuery.builder(new CriteriaQuery(new Criteria()
+                .and("group." + groupId).exists()))
+                .withParams(param)
+                .withScript(String.format("ctx._source.group.%s=params.group", groupId))
+                .withScriptType(ScriptType.INLINE)
+                .build();
+
+        elasticsearchRestTemplate.update(updateQuery, IndexCoordinates.of("device_info"));
     }
 
     /**
      * 移除指定设备信息中的分组
      */
     public void removeGroup(String deviceId, String groupId) {
-        Query query = Query.query(new Criteria().and("deviceId").is(deviceId).and("group." + groupId).exists(true));
-        Update update = new Update();
-        update.unset("group." + groupId);
-        mongoTemplate.updateFirst(query, update, DeviceInfo.class);
+        UpdateQuery updateQuery = UpdateQuery.builder(new CriteriaQuery(
+                Criteria.where("deviceId").is(deviceId)))
+                .withScript(String.format("ctx._source.group.remove('%s')", groupId))
+                .withScriptType(ScriptType.INLINE)
+                .build();
+
+        elasticsearchRestTemplate.updateByQuery(updateQuery, IndexCoordinates.of("device_info"));
     }
 
     /**
      * 移除设备信息中的分组
      */
     public void removeGroup(String groupId) {
-        Query query = Query.query(new Criteria().and("group." + groupId).exists(true));
-        Update update = new Update();
-        update.unset("group." + groupId);
-        mongoTemplate.updateMulti(query, update, DeviceInfo.class);
+        UpdateQuery updateQuery = UpdateQuery.builder(new CriteriaQuery(new Criteria()
+                .and("group." + groupId).exists()))
+                .withScript(String.format("ctx._source.group.remove('%s')", groupId))
+                .withScriptType(ScriptType.INLINE)
+                .build();
+
+        elasticsearchRestTemplate.update(updateQuery, IndexCoordinates.of("device_info"));
     }
 }

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/DeviceGroupRepository.java

@@ -1,13 +1,20 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.DeviceGroup;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface DeviceGroupRepository extends MongoRepository<DeviceGroup, String> {
+public interface DeviceGroupRepository extends ElasticsearchRepository<DeviceGroup, String> {
 
     Page<DeviceGroup> findByNameLike(String name, Pageable pageable);
 

+ 31 - 0
dao/src/main/java/cc/iotkit/dao/DeviceInfoRepository.java

@@ -0,0 +1,31 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.dao;
+
+import cc.iotkit.model.device.DeviceInfo;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
+
+import java.util.List;
+
+public interface DeviceInfoRepository extends ElasticsearchRepository<DeviceInfo, String> {
+
+    DeviceInfo findByProductKeyAndDeviceName(String productKey, String deviceName);
+
+    DeviceInfo findByDeviceId(String deviceId);
+
+    List<DeviceInfo> findByParentId(String parentId);
+
+    List<DeviceInfo> findByParentIdAndUid(String parentId, String uid);
+
+    List<DeviceInfo> findByDeviceName(String deviceName);
+
+    long countByUid(String uid);
+
+}

+ 9 - 0
dao/src/main/java/cc/iotkit/dao/DevicePropertyDao.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.message.DeviceProperty;

+ 9 - 2
dao/src/main/java/cc/iotkit/dao/DevicePropertyRepository.java

@@ -1,10 +1,17 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.message.DeviceProperty;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
-import org.springframework.stereotype.Repository;
 
-@Repository
 public interface DevicePropertyRepository extends ElasticsearchRepository<DeviceProperty, String> {
 
 

+ 9 - 0
dao/src/main/java/cc/iotkit/dao/DeviceReportDao.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.message.DeviceReport;

+ 9 - 2
dao/src/main/java/cc/iotkit/dao/DeviceReportRepository.java

@@ -1,10 +1,17 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.message.DeviceReport;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
-import org.springframework.stereotype.Repository;
 
-@Repository
 public interface DeviceReportRepository extends ElasticsearchRepository<DeviceReport, String> {
 
     long countByUid(String uid);

+ 0 - 22
dao/src/main/java/cc/iotkit/dao/DeviceRepository.java

@@ -1,22 +0,0 @@
-package cc.iotkit.dao;
-
-import cc.iotkit.model.device.DeviceInfo;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-
-@Repository
-public interface DeviceRepository extends MongoRepository<DeviceInfo, String> {
-
-    DeviceInfo findByProductKeyAndDeviceName(String productKey, String deviceName);
-
-    DeviceInfo findByDeviceId(String deviceId);
-
-    List<DeviceInfo> findByParentId(String parentId);
-
-    List<DeviceInfo> findByDeviceName(String deviceName);
-
-    long countByUid(String uid);
-
-}

+ 15 - 5
dao/src/main/java/cc/iotkit/dao/HomeRepository.java

@@ -1,15 +1,25 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.space.Home;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface HomeRepository extends MongoRepository<Home, String> {
+public interface HomeRepository extends ElasticsearchRepository<Home, String> {
 
     List<Home> findByUid(String uid);
 
-    Home findByUidAndCurrent(String uid,boolean current);
+    Home findByUidAndCurrent(String uid, boolean current);
+
+    Home findByUidAndId(String uid, String id);
+
 }

+ 9 - 0
dao/src/main/java/cc/iotkit/dao/OauthClientCache.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.common.Constants;

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/OauthClientRepository.java

@@ -1,11 +1,18 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.OauthClient;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface OauthClientRepository extends MongoRepository<OauthClient, String> {
+public interface OauthClientRepository extends ElasticsearchRepository<OauthClient, String> {
 
 
 }

+ 9 - 0
dao/src/main/java/cc/iotkit/dao/ProductCache.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.common.Constants;

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/ProductModelRepository.java

@@ -1,13 +1,20 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.product.ProductModel;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface ProductModelRepository extends MongoRepository<ProductModel, String> {
+public interface ProductModelRepository extends ElasticsearchRepository<ProductModel, String> {
 
     ProductModel findByModel(String model);
 

+ 14 - 4
dao/src/main/java/cc/iotkit/dao/ProductRepository.java

@@ -1,15 +1,25 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.product.Product;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface ProductRepository extends MongoRepository<Product, String> {
+public interface ProductRepository extends ElasticsearchRepository<Product, String> {
 
     long countByUid(String uid);
 
     List<Product> findByUid(String uid);
+
+    List<Product> findByCategory(String category);
+
 }

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/ProtocolComponentRepository.java

@@ -1,13 +1,20 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.protocol.ProtocolComponent;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface ProtocolComponentRepository extends MongoRepository<ProtocolComponent, String> {
+public interface ProtocolComponentRepository extends ElasticsearchRepository<ProtocolComponent, String> {
 
     List<ProtocolComponent> findByState(String state);
 

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/ProtocolConverterRepository.java

@@ -1,9 +1,16 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.protocol.ProtocolConverter;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface ProtocolConverterRepository extends MongoRepository<ProtocolConverter, String> {
+public interface ProtocolConverterRepository extends ElasticsearchRepository<ProtocolConverter, String> {
 }

+ 0 - 11
dao/src/main/java/cc/iotkit/dao/ProtocolGatewayRepository.java

@@ -1,11 +0,0 @@
-package cc.iotkit.dao;
-
-import cc.iotkit.model.protocol.ProtocolComponent;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface ProtocolGatewayRepository extends MongoRepository<ProtocolComponent, String> {
-
-
-}

+ 17 - 4
dao/src/main/java/cc/iotkit/dao/RuleInfoRepository.java

@@ -1,14 +1,27 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.rule.RuleInfo;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface RuleInfoRepository extends MongoRepository<RuleInfo, String> {
+public interface RuleInfoRepository extends ElasticsearchRepository<RuleInfo, String> {
 
     List<RuleInfo> findByUidAndType(String uid, String type);
 
+    Page<RuleInfo> findByUidAndType(String uid, String type, Pageable pageable);
+
+    Page<RuleInfo> findByType(String type, Pageable pageable);
+
 }

+ 9 - 2
dao/src/main/java/cc/iotkit/dao/RuleLogRepository.java

@@ -1,12 +1,19 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.rule.RuleLog;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
-import org.springframework.stereotype.Repository;
 
-@Repository
 public interface RuleLogRepository extends ElasticsearchRepository<RuleLog, String> {
 
     void deleteByRuleId(String ruleId);

+ 15 - 4
dao/src/main/java/cc/iotkit/dao/SpaceDeviceRepository.java

@@ -1,18 +1,29 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.space.SpaceDevice;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface SpaceDeviceRepository extends MongoRepository<SpaceDevice, String> {
+public interface SpaceDeviceRepository extends ElasticsearchRepository<SpaceDevice, String> {
 
     List<SpaceDevice> findByUidOrderByUseAtDesc(String uid);
 
     List<SpaceDevice> findByUidOrderByAddAtDesc(String uid);
 
+    List<SpaceDevice> findByUid(String uid);
+
+    List<SpaceDevice> findBySpaceIdOrderByAddAtDesc(String spaceId);
+
     List<SpaceDevice> findByUidAndSpaceIdOrderByAddAtDesc(String uid, String spaceId);
 
     SpaceDevice findByDeviceId(String deviceId);

+ 13 - 4
dao/src/main/java/cc/iotkit/dao/SpaceRepository.java

@@ -1,16 +1,25 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.space.Space;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface SpaceRepository extends MongoRepository<Space, String> {
+public interface SpaceRepository extends ElasticsearchRepository<Space, String> {
 
     List<Space> findByUidOrderByCreateAtDesc(String uid);
 
     List<Space> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId);
 
+    List<Space> findByHomeId(String homeId);
+
 }

+ 16 - 4
dao/src/main/java/cc/iotkit/dao/TaskInfoRepository.java

@@ -1,9 +1,21 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.rule.TaskInfo;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
+
+import java.util.List;
+
+public interface TaskInfoRepository extends ElasticsearchRepository<TaskInfo, String> {
+
+    List<TaskInfo> findByUid(String uid);
 
-@Repository
-public interface TaskInfoRepository extends MongoRepository<TaskInfo, String> {
 }

+ 9 - 2
dao/src/main/java/cc/iotkit/dao/TaskLogRepository.java

@@ -1,12 +1,19 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.rule.TaskLog;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
-import org.springframework.stereotype.Repository;
 
-@Repository
 public interface TaskLogRepository extends ElasticsearchRepository<TaskLog, String> {
 
     void deleteByTaskId(String taskId);

+ 9 - 2
dao/src/main/java/cc/iotkit/dao/ThingModelMessageRepository.java

@@ -1,12 +1,19 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.message.ThingModelMessage;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
-import org.springframework.stereotype.Repository;
 
-@Repository
 public interface ThingModelMessageRepository extends ElasticsearchRepository<ThingModelMessage, String> {
 
     Page<ThingModelMessage> findByTypeAndIdentifier(String type, String identifier, Pageable pageable);

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/ThingModelRepository.java

@@ -1,11 +1,18 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.product.ThingModel;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface ThingModelRepository extends MongoRepository<ThingModel, String> {
+public interface ThingModelRepository extends ElasticsearchRepository<ThingModel, String> {
 
     ThingModel findByProductKey(String productKey);
 

+ 2 - 4
dao/src/main/java/cc/iotkit/dao/ThirdUserSessionRepository.java

@@ -1,11 +1,9 @@
 package cc.iotkit.dao;
 
 import cc.iotkit.model.ThirdUserSession;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface ThirdUserSessionRepository extends MongoRepository<ThirdUserSession, String> {
+public interface ThirdUserSessionRepository extends ElasticsearchRepository<ThirdUserSession, String> {
 
 
 }

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/UserActionLogRepository.java

@@ -1,10 +1,17 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.UserActionLog;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
-@Repository
-public interface UserActionLogRepository extends MongoRepository<UserActionLog, String> {
+public interface UserActionLogRepository extends ElasticsearchRepository<UserActionLog, String> {
 
 }

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/UserInfoRepository.java

@@ -1,13 +1,20 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.UserInfo;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface UserInfoRepository extends MongoRepository<UserInfo, String> {
+public interface UserInfoRepository extends ElasticsearchRepository<UserInfo, String> {
 
     UserInfo findByUid(String uid);
 

+ 9 - 2
dao/src/main/java/cc/iotkit/dao/VirtualDeviceLogRepository.java

@@ -1,12 +1,19 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.VirtualDeviceLog;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
-import org.springframework.stereotype.Repository;
 
-@Repository
 public interface VirtualDeviceLogRepository extends ElasticsearchRepository<VirtualDeviceLog, String> {
 
     Page<VirtualDeviceLog> findByVirtualDeviceId(String virtualDeviceId, Pageable pageable);

+ 11 - 4
dao/src/main/java/cc/iotkit/dao/VirtualDeviceRepository.java

@@ -1,15 +1,22 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.dao;
 
 import cc.iotkit.model.device.VirtualDevice;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.stereotype.Repository;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 
 import java.util.List;
 
-@Repository
-public interface VirtualDeviceRepository extends MongoRepository<VirtualDevice, String> {
+public interface VirtualDeviceRepository extends ElasticsearchRepository<VirtualDevice, String> {
 
     Page<VirtualDevice> findByUid(String uid, Pageable pageable);
 

+ 10 - 0
dao/src/main/java/cc/iotkit/dao/config/ElasticsearchConfiguration.java

@@ -1,3 +1,13 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+
 package cc.iotkit.dao.config;
 
 import org.springframework.context.annotation.ComponentScan;

+ 0 - 48
dao/src/main/java/cc/iotkit/dao/config/RepositoryConfig.java

@@ -1,48 +0,0 @@
-package cc.iotkit.dao.config;
-
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
-import org.springframework.context.annotation.*;
-import org.springframework.data.convert.CustomConversions;
-import org.springframework.data.mongodb.MongoDatabaseFactory;
-import org.springframework.data.mongodb.core.MongoOperations;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.convert.*;
-import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
-import org.springframework.data.mongodb.repository.MongoRepository;
-import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
-
-import java.util.Collections;
-
-@Configuration
-@Import(value = MongoAutoConfiguration.class)
-@EnableMongoRepositories(basePackages = "cc.iotkit.dao", includeFilters = @ComponentScan.Filter(
-        type = FilterType.ASSIGNABLE_TYPE, value = MongoRepository.class))
-public class RepositoryConfig {
-
-    @Bean
-    public MappingMongoConverter mappingMongoConverter(
-            MongoDatabaseFactory factory,
-            MongoMappingContext context,
-            BeanFactory beanFactory) {
-        DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
-        MappingMongoConverter mappingMongoConverter = new MappingMongoConverter(dbRefResolver, context);
-        mappingMongoConverter.setCustomConversions(beanFactory.getBean(CustomConversions.class));
-        mappingMongoConverter.setTypeMapper(new DefaultMongoTypeMapper(null));
-        return mappingMongoConverter;
-    }
-
-    @Bean
-    @ConditionalOnMissingBean({MongoOperations.class})
-    MongoTemplate mongoTemplate(MongoDatabaseFactory factory, MongoConverter converter) {
-        return new MongoTemplate(factory, converter);
-    }
-
-    @Bean
-    @Primary
-    MongoCustomConversions mongoCustomConversions() {
-        return new MongoCustomConversions(Collections.emptyList());
-    }
-
-}

BIN
data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/mqtt-component-0.2.2-SNAPSHOT.jar → data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/mqtt-component-0.3.0-SNAPSHOT.jar


+ 42 - 0
data/init/category.json

@@ -0,0 +1,42 @@
+[
+  {
+    "id": "switch",
+    "name": "开关",
+    "createAt": 1647599367057
+  },
+  {
+    "id": "sensor",
+    "name": "传感器",
+    "createAt": 1649743382683
+  },
+  {
+    "id": "meter",
+    "name": "表计",
+    "createAt": 1654237582120
+  },
+  {
+    "id": "light",
+    "name": "灯",
+    "createAt": 1650174762755
+  },
+  {
+    "id": "gateway",
+    "name": "网关",
+    "createAt": 1646637047902
+  },
+  {
+    "id": "fan",
+    "name": "风扇",
+    "createAt": 1646630215889
+  },
+  {
+    "id": "door",
+    "name": "门磁",
+    "createAt": 1650173898298
+  },
+  {
+    "id": "SmartPlug",
+    "name": "智能插座",
+    "createAt": 1645409421118
+  }
+]

+ 26 - 0
data/init/deviceGroup.json

@@ -0,0 +1,26 @@
+[
+  {
+    "id": "g3",
+    "name": "组3",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "remark": "2223333",
+    "deviceQty": 7,
+    "createAt": 0
+  },
+  {
+    "id": "g2",
+    "name": "组2",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "remark": "222",
+    "deviceQty": 12,
+    "createAt": 0
+  },
+  {
+    "id": "g1",
+    "name": "分组1",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "remark": "1111",
+    "deviceQty": 10,
+    "createAt": 0
+  }
+]

+ 1655 - 0
data/init/deviceInfo.json

@@ -0,0 +1,1655 @@
+[
+  {
+    "id": "16552595723210menci0001008000012f",
+    "deviceId": "16552595723210menci0001008000012f",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "deviceName": "MENCI0001008",
+    "secret": "rMAweEJrE7cxbQWa",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655415536032
+    },
+    "property": {
+      "doorStatus": 0,
+      "power": 65,
+      "rssi": 106
+    },
+    "tag": {},
+    "createAt": 1655259572321,
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      }
+    }
+  },
+  {
+    "id": "16552595685220menci00010070000127",
+    "deviceId": "16552595685220menci00010070000127",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "deviceName": "MENCI0001007",
+    "secret": "eN4PjDhH4yx4mrmi",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655415536130
+    },
+    "property": {
+      "doorStatus": 1,
+      "power": 34,
+      "rssi": 64
+    },
+    "tag": {},
+    "createAt": 1655259568522,
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      }
+    }
+  },
+  {
+    "id": "16552595656210menci0001006000012d",
+    "deviceId": "16552595656210menci0001006000012d",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "deviceName": "MENCI0001006",
+    "secret": "ePSkE7bzGMsR6rTs",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655415536135
+    },
+    "property": {
+      "doorStatus": 1,
+      "power": 33,
+      "rssi": 40
+    },
+    "tag": {},
+    "createAt": 1655259565621,
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      }
+    }
+  },
+  {
+    "id": "16552594933210linght001007000012f",
+    "deviceId": "16552594933210linght001007000012f",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "deviceName": "LINGHT001007",
+    "secret": "mkQiSDk4rF3EWKFM",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416465031
+    },
+    "property": {
+      "brightness": 12,
+      "powerstate": 0
+    },
+    "tag": {},
+    "createAt": 1655259493321,
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      },
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    }
+  },
+  {
+    "id": "16552594898210linght0010060000129",
+    "deviceId": "16552594898210linght0010060000129",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "deviceName": "LINGHT001006",
+    "secret": "p72KAZyTA42zi8cJ",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416465035
+    },
+    "property": {
+      "brightness": 86,
+      "powerstate": 1
+    },
+    "tag": {},
+    "createAt": 1655259489821,
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      }
+    }
+  },
+  {
+    "id": "16552594863210linght001005000012c",
+    "deviceId": "16552594863210linght001005000012c",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "deviceName": "LINGHT001005",
+    "secret": "xnKZZyPKj2rH6ee3",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416465133
+    },
+    "property": {
+      "brightness": 16,
+      "powerstate": 1
+    },
+    "tag": {},
+    "createAt": 1655259486321,
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      },
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    }
+  },
+  {
+    "id": "16552594812210linght001004000012d",
+    "deviceId": "16552594812210linght001004000012d",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "deviceName": "LINGHT001004",
+    "secret": "PDkTxHPfw2H4WZjQ",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416465231
+    },
+    "property": {
+      "brightness": 32,
+      "powerstate": 0
+    },
+    "tag": {},
+    "createAt": 1655259481221,
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      }
+    }
+  },
+  {
+    "id": "16552594646210pulg0a0010160000122",
+    "deviceId": "16552594646210pulg0a0010160000122",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001016",
+    "secret": "3KdPNBKZEyDGaNYK",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652738672
+    },
+    "property": {
+      "powerstate": 0,
+      "rssi": 66
+    },
+    "tag": {},
+    "group": {
+      "g1": {
+        "id": "g1",
+        "name": "分组1"
+      }
+    },
+    "createAt": 1655259464621
+  },
+  {
+    "id": "16552594604220pulg0a0010150000127",
+    "deviceId": "16552594604220pulg0a0010150000127",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001015",
+    "secret": "TBwbHJdJBQCpGdHi",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652738676
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 67
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259460422
+  },
+  {
+    "id": "16552594572370pulg0a001014000012e",
+    "deviceId": "16552594572370pulg0a001014000012e",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001014",
+    "secret": "86pTYbQxxX3wd2FR",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652738773
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 42
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259457237
+  },
+  {
+    "id": "16552594542310pulg0a0010130000123",
+    "deviceId": "16552594542310pulg0a0010130000123",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001013",
+    "secret": "FtxYcTM5p6B5GyPk",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652738872
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 45
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259454231
+  },
+  {
+    "id": "16552594511210pulg0a001012000012c",
+    "deviceId": "16552594511210pulg0a001012000012c",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001012",
+    "secret": "5yHFHseBHDbCK3eZ",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652738972
+    },
+    "property": {
+      "powerstate": 0,
+      "rssi": 60
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259451121
+  },
+  {
+    "id": "16552594475270pulg0a0010110000125",
+    "deviceId": "16552594475270pulg0a0010110000125",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001011",
+    "secret": "pGC4z4TrbjZhii2m",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652739072
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 27
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259447528
+  },
+  {
+    "id": "16552594444210pulg0a0010100000128",
+    "deviceId": "16552594444210pulg0a0010100000128",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001010",
+    "secret": "HMxT2rQ55bzeRNJx",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652739076
+    },
+    "property": {
+      "powerstate": 0,
+      "rssi": 117
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259444422
+  },
+  {
+    "id": "16552594405220pulg0a0010090000124",
+    "deviceId": "16552594405220pulg0a0010090000124",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001009",
+    "secret": "Z6yMp6D6mHKMjFi7",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652739174
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 20
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259440522
+  },
+  {
+    "id": "16552594368340pulg0a0010080000126",
+    "deviceId": "16552594368340pulg0a0010080000126",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001008",
+    "secret": "Ek3ZjwPayCymDxhN",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652739272
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 77
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259436834
+  },
+  {
+    "id": "16552594320310pulg0a0010070000126",
+    "deviceId": "16552594320310pulg0a0010070000126",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001007",
+    "secret": "NnnHaibdHJXMxNbC",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655652739372
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 75
+    },
+    "tag": {},
+    "group": {
+      "g2": {
+        "id": "g2",
+        "name": "组2"
+      }
+    },
+    "createAt": 1655259432067
+  },
+  {
+    "id": "16542484163750d60ee9025d8430e327",
+    "deviceId": "16542484163750d60ee9025d8430e327",
+    "productKey": "Eit3kmGJtxSHfCKT",
+    "deviceName": "2475b491e72541f7ad60ee9025d8430e",
+    "secret": "bWkiEmY6wKM8WQP5",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false
+    },
+    "property": {
+      "flow": "333",
+      "fee": "2121212"
+    },
+    "tag": {},
+    "createAt": 1654248416391
+  },
+  {
+    "id": "16538390924670pulg0a001006000012a",
+    "deviceId": "16538390924670pulg0a001006000012a",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001006",
+    "secret": "FFSdNXDRJbnE8fm2",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [
+      "04c6722f-9a6d-40f3-ac9b-cd791b4c8933"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839933067
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 53,
+      "DeviceType": "222"
+    },
+    "tag": {
+      "aligenie": {
+        "id": "aligenie",
+        "name": "天猫精灵",
+        "value": "是"
+      },
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "0cfd14fc6d1ec120fcd38885df09f33c"
+      }
+    },
+    "createAt": 1653839092467
+  },
+  {
+    "id": "16538390885690pulg0a0010050000126",
+    "deviceId": "16538390885690pulg0a0010050000126",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001005",
+    "secret": "CN8ZGpcAheAbsDn2",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839933167
+    },
+    "property": {
+      "powerstate": 0,
+      "rssi": 117
+    },
+    "tag": {},
+    "createAt": 1653839088569
+  },
+  {
+    "id": "16538390853670pulg0a0010040000121",
+    "deviceId": "16538390853670pulg0a0010040000121",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001004",
+    "secret": "S4SDRKscRXAn43bc",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839933267
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 45
+    },
+    "tag": {},
+    "createAt": 1653839085367,
+    "group": {
+      "g3": {
+        "id": "g3",
+        "name": "组3"
+      }
+    }
+  },
+  {
+    "id": "16538390820760pulg0a0010030000127",
+    "deviceId": "16538390820760pulg0a0010030000127",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001003",
+    "secret": "7N4S6eYzMCjA7YfK",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839933367
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 101
+    },
+    "tag": {},
+    "createAt": 1653839082076
+  },
+  {
+    "id": "16538390787670pulg0a0010020000124",
+    "deviceId": "16538390787670pulg0a0010020000124",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001002",
+    "secret": "Jm7ecfyXawiend8K",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839933376
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 70
+    },
+    "tag": {},
+    "createAt": 1653839078767,
+    "group": {
+      "g3": {
+        "id": "g3",
+        "name": "组3"
+      }
+    }
+  },
+  {
+    "id": "16538390738670pulg0a0010010000125",
+    "deviceId": "16538390738670pulg0a0010010000125",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "PULG0A001001",
+    "secret": "rtsZbST3tiJHccbe",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839933474
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 118
+    },
+    "tag": {},
+    "createAt": 1653839073867,
+    "group": {
+      "g3": {
+        "id": "g3",
+        "name": "组3"
+      }
+    }
+  },
+  {
+    "id": "16538390097670switch0300100500143",
+    "deviceId": "16538390097670switch0300100500143",
+    "productKey": "eDhXKwEzwFybM5R7",
+    "deviceName": "SWITCH03001005",
+    "secret": "PXHwHXH4a8YJzZ3S",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839918667
+    },
+    "property": {
+      "powerstate_1": 0,
+      "powerstate_2": 0,
+      "powerstate_3": 1,
+      "rssi": 86
+    },
+    "tag": {},
+    "createAt": 1653839009767,
+    "group": {
+      "g3": {
+        "id": "g3",
+        "name": "组3"
+      }
+    }
+  },
+  {
+    "id": "16538390048670switch0300100400141",
+    "deviceId": "16538390048670switch0300100400141",
+    "productKey": "eDhXKwEzwFybM5R7",
+    "deviceName": "SWITCH03001004",
+    "secret": "BQj5SZetsC3eGtfM",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839918676
+    },
+    "property": {
+      "powerstate_1": 0,
+      "powerstate_2": 0,
+      "powerstate_3": 0,
+      "rssi": 27
+    },
+    "tag": {},
+    "createAt": 1653839004867,
+    "group": {
+      "g3": {
+        "id": "g3",
+        "name": "组3"
+      }
+    }
+  },
+  {
+    "id": "16538390008670switch0300100300145",
+    "deviceId": "16538390008670switch0300100300145",
+    "productKey": "eDhXKwEzwFybM5R7",
+    "deviceName": "SWITCH03001003",
+    "secret": "mbs4PsY4atEtzcA3",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839918771
+    },
+    "property": {
+      "powerstate_1": 0,
+      "powerstate_2": 0,
+      "powerstate_3": 0,
+      "rssi": 29
+    },
+    "tag": {},
+    "createAt": 1653839000867,
+    "group": {
+      "g3": {
+        "id": "g3",
+        "name": "组3"
+      }
+    }
+  },
+  {
+    "id": "16538389971670switch0300100200140",
+    "deviceId": "16538389971670switch0300100200140",
+    "productKey": "eDhXKwEzwFybM5R7",
+    "deviceName": "SWITCH03001002",
+    "secret": "4nrNrjnFMSQZB562",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839918871
+    },
+    "property": {
+      "powerstate_1": 1,
+      "powerstate_2": 0,
+      "powerstate_3": 0,
+      "rssi": 12
+    },
+    "tag": {},
+    "createAt": 1653838997167,
+    "group": {
+      "g3": {
+        "id": "g3",
+        "name": "组3"
+      }
+    }
+  },
+  {
+    "id": "16538389915670switch030010010014c",
+    "deviceId": "16538389915670switch030010010014c",
+    "productKey": "eDhXKwEzwFybM5R7",
+    "deviceName": "SWITCH03001001",
+    "secret": "Js66kBbXRjXmcpMB",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839918967
+    },
+    "property": {
+      "powerstate_1": 0,
+      "powerstate_2": 1,
+      "powerstate_3": 0,
+      "rssi": 18
+    },
+    "tag": {},
+    "createAt": 1653838991567
+  },
+  {
+    "id": "16538383943670wenshidu01008000139",
+    "deviceId": "16538383943670wenshidu01008000139",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01008",
+    "secret": "pGxKYrNJC7rDhsr8",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416485331
+    },
+    "property": {
+      "humidity": 93,
+      "temperature": 330
+    },
+    "tag": {},
+    "createAt": 1653838394367
+  },
+  {
+    "id": "16538383910670wenshidu01007000136",
+    "deviceId": "16538383910670wenshidu01007000136",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01007",
+    "secret": "ZxDQeQ8jhMrfx8eE",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416485335
+    },
+    "property": {
+      "humidity": 91,
+      "temperature": -29
+    },
+    "tag": {},
+    "createAt": 1653838391067
+  },
+  {
+    "id": "16538383880670wenshidu0100600013b",
+    "deviceId": "16538383880670wenshidu0100600013b",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01006",
+    "secret": "fEbdXEayedpBx6wk",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416485433
+    },
+    "property": {
+      "humidity": 95,
+      "temperature": 394
+    },
+    "tag": {},
+    "createAt": 1653838388067
+  },
+  {
+    "id": "16538383850710wenshidu01005000134",
+    "deviceId": "16538383850710wenshidu01005000134",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01005",
+    "secret": "Crm28CTD6iw7hYw5",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416485531
+    },
+    "property": {
+      "humidity": 23,
+      "temperature": 425
+    },
+    "tag": {},
+    "createAt": 1653838385071
+  },
+  {
+    "id": "16538383810690wenshidu01004000132",
+    "deviceId": "16538383810690wenshidu01004000132",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01004",
+    "secret": "FkCQGREXYCmjzxaZ",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655416485631
+    },
+    "property": {
+      "humidity": 96,
+      "temperature": 263
+    },
+    "tag": {},
+    "createAt": 1653838381074
+  },
+  {
+    "id": "16537595658790linght0010030000128",
+    "deviceId": "16537595658790linght0010030000128",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "deviceName": "LINGHT001003",
+    "secret": "JwKxnDWGrRcP8xAJ",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839919567
+    },
+    "property": {
+      "brightness": 9,
+      "powerstate": 0
+    },
+    "tag": {},
+    "createAt": 1653759565879
+  },
+  {
+    "id": "16537595624750linght001002000012c",
+    "deviceId": "16537595624750linght001002000012c",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "deviceName": "LINGHT001002",
+    "secret": "xrX2mrkQwf3YYaWc",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839919576
+    },
+    "property": {
+      "brightness": 83,
+      "powerstate": 1
+    },
+    "tag": {},
+    "createAt": 1653759562475
+  },
+  {
+    "id": "16537595591780linght0010010000121",
+    "deviceId": "16537595591780linght0010010000121",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "deviceName": "LINGHT001001",
+    "secret": "diRBkEREDt47MzWF",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839919673
+    },
+    "property": {
+      "brightness": 81,
+      "powerstate": 1
+    },
+    "tag": {},
+    "createAt": 1653759559178
+  },
+  {
+    "id": "16537595308820fan000100300000010d",
+    "deviceId": "16537595308820fan000100300000010d",
+    "productKey": "hdX3PCMcFrCYpesJ",
+    "deviceName": "FAN0001003",
+    "secret": "fR3R3i8BYDKWAiDj",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false
+    },
+    "property": {},
+    "tag": {},
+    "createAt": 1653759530882
+  },
+  {
+    "id": "16537595248720fan0001002000000101",
+    "deviceId": "16537595248720fan0001002000000101",
+    "productKey": "hdX3PCMcFrCYpesJ",
+    "deviceName": "FAN0001002",
+    "secret": "t3NYS5p7ExYaWKx4",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false
+    },
+    "property": {},
+    "tag": {},
+    "createAt": 1653759524872
+  },
+  {
+    "id": "16537595195720fan0001001000000108",
+    "deviceId": "16537595195720fan0001001000000108",
+    "productKey": "hdX3PCMcFrCYpesJ",
+    "deviceName": "FAN0001001",
+    "secret": "KSpeRjXRP8H7tcAn",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false
+    },
+    "property": {},
+    "tag": {},
+    "createAt": 1653759519572
+  },
+  {
+    "id": "16537594784840wenshidu0100300013a",
+    "deviceId": "16537594784840wenshidu0100300013a",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01003",
+    "secret": "DSBbhJW7cGXRWeZA",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839926671
+    },
+    "property": {
+      "humidity": 45,
+      "temperature": 123
+    },
+    "tag": {},
+    "createAt": 1653759478484
+  },
+  {
+    "id": "16537594752710wenshidu0100200013d",
+    "deviceId": "16537594752710wenshidu0100200013d",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01002",
+    "secret": "5bm8pNYcdj7YPMXn",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839926777
+    },
+    "property": {
+      "humidity": 6,
+      "temperature": 28
+    },
+    "tag": {},
+    "createAt": 1653759475271
+  },
+  {
+    "id": "16537594707840wenshidu0100100013c",
+    "deviceId": "16537594707840wenshidu0100100013c",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "WENSHIDU01001",
+    "secret": "neSfPnhsjCsQiCQx",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653839927067
+    },
+    "property": {
+      "humidity": 35,
+      "temperature": 392
+    },
+    "tag": {},
+    "createAt": 1653759470784
+  },
+  {
+    "id": "16537591055800menci0001003000012e",
+    "deviceId": "16537591055800menci0001003000012e",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "deviceName": "MENCI0001003",
+    "secret": "2D2k8mmHbi2AMh8G",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653785231385
+    },
+    "property": {
+      "doorStatus": 1,
+      "power": 70,
+      "rssi": 38
+    },
+    "tag": {},
+    "createAt": 1653759105580
+  },
+  {
+    "id": "16537590838150menci00010020000128",
+    "deviceId": "16537590838150menci00010020000128",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "deviceName": "MENCI0001002",
+    "secret": "AQHQJTQ2iXkncb3C",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653785231786
+    },
+    "property": {
+      "doorStatus": 1,
+      "power": 99,
+      "rssi": 48
+    },
+    "tag": {},
+    "createAt": 1653759083815
+  },
+  {
+    "id": "16537590780810menci0001001000012b",
+    "deviceId": "16537590780810menci0001001000012b",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "deviceName": "MENCI0001001",
+    "secret": "PwYEKSARBJjD4y6B",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653785232184
+    },
+    "property": {
+      "doorStatus": 1,
+      "power": 67,
+      "rssi": 54
+    },
+    "tag": {},
+    "createAt": 1653759078092
+  },
+  {
+    "id": "16534030209640test001230100000118",
+    "deviceId": "16534030209640test001230100000118",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "TEST0012301",
+    "secret": "C8YxCycFFeQDPKX4",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653730979070
+    },
+    "property": {
+      "DeviceType": "",
+      "powerstate": 1,
+      "rssi": 15
+    },
+    "tag": {},
+    "createAt": 1653403020971
+  },
+  {
+    "id": "16514657683280abe125000010000011f",
+    "deviceId": "16514657683280abe125000010000011f",
+    "productKey": "AWcJnf7ymGSkaz5M",
+    "deviceName": "ABE12500001",
+    "model": "M1",
+    "parentId": "16514626212240aabbccee01000000143",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653380321483
+    },
+    "property": {
+      "powerstate": "1",
+      "power": "1",
+      "rssi": "1",
+      "switch": "3232",
+      "current": "10000",
+      "electricty": "10"
+    },
+    "tag": {},
+    "createAt": 1651465768328
+  },
+  {
+    "id": "16514627991620aabbccdd1000000014f",
+    "deviceId": "16514627991620aabbccdd1000000014f",
+    "productKey": "hbtgIA0SuVw9lxjB",
+    "deviceName": "AA:BB:CC:DD:10",
+    "model": "GW01",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false,
+      "onlineTime": 1653185932725,
+      "offlineTime": 1653187754035
+    },
+    "property": {},
+    "tag": {},
+    "createAt": 1651462799162
+  },
+  {
+    "id": "16514626218250abe124000010000011a",
+    "deviceId": "16514626218250abe124000010000011a",
+    "productKey": "6kYp6jszrDns2yh4",
+    "deviceName": "ABE12400001",
+    "model": "S1",
+    "parentId": "16514626212240aabbccee01000000143",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653380322090,
+      "offlineTime": 1652593079579
+    },
+    "property": {
+      "humidity": 14,
+      "temperature": 447
+    },
+    "tag": {},
+    "createAt": 1651462621825
+  },
+  {
+    "id": "16514626216250abe1230000200000114",
+    "deviceId": "16514626216250abe1230000200000114",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "ABE12300002",
+    "model": "S1",
+    "parentId": "16514626212240aabbccee01000000143",
+    "uid": "15620886-b30d-439d-9e5f-13a094c1f1f9",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653380319984,
+      "offlineTime": 1652593079484
+    },
+    "property": {
+      "powerstate": 0,
+      "rssi": 26
+    },
+    "tag": {},
+    "createAt": 1651462621625
+  },
+  {
+    "id": "16514626214280abe1230000100000116",
+    "deviceId": "16514626214280abe1230000100000116",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "ABE12300001",
+    "model": "S1",
+    "parentId": "16514626212240aabbccee01000000143",
+    "uid": "15620886-b30d-439d-9e5f-13a094c1f1f9",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653380317469,
+      "offlineTime": 1652593079473
+    },
+    "property": {
+      "powerstate": 1,
+      "rssi": 48
+    },
+    "tag": {},
+    "createAt": 1651462621428
+  },
+  {
+    "id": "16514626212240aabbccee01000000143",
+    "deviceId": "16514626212240aabbccee01000000143",
+    "productKey": "N523nWsCiG3CAn6X",
+    "deviceName": "AA:BB:CC:EE:01",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653380312358,
+      "offlineTime": 1652593079381
+    },
+    "property": {
+      "UnbindAndDelete": "1"
+    },
+    "tag": {},
+    "createAt": 1651462621224
+  },
+  {
+    "id": "16501898583770f4cce4feffbd1bec164",
+    "deviceId": "16501898583770f4cce4feffbd1bec164",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "deviceName": "F4CCE4FEFFBD1BEC",
+    "model": "device",
+    "parentId": "165017126122400cefafcfee61000012b",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1655415536433,
+      "offlineTime": 1652669743574
+    },
+    "property": {
+      "DeviceType": "TY0203@_TZ1800_ho6i0zk9",
+      "power": 12,
+      "doorStatus": 1,
+      "rssi": 42
+    },
+    "tag": {
+      "aligenie": {
+        "id": "aligenie",
+        "name": "天猫精灵接入",
+        "value": "是"
+      }
+    },
+    "createAt": 1650189858377
+  },
+  {
+    "id": "16501806313260000833feffac33bc16c",
+    "deviceId": "16501806313260000833feffac33bc16c",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "000833FEFFAC33BC",
+    "model": "device",
+    "parentId": "165017126122400cefafcfee61000012b",
+    "uid": "15620886-b30d-439d-9e5f-13a094c1f1f9",
+    "subUid": [
+      "04c6722f-9a6d-40f3-ac9b-cd791b4c8933"
+    ],
+    "state": {
+      "online": false,
+      "onlineTime": 1652602130873,
+      "offlineTime": 1652669743479
+    },
+    "property": {
+      "DeviceType": "S2100-5102@_TZ2000_muw96vx2ppq6zh2k",
+      "powerstate": 1,
+      "rssi": -32
+    },
+    "tag": {
+      "aligenie": {
+        "id": "aligenie",
+        "name": "天猫精灵",
+        "value": "是"
+      },
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "0cfd14fc6d1ec120fcd38885df09f33c"
+      }
+    },
+    "createAt": 1650180631326
+  },
+  {
+    "id": "165017126122400cefafcfee61000012b",
+    "deviceId": "165017126122400cefafcfee61000012b",
+    "productKey": "N523nWsCiG3CAn6X",
+    "deviceName": "0CEFAFCFEE61",
+    "subUid": [
+      "04c6722f-9a6d-40f3-ac9b-cd791b4c8933"
+    ],
+    "state": {
+      "online": false,
+      "onlineTime": 1652602115884,
+      "offlineTime": 1652669743471
+    },
+    "property": {
+      "DeviceType": "WIDORA-BIT5"
+    },
+    "tag": {
+      "aligenie": {
+        "id": "aligenie",
+        "name": "天猫精灵",
+        "value": "是"
+      },
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "0cfd14fc6d1ec120fcd38885df09f33c"
+      }
+    },
+    "createAt": 1650171261224
+  },
+  {
+    "id": "164951142660200010000000000000034",
+    "deviceId": "164951142660200010000000000000034",
+    "productKey": "KdJYpTp5ywNhmrmC",
+    "deviceName": "001",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "state": {
+      "online": false
+    },
+    "createAt": 1649511426602,
+    "tag": {
+      "aligenie": {
+        "id": "aligenie",
+        "name": "天猫精灵接入",
+        "value": "是"
+      }
+    }
+  },
+  {
+    "id": "164785263238900cefafcfeeab0000125",
+    "deviceId": "164785263238900cefafcfeeab0000125",
+    "productKey": "N523nWsCiG3CAn6X",
+    "deviceName": "0CEFAFCFEEAB",
+    "subUid": [
+      "629daa3de5a005209d182876"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1655581924548,
+      "offlineTime": 1655581807987
+    },
+    "property": {
+      "DeviceType": "WIDORA-BIT5"
+    },
+    "tag": {
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "b980663dfbcf35126bb5b85031c3413a"
+      }
+    },
+    "group": {},
+    "createAt": 1647852632389
+  },
+  {
+    "id": "16477632226720c2cc9f03008d1500166",
+    "deviceId": "16477632226720c2cc9f03008d1500166",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "C2CC9F03008D1500",
+    "model": "device",
+    "parentId": "164785263238900cefafcfeeab0000125",
+    "subUid": [
+      "629daa3de5a005209d182876"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1655581925148,
+      "offlineTime": 1655581808150
+    },
+    "property": {
+      "DeviceType": "lumi.plug@LUMI",
+      "powerstate": 0,
+      "rssi": -77
+    },
+    "tag": {
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "b980663dfbcf35126bb5b85031c3413a"
+      }
+    },
+    "group": {},
+    "createAt": 1647763222672
+  },
+  {
+    "id": "164776322227201472a803008d150016e",
+    "deviceId": "164776322227201472a803008d150016e",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "1472A803008D1500",
+    "model": "device",
+    "parentId": "164785263238900cefafcfeeab0000125",
+    "subUid": [
+      "629daa3de5a005209d182876"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1655581925152,
+      "offlineTime": 1655581808148
+    },
+    "property": {
+      "DeviceType": "lumi.plug@LUMI",
+      "powerstate": 1,
+      "rssi": -77
+    },
+    "tag": {
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "b980663dfbcf35126bb5b85031c3413a"
+      }
+    },
+    "group": {},
+    "createAt": 1647763222272
+  },
+  {
+    "id": "1647763221972019a89f03008d1500163",
+    "deviceId": "1647763221972019a89f03008d1500163",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "19A89F03008D1500",
+    "model": "device",
+    "parentId": "164785263238900cefafcfeeab0000125",
+    "subUid": [
+      "629daa3de5a005209d182876"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1655581925157,
+      "offlineTime": 1655581808053
+    },
+    "property": {
+      "DeviceType": "lumi.plug@LUMI",
+      "powerstate": 1,
+      "rssi": -80
+    },
+    "tag": {
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "b980663dfbcf35126bb5b85031c3413a"
+      }
+    },
+    "group": {},
+    "createAt": 1647763221972
+  },
+  {
+    "id": "16477632215720c11b1602008d1500160",
+    "deviceId": "16477632215720c11b1602008d1500160",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "C11B1602008D1500",
+    "model": "device",
+    "parentId": "164785263238900cefafcfeeab0000125",
+    "subUid": [
+      "629daa3de5a005209d182876"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1655581925252,
+      "offlineTime": 1655581808052
+    },
+    "property": {
+      "DeviceType": "lumi.plug@LUMI",
+      "powerstate": 1,
+      "rssi": -78
+    },
+    "tag": {
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "b980663dfbcf35126bb5b85031c3413a"
+      }
+    },
+    "group": {},
+    "createAt": 1647763221572
+  },
+  {
+    "id": "164776322117404acb9f03008d1500168",
+    "deviceId": "164776322117404acb9f03008d1500168",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "4ACB9F03008D1500",
+    "model": "device",
+    "parentId": "164785263238900cefafcfeeab0000125",
+    "subUid": [
+      "629daa3de5a005209d182876"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1655581925255,
+      "offlineTime": 1655581808049
+    },
+    "property": {
+      "DeviceType": "lumi.plug@LUMI",
+      "powerstate": 1,
+      "rssi": -78
+    },
+    "tag": {
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "b980663dfbcf35126bb5b85031c3413a"
+      }
+    },
+    "group": {},
+    "createAt": 1647763221174
+  },
+  {
+    "id": "1647690908735019dd9f03008d1500163",
+    "deviceId": "1647690908735019dd9f03008d1500163",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "deviceName": "19DD9F03008D1500",
+    "model": "device",
+    "parentId": "164785263238900cefafcfeeab0000125",
+    "subUid": [
+      "629daa3de5a005209d182876"
+    ],
+    "state": {
+      "online": true,
+      "onlineTime": 1655581925247,
+      "offlineTime": 1655581808009
+    },
+    "property": {
+      "powerstate": 1,
+      "DeviceType": "lumi.plug@LUMI",
+      "rssi": -78
+    },
+    "tag": {
+      "dueros": {
+        "id": "dueros",
+        "name": "小度",
+        "value": "是"
+      },
+      "duerosOpenUid": {
+        "id": "duerosOpenUid",
+        "name": "小度OpenUid",
+        "value": "b980663dfbcf35126bb5b85031c3413a"
+      }
+    },
+    "group": {},
+    "createAt": 1647690908735
+  },
+  {
+    "id": "16465723457670abd123000020000011c",
+    "deviceId": "16465723457670abd123000020000011c",
+    "productKey": "hdX3PCMcFrCYpesJ",
+    "deviceName": "ABD12300002",
+    "model": "F01",
+    "parentId": "16465226744430aabbccdd22000000143",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false,
+      "onlineTime": 1653380311848,
+      "offlineTime": 1653380472842
+    },
+    "property": {
+      "windSpeed": "7",
+      "powerSwitch": "1",
+      "workMode": "5"
+    },
+    "tag": {},
+    "createAt": 1646572345767
+  },
+  {
+    "id": "16465723454670abd1230000100000117",
+    "deviceId": "16465723454670abd1230000100000117",
+    "productKey": "hdX3PCMcFrCYpesJ",
+    "deviceName": "ABD12300001",
+    "model": "F01",
+    "parentId": "16465226744430aabbccdd22000000143",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false,
+      "onlineTime": 1653380308883,
+      "offlineTime": 1653380472498
+    },
+    "property": {
+      "windSpeed": "68"
+    },
+    "tag": {},
+    "createAt": 1646572345467
+  },
+  {
+    "id": "16465723451670abc123000030000011a",
+    "deviceId": "16465723451670abc123000030000011a",
+    "productKey": "Rf4QSjbm65X45753",
+    "deviceName": "ABC12300003",
+    "model": "S01",
+    "parentId": "16465226744430aabbccdd22000000143",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653729780071,
+      "offlineTime": 1653380472221
+    },
+    "property": {
+      "powerstate": 0,
+      "volt": 81
+    },
+    "tag": {},
+    "createAt": 1646572345167
+  },
+  {
+    "id": "16465723448670abc1230000200000115",
+    "deviceId": "16465723448670abc1230000200000115",
+    "productKey": "Rf4QSjbm65X45753",
+    "deviceName": "ABC12300002",
+    "model": "S01",
+    "parentId": "16465226744430aabbccdd22000000143",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": true,
+      "onlineTime": 1653729780174,
+      "offlineTime": 1653380471930
+    },
+    "property": {
+      "powerstate": 1,
+      "volt": 69
+    },
+    "tag": {},
+    "createAt": 1646572344867
+  },
+  {
+    "id": "16465226744430aabbccdd22000000143",
+    "deviceId": "16465226744430aabbccdd22000000143",
+    "productKey": "hbtgIA0SuVw9lxjB",
+    "deviceName": "AA:BB:CC:DD:22",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "subUid": [],
+    "state": {
+      "online": false,
+      "onlineTime": 1653380299997,
+      "offlineTime": 1653380471302
+    },
+    "property": {},
+    "tag": {},
+    "createAt": 1646522674443
+  }
+]

+ 54 - 0
data/init/home.json

@@ -0,0 +1,54 @@
+[
+  {
+    "id": "629e1d80a176d816952f1e82",
+    "name": "我的家庭",
+    "address": "",
+    "uid": "629e1d7fa176d816952f1e81",
+    "spaceNum": 0,
+    "deviceNum": 0,
+    "current": true
+  },
+  {
+    "id": "629e18e96b16ad6a3e158645",
+    "name": "我的家",
+    "uid": "629daa3de5a005209d182876",
+    "current": true
+  },
+  {
+    "id": "6238a49fecf37861bed7ad11",
+    "name": "我深圳的家",
+    "address": "广东省深圳市南山区西丽镇",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "current": true
+  },
+  {
+    "id":"6238a485ecf37861bed7ad10",
+    "name": "我深圳的家",
+    "address": "广东省深圳市南山区西丽镇",
+    "uid": "232f506f-76c0-46eb-890b-15edd1022ba1"
+  },
+  {
+    "id": "6238a2caecf37861bed7ad0f",
+    "name": "我深圳的家",
+    "address": "广东省深圳市南山区西丽镇",
+    "uid": "232f506f-76c0-46eb-890b-15edd1022ba1"
+  },
+  {
+    "id": "6238a2adecf37861bed7ad0e",
+    "name": "我深圳的家",
+    "address": "广东省深圳市南山区西丽镇",
+    "uid": "232f506f-76c0-46eb-890b-15edd1022ba1"
+  },
+  {
+    "id": "61bafc1e16cb60612ab95f98",
+    "name": "myhome",
+    "address": "shengzhen nanshan",
+    "uid": "183b4732-ce7f-4e4c-9c18-7e49fbf45579"
+  },
+  {
+    "id": "61bafb6fb8477d132da69513",
+    "name": "myhome",
+    "address": "shengzhen nanshan",
+    "uid": "183b4732-ce7f-4e4c-9c18-7e49fbf45579"
+  }
+]

+ 16 - 0
data/init/oauthClient.json

@@ -0,0 +1,16 @@
+[
+  {
+    "id": "iotkit",
+    "name": "奇特物联",
+    "clientSecret": "b86cb53d-c005-48a3-bb02-3c262151b68c",
+    "allowUrl": "*",
+    "createAt": 1652840868485
+  },
+  {
+    "id": "dueros",
+    "name": "小度音箱",
+    "clientSecret": "750c67c2-29cb-40c3-bf4d-c0b9bf3eed88",
+    "allowUrl": "*",
+    "createAt": 1652840868485
+  }
+]

+ 133 - 0
data/init/product.json

@@ -0,0 +1,133 @@
+[
+  {
+    "id": "xpsYHExTKPFaQMS7",
+    "name": "调光灯",
+    "category": "light",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "createAt": 1650174777304
+  },
+  {
+    "id": "hdX3PCMcFrCYpesJ",
+    "code": "hdX3PCMcFrCYpesJ",
+    "name": "智能风扇",
+    "category": "fan",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "createAt": 1646571291131
+  },
+  {
+    "id": "hbtgIA0SuVw9lxjB",
+    "name": "GW01网关",
+    "category": "gateway",
+    "nodeType": 0,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/hbtgIA0SuVw9lxjB/cover.jpg?Expires=1967598154&OSSAccessKeyId=LTAI5tGEHNoVu5tWHUWnosrs&Signature=2gh2jad14mVHGvWThwOd%2FykiB5g%3D",
+    "transparent": false,
+    "createAt": 1652238155938
+  },
+  {
+    "id": "eDhXKwEzwFybM5R7",
+    "name": "三路开关",
+    "category": "switch",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/eDhXKwEzwFybM5R7/cover.jpeg?Expires=1967598172&OSSAccessKeyId=LTAI5tGEHNoVu5tWHUWnosrs&Signature=ZrFgANkomVEDQRV5JdmONL0S2sY%3D",
+    "transparent": false,
+    "createAt": 1652238173536
+  },
+  {
+    "id": "cGCrkK7Ex4FESAwe",
+    "name": "插座",
+    "category": "SmartPlug",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/cGCrkK7Ex4FESAwe/cover.jpeg?Expires=1967598137&OSSAccessKeyId=LTAI5tGEHNoVu5tWHUWnosrs&Signature=vOjqav0pRZqQFgx8xBo99WhgWXk%3D",
+    "transparent": false,
+    "createAt": 1652238138626
+  },
+  {
+    "id": "Rf4QSjbm65X45753",
+    "name": "一路开关",
+    "category": "switch",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/Rf4QSjbm65X45753/cover.jpeg?Expires=1967598145&OSSAccessKeyId=LTAI5tGEHNoVu5tWHUWnosrs&Signature=ksQhmEm5Rn7C7FFqY09o9l%2BZ%2BIQ%3D",
+    "transparent": false,
+    "createAt": 1652238147123
+  },
+  {
+    "id": "PN3EDmkBZDD8whDd",
+    "name": "门磁",
+    "category": "door",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "null",
+    "createAt": 1650190400357
+  },
+  {
+    "id": "N523nWsCiG3CAn6X",
+    "name": "ZGW01",
+    "category": "gateway",
+    "nodeType": 0,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/N523nWsCiG3CAn6X/cover.jpg?Expires=1967597641&OSSAccessKeyId=LTAI5tGEHNoVu5tWHUWnosrs&Signature=%2BaGcHBT%2FHA3s%2BrZ687U50b4YE0A%3D",
+    "transparent": false,
+    "createAt": 1652237643216
+  },
+  {
+    "id": "KdJYpTp5ywNhmrmC",
+    "name": "第三方接入",
+    "category": "",
+    "nodeType": 0,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/KdJYpTp5ywNhmrmC/cover.png?Expires=1968261336&OSSAccessKeyId=LTAI5t8UFEH5eGrBUS5zSiof&Signature=df%2F6JEcxBlXitSNIENPMYJlRE8Y%3D",
+    "transparent": false,
+    "createAt": 1655637610215
+  },
+  {
+    "id": "Eit3kmGJtxSHfCKT",
+    "name": "燃气表",
+    "category": "meter",
+    "nodeType": 2,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "transparent": false,
+    "createAt": 1654237604221
+  },
+  {
+    "id": "DSGxxKk6E8mmDk6C",
+    "name": "通断器",
+    "category": "switch",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/DSGxxKk6E8mmDk6C/cover.jpeg?Expires=1967598201&OSSAccessKeyId=LTAI5tGEHNoVu5tWHUWnosrs&Signature=k2PqHc%2BI14DfCwD8kQIflwoBAog%3D",
+    "transparent": false,
+    "createAt": 1652238202310
+  },
+  {
+    "id": "D8c5pXFmt2KJDxNm",
+    "name": "四路场景面板",
+    "category": "switch",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "createAt": 1650187781637
+  },
+  {
+    "id": "AWcJnf7ymGSkaz5M",
+    "name": "smart pulg",
+    "category": "SmartPlug",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "img": "http://iotkit-img.oss-cn-shenzhen.aliyuncs.com/product/AWcJnf7ymGSkaz5M/cover.jpeg?Expires=1967598035&OSSAccessKeyId=LTAI5tGEHNoVu5tWHUWnosrs&Signature=tXzWH5%2B4JNcnuTFrJbvGwsbx97c%3D",
+    "transparent": true,
+    "createAt": 1652279098100
+  },
+  {
+    "id": "6kYp6jszrDns2yh4",
+    "name": "温湿度传感器",
+    "category": "sensor",
+    "nodeType": 1,
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "createAt": 1649653149339
+  }
+]

+ 11 - 0
data/init/productModel.json

@@ -0,0 +1,11 @@
+[
+  {
+    "id": "M1",
+    "name": "型号1",
+    "productKey": "AWcJnf7ymGSkaz5M",
+    "type": "LuaScript",
+    "script": "\nfunction decode(msg)\n   return {\n        ['identifier'] = 'report',\n        ['mid'] = '1',\n        ['type'] = 'property',\n        ['data'] ={\n            ['power']=string.sub(msg.data,3,3)\n        }\n    }\nend\n\nfunction encode(service)\n    return {\n\t['mid'] = 1,\n\t['model'] = 'M1',\n\t['mac'] = service.deviceName,\n\t['data'] = 'BB2'\n  }\nend\n",
+    "state": "publish",
+    "modifyAt": 1651466083339
+  }
+]

+ 62 - 0
data/init/protocolComponent.json

@@ -0,0 +1,62 @@
+[
+  {
+    "id": "fee0e826-963f-4e53-a2cf-11e3e5f784ea",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "移动Onenet Studio接入",
+    "type": "biz",
+    "protocol": "http",
+    "jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
+    "config": "{\"port\":\"8086\"}",
+    "converter": "6260396d67aced2696184053",
+    "state": "running",
+    "createAt": 1652238780184
+  },
+  {
+    "id": "eabb131d-8fd1-43a8-88d9-a198abfd3d42",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "MQTT标准协议组件",
+    "type": "device",
+    "protocol": "mqtt",
+    "jarFile": "mqtt-component-0.2.1-SNAPSHOT.jar",
+    "config": "{\"port\":1883,\"ssl\":false,\"type\":\"server\"}",
+    "converter": "6260396d67aced2696184053",
+    "state": "running",
+    "createAt": 1650473458084
+  },
+  {
+    "id": "cd8253c1-b489-434c-845d-d18c7b70dcea",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "电信NB协议接入组件",
+    "type": "device",
+    "protocol": "http",
+    "jarFile": "ctwing-component-0.2.1-SNAPSHOT.jar",
+    "config": "{\"port\":\"8087\"}",
+    "converter": "62995ba4dbf51a5ec41d5f7b",
+    "state": "stopped",
+    "createAt": 1654235056032
+  },
+  {
+    "id": "6c095554-35e7-4e9d-a8d2-bb919e9479f4",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "EMQX标准协议组件",
+    "type": "device",
+    "protocol": "mqtt",
+    "jarFile": "emqx-component-0.2.1-SNAPSHOT.jar",
+    "config": "{\"port\":\"1884\",\"ssl\":false,\"type\":\"client\",\"subscribeTopics\":[\"/sys/+/+/s/#\",\"/sys/client/connected\",\"/sys/client/disconnected\",\"/sys/session/subscribed\",\"/sys/session/unsubscribed\"],\"authPort\":\"8088\",\"broker\":\"127.0.0.1\",\"clientId\":\"test\",\"username\":\"test\",\"password\":\"123\"}",
+    "converter": "6260396d67aced2696184053",
+    "state": "running",
+    "createAt": 1653180468724
+  },
+  {
+    "id": "3ababc5e-15e9-45a7-8f38-2a6afd45c780",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "小度音箱接入组件",
+    "type": "biz",
+    "protocol": "http",
+    "jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
+    "config": "{\"port\":\"8084\"}",
+    "converter": "",
+    "state": "running",
+    "createAt": 1650685502665
+  }
+]

+ 23 - 0
data/init/protocolConverter.json

@@ -0,0 +1,23 @@
+[
+  {
+    "id": "62995ba4dbf51a5ec41d5f7b",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "自定义表计协议",
+    "desc": "用于燃气表的协议",
+    "createAt": 1654217636597
+  },
+  {
+    "id": "628ceb14addfdb2a3b4b5727",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "奇特HTTP标准协议",
+    "desc": "奇特HTTP标准协议转换器",
+    "createAt": 1653402388275
+  },
+  {
+    "id": "6260396d67aced2696184053",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "奇特MQTT标准协议",
+    "desc": "奇特MQTT标准协议转换器",
+    "createAt": 1650473325173
+  }
+]

+ 95 - 0
data/init/ruleInfo.json

@@ -0,0 +1,95 @@
+[
+  {
+    "id": "6b253651-f4f9-44b9-a802-115b668b68e1",
+    "name": "天猫精灵设备属性和状态推送",
+    "type": "flow",
+    "listeners": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"077319c3-325b-4bb6-8e07-dd2eed617f6f\",\"type\":\"device\",\"topic\":\"\",\"conditions\":[{\"id\":0.6683545166149798,\"type\":\"property\",\"device\":\"cGCrkK7Ex4FESAwe/#\",\"identifier\":\"report\",\"parameters\":[{\"identifier\":\"powerstate\",\"comparator\":\"*\"}]},{\"id\":0.6047040921280786,\"type\":\"state\",\"device\":\"cGCrkK7Ex4FESAwe/#\",\"identifier\":\"state:*\",\"parameters\":[]}]}"
+      },
+      {
+        "type": "device",
+        "config": "{\"id\":\"08d72321-39d4-4dcc-ba69-b09c4af187a3\",\"type\":\"device\",\"topic\":\"\",\"conditions\":[{\"id\":0.7992853094329277,\"type\":\"event\",\"device\":\"KdJYpTp5ywNhmrmC/001\",\"identifier\":\"userDevicesChange\",\"parameters\":[{\"comparator\":\"*\"}]}]}"
+      },
+      {
+        "type": "device",
+        "config": "{\"id\":\"554aba1c-9684-4e36-8f72-cdb325f86712\",\"type\":\"device\",\"topic\":\"\",\"conditions\":[{\"id\":0.9179545682030454,\"type\":\"property\",\"device\":\"PN3EDmkBZDD8whDd/#\",\"identifier\":\"report\",\"parameters\":[{\"identifier\":\"doorStatus\",\"comparator\":\"*\"}]}]}"
+      }
+    ],
+    "filters": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"0a8285df-f778-4e20-b26b-2b569fc1d3dd\",\"type\":\"device\",\"conditions\":[{\"id\":0.11425312074571847,\"device\":\"\",\"type\":\"tag\",\"identifier\":\"aligenie\",\"value\":\"是\",\"comparator\":\"==\"}]}"
+      }
+    ],
+    "actions": [
+      {
+        "type": "http",
+        "config": "{\"id\":\"de533da1-18cb-48ef-b913-22bdd96dcac9\",\"type\":\"http\",\"services\":[{\"url\":\"http://localhost:8087/aligenie/push\",\"script\":\"this.translate=function(msg){\\n  var data={};\\n  for(var p in msg.data){\\n\\tdata[p]=msg.data[p];\\n  }\\n  \\nreturn {\\n\\t//指定相对路径\\n    path:\\\"/\\\",\\n    method:\\\"post\\\",\\n    header:{\\n      //指定请求头\\n      contentType:\\\"application/json; charset=utf-8\\\"\\n    },\\n    body:JSON.stringify({\\n      deviceId:msg.deviceId,\\n      type:msg.type,\\n      identifier:msg.identifier,\\n      data:data\\n    })\\n  }\\n}\"}]}"
+      }
+    ],
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "state": "stopped",
+    "desc": "ss",
+    "createAt": 1649218592640
+  },
+  {
+    "id": "2c10229b-dcb2-439e-b411-5425b49657a1",
+    "name": "小度设备属性更新推送",
+    "type": "flow",
+    "listeners": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"11ae4827-d58b-44d7-8a4d-090bac2ddce8\",\"type\":\"device\",\"topic\":\"\",\"conditions\":[{\"id\":0.5375444987425966,\"type\":\"property\",\"device\":\"cGCrkK7Ex4FESAwe/#\",\"identifier\":\"report\",\"parameters\":[{\"identifier\":\"powerstate\",\"comparator\":\"*\"}]}]}"
+      },
+      {
+        "type": "device",
+        "config": "{\"id\":\"f0752ba9-38d8-4ee8-91cc-7f267875c358\",\"type\":\"device\",\"topic\":\"\",\"conditions\":[{\"id\":0.20619179667807042,\"type\":\"property\",\"device\":\"Rf4QSjbm65X45753/#\",\"identifier\":\"report\",\"parameters\":[{\"identifier\":\"powerstate\",\"comparator\":\"*\"}]}]}"
+      }
+    ],
+    "filters": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"747eb070-92ed-4e60-9a39-3b9a71afee9e\",\"type\":\"device\",\"conditions\":[{\"id\":0.7199397992080254,\"device\":\"\",\"type\":\"tag\",\"comparator\":\"==\",\"identifier\":\"dueros\",\"value\":\"是\"}]}"
+      }
+    ],
+    "actions": [
+      {
+        "type": "http",
+        "config": "{\"id\":\"35781aae-360f-4931-9d72-69f27e326e68\",\"type\":\"http\",\"services\":[{\"url\":\"https://xiaodu.baidu.com/saiya/smarthome/changereport\",\"script\":\"this.translate=function(msg,device){\\n  var pk=msg.productKey;\\n  var attributeName=\\\"\\\";\\n  //插座/开关\\n  if(pk==\\\"cGCrkK7Ex4FESAwe\\\" || pk==\\\"Rf4QSjbm65X45753\\\"){\\n\\tattributeName=\\\"turnOnState\\\";\\n  }\\n  //取openUid\\n  var tag=device.tag;\\n  if(!tag || !tag.duerosOpenUid){\\n\\treturn null;\\n  }\\n  var openUid=tag.duerosOpenUid.value;\\n  \\n  return {\\n    \\\"path\\\":\\\"\\\",\\n    \\\"method\\\":\\\"post\\\",\\n    \\\"header\\\":{\\n      //指定请求头\\n      \\\"contentType\\\":\\\"application/json; charset=utf-8\\\"\\n    },\\n    \\\"body\\\":JSON.stringify({\\n\\t  \\\"header\\\": {\\n\\t\\t  \\\"namespace\\\": \\\"DuerOS.ConnectedHome.Control\\\",\\n\\t\\t  \\\"name\\\": \\\"ChangeReportRequest\\\",\\n\\t\\t  \\\"messageId\\\": new Date().getTime()+\\\"\\\",\\n\\t\\t  \\\"payloadVersion\\\": \\\"1\\\"\\n\\t  },\\n\\t  \\\"payload\\\": {\\n\\t\\t  \\\"botId\\\": \\\"eb20e515-f505-8d31-abef-46da3345f114\\\",\\n\\t\\t  \\\"openUid\\\": openUid,\\n\\t\\t  \\\"appliance\\\": {\\n\\t\\t\\t  \\\"applianceId\\\": msg.deviceId,\\n\\t\\t\\t  \\\"attributeName\\\": attributeName\\n\\t\\t  }\\n\\t  }\\n  \\t})\\n  }\\n}\"}]}"
+      }
+    ],
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "state": "running",
+    "desc": "开关插座开关状态推送",
+    "createAt": 1652515471242
+  },
+  {
+    "id": "2820c218-660e-48ff-a234-c7b6793a5bb8",
+    "name": "测试场景1",
+    "type": "scene",
+    "listeners": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"4ff98e8c-e6f6-4e96-8932-de488a0a4bfb\",\"type\":\"device\",\"topic\":\"\",\"conditions\":[{\"id\":0.8212160690052512,\"type\":\"property\",\"device\":\"Rf4QSjbm65X45753/ABC12400001\",\"identifier\":\"report\",\"parameters\":[{\"identifier\":\"powerstate\",\"comparator\":\">\",\"value\":\"0\"}]}]}"
+      }
+    ],
+    "filters": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"24b4b975-d8ac-431d-881d-8c8b40e92861\",\"type\":\"device\",\"conditions\":[{\"id\":0.08981222614734863,\"device\":\"hdX3PCMcFrCYpesJ/ABD12300002\",\"identifier\":\"powerSwitch\",\"type\":\"property\",\"comparator\":\"==\",\"value\":\"0\"}]}"
+      }
+    ],
+    "actions": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"fde024b5-5105-4639-8602-d04300613af9\",\"type\":\"device\",\"services\":[{\"device\":\"hdX3PCMcFrCYpesJ/ABD12300002\",\"identifier\":\"set\",\"inputData\":[{\"identifier\":\"powerSwitch\",\"value\":\"1\"}]},{\"device\":\"hdX3PCMcFrCYpesJ/ABD12300002\",\"identifier\":\"set\",\"inputData\":[{\"identifier\":\"windSpeed\",\"value\":\"20\"}]}]}"
+      }
+    ],
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "state": "stopped",
+    "desc": "test",
+    "createAt": 1649167998895
+  }
+]

+ 65 - 0
data/init/space.json

@@ -0,0 +1,65 @@
+[
+  {
+    "id": "62a6a897f60ef7500d1a916b",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "name": "123",
+    "createAt": 1655089303228
+  },
+  {
+    "id": "62a6a894f60ef7500d1a916a",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "name": "123",
+    "createAt": 1655089300741
+  },
+  {
+    "id": "629e233be0dc6d4171e1a023",
+    "homeId": "629e1d80a176d816952f1e82",
+    "uid": "629e1d7fa176d816952f1e81",
+    "name": "客厅",
+    "createAt": 1654530875839
+  },
+  {
+    "id": "629e18fee0dc6d4171e1a021",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "uid": "629daa3de5a005209d182876",
+    "name": "卧室",
+    "createAt": 1654528254438
+  },
+  {
+    "id": "629e18f3e0dc6d4171e1a020",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "uid": "629daa3de5a005209d182876",
+    "name": "客厅",
+    "createAt": 1654528243058
+  },
+  {
+    "id": "62794a820b0776663635e636",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "name": "阳台",
+    "createAt": 1652116098020
+  },
+  {
+    "id": "62794a7d0b0776663635e635",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "name": "厨房",
+    "createAt": 1652116093323
+  },
+  {
+    "id": "62794a740b0776663635e634",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "name": "卧室",
+    "createAt": 1652116084721
+  },
+  {
+    "id": "62794a5c0b0776663635e633",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "name": "客厅",
+    "createAt": 1652116060926
+  }
+]

+ 101 - 0
data/init/spaceDevice.json

@@ -0,0 +1,101 @@
+[
+  {
+    "id": "629f5821e0dc6d4171e1a029",
+    "uid": "629daa3de5a005209d182876",
+    "deviceId": "164785263238900cefafcfeeab0000125",
+    "name": "卧室的ZGW01",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "spaceId": "629e18fee0dc6d4171e1a021",
+    "addAt": 1654609953349
+  },
+  {
+    "id": "629f581ee0dc6d4171e1a028",
+    "uid": "629daa3de5a005209d182876",
+    "deviceId": "164776322117404acb9f03008d1500168",
+    "name": "卧室的插座",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "spaceId": "629e18fee0dc6d4171e1a021",
+    "addAt": 1654609950464,
+    "useAt": 1655653227177
+  },
+  {
+    "id": "629f581ce0dc6d4171e1a027",
+    "uid": "629daa3de5a005209d182876",
+    "deviceId": "1647763221972019a89f03008d1500163",
+    "name": "卧室的插座",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "spaceId": "629e18fee0dc6d4171e1a021",
+    "addAt": 1654609948550,
+    "useAt": 1655653294372
+  },
+  {
+    "id": "629f581ae0dc6d4171e1a026",
+    "uid": "629daa3de5a005209d182876",
+    "deviceId": "164776322227201472a803008d150016e",
+    "name": "卧室的插座",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "spaceId": "629e18fee0dc6d4171e1a021",
+    "addAt": 1654609946750,
+    "useAt": 1655653552172
+  },
+  {
+    "id":  "629f5818e0dc6d4171e1a025",
+    "uid": "629daa3de5a005209d182876",
+    "deviceId": "16477632226720c2cc9f03008d1500166",
+    "name": "卧室的插座",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "spaceId": "629e18fee0dc6d4171e1a021",
+    "addAt": 1654609944061,
+    "useAt": 1655653548172
+  },
+  {
+    "id": "629f5734e0dc6d4171e1a024",
+    "uid": "629daa3de5a005209d182876",
+    "deviceId": "16477632215720c11b1602008d1500160",
+    "name": "卧室的插座",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "spaceId": "629e18fee0dc6d4171e1a021",
+    "addAt": 1654609716856,
+    "useAt": 1655653590474
+  },
+  {
+    "id": "629e1a1de0dc6d4171e1a022",
+    "uid": "629daa3de5a005209d182876",
+    "deviceId": "1647690908735019dd9f03008d1500163",
+    "name": "卧室的插座",
+    "homeId": "629e18e96b16ad6a3e158645",
+    "spaceId": "629e18fee0dc6d4171e1a021",
+    "addAt": 1654528541149,
+    "useAt": 1655653255089
+  },
+  {
+    "id": "629db2e1e5a005209d182877",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "deviceId": "16538390924670pulg0a001006000012a",
+    "name": "阳台的插座",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "spaceId": "62794a820b0776663635e636",
+    "addAt": 1654502113734,
+    "useAt": 1655653724374
+  },
+  {
+    "id": "6280d7cd7e234141ee9d1fd2",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "deviceId": "16501806313260000833feffac33bc16c",
+    "name": "灯的插座",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "spaceId": "62794a5c0b0776663635e633",
+    "addAt": 1652611021619,
+    "useAt": 1655181137254
+  },
+  {
+    "id": "6280b17d7e234141ee9d1fcf",
+    "uid": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "deviceId": "165017126122400cefafcfee61000012b",
+    "name": "客厅网关",
+    "homeId": "6238a49fecf37861bed7ad11",
+    "spaceId": "62794a5c0b0776663635e633",
+    "addAt": 1652601213676,
+    "useAt": 1655189186348
+  }
+]

+ 35 - 0
data/init/taskInfo.json

@@ -0,0 +1,35 @@
+[
+  {
+    "id": "97f79dde-bf3c-4d5b-bfd8-8102539002ad",
+    "name": "测试111",
+    "type": "timer",
+    "expression": "*/25 * * * * ? *",
+    "desc": "sss入网",
+    "actions": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"f8de6282-771d-4cdb-9929-299db46f361d\",\"type\":\"device\",\"services\":[{\"device\":\"hbtgIA0SuVw9lxjB/AA:BB:CC:DD:11\",\"identifier\":\"allowJoin\",\"inputData\":[]}]}"
+      }
+    ],
+    "state": "stopped",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "createAt": 1645928016031,
+    "reason": "stop by fa1c5eaa-de6e-48b6-805e-8f091c7bb831"
+  },
+  {
+    "id": "667bbfa1-a7ed-4ce8-9ce0-cfa8cac90e6c",
+    "name": "2222",
+    "type": "delay",
+    "expression": "22",
+    "desc": "2222",
+    "actions": [
+      {
+        "type": "device",
+        "config": "{\"id\":\"24fd7df7-5c7d-4964-83af-a83d04b4db58\",\"type\":\"device\",\"services\":[{\"device\":\"Rf4QSjbm65X45753/ABC12300001\",\"identifier\":\"set\",\"inputData\":[{\"identifier\":\"powerstate\",\"value\":\"1\"}]}]}"
+      }
+    ],
+    "state": "stopped",
+    "createAt": 1645871966035,
+    "reason": "stop by 6286886077b91b031115e6a6"
+  }
+]

+ 980 - 0
data/init/thingModel.json

@@ -0,0 +1,980 @@
+[
+  {
+    "id": "xpsYHExTKPFaQMS7",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "model": {
+      "properties": [
+        {
+          "identifier": "powerstate",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "brightness",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "1",
+              "max": "100"
+            }
+          },
+          "name": "亮度",
+          "accessMode": "rw"
+        }
+      ],
+      "services": [],
+      "events": []
+    }
+  },
+  {
+    "id": "hdX3PCMcFrCYpesJ",
+    "productKey": "hdX3PCMcFrCYpesJ",
+    "model": {
+      "properties": [
+        {
+          "identifier": "windSpeed",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "1",
+              "max": "10"
+            }
+          },
+          "name": "风速",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "powerSwitch",
+          "dataType": {
+            "type": "bool",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "电源开关",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "workMode",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "1": "正常风",
+              "2": "自然风",
+              "3": "睡眠风",
+              "4": "静音风"
+            }
+          },
+          "name": "工作模式",
+          "accessMode": "rw"
+        }
+      ],
+      "services": [],
+      "events": []
+    }
+  },
+  {
+    "id": "hbtgIA0SuVw9lxjB",
+    "productKey": "hbtgIA0SuVw9lxjB",
+    "model": {
+      "properties": [],
+      "services": [
+        {
+          "identifier": "allowJoin",
+          "inputData": [],
+          "outputData": [],
+          "name": "开启入网"
+        },
+        {
+          "identifier": "rawSend",
+          "inputData": [
+            {
+              "identifier": "data",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "10240"
+                }
+              },
+              "name": "数据"
+            },
+            {
+              "identifier": "mac",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "128"
+                }
+              },
+              "name": "设备mac"
+            },
+            {
+              "identifier": "model",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "128"
+                }
+              },
+              "name": "设备型号"
+            }
+          ],
+          "outputData": [],
+          "name": "透传下发"
+        }
+      ],
+      "events": [
+        {
+          "identifier": "rawReport",
+          "outputData": [
+            {
+              "identifier": "data",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "10240"
+                }
+              },
+              "name": "数据"
+            },
+            {
+              "identifier": "mac",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "128"
+                }
+              },
+              "name": "设备mac"
+            },
+            {
+              "identifier": "model",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "128"
+                }
+              },
+              "name": "设备型号"
+            }
+          ],
+          "name": "透传上报"
+        }
+      ]
+    }
+  },
+  {
+    "id": "eDhXKwEzwFybM5R7",
+    "productKey": "eDhXKwEzwFybM5R7",
+    "model": {
+      "properties": [
+        {
+          "identifier": "powerstate",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "全开关",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "powerstate_1",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关1",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "powerstate_2",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关2",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "powerstate_3",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关3",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "DeviceType",
+          "dataType": {
+            "type": "text",
+            "specs": {
+              "length": "128"
+            }
+          },
+          "name": "型号",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "rssi",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "-127",
+              "max": "127"
+            }
+          },
+          "name": "信号强度",
+          "accessMode": "r"
+        }
+      ],
+      "services": [],
+      "events": [
+        {
+          "identifier": "faultReportEvent",
+          "outputData": [
+            {
+              "identifier": "code",
+              "dataType": {
+                "type": "int32",
+                "specs": {}
+              },
+              "name": "错误代码"
+            }
+          ],
+          "name": "故障上报"
+        }
+      ]
+    }
+  },
+  {
+    "id": "cGCrkK7Ex4FESAwe",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "model": {
+      "properties": [
+        {
+          "identifier": "rssi",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "-127",
+              "max": "127"
+            }
+          },
+          "name": "信号强度",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "DeviceType",
+          "dataType": {
+            "type": "text",
+            "specs": {
+              "length": "128"
+            }
+          },
+          "name": "设备型号",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "powerstate",
+          "dataType": {
+            "type": "bool",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关",
+          "accessMode": "rw"
+        }
+      ],
+      "services": [
+        {
+          "identifier": "Toggle",
+          "inputData": [],
+          "outputData": [],
+          "name": "开关切换"
+        }
+      ],
+      "events": [
+        {
+          "identifier": "faultReportEvent",
+          "outputData": [
+            {
+              "identifier": "code",
+              "dataType": {
+                "type": "int32",
+                "specs": {
+                  "min": "0",
+                  "max": "255"
+                }
+              },
+              "name": "错误代码"
+            }
+          ],
+          "name": "故障上报"
+        }
+      ]
+    }
+  },
+  {
+    "id": "Rf4QSjbm65X45753",
+    "productKey": "Rf4QSjbm65X45753",
+    "model": {
+      "properties": [
+        {
+          "identifier": "powerstate",
+          "dataType": {
+            "type": "bool",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关状态",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "volt",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "100"
+            }
+          },
+          "name": "电压",
+          "accessMode": "r"
+        }
+      ],
+      "services": [
+        {
+          "identifier": "service1",
+          "inputData": [
+            {
+              "identifier": "p1",
+              "dataType": {
+                "type": "int32",
+                "specs": {
+                  "min": "1",
+                  "max": "100"
+                }
+              },
+              "name": "参数1"
+            },
+            {
+              "identifier": "p2",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "90"
+                }
+              },
+              "name": "参数2"
+            }
+          ],
+          "outputData": [],
+          "name": "服务1"
+        }
+      ],
+      "events": [
+        {
+          "identifier": "event1",
+          "outputData": [
+            {
+              "identifier": "p1",
+              "dataType": {
+                "type": "int32",
+                "specs": {
+                  "min": "0",
+                  "max": "100"
+                }
+              },
+              "name": "参数p1"
+            },
+            {
+              "identifier": "p2",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "100"
+                }
+              },
+              "name": "参数p2"
+            }
+          ],
+          "name": "测试event1"
+        }
+      ]
+    },
+    "_class": "cc.iotkit.model.ThingModel"
+  },
+  {
+    "id": "PN3EDmkBZDD8whDd",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "model": {
+      "properties": [
+        {
+          "identifier": "power",
+          "dataType": {
+            "type": "int32",
+            "specs": {}
+          },
+          "name": "电量",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "DeviceType",
+          "dataType": {
+            "type": "text",
+            "specs": {
+              "length": "128"
+            }
+          },
+          "name": "设备型号",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "rssi",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "-127",
+              "max": "127"
+            }
+          },
+          "name": "信号强度",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "doorStatus",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "门状态",
+          "accessMode": "r"
+        }
+      ],
+      "services": [],
+      "events": [
+        {
+          "identifier": "prylockEvent",
+          "outputData": [],
+          "name": "防撬报警事件"
+        }
+      ]
+    }
+  },
+  {
+    "id": "N523nWsCiG3CAn6X",
+    "productKey": "N523nWsCiG3CAn6X",
+    "model": {
+      "properties": [
+        {
+          "identifier": "DeviceType",
+          "dataType": {
+            "type": "text",
+            "specs": {
+              "length": "128"
+            }
+          },
+          "name": "设备型号",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "UnbindAndDelete",
+          "dataType": {
+            "type": "bool",
+            "specs": {
+              "0": "否",
+              "1": "是"
+            }
+          },
+          "name": "解绑并删除设备",
+          "accessMode": "rw"
+        }
+      ],
+      "services": [
+        {
+          "identifier": "Reboot",
+          "inputData": [],
+          "outputData": [],
+          "name": "重启"
+        },
+        {
+          "identifier": "AllowJoin",
+          "inputData": [],
+          "outputData": [],
+          "name": "开启组网"
+        },
+        {
+          "identifier": "OpenTrace",
+          "inputData": [
+            {
+              "identifier": "enable",
+              "dataType": {
+                "type": "bool",
+                "specs": {
+                  "0": "Close",
+                  "1": "Open"
+                }
+              },
+              "name": "值"
+            }
+          ],
+          "outputData": [],
+          "name": "打开调试"
+        },
+        {
+          "identifier": "ShowDesc",
+          "inputData": [
+            {
+              "identifier": "ieee",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "32"
+                }
+              },
+              "name": "设备地址"
+            }
+          ],
+          "outputData": [],
+          "name": "显示设备信息"
+        },
+        {
+          "identifier": "rawSend",
+          "inputData": [
+            {
+              "identifier": "model",
+              "dataType": {
+                "type": "text",
+                "specs": {}
+              },
+              "name": "设备型号"
+            },
+            {
+              "identifier": "mac",
+              "dataType": {
+                "type": "text",
+                "specs": {}
+              },
+              "name": "设备mac"
+            },
+            {
+              "identifier": "data",
+              "dataType": {
+                "type": "text",
+                "specs": {}
+              },
+              "name": "数据"
+            }
+          ],
+          "outputData": [],
+          "name": "透传下发"
+        }
+      ],
+      "events": [
+        {
+          "identifier": "faultReport",
+          "outputData": [
+            {
+              "identifier": "code",
+              "dataType": {
+                "type": "int32",
+                "specs": {
+                  "min": "0",
+                  "max": "255"
+                }
+              },
+              "name": "错误码"
+            }
+          ],
+          "name": "故障上报"
+        },
+        {
+          "identifier": "rawReport",
+          "outputData": [
+            {
+              "identifier": "model",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "128"
+                }
+              },
+              "name": "设备型号"
+            },
+            {
+              "identifier": "mac",
+              "dataType": {
+                "type": "text",
+                "specs": {}
+              },
+              "name": "设备mac"
+            },
+            {
+              "identifier": "data",
+              "dataType": {
+                "type": "text",
+                "specs": {}
+              },
+              "name": "数据"
+            }
+          ],
+          "name": "透传上报"
+        }
+      ]
+    }
+  },
+  {
+    "id": "KdJYpTp5ywNhmrmC",
+    "productKey": "KdJYpTp5ywNhmrmC",
+    "model": {
+      "properties": [],
+      "services": [],
+      "events": [
+        {
+          "identifier": "userDevicesChange",
+          "outputData": [
+            {
+              "identifier": "uid",
+              "dataType": {
+                "type": "text",
+                "specs": {
+                  "length": "100"
+                }
+              },
+              "name": "用户Id"
+            }
+          ],
+          "name": "用户设备列表变更"
+        }
+      ]
+    }
+  },
+  {
+    "id": "Eit3kmGJtxSHfCKT",
+    "productKey": "Eit3kmGJtxSHfCKT",
+    "model": {
+      "properties": [
+        {
+          "identifier": "flow",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "100000"
+            }
+          },
+          "name": "用量",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "fee",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "100000"
+            }
+          },
+          "name": "费用",
+          "accessMode": "rw"
+        }
+      ],
+      "services": [],
+      "events": []
+    }
+  },
+  {
+    "id": "D8c5pXFmt2KJDxNm",
+    "productKey": "D8c5pXFmt2KJDxNm",
+    "model": {
+      "properties": [
+        {
+          "identifier": "powerstate_1",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关1",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "powerstate_2",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关2",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "powerstate_3",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关3",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "powerstate_4",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关4",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "DeviceType",
+          "dataType": {
+            "type": "text",
+            "specs": {
+              "length": "128"
+            }
+          },
+          "name": "型号",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "rssi",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "-127",
+              "max": "127"
+            }
+          },
+          "name": "信号强度",
+          "accessMode": "r"
+        }
+      ],
+      "services": [],
+      "events": [
+        {
+          "identifier": "faultReportEvent",
+          "outputData": [
+            {
+              "identifier": "code",
+              "dataType": {
+                "type": "int32",
+                "specs": {}
+              },
+              "name": "错误代码"
+            }
+          ],
+          "name": "故障上报"
+        }
+      ]
+    }
+  },
+  {
+    "id": "AWcJnf7ymGSkaz5M",
+    "productKey": "AWcJnf7ymGSkaz5M",
+    "model": {
+      "properties": [
+        {
+          "identifier": "rssi",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "-128",
+              "max": "128"
+            }
+          },
+          "name": "信号强度",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "switch",
+          "dataType": {
+            "type": "bool",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "开关",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "voltage",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "1000"
+            }
+          },
+          "name": "电压",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "current",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "1000"
+            }
+          },
+          "name": "电流",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "power",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "1000000"
+            }
+          },
+          "name": "功率",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "electricty",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "1000000000"
+            }
+          },
+          "name": "电量",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "back_light",
+          "dataType": {
+            "type": "bool",
+            "specs": {
+              "0": "关",
+              "1": "开"
+            }
+          },
+          "name": "背光灯",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "start_onoff",
+          "dataType": {
+            "type": "enum",
+            "specs": {
+              "0": "off",
+              "1": "onoff with swithc",
+              "2": "on"
+            }
+          },
+          "name": "上电启动配置",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "cycle_timer",
+          "dataType": {
+            "type": "text",
+            "specs": {
+              "length": "64"
+            }
+          },
+          "name": "循环定时",
+          "accessMode": "rw"
+        },
+        {
+          "identifier": "countdown",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "1000000"
+            }
+          },
+          "name": "倒计时",
+          "accessMode": "rw"
+        }
+      ],
+      "services": [],
+      "events": []
+    }
+  },
+  {
+    "id": "6kYp6jszrDns2yh4",
+    "productKey": "6kYp6jszrDns2yh4",
+    "model": {
+      "properties": [
+        {
+          "identifier": "humidity",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "0",
+              "max": "100"
+            }
+          },
+          "name": "湿度\t",
+          "accessMode": "r"
+        },
+        {
+          "identifier": "temperature",
+          "dataType": {
+            "type": "int32",
+            "specs": {
+              "min": "-38",
+              "max": "656"
+            }
+          },
+          "name": "温度\t",
+          "accessMode": "r"
+        }
+      ],
+      "services": [],
+      "events": [
+        {
+          "identifier": "temperatureTooLowEvent",
+          "outputData": [],
+          "name": "温度过低事件"
+        }
+      ]
+    }
+  }
+]

+ 124 - 0
data/init/userInfo.json

@@ -0,0 +1,124 @@
+[
+  {
+    "id":  "629e1d7fa176d816952f1e81",
+    "uid": "13480802157",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "secret": "483752384B473759556E685768796B6F644E48634F76486C51646A41576B545A2B396C34474244414F334F78574F4778613764564338594E666770595A376177",
+    "nickName": "song2",
+    "type": 1,
+    "roles": [
+      "iot_client"
+    ],
+    "permissions": [],
+    "usePlatforms": [
+      "dueros"
+    ],
+    "createAt": 1654529407977
+  },
+  {
+    "id": "6286886077b91b031115e6a6",
+    "uid": "guest1",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "nickName": "演示账户",
+    "secret": "48774861346645676F51324A4D6E6639306E6474437741634C4333746C4575666C316F76503455542B5836763065315A2F676244695056557356704D49513569",
+    "type": 0,
+    "roles": [
+      "iot_system",
+      "iot_admin"
+    ],
+    "permissions": [],
+    "usePlatforms": [],
+    "createAt": 1647592821770
+  },
+  {
+    "id": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "uid": "iotkit",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "nickName": "管理员",
+    "secret": "6E49354D37437030564370666E48486150524B3134743258735059354D75324F6532594478654C47767535614C6C6E767139625170774E576477785A34513369",
+    "type": 0,
+    "roles": [
+      "iot_system",
+      "iot_admin"
+    ],
+    "permissions": [
+      "write"
+    ],
+    "usePlatforms": [],
+    "createAt": 1647592821770
+  },
+  {
+    "id": "a1051e81-f4fc-4182-a750-1a53a27f4c71",
+    "uid": "du2",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "nickName": "小度接入2",
+    "type": 1,
+    "roles": [
+      "iot_client"
+    ],
+    "usePlatforms": [
+      "dueros"
+    ],
+    "createAt": 1651230139460
+  },
+  {
+    "id": "5c0bea53-a318-42ed-a7c5-6e05e6db4ef2",
+    "uid": "tm3",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "nickName": "天猫精灵test3",
+    "type": 1,
+    "roles": [
+      "iot_client"
+    ],
+    "usePlatforms": [
+      "aligenie"
+    ],
+    "createAt": 1647982036151
+  },
+  {
+    "id": "2bb3e6f1-17ba-4bf5-9d5e-85fdffd8b85d",
+    "uid": "du1",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "nickName": "小度接入1",
+    "secret": "483752384B473759556E685768796B6F644E48634F76486C51646A41576B545A2B396C34474244414F334F517674507547437A72627A7154302B724441734C5A",
+    "type": 1,
+    "roles": [
+      "iot_client"
+    ],
+    "usePlatforms": [
+      "dueros",
+      "aligenie"
+    ],
+    "createAt": 1651226639006
+  },
+  {
+    "id": "0ca377e2-66ff-49f3-90c3-108a86bc90eb",
+    "uid": "tm1",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "nickName": "天猫精灵1",
+    "type": 1,
+    "roles": [
+      "iot_client"
+    ],
+    "usePlatforms": [
+      "aligenie"
+    ],
+    "createAt": 1648486563107
+  },
+  {
+    "id": "04c6722f-9a6d-40f3-ac9b-cd791b4c8933",
+    "uid": "18126045687",
+    "ownerId": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "nickName": "song",
+    "secret": "483752384B473759556E685768796B6F644E48634F76486C51646A41576B545A2B396C34474244414F334F517674507547437A72627A7154302B724441734C5A",
+    "type": 1,
+    "roles": [
+      "iot_client"
+    ],
+    "usePlatforms": [
+      "aligenie",
+      "dueros"
+    ],
+    "createAt": 1652115298592
+  }
+]

+ 137 - 0
data/init/virtualDevice.json

@@ -0,0 +1,137 @@
+[
+  {
+    "id":"6293953092084e2df303ba3e",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "三路开关",
+    "productKey": "eDhXKwEzwFybM5R7",
+    "devices": [
+      "16538390097670switch0300100500143",
+      "16538390048670switch0300100400141",
+      "16538390008670switch0300100300145",
+      "16538389971670switch0300100200140",
+      "16538389915670switch030010010014c"
+    ],
+    "type": "thingModel",
+    "script": "\nvar mid=1000;\n\nfunction getMid(){\n  mid++;\n  if(mid>9999){\n\tmid=1;\n  }\n  return mid+\"\";\n}\n\nfunction getRequestId(){\n  return \"RID\"+new Date().getTime()+getMid();\n}\n\n\nthis.receive=function(service,device){\n  return [];\n}\n\nthis.report=function(device){\n  return {\n    \"mid\":getRequestId(),\n    \"productKey\":device.productKey,  \n    \"deviceName\":device.deviceName,\n    \"type\":\"property\",\n    \"identifier\":\"report\",\n    \"occurred\":new Date().getTime(),\t//时间戳,设备上的事件或数据产生的本地时间\n    \"time\":new Date().getTime(),\t\t//时间戳,消息上报时间\n    \"data\":{\n\t  \"rssi\":127-parseInt(Math.random()*127),\n\t  \"powerstate_1\":Math.random()>0.5?1:0,\n\t  \"powerstate_2\":Math.random()>0.5?1:0,\n\t  \"powerstate_3\":Math.random()>0.5?1:0\n    }\n  }\n}",
+    "trigger": "random",
+    "triggerExpression": "second",
+    "state": "running",
+    "createAt": 1653839152090
+  },
+  {
+    "id":"629391ae92084e2df303ba3d",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "温湿度传感器",
+    "productKey": "6kYp6jszrDns2yh4",
+    "devices": [
+      "16538383943670wenshidu01008000139",
+      "16538383910670wenshidu01007000136",
+      "16538383880670wenshidu0100600013b",
+      "16538383850710wenshidu01005000134",
+      "16538383810690wenshidu01004000132",
+      "16537594784840wenshidu0100300013a",
+      "16537594752710wenshidu0100200013d",
+      "16537594707840wenshidu0100100013c",
+      "16514626218250abe124000010000011a"
+    ],
+    "type": "thingModel",
+    "script": "\nvar mid=1000;\n\nfunction getMid(){\n  mid++;\n  if(mid>9999){\n\tmid=1;\n  }\n  return mid+\"\";\n}\n\nfunction getRequestId(){\n  return \"RID\"+new Date().getTime()+getMid();\n}\n\n\nthis.receive=function(service,device){\n  return [];\n}\n\nthis.report=function(device){\n  return {\n    \"mid\":getRequestId(),\n    \"productKey\":device.productKey,  \n    \"deviceName\":device.deviceName,\n    \"type\":\"property\",\n    \"identifier\":\"report\",\n    \"occurred\":new Date().getTime(),\t//时间戳,设备上的事件或数据产生的本地时间\n    \"time\":new Date().getTime(),\t\t//时间戳,消息上报时间\n    \"data\":{\n      \"humidity\":parseInt(Math.random()*100),\n\t  \"temperature\":parseInt(Math.random()*500)-38\n    }\n  }\n}",
+    "trigger": "random",
+    "triggerExpression": "second",
+    "state": "running",
+    "createAt": 1653838254989
+  },
+  {
+    "id":  "629390f492084e2df303ba3c",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "调光灯",
+    "productKey": "xpsYHExTKPFaQMS7",
+    "devices": [
+      "16537595658790linght0010030000128",
+      "16537595624750linght001002000012c",
+      "16537595591780linght0010010000121",
+      "16552594933210linght001007000012f",
+      "16552594898210linght0010060000129",
+      "16552594863210linght001005000012c",
+      "16552594812210linght001004000012d"
+    ],
+    "type": "thingModel",
+    "script": "\nvar mid=1000;\n\nfunction getMid(){\n  mid++;\n  if(mid>9999){\n\tmid=1;\n  }\n  return mid+\"\";\n}\n\nfunction getRequestId(){\n  return \"RID\"+new Date().getTime()+getMid();\n}\n\n\nthis.receive=function(service,device){\n  return [];\n}\n\nthis.report=function(device){\n  return {\n    \"mid\":getRequestId(),\n    \"productKey\":device.productKey,  \n    \"deviceName\":device.deviceName,\n    \"type\":\"property\",\n    \"identifier\":\"report\",\n    \"occurred\":new Date().getTime(),\t//时间戳,设备上的事件或数据产生的本地时间\n    \"time\":new Date().getTime(),\t\t//时间戳,消息上报时间\n    \"data\":{\n      \"brightness\":parseInt(Math.random()*100),\n\t  \"powerstate\":Math.random()>0.5?1:0\n    }\n  }\n}",
+    "trigger": "random",
+    "triggerExpression": "second",
+    "state": "running",
+    "createAt": 1653838068860
+  },
+  {
+    "id": "62925cb72002b44c15caeb1c",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "虚拟门磁1",
+    "productKey": "PN3EDmkBZDD8whDd",
+    "devices": [
+      "16537591055800menci0001003000012e",
+      "16537590838150menci00010020000128",
+      "16537590780810menci0001001000012b",
+      "16552595723210menci0001008000012f",
+      "16552595685220menci00010070000127",
+      "16552595656210menci0001006000012d",
+      "16552595626260menci0001005000012b",
+      "16552595580220menci0001004000012a",
+      "16501898583770f4cce4feffbd1bec164"
+    ],
+    "type": "thingModel",
+    "script": "\nvar mid=1000;\n\nfunction getMid(){\n  mid++;\n  if(mid>9999){\n\tmid=1;\n  }\n  return mid+\"\";\n}\n\nfunction getRequestId(){\n  return \"RID\"+new Date().getTime()+getMid();\n}\n\n\nthis.receive=function(service,device){\n  return [];\n}\n\nthis.report=function(device){\n  return {\n    \"mid\":getRequestId(),\n    \"productKey\":device.productKey,  \n    \"deviceName\":device.deviceName,\n    \"type\":\"property\",\n    \"identifier\":\"report\",\n    \"occurred\":new Date().getTime(),\t//时间戳,设备上的事件或数据产生的本地时间\n    \"time\":new Date().getTime(),\t\t//时间戳,消息上报时间\n    \"data\":{\n      \"rssi\":127-parseInt(Math.random()*127),\n      \"power\":parseInt(Math.random()*100),\n\t  \"doorStatus\":Math.random()>0.5?1:0\n    }\n  }\n}",
+    "trigger": "random",
+    "triggerExpression": "minute",
+    "state": "running",
+    "createAt": 1653759159567
+  },
+  {
+    "id":  "628fd800fba69e633a972e12",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "开关1",
+    "productKey": "Rf4QSjbm65X45753",
+    "devices": [
+      "16465723451670abc123000030000011a",
+      "16465723448670abc1230000200000115"
+    ],
+    "type": "thingModel",
+    "script": "\nvar mid=1000;\n\nfunction getMid(){\n  mid++;\n  if(mid>9999){\n\tmid=1;\n  }\n  return mid+\"\";\n}\n\nfunction getRequestId(){\n  return \"RID\"+new Date().getTime()+getMid();\n}\n\n\nthis.receive=function(service,device){\n  return [{\n    \"productKey\":service.productKey,\n    \"deviceName\":service.deviceName,\n    \"mid\":service.mid,\n    \"type\":\"service\",\n    \"identifier\":\"reboot_reply\",\n    \"data\":{},\n    \"code\":0\n  },{\n    \"mid\":getRequestId(),\n    \"productKey\":service.productKey,  \n    \"deviceName\":service.deviceName,\n    \"type\":\"property\",\n    \"identifier\":\"report\",\n    \"occurred\":new Date().getTime(),\n    \"time\":new Date().getTime(),\n    \"data\":{\n      \"volt\":parseInt(Math.random()*100),\n\t  \"powerstate\":Math.random()>0.5?1:0\n    }\n  }]\n}\n\nthis.report=function(device){\n  return {\n    \"mid\":getRequestId(),\n    \"productKey\":device.productKey,  \n    \"deviceName\":device.deviceName,\n    \"type\":\"property\",\n    \"identifier\":\"report\",\n    \"occurred\":new Date().getTime(),\t//时间戳,设备上的事件或数据产生的本地时间\n    \"time\":new Date().getTime(),\t\t//时间戳,消息上报时间\n    \"data\":{\n      \"volt\":parseInt(Math.random()*100)\n    }\n  }\n}",
+    "trigger": "cron",
+    "triggerExpression": "0 * * * * ? ",
+    "state": "running",
+    "createAt": 1653594112764
+  },
+  {
+    "id":  "628fa6bc1b735b73cb260042",
+    "uid": "fa1c5eaa-de6e-48b6-805e-8f091c7bb831",
+    "name": "虚拟插座12",
+    "productKey": "cGCrkK7Ex4FESAwe",
+    "devices": [
+      "16534030209640test001230100000118",
+      "16514626216250abe1230000200000114",
+      "16514626214280abe1230000100000116",
+      "16538390924670pulg0a001006000012a",
+      "16538390885690pulg0a0010050000126",
+      "16538390853670pulg0a0010040000121",
+      "16538390820760pulg0a0010030000127",
+      "16538390787670pulg0a0010020000124",
+      "16538390738670pulg0a0010010000125",
+      "16552594646210pulg0a0010160000122",
+      "16552594604220pulg0a0010150000127",
+      "16552594572370pulg0a001014000012e",
+      "16552594542310pulg0a0010130000123",
+      "16552594511210pulg0a001012000012c",
+      "16552594475270pulg0a0010110000125",
+      "16552594444210pulg0a0010100000128",
+      "16552594405220pulg0a0010090000124",
+      "16552594368340pulg0a0010080000126",
+      "16552594320310pulg0a0010070000126"
+    ],
+    "type": "thingModel",
+    "script": "\nvar mid=1000;\n\nfunction getMid(){\n  mid++;\n  if(mid>9999){\n\tmid=1;\n  }\n  return mid+\"\";\n}\n\nfunction getRequestId(){\n  return \"RID\"+new Date().getTime()+getMid();\n}\n\n\nthis.receive=function(service,device){\n  var identifier=service.identifier;\n  var result= [{\n    \"productKey\":service.productKey,\n    \"deviceName\":service.deviceName,\n    \"mid\":service.mid,\n    \"type\":\"service\",\n    \"identifier\":identifier+\"_reply\",\n    \"data\":{},\n    \"code\":0\n  }]\n  \n  if(service.type==\"property\" && (identifier==\"get\" || identifier==\"set\")){\n\tresult.push({\n\t  \"mid\":getRequestId(),\n\t  \"productKey\":device.productKey,  \n\t  \"deviceName\":device.deviceName,\n\t  \"type\":\"property\",\n\t  \"identifier\":\"report\",\n\t  \"occurred\":new Date().getTime(),\n\t  \"time\":new Date().getTime(),\n\t  \"data\":service.params\n\t});\n  }\n  \n  return result;\n}\n\nthis.report=function(device){\n  return {\n    \"mid\":getRequestId(),\n    \"productKey\":device.productKey,  \n    \"deviceName\":device.deviceName,\n    \"type\":\"property\",\n    \"identifier\":\"report\",\n    \"occurred\":new Date().getTime(),\t//时间戳,设备上的事件或数据产生的本地时间\n    \"time\":new Date().getTime(),\t\t//时间戳,消息上报时间\n    \"data\":{\n      \"rssi\":127-parseInt(Math.random()*127),\n\t  \"powerstate\":Math.random()>0.5?1:0\n    }\n  }\n}",
+    "trigger": "random",
+    "triggerExpression": "second",
+    "state": "running",
+    "createAt": 1653581500076
+  }
+]

+ 2 - 2
manager/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iotkit-parent</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.2.2-SNAPSHOT</version>
+        <version>0.3.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -15,7 +15,7 @@
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-mongodb</artifactId>
+            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
         </dependency>
 
         <dependency>

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/Application.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager;
 
 import cc.iotkit.manager.config.EmbeddedElasticSearchConfig;

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/config/AliyunConfig.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.config;
 
 

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/config/CacheConfig.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.config;
 
 import cc.iotkit.common.Constants;

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/config/CrossConfig.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.config;
 
 

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/config/EmbeddedElasticSearchConfig.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.config;
 
 import lombok.SneakyThrows;

+ 3 - 0
manager/src/main/java/cc/iotkit/manager/config/SaTokenConfigure.java

@@ -52,9 +52,12 @@ public class SaTokenConfigure implements WebMvcConfigurer {
                     .check(c -> StpUtil.checkRoleOr("iot_admin", "iot_system"))
                     //需要有可写权限的功能
                     .match(
+                            "/**/save*",
                             "/**/save*/**",
                             "/**/remove*/**",
+                            "/**/del*",
                             "/**/del*/**",
+                            "/**/add*",
                             "/**/add*/**",
                             "/**/create*/**",
                             "/**/clear*/**",

+ 19 - 6
manager/src/main/java/cc/iotkit/manager/controller/AppController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller;
 
 import cc.iotkit.dao.AppDesignRepository;
@@ -9,10 +18,10 @@ import cc.iotkit.model.Paging;
 import cc.iotkit.model.product.AppDesign;
 import cc.iotkit.model.product.Category;
 import cc.iotkit.model.product.Product;
+import cc.iotkit.utils.AuthUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,11 +49,15 @@ public class AppController {
     public Paging<AppDesignVo> getDesigns() {
 
         List<AppDesignVo> appDesignVos = new ArrayList<>();
-        List<Product> products = productRepository.findAll(Example
-                .of(dataOwnerService.wrapExample(new Product())));
-
-        List<AppDesign> appDesigns = appDesignRepository.findAll(Example
-                .of(dataOwnerService.wrapExample(new AppDesign())));
+        Iterable<Product> products;
+        Iterable<AppDesign> appDesigns;
+        if (AuthUtil.isAdmin()) {
+            products = productRepository.findAll();
+            appDesigns = appDesignRepository.findAll();
+        } else {
+            products = productRepository.findByUid(AuthUtil.getUserId());
+            appDesigns = appDesignRepository.findByUid(AuthUtil.getUserId());
+        }
 
         products.forEach(product -> {
             Category category = categoryRepository.findById(product.getCategory()).orElse(new Category());

+ 29 - 28
manager/src/main/java/cc/iotkit/manager/controller/DeviceController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller;
 
 import cc.iotkit.common.Constants;
@@ -24,18 +33,16 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
-import org.springframework.data.domain.Example;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
-import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.elasticsearch.core.query.Criteria;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.context.request.async.DeferredResult;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.regex.Pattern;
 
 @Slf4j
 @RestController
@@ -45,7 +52,7 @@ public class DeviceController {
     @Autowired
     private DeviceService deviceService;
     @Autowired
-    private DeviceRepository deviceRepository;
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private ProductRepository productRepository;
     @Autowired
@@ -96,32 +103,30 @@ public class DeviceController {
         if (!AuthUtil.isAdmin()) {
             //客户端用户使用绑定子用户查询
             if (AuthUtil.isClientUser()) {
-                condition.and("subUid").elemMatch(new Criteria().is(uid));
+                condition = condition.and("subUid").matches(uid);
             } else {
-                condition.and("uid").is(uid);
+                condition = condition.and("uid").is(uid);
             }
         }
 
         String pk = query.getProductKey();
         if (StringUtils.isNotBlank(pk)) {
-            condition.and("productKey").is(pk);
+            condition = condition.and("productKey").is(pk);
         }
         //关键字查询
         String keyword = query.getKeyword();
         if (StringUtils.isNotBlank(keyword)) {
-            Pattern pattern = Pattern.compile("^.*" + keyword + ".*$", Pattern.CASE_INSENSITIVE);
-            condition.orOperator(
-                    Criteria.where("deviceName").regex(pattern),
-                    Criteria.where("deviceId").regex(pattern)
+            condition = condition.and(
+                    Criteria.where("deviceName").contains(keyword).and("deviceId").contains(keyword)
             );
         }
         String group = query.getGroup();
         if (StringUtils.isNotBlank(group)) {
-            condition.and("group." + group).exists(true);
+            condition = condition.and("group." + group).exists();
         }
         String state = query.getState();
         if (StringUtils.isNotBlank(state)) {
-            condition.and("state.online").is(state.equals("online"));
+            condition = condition.and("state.online").is(state.equals("online"));
         }
 
         return deviceDao.find(condition, size, page);
@@ -152,37 +157,33 @@ public class DeviceController {
         device.setState(new DeviceInfo.State(false, null, null));
         device.setCreateAt(System.currentTimeMillis());
 
-        deviceRepository.save(device);
+        deviceInfoRepository.save(device);
     }
 
     @GetMapping("/{deviceId}/children")
     public List<DeviceInfo> getChildren(@PathVariable("deviceId") String deviceId) {
-        return deviceRepository.findAll(Example.of(
-                dataOwnerService.wrapExample(
-                        DeviceInfo.builder()
-                                .parentId(deviceId)
-                                .build())));
+        if (AuthUtil.isAdmin()) {
+            return deviceInfoRepository.findByParentId(deviceId);
+        }
+        return deviceInfoRepository.findByParentIdAndUid(deviceId, AuthUtil.getUserId());
     }
 
     @GetMapping(Constants.API_DEVICE.DETAIL)
     public DeviceInfo getDetail(@PathVariable("deviceId") String deviceId) {
-        return dataOwnerService.checkOwner(deviceRepository.findById(deviceId).orElse(new DeviceInfo()));
+        return dataOwnerService.checkOwner(deviceInfoRepository.findById(deviceId).orElse(new DeviceInfo()));
     }
 
     @GetMapping("/{pk}/{dn}")
     public DeviceInfo getByPkDn(@PathVariable("pk") String pk,
                                 @PathVariable("dn") String dn) {
         return dataOwnerService.checkOwner(
-                deviceRepository.findOne(Example.of(DeviceInfo.builder()
-                        .productKey(pk)
-                        .deviceName(dn)
-                        .build())).orElse(new DeviceInfo()));
+                deviceInfoRepository.findByProductKeyAndDeviceName(pk, dn));
     }
 
     @PostMapping("/{deviceId}/delete")
     public void deleteDevice(@PathVariable("deviceId") String deviceId) {
         deviceId = getDetail(deviceId).getDeviceId();
-        deviceRepository.deleteById(deviceId);
+        deviceInfoRepository.deleteById(deviceId);
     }
 
     @PostMapping("/{deviceId}/logs/{size}/{page}")
@@ -218,7 +219,7 @@ public class DeviceController {
     @PostMapping("/{deviceId}/tag/add")
     public void addTag(@PathVariable("deviceId") String deviceId,
                        DeviceInfo.Tag tag) {
-        DeviceInfo device = deviceRepository.findByDeviceId(deviceId);
+        DeviceInfo device = deviceInfoRepository.findByDeviceId(deviceId);
         dataOwnerService.checkOwner(device);
         deviceDao.updateTag(deviceId, tag);
     }
@@ -227,7 +228,7 @@ public class DeviceController {
     public void simulateSend(
             @PathVariable("deviceId") String deviceId,
             @RequestBody ThingModelMessage message) {
-        DeviceInfo device = deviceRepository.findByDeviceId(deviceId);
+        DeviceInfo device = deviceInfoRepository.findByDeviceId(deviceId);
         dataOwnerService.checkOwner(device);
 
         message.setMid(UniqueIdUtil.newRequestId());
@@ -245,7 +246,7 @@ public class DeviceController {
             @PathVariable("clientId") String clientId
     ) {
         String uid = AuthUtil.getUserId();
-        DeviceInfo deviceInfo = deviceRepository.findByDeviceId(deviceId);
+        DeviceInfo deviceInfo = deviceInfoRepository.findByDeviceId(deviceId);
         dataOwnerService.checkOwner(deviceInfo);
 
         //按用户+客户端ID订阅

+ 30 - 14
manager/src/main/java/cc/iotkit/manager/controller/ProductController.java

@@ -1,11 +1,17 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller;
 
 import cc.iotkit.common.exception.BizException;
 import cc.iotkit.common.utils.JsonUtil;
-import cc.iotkit.dao.CategoryRepository;
-import cc.iotkit.dao.ProductRepository;
-import cc.iotkit.dao.ProductModelRepository;
-import cc.iotkit.dao.ThingModelRepository;
+import cc.iotkit.dao.*;
 import cc.iotkit.manager.config.AliyunConfig;
 import cc.iotkit.manager.service.DataOwnerService;
 import cc.iotkit.model.Paging;
@@ -13,20 +19,21 @@ import cc.iotkit.model.product.Category;
 import cc.iotkit.model.product.Product;
 import cc.iotkit.model.product.ProductModel;
 import cc.iotkit.model.product.ThingModel;
+import cc.iotkit.utils.AuthUtil;
 import cn.dev33.satoken.annotation.SaCheckRole;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.model.PutObjectResult;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
+import org.springframework.data.elasticsearch.core.query.Criteria;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Optional;
@@ -48,6 +55,9 @@ public class ProductController {
     private AliyunConfig aliyunConfig;
     @Autowired
     private ProductModelRepository productModelRepository;
+    @Autowired
+    private CommonDao commonDao;
+
 
     private OSS ossClient;
 
@@ -55,12 +65,16 @@ public class ProductController {
     public Paging<Product> getProducts(
             @PathVariable("size") int size,
             @PathVariable("page") int page,
-            Product form) {
-        form = dataOwnerService.wrapExample(form);
-        Page<Product> products = productRepository.findAll(Example.of(form),
-                PageRequest.of(page - 1, size, Sort.by(Sort.Order.desc("createAt")))
-        );
-        return new Paging<>(products.getTotalElements(), products.getContent());
+            String id) {
+        Criteria criteria = new Criteria();
+
+        if (StringUtils.isNotBlank(id)) {
+            criteria = criteria.and("id").is(id);
+        }
+        if (!AuthUtil.isAdmin()) {
+            criteria = criteria.and("uid").is(AuthUtil.getUserId());
+        }
+        return commonDao.pagedFind(Product.class, criteria, Sort.Order.desc("createAt"), size, page);
     }
 
     @PostMapping("/save")
@@ -98,7 +112,9 @@ public class ProductController {
 
     @GetMapping("/categories")
     public List<Category> getCategories() {
-        return categoryRepository.findAll();
+        List<Category> list = new ArrayList<>();
+        categoryRepository.findAll().forEach(list::add);
+        return list;
     }
 
     @SaCheckRole("iot_admin")

+ 0 - 2
manager/src/main/java/cc/iotkit/manager/controller/ProtocolController.java

@@ -204,8 +204,6 @@ public class ProtocolController {
     public Paging<ProtocolConverter> getConverters(
             @PathVariable("size") int size,
             @PathVariable("page") int page) {
-        protocolConverterRepository.deleteById("");
-        protocolConverterRepository.deleteById("null");
         Page<ProtocolConverter> converters = protocolConverterRepository.findAll(
                 PageRequest.of(page - 1, size, Sort.by(Sort.Order.desc("createAt"))));
         return new Paging<>(converters.getTotalElements(), converters.getContent());

+ 22 - 5
manager/src/main/java/cc/iotkit/manager/controller/RuleEngineController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller;
 
 import cc.iotkit.common.exception.BizException;
@@ -20,6 +29,7 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.data.domain.*;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import java.util.UUID;
@@ -60,8 +70,12 @@ public class RuleEngineController {
     ) {
         RuleInfo ruleInfo = new RuleInfo();
         ruleInfo.setType(type);
-        Page<RuleInfo> rules = ruleInfoRepository.findAll(Example.of(dataOwnerService
-                .wrapExample(ruleInfo)), Pageable.ofSize(size).withPage(page - 1));
+        Page<RuleInfo> rules;
+        if (AuthUtil.isAdmin()) {
+            rules = ruleInfoRepository.findByType(type, Pageable.ofSize(size).withPage(page - 1));
+        } else {
+            rules = ruleInfoRepository.findByUidAndType(AuthUtil.getUserId(), type, Pageable.ofSize(size).withPage(page - 1));
+        }
         return new Paging<>(rules.getTotalElements(), rules.getContent());
     }
 
@@ -155,9 +169,12 @@ public class RuleEngineController {
 
     @PostMapping("/tasks")
     public List<TaskInfo> tasks() {
-        return taskInfoRepository.findAll(Example.of(dataOwnerService
-                .wrapExample(new TaskInfo()))
-        );
+        List<TaskInfo> list = new ArrayList<>();
+        if (AuthUtil.isAdmin()) {
+            taskInfoRepository.findAll().forEach(list::add);
+            return list;
+        }
+        return taskInfoRepository.findByUid(AuthUtil.getUserId());
     }
 
     @PostMapping("/saveTask")

+ 20 - 12
manager/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller;
 
 import cc.iotkit.common.Constants;
@@ -15,7 +24,6 @@ import cc.iotkit.model.space.Space;
 import cc.iotkit.model.space.SpaceDevice;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
@@ -32,7 +40,7 @@ public class SpaceDeviceController {
     @Autowired
     private SpaceDeviceRepository spaceDeviceRepository;
     @Autowired
-    private DeviceRepository deviceRepository;
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private DeviceCache deviceCache;
     @Autowired
@@ -78,7 +86,7 @@ public class SpaceDeviceController {
     }
 
     private SpaceDeviceVo parseSpaceDevice(SpaceDevice sd) {
-        DeviceInfo device = deviceRepository.findByDeviceId(sd.getDeviceId());
+        DeviceInfo device = deviceInfoRepository.findByDeviceId(sd.getDeviceId());
         Space space = spaceCache.getSpace(sd.getSpaceId());
         Product product = productCache.findById(device.getProductKey());
         Category category = categoryCache.getById(product.getCategory());
@@ -107,7 +115,7 @@ public class SpaceDeviceController {
      */
     @GetMapping("/{userId}/devices")
     public List<SpaceDeviceVo> getDevices(@PathVariable("userId") String userId) {
-        List<SpaceDevice> spaceDevices = spaceDeviceRepository.findAll(Example.of(SpaceDevice.builder().uid(userId).build()));
+        List<SpaceDevice> spaceDevices = spaceDeviceRepository.findByUid(userId);
         return spaceDevices.stream().map((this::parseSpaceDevice)).collect(Collectors.toList());
     }
 
@@ -121,7 +129,7 @@ public class SpaceDeviceController {
         }
 
         List<FindDeviceVo> findDeviceVos = new ArrayList<>();
-        List<DeviceInfo> devices = deviceRepository.findByDeviceName(mac);
+        List<DeviceInfo> devices = deviceInfoRepository.findByDeviceName(mac);
         if (devices == null) {
             return findDeviceVos;
         }
@@ -130,7 +138,7 @@ public class SpaceDeviceController {
         List<DeviceInfo> subDevices = new ArrayList<>();
         for (DeviceInfo device : devices) {
             if (device.getParentId() == null) {
-                subDevices = deviceRepository.findByParentId(device.getDeviceId());
+                subDevices = deviceInfoRepository.findByParentId(device.getDeviceId());
             }
         }
         devices.addAll(subDevices);
@@ -167,7 +175,7 @@ public class SpaceDeviceController {
     @PostMapping(Constants.API_SPACE.ADD_DEVICE)
     public void addDevice(SpaceDevice device) {
         String deviceId = device.getDeviceId();
-        DeviceInfo deviceInfo = deviceRepository.findByDeviceId(deviceId);
+        DeviceInfo deviceInfo = deviceInfoRepository.findByDeviceId(deviceId);
         if (deviceInfo == null) {
             throw new BizException("device does not exist");
         }
@@ -219,7 +227,7 @@ public class SpaceDeviceController {
             tags.put(platform, new DeviceInfo.Tag(platform, thirdPlatform.desc, "是"));
         }
 
-        deviceRepository.save(deviceInfo);
+        deviceInfoRepository.save(deviceInfo);
     }
 
     /**
@@ -235,7 +243,7 @@ public class SpaceDeviceController {
         dataOwnerService.checkOwner(spaceDevice);
 
         spaceDeviceRepository.deleteById(spaceDevice.getId());
-        DeviceInfo deviceInfo = deviceRepository.findByDeviceId(deviceId);
+        DeviceInfo deviceInfo = deviceInfoRepository.findByDeviceId(deviceId);
         Optional<UserInfo> optUser = userInfoRepository.findById(uid);
         if (optUser.isEmpty()) {
             throw new BizException("user does not exist");
@@ -249,7 +257,7 @@ public class SpaceDeviceController {
             deviceInfo.getTag().remove(platform);
         }
 
-        deviceRepository.save(deviceInfo);
+        deviceInfoRepository.save(deviceInfo);
     }
 
     /**
@@ -296,12 +304,12 @@ public class SpaceDeviceController {
         dataOwnerService.checkOwner(spaceDevice);
 
         //找到设备
-        DeviceInfo deviceInfo = deviceRepository.findByDeviceId(deviceId);
+        DeviceInfo deviceInfo = deviceInfoRepository.findByDeviceId(deviceId);
         Map<String, DeviceInfo.Tag> tags = deviceInfo.getTag();
         String openUidName = platform + "OpenUid";
         //给设备添加对应平台openUid的设备标签
         Constants.ThirdOpenUid thirdOpenUid = Constants.ThirdOpenUid.valueOf(openUidName);
         tags.put(openUidName, new DeviceInfo.Tag(openUidName, thirdOpenUid.desc, openUid));
-        deviceRepository.save(deviceInfo);
+        deviceInfoRepository.save(deviceInfo);
     }
 }

+ 12 - 3
manager/src/main/java/cc/iotkit/manager/controller/StatsController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller;
 
 import cc.iotkit.dao.*;
@@ -19,7 +28,7 @@ public class StatsController {
     @Autowired
     private ProductRepository productRepository;
     @Autowired
-    private DeviceRepository deviceRepository;
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private DeviceReportRepository deviceReportRepository;
     @Autowired
@@ -36,7 +45,7 @@ public class StatsController {
         if (AuthUtil.isAdmin()) {
             mainStats.setCategoryTotal(categoryRepository.count());
             mainStats.setProductTotal(productRepository.count());
-            mainStats.setDeviceTotal(deviceRepository.count());
+            mainStats.setDeviceTotal(deviceInfoRepository.count());
             mainStats.setReportTotal(deviceReportRepository.count());
             //上报数据统计
             mainStats.setReportDataStats(deviceReportDao.getDeviceMessageStats(now - 48 * 3600 * 1000, now));
@@ -45,7 +54,7 @@ public class StatsController {
         } else {
             mainStats.setCategoryTotal(categoryRepository.count());
             mainStats.setProductTotal(productRepository.countByUid(uid));
-            mainStats.setDeviceTotal(deviceRepository.countByUid(uid));
+            mainStats.setDeviceTotal(deviceInfoRepository.countByUid(uid));
             mainStats.setReportTotal(deviceReportRepository.countByUid(uid));
             //上报数据统计
             mainStats.setReportDataStats(deviceReportDao.getDeviceMessageStatsWithUid(uid, now - 48 * 3600 * 1000, now));

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller;
 
 import cc.iotkit.common.exception.BizException;

+ 11 - 2
manager/src/main/java/cc/iotkit/manager/controller/aligenie/AligenieDeviceController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller.aligenie;
 
 import cc.iotkit.common.exception.BizException;
@@ -29,7 +38,7 @@ public class AligenieDeviceController {
     @Autowired
     private DataOwnerService ownerService;
     @Autowired
-    private DeviceRepository deviceRepository;
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private AligenieProductRepository aligenieProductRepository;
     @Autowired
@@ -66,7 +75,7 @@ public class AligenieDeviceController {
         aligenieDeviceRepository.deleteByUid(uid);
 
         for (Device device : devices) {
-            DeviceInfo deviceInfo = deviceRepository.findById(device.getDeviceId()).get();
+            DeviceInfo deviceInfo = deviceInfoRepository.findById(device.getDeviceId()).get();
             AligenieProduct product = aligenieProductRepository.findByProductKey(deviceInfo.getProductKey());
             aligenieDeviceRepository.save(AligenieDevice.builder()
                     .uid(user.getId())

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/controller/aligenie/AligenieProductController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller.aligenie;
 
 import cc.iotkit.dao.AligenieProductRepository;

+ 14 - 3
manager/src/main/java/cc/iotkit/manager/controller/api/AccountController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller.api;
 
 import cc.iotkit.dao.AppInfoRepository;
@@ -37,8 +46,10 @@ public class AccountController {
             throw new RuntimeException("用户不属于该家庭");
         }
 
-        UserInfo userInfo = userInfoRepository.findOne(Example.of(UserInfo.builder().uid(uid).build()))
-                .orElseThrow(() -> new RuntimeException(("用户信息不存在")));
+        UserInfo userInfo = userInfoRepository.findByUid(uid);
+        if (userInfo == null) {
+            throw new RuntimeException("用户信息不存在");
+        }
         userInfo.setCurrHomeId(homeId);
         userInfoRepository.save(userInfo);
     }
@@ -52,6 +63,6 @@ public class AccountController {
 
     @GetMapping("/getAppInfo")
     public AppInfo getAppInfo() {
-        return appInfoRepository.findAll().get(0);
+        return appInfoRepository.findAll().iterator().next();
     }
 }

+ 18 - 8
manager/src/main/java/cc/iotkit/manager/controller/api/DeviceController.java

@@ -1,7 +1,16 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller.api;
 
 import cc.iotkit.dao.AppDesignRepository;
-import cc.iotkit.dao.DeviceRepository;
+import cc.iotkit.dao.DeviceInfoRepository;
 import cc.iotkit.dao.SpaceDeviceRepository;
 import cc.iotkit.manager.model.vo.AppPageNode;
 import cc.iotkit.manager.service.AppDesignService;
@@ -12,12 +21,12 @@ import cc.iotkit.utils.AuthUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -29,7 +38,7 @@ public class DeviceController {
     @Autowired
     private DeviceService deviceService;
     @Autowired
-    private DeviceRepository deviceRepository;
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private SpaceDeviceRepository spaceDeviceRepository;
     @Autowired
@@ -39,7 +48,9 @@ public class DeviceController {
 
     @GetMapping("/list")
     public List<DeviceInfo> list() {
-        return deviceRepository.findAll();
+        List<DeviceInfo> list = new ArrayList<>();
+        deviceInfoRepository.findAll().forEach(list::add);
+        return list;
     }
 
     @GetMapping("/{deviceId}")
@@ -47,13 +58,12 @@ public class DeviceController {
         if (StringUtils.isBlank(deviceId)) {
             throw new RuntimeException("deviceId is blank.");
         }
-        return deviceRepository.findById(deviceId).orElseThrow(() -> new RuntimeException("device not found."));
+        return deviceInfoRepository.findById(deviceId).orElseThrow(() -> new RuntimeException("device not found."));
     }
 
     @GetMapping("/getAllDeviceIds")
     public List<String> getAllDeviceIds() {
-        List<SpaceDevice> spaceDevices = spaceDeviceRepository.findAll(
-                Example.of(SpaceDevice.builder().uid(AuthUtil.getUserId()).build()));
+        List<SpaceDevice> spaceDevices = spaceDeviceRepository.findByUid(AuthUtil.getUserId());
         return spaceDevices.stream()
                 .map(SpaceDevice::getDeviceId)
                 .collect(Collectors.toList());
@@ -61,7 +71,7 @@ public class DeviceController {
 
     @GetMapping("/detailPage/{deviceId}")
     public List<AppPageNode> deviceDetailPage(@PathVariable("deviceId") String deviceId) {
-        DeviceInfo device = deviceRepository.findById(deviceId).orElseThrow(() -> new RuntimeException("device not found"));
+        DeviceInfo device = deviceInfoRepository.findById(deviceId).orElseThrow(() -> new RuntimeException("device not found"));
         return appDesignService.getAppPageNodes(device.getProductKey());
     }
 

+ 15 - 7
manager/src/main/java/cc/iotkit/manager/controller/api/HomeController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller.api;
 
 import cc.iotkit.dao.HomeRepository;
@@ -51,9 +60,7 @@ public class HomeController {
 
     @GetMapping("/list")
     public List<Home> list() {
-//        return homeRepository.findAll();
-        return homeRepository.findAll(Example.of(Home.builder()
-                .uid(AuthUtil.getUserId()).build()));
+        return homeRepository.findByUid(AuthUtil.getUserId());
     }
 
     @PostMapping("/addSpace")
@@ -62,8 +69,10 @@ public class HomeController {
             throw new RuntimeException("name/homeId is blank.");
         }
         String uid = AuthUtil.getUserId();
-        Home home = homeRepository.findOne(Example.of(Home.builder().uid(uid).id(homeId).build()))
-                .orElseThrow(() -> new RuntimeException("用户家庭不存在"));
+        Home home = homeRepository.findByUidAndId(uid, homeId);
+        if (home == null) {
+            throw new RuntimeException("用户家庭不存在");
+        }
 
         Space s = spaceRepository.save(Space.builder()
                 .name(name)
@@ -96,8 +105,7 @@ public class HomeController {
         if (StringUtils.isBlank(homeId)) {
             throw new RuntimeException("homeId is blank.");
         }
-//        return spaceRepository.findAll();
-        return spaceRepository.findAll(Example.of(Space.builder().homeId(homeId).build()));
+        return spaceRepository.findByHomeId(homeId);
     }
 
     @GetMapping("/getCurrentHome")

+ 13 - 1
manager/src/main/java/cc/iotkit/manager/controller/api/ProductController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller.api;
 
 import cc.iotkit.dao.ProductRepository;
@@ -10,6 +19,7 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @RestController("api-product")
@@ -23,7 +33,9 @@ public class ProductController {
 
     @GetMapping("/list")
     public List<Product> list() {
-        return productRepository.findAll();
+        List<Product> list = new ArrayList<>();
+        productRepository.findAll().forEach(list::add);
+        return list;
     }
 
     @GetMapping("/{pk}")

+ 33 - 25
manager/src/main/java/cc/iotkit/manager/controller/api/SpaceController.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.controller.api;
 
 import cc.iotkit.dao.*;
@@ -10,7 +19,7 @@ import cc.iotkit.model.space.SpaceDevice;
 import cc.iotkit.utils.AuthUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
+import org.springframework.data.elasticsearch.core.query.Criteria;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -28,7 +37,7 @@ public class SpaceController {
     @Autowired
     private SpaceDeviceRepository spaceDeviceRepository;
     @Autowired
-    private DeviceRepository deviceRepository;
+    private DeviceInfoRepository deviceInfoRepository;
     @Autowired
     private CategoryRepository categoryRepository;
     @Autowired
@@ -41,6 +50,8 @@ public class SpaceController {
     private DeviceCache deviceCache;
     @Autowired
     private SpaceDeviceService spaceDeviceService;
+    @Autowired
+    private CommonDao commonDao;
 
     @PostMapping("/addGateway")
     public void addGateway(String pk, String mac, String name, String spaceId) {
@@ -48,14 +59,12 @@ public class SpaceController {
             throw new RuntimeException("pk/name/mac/spaceId is blank.");
         }
         mac = mac.toUpperCase();
-        DeviceInfo device = deviceRepository.findOne(Example.of(DeviceInfo.builder()
-                .productKey(pk)
-                .deviceName(mac).build())).orElseThrow(() -> new RuntimeException("未找到该设备"));
+        DeviceInfo device = deviceInfoRepository.findByProductKeyAndDeviceName(pk, mac);
+        if (device == null) {
+            throw new RuntimeException("未找到该设备");
+        }
         Space space = spaceRepository.findById(spaceId).orElseThrow(() -> new RuntimeException("未找到空间"));
         addSpaceDevice(name, device, space);
-//
-//        List<DeviceInfo> addDevices = deviceRepository.findAll(Example.of(DeviceInfo.builder().parentId(device.getDeviceId()).build()));
-//        addDevices.forEach((d -> addSpaceDevice(null, d, space)));
     }
 
     @PostMapping("/add")
@@ -63,7 +72,7 @@ public class SpaceController {
         if (StringUtils.isBlank(deviceId) || StringUtils.isBlank(name) || StringUtils.isBlank(spaceId)) {
             throw new RuntimeException("deviceId/name/spaceId is blank.");
         }
-        DeviceInfo device = deviceRepository.findById(deviceId)
+        DeviceInfo device = deviceInfoRepository.findById(deviceId)
                 .orElseThrow(() -> new RuntimeException("device not found."));
         Space space = spaceRepository.findById(spaceId)
                 .orElseThrow(() -> new RuntimeException("space not found."));
@@ -73,8 +82,7 @@ public class SpaceController {
     @PostMapping("/scan")
     public List<SpaceDeviceVo> scan() {
         //找到网关产品id
-        List<String> gateways = productRepository.findAll(Example
-                .of(Product.builder().category("gateway").build()))
+        List<String> gateways = productRepository.findByCategory("gateway")
                 .stream().map(Product::getId).collect(Collectors.toList());
         //找到用户已添加的所有设备
         List<SpaceDeviceVo> spaceDeviceVos = spaceDeviceService.getUserDevices(AuthUtil.getUserId(), "");
@@ -84,8 +92,8 @@ public class SpaceController {
 
         List<DeviceInfo> foundDevices = new ArrayList<>();
         //找到网关下的所有设备
-        userGateways.forEach((g) -> foundDevices.addAll(deviceRepository.findAll(Example.of(DeviceInfo.builder()
-                .parentId(g.getDeviceId()).build()))));
+        userGateways.forEach((g) -> foundDevices.addAll(
+                deviceInfoRepository.findByParentId(g.getDeviceId())));
 
         //过滤已添加的设备
         return foundDevices.stream().filter((d) -> {
@@ -105,15 +113,16 @@ public class SpaceController {
 
     @GetMapping("/devices")
     public List<SpaceDeviceVo> devices(String homeId, String spaceId) {
+        Criteria criteria = new Criteria();
+
         SpaceDevice device = new SpaceDevice();
         device.setUid(AuthUtil.getUserId());
         if (StringUtils.isNotBlank(spaceId)) {
-            device.setSpaceId(spaceId);
+            criteria = criteria.and("spaceId").is(spaceId);
         } else {
-            device.setHomeId(homeId);
+            criteria = criteria.and("homeId").is(homeId);
         }
-
-        List<SpaceDevice> spaceDevices = spaceDeviceRepository.findAll(Example.of(device));
+        List<SpaceDevice> spaceDevices = commonDao.find(SpaceDevice.class, criteria);
         List<SpaceDeviceVo> spaceDeviceVos = new ArrayList<>();
         spaceDevices.forEach(sd -> spaceDeviceVos.add(buildSpaceDeviceVo(
                 sd.getId(), sd.getDeviceId(),
@@ -128,15 +137,17 @@ public class SpaceController {
 
         return buildSpaceDeviceVo(device.getId(), device.getDeviceId(),
                 AuthUtil.getUserId(), device.getName(),
-               "");
+                "");
     }
 
     @GetMapping("/getDeviceByMac")
     public SpaceDeviceVo getDeviceByMac(String mac) {
-        DeviceInfo device = deviceRepository.findOne(Example.of(DeviceInfo.builder().deviceName(mac).build()))
-                .orElseThrow(() -> new RuntimeException("device not found by mac"));
+        List<DeviceInfo> devices = deviceInfoRepository.findByDeviceName(mac);
+        if (devices.size() == 0) {
+            throw new RuntimeException("device not found by mac");
+        }
 
-        return buildSpaceDeviceVo("", device.getDeviceId(),
+        return buildSpaceDeviceVo("", devices.get(0).getDeviceId(),
                 AuthUtil.getUserId(), "", "");
     }
 
@@ -170,10 +181,7 @@ public class SpaceController {
     private void addSpaceDevice(String name, DeviceInfo device, Space space) {
         String uid = AuthUtil.getUserId();
 
-        SpaceDevice sd = spaceDeviceRepository.findOne(Example.of(SpaceDevice
-                .builder()
-                .deviceId(device.getDeviceId()).build())
-        ).orElse(null);
+        SpaceDevice sd = spaceDeviceRepository.findByDeviceId(device.getDeviceId());
         String id = null;
 
         //重复添加,更新

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/model/aligenie/AligenieProductVo.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.model.aligenie;
 
 import cc.iotkit.model.aligenie.AligenieProduct;

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/model/vo/AppDesignVo.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.model.vo;
 
 import lombok.AllArgsConstructor;

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/model/vo/AppPageNode.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.model.vo;
 
 import lombok.AllArgsConstructor;

+ 9 - 0
manager/src/main/java/cc/iotkit/manager/model/vo/DeviceLog.java

@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.manager.model.vo;
 
 import lombok.Data;

Some files were not shown because too many files changed in this diff