فهرست منبع

关系数据库存储实现

xiwa 3 سال پیش
والد
کامیت
3910bd23ca
100فایلهای تغییر یافته به همراه1843 افزوده شده و 433 حذف شده
  1. 2 2
      .workflow/BranchPipeline.yml
  2. 3 3
      data/init/product.json
  3. 1 1
      data/init/protocolConverter.json
  4. 18 6
      iot-auth-server/readme.txt
  5. 5 3
      iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthServerController.java
  6. 6 4
      iot-auth-server/src/main/java/cc/iotkit/oauth/service/StpInterfaceImpl.java
  7. 9 0
      iot-auth-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java
  8. 1 1
      iot-auth-server/src/main/java/cc/iotkit/oauth/vo/UserInfoVo.java
  9. 8 8
      iot-common/readme.txt
  10. 1 1
      iot-common/src/main/java/cc/iotkit/common/exception/BizException.java
  11. 1 1
      iot-components/iot-component-base/src/main/java/cc/iotkit/comp/AbstractDeviceComponent.java
  12. 1 1
      iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/Device.java
  13. 16 13
      iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ApiTool.java
  14. 11 10
      iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java
  15. 12 4
      iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigConsumer.java
  16. 3 3
      iot-components/iot-ctwing-component/.DS_Store
  17. 9 0
      iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingConfig.java
  18. 9 0
      iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/ProtocolUtil.java
  19. 7 7
      iot-components/iot-ctwing-component/src/main/resources/component.js
  20. 3 3
      iot-components/iot-emqx-component/pom.xml
  21. 1 1
      iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/AuthVerticle.java
  22. 9 0
      iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/IScripter.java
  23. 27 4
      iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java
  24. 4 4
      iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentMsg.java
  25. 3 3
      iot-components/iot-http-biz-component/pom.xml
  26. 6 6
      iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java
  27. 3 3
      iot-components/iot-mqtt-component/pom.xml
  28. 17 4
      iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/IScripter.java
  29. 1 1
      iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentMsg.java
  30. 1 1
      iot-components/readme.txt
  31. 0 43
      iot-data/iot-dao/src/main/java/cc/iotkit/dao/CategoryCache.java
  32. 0 57
      iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceCache.java
  33. 2 3
      iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceDao.java
  34. 0 43
      iot-data/iot-dao/src/main/java/cc/iotkit/dao/OauthClientCache.java
  35. 0 62
      iot-data/iot-dao/src/main/java/cc/iotkit/dao/ProductCache.java
  36. 1 1
      iot-data/iot-dao/src/main/java/cc/iotkit/dao/SpaceCache.java
  37. 0 43
      iot-data/iot-dao/src/main/java/cc/iotkit/dao/UserInfoCache.java
  38. 19 5
      iot-data/iot-data-cache/pom.xml
  39. 14 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/CategoryCacheEvict.java
  40. 0 41
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceCacheService.java
  41. 18 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCacheEvict.java
  42. 28 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCachePut.java
  43. 14 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/OauthClientCacheEvict.java
  44. 14 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java
  45. 14 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductModelCacheEvict.java
  46. 14 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/SpaceCacheEvict.java
  47. 14 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/UserInfoCacheEvict.java
  48. 46 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/config/CacheConfig.java
  49. 61 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java
  50. 253 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java
  51. 67 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java
  52. 84 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java
  53. 71 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductModelDataCache.java
  54. 91 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/SpaceDataCache.java
  55. 77 0
      iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/UserInfoDataCache.java
  56. 1 1
      iot-data/iot-data-service/pom.xml
  57. 23 0
      iot-data/iot-data-service/src/main/java/cc/iotkit/data/ICategoryData.java
  58. 1 0
      iot-data/iot-data-service/src/main/java/cc/iotkit/data/IHomeData.java
  59. 9 0
      iot-data/iot-data-service/src/main/java/cc/iotkit/data/IRuleInfoData.java
  60. 9 0
      iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceDeviceData.java
  61. 9 0
      iot-data/iot-data-service/src/main/java/cc/iotkit/data/ITaskInfoData.java
  62. 9 0
      iot-data/iot-data-service/src/main/java/cc/iotkit/data/IVirtualDeviceData.java
  63. 1 1
      iot-data/iot-es-temporal-service/pom.xml
  64. 2 1
      iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/document/DevicePropertyDoc.java
  65. 2 2
      iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java
  66. 9 0
      iot-data/iot-model/src/main/java/cc/iotkit/model/AppInfo.java
  67. 9 0
      iot-data/iot-model/src/main/java/cc/iotkit/model/InvokeResult.java
  68. 9 0
      iot-data/iot-model/src/main/java/cc/iotkit/model/product/ThingModel.java
  69. 9 0
      iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleLog.java
  70. 2 2
      iot-data/iot-model/src/main/java/cc/iotkit/model/rule/TaskInfo.java
  71. 0 30
      iot-data/iot-rdb-data-service/readme.md
  72. 10 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/CategoryRepository.java
  73. 9 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductModelRepository.java
  74. 19 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java
  75. 18 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolConverterRepository.java
  76. 33 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/RuleInfoRepository.java
  77. 36 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceDeviceRepository.java
  78. 22 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceRepository.java
  79. 25 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/TaskInfoRepository.java
  80. 19 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ThingModelRepository.java
  81. 25 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/UserInfoRepository.java
  82. 23 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceMappingRepository.java
  83. 27 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceRepository.java
  84. 9 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/CategoryMapper.java
  85. 16 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceGroupMapper.java
  86. 9 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceInfoMapper.java
  87. 15 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/OauthClientMapper.java
  88. 22 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProductMapper.java
  89. 57 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/RuleInfoMapper.java
  90. 32 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceDeviceMapper.java
  91. 24 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceMapper.java
  92. 50 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TaskInfoMapper.java
  93. 2 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbCategory.java
  94. 9 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroup.java
  95. 9 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroupMapping.java
  96. 27 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceTag.java
  97. 2 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProduct.java
  98. 2 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolComponent.java
  99. 39 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolConverter.java
  100. 49 0
      iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbRuleInfo.java

+ 2 - 2
.workflow/BranchPipeline.yml

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

+ 3 - 3
data/init/product.json

@@ -8,7 +8,7 @@
     "jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
     "config": "{\"port\":\"8086\"}",
     "converter": "6260396d67aced2696184053",
-    "state": "running",
+    "state": "stopped",
     "createAt": 1652238780184
   },
   {
@@ -44,7 +44,7 @@
     "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",
+    "state": "stopped",
     "createAt": 1653180468724
   },
   {
@@ -56,7 +56,7 @@
     "jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
     "config": "{\"port\":\"8084\"}",
     "converter": "",
-    "state": "running",
+    "state": "stopped",
     "createAt": 1650685502665
   }
 ]

+ 1 - 1
data/init/protocolConverter.json

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

+ 18 - 6
iot-auth-server/readme.txt

@@ -1,10 +1,19 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.oauth.controller;
 
 import cc.iotkit.common.Constants;
 import cc.iotkit.common.utils.CodecUtil;
 import cc.iotkit.common.utils.ReflectUtil;
-import cc.iotkit.dao.OauthClientCache;
-import cc.iotkit.dao.UserInfoCache;
+import cc.iotkit.data.IOauthClientData;
+import cc.iotkit.data.IUserInfoData;
 import cc.iotkit.model.OauthClient;
 import cc.iotkit.model.UserInfo;
 import cc.iotkit.oauth.vo.UserInfoVo;
@@ -16,6 +25,7 @@ import com.ejlchina.okhttps.OkHttps;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cglib.beans.BeanMap;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -36,16 +46,18 @@ public class AuthClientController {
     private String serverUrl;
 
     @Autowired
-    private OauthClientCache oauthClientCache;
+    @Qualifier("oauthClientDataCache")
+    private IOauthClientData oauthClientData;
     @Autowired
-    private UserInfoCache userInfoCache;
+    @Qualifier("userInfoDataCache")
+    private IUserInfoData userInfoData;
 
     /**
      * 根据Code码进行登录,获取 Access-Token 和 用户信息
      */
     @RequestMapping("/codeLogin")
     public SaResult codeLogin(String code, String clientId) {
-        OauthClient oauthClient = oauthClientCache.getClient(clientId);
+        OauthClient oauthClient = oauthClientData.findByClientId(clientId);
         if (oauthClient == null) {
             return SaResult.error("clientId does not exist");
         }
@@ -117,7 +129,7 @@ public class AuthClientController {
     }
 
     private UserInfoVo getUserInfo(String uid) {
-        UserInfo userInfo = userInfoCache.getUserInfo(uid);
+        UserInfo userInfo = userInfoData.findById(uid);
         UserInfoVo userVo = new UserInfoVo();
         ReflectUtil.copyNoNulls(userInfo, userVo);
         return userVo;

+ 5 - 3
iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthServerController.java

@@ -11,25 +11,27 @@ package cc.iotkit.oauth.service;
 
 import cc.iotkit.common.Constants;
 import cc.iotkit.common.utils.CodecUtil;
-import cc.iotkit.dao.OauthClientCache;
+import cc.iotkit.data.IOauthClientData;
 import cc.iotkit.model.OauthClient;
 import cn.dev33.satoken.oauth2.logic.SaOAuth2Template;
 import cn.dev33.satoken.oauth2.model.SaClientModel;
 import cn.dev33.satoken.stp.StpUtil;
 import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 @Component
 public class SaOAuth2TemplateImpl extends SaOAuth2Template {
 
     @Autowired
-    private OauthClientCache oauthClientCache;
+    @Qualifier("oauthClientDataCache")
+    private IOauthClientData oauthClientData;
 
     // 根据 id 获取 Client 信息
     @Override
     public SaClientModel getClientModel(String clientId) {
-        OauthClient client = oauthClientCache.getClient(clientId);
+        OauthClient client = oauthClientData.findByClientId(clientId);
         if (client == null) {
             return null;
         }

+ 6 - 4
iot-auth-server/src/main/java/cc/iotkit/oauth/service/StpInterfaceImpl.java

@@ -9,10 +9,11 @@
  */
 package cc.iotkit.oauth.service;
 
-import cc.iotkit.dao.UserInfoCache;
+import cc.iotkit.data.IUserInfoData;
 import cc.iotkit.model.UserInfo;
 import cn.dev33.satoken.stp.StpInterface;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -21,14 +22,15 @@ import java.util.List;
 public class StpInterfaceImpl implements StpInterface {
 
     @Autowired
-    private UserInfoCache userInfoCache;
+    @Qualifier("userInfoDataCache")
+    private IUserInfoData userInfoData;
 
     /**
      * 返回一个账号所拥有的权限码集合
      */
     @Override
     public List<String> getPermissionList(Object loginId, String loginType) {
-        UserInfo userInfo = userInfoCache.getUserInfo(loginId.toString());
+        UserInfo userInfo = userInfoData.findById(loginId.toString());
         return userInfo.getPermissions();
     }
 
@@ -37,7 +39,7 @@ public class StpInterfaceImpl implements StpInterface {
      */
     @Override
     public List<String> getRoleList(Object loginId, String loginType) {
-        UserInfo userInfo = userInfoCache.getUserInfo(loginId.toString());
+        UserInfo userInfo = userInfoData.findById(loginId.toString());
         return userInfo.getRoles();
     }
 

+ 9 - 0
iot-auth-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java

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

+ 1 - 1
iot-auth-server/src/main/java/cc/iotkit/oauth/vo/UserInfoVo.java

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

+ 8 - 8
iot-common/readme.txt

@@ -15,21 +15,21 @@ public interface Constants {
 
     String ACCOUNT_SECRET = "3n1z33kzvpgz1foijpkepyd3e8tw84us";
 
-    String PRODUCT_CACHE = "product_cache";
+    String CACHE_PRODUCT = "product_cache";
 
-    String DEVICE_CACHE = "device_cache";
+    String CACHE_DEVICE_INFO = "device_info_cache";
 
-    String DEVICE_STATS_CACHE = "device_stats_cache";
+    String CACHE_DEVICE_STATS = "device_stats_cache";
 
-    String CATEGORY_CACHE = "category_cache";
+    String CACHE_CATEGORY = "category_cache";
 
-    String SPACE_CACHE = "space_cache";
+    String CACHE_SPACE = "space_cache";
 
     String THING_MODEL_CACHE = "thing_model_cache";
 
-    String USER_CACHE = "user_info_cache";
+    String CACHE_USER_INFO = "user_info_cache";
 
-    String OAUTH_CLIENT_CACHE = "oauth_client_cache";
+    String CACHE_OAUTH_CLIENT = "oauth_client_cache";
 
     String WECHAT_APP_ID = "wx791cb7bf75950e0c";
 
@@ -37,7 +37,7 @@ public interface Constants {
 
     String APP_DESIGN_CACHE = "app_design_cache";
 
-    String PRODUCT_SCRIPT_CACHE = "product_script_cache";
+    String CACHE_PRODUCT_SCRIPT = "product_script_cache";
 
     /**
      * 管理员角色

+ 1 - 1
iot-common/src/main/java/cc/iotkit/common/exception/BizException.java

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-components</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/AbstractDeviceComponent.java

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-components</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/Device.java

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-components</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 16 - 13
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ApiTool.java

@@ -23,8 +23,8 @@ import cc.iotkit.converter.Device;
 import cc.iotkit.converter.DeviceMessage;
 import cc.iotkit.converter.ScriptConverter;
 import cc.iotkit.common.thing.ThingService;
-import cc.iotkit.dao.DeviceCache;
-import cc.iotkit.dao.ProductCache;
+import cc.iotkit.data.IDeviceInfoData;
+import cc.iotkit.data.IProductData;
 import cc.iotkit.data.IProtocolComponentData;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.device.message.ThingModelMessage;
@@ -34,6 +34,7 @@ import cc.iotkit.model.protocol.ProtocolConverter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Component;
 
@@ -62,23 +63,25 @@ public class DeviceComponentManager {
     @Autowired
     private IProtocolComponentData protocolComponentData;
     @Autowired
-    private DeviceCache deviceCache;
+    @Qualifier("productDataCache")
+    IProductData productData;
     @Autowired
-    ProductCache productCache;
+    @Qualifier("deviceInfoDataCache")
+    private IDeviceInfoData deviceInfoData;
     @Autowired
     private DeviceRouter deviceRouter;
 
     @PostConstruct
     public void init() {
-        try {
-            List<ProtocolComponent> componentList = protocolComponentData.findByStateAndType(
-                    ProtocolComponent.STATE_RUNNING, ProtocolComponent.TYPE_DEVICE);
-            for (ProtocolComponent component : componentList) {
+        List<ProtocolComponent> componentList = protocolComponentData.findByStateAndType(
+                ProtocolComponent.STATE_RUNNING, ProtocolComponent.TYPE_DEVICE);
+        for (ProtocolComponent component : componentList) {
+            try {
                 register(component);
                 start(component.getId());
+            } catch (Throwable e) {
+                log.error("init protocol components error", e);
             }
-        } catch (Throwable e) {
-            log.error("init protocol components error", e);
         }
     }
 
@@ -170,14 +173,14 @@ public class DeviceComponentManager {
             throw new BizException("there is no components");
         }
 
-        DeviceInfo deviceInfo = deviceCache.getDeviceInfo(service.getProductKey(), service.getDeviceName());
-        Product product = productCache.findById(service.getProductKey());
+        DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(service.getProductKey(), service.getDeviceName());
+        Product product = productData.findById(service.getProductKey());
         String linkPk = service.getProductKey();
         String linkDn = service.getDeviceName();
 
         if (product.isTransparent()) {
             //如果是透传设备,取父级设备进行链路查找
-            DeviceInfo parent = deviceCache.get(deviceInfo.getParentId());
+            DeviceInfo parent = deviceInfoData.findByDeviceId(deviceInfo.getParentId());
             linkPk = parent.getProductKey();
             linkDn = parent.getDeviceName();
         }

+ 11 - 10
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java

@@ -16,7 +16,6 @@ import cc.iotkit.common.utils.JsonUtil;
 import cc.iotkit.common.utils.UniqueIdUtil;
 import cc.iotkit.comp.model.DeviceState;
 import cc.iotkit.comp.model.RegisterInfo;
-import cc.iotkit.dao.*;
 import cc.iotkit.data.IDeviceInfoData;
 import cc.iotkit.data.IProductModelData;
 import cc.iotkit.data.IProductData;
@@ -28,6 +27,7 @@ import cc.iotkit.mq.MqProducer;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -41,14 +41,12 @@ public class DeviceBehaviourService {
     @Autowired
     private IProductModelData productModelData;
     @Autowired
-    private ProductCache productCache;
-    @Autowired
+    @Qualifier("deviceInfoDataCache")
     private IDeviceInfoData deviceInfoData;
     @Autowired
-    private DeviceCache deviceCache;
-    @Autowired
     private MqProducer<ThingModelMessage> producer;
     @Autowired
+    @Qualifier("productDataCache")
     private IProductData productData;
 
     public void register(RegisterInfo info) {
@@ -187,13 +185,16 @@ public class DeviceBehaviourService {
         }
         deviceStateChange(device, online);
 
+        //父设备ID不为空说明是子设备
         if (device.getParentId() != null) {
             return;
         }
 
-        List<DeviceInfo> subDevices = deviceInfoData.findByParentId(device.getDeviceId());
-        for (DeviceInfo subDevice : subDevices) {
-            Product product = productCache.findById(subDevice.getProductKey());
+        //否则为父设备,同步透传子设备状态
+        List<String> subDeviceIds = deviceInfoData.findSubDeviceIds(device.getDeviceId());
+        for (String subDeviceId : subDeviceIds) {
+            DeviceInfo subDevice=deviceInfoData.findByDeviceId(subDeviceId);
+            Product product = productData.findById(subDevice.getProductKey());
             Boolean transparent = product.getTransparent();
             //透传设备父设备上线,子设备也上线。非透传设备父设备离线,子设备才离线
             if (transparent != null && transparent || !online) {
@@ -229,8 +230,8 @@ public class DeviceBehaviourService {
 
     public void reportMessage(ThingModelMessage message) {
         try {
-            DeviceInfo device = deviceCache.getDeviceInfo(message.getProductKey(),
-                    message.getDeviceName());
+            DeviceInfo device = deviceInfoData.findByProductKeyAndDeviceName(
+                    message.getProductKey(), message.getDeviceName());
             if (device == null) {
                 return;
             }

+ 12 - 4
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigConsumer.java

@@ -1,10 +1,18 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.comps.service;
 
 import cc.iotkit.common.Constants;
 import cc.iotkit.common.utils.JsonUtil;
 import cc.iotkit.dao.DeviceDao;
 import cc.iotkit.data.IDeviceInfoData;
-import cc.iotkit.data.cache.DeviceCacheService;
 import cc.iotkit.model.device.message.DeviceProperty;
 import cc.iotkit.model.device.message.ThingModelMessage;
 import cc.iotkit.mq.ConsumerHandler;
@@ -12,6 +20,7 @@ import cc.iotkit.mq.MqConsumer;
 import cc.iotkit.temporal.IDevicePropertyData;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
@@ -33,9 +42,8 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
     @Autowired
     private IDevicePropertyData devicePropertyData;
     @Autowired
+    @Qualifier("deviceInfoDataCache")
     private IDeviceInfoData deviceInfoData;
-    @Autowired
-    private DeviceCacheService deviceCacheService;
 
     @PostConstruct
     public void init() {
@@ -81,7 +89,7 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
     private void updateDeviceCurrentProperties(String deviceId, Map<String, Object> properties) {
         try {
             log.info("save device property,deviceId:{},property:{}", deviceId, JsonUtil.toJsonString(properties));
-            deviceCacheService.saveProperties(deviceId, properties);
+            deviceInfoData.saveProperties(deviceId, properties);
         } catch (Throwable e) {
             log.error("save device current properties error", e);
         }

+ 3 - 3
iot-components/iot-ctwing-component/.DS_Store

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-components</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -82,8 +82,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>8</source>
-                    <target>8</target>
+                    <source>11</source>
+                    <target>11</target>
                 </configuration>
             </plugin>
         </plugins>

+ 9 - 0
iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingConfig.java

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

+ 9 - 0
iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/ProtocolUtil.java

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

+ 7 - 7
iot-components/iot-ctwing-component/src/main/resources/component.js

@@ -3,7 +3,7 @@
   <parent>
     <artifactId>iot-components</artifactId>
     <groupId>cc.iotkit</groupId>
-    <version>0.3.3-SNAPSHOT</version>
+    <version>0.4.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>iot-emqx-component</artifactId>
@@ -48,8 +48,8 @@
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-          <source>8</source>
-          <target>8</target>
+          <source>11</source>
+          <target>11</target>
         </configuration>
       </plugin>
     </plugins>
@@ -82,25 +82,25 @@
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-model</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-dao</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-common</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-component-base</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
   </dependencies>

+ 3 - 3
iot-components/iot-emqx-component/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-components</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -105,8 +105,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>8</source>
-                    <target>8</target>
+                    <source>11</source>
+                    <target>11</target>
                 </configuration>
             </plugin>
         </plugins>

+ 1 - 1
iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/AuthVerticle.java

@@ -173,7 +173,7 @@ public class EmqxDeviceComponent extends AbstractDeviceComponent {
         if (parent == null) {
             return;
         }
-        IDeviceInfoData deviceInfoService = SpringUtils.getBean(IDeviceInfoData.class);
+        IDeviceInfoData deviceInfoService = SpringUtils.getBean("deviceInfoDataCache");
 
         DeviceInfo deviceInfo = deviceInfoService.findByProductKeyAndDeviceName(state.getProductKey(), state.getDeviceName());
         if (deviceInfo != null) {

+ 9 - 0
iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/IScripter.java

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

+ 27 - 4
iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java

@@ -1,11 +1,23 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.comp.emqx;
 
 
+import cc.iotkit.comp.utils.SpringUtils;
 import cc.iotkit.converter.Device;
 import cc.iotkit.converter.DeviceMessage;
 import cc.iotkit.common.thing.ThingService;
-import cc.iotkit.dao.DeviceCache;
 import cc.iotkit.dao.ProductCache;
+import cc.iotkit.data.IDeviceInfoData;
+import cc.iotkit.data.IProductData;
+import cc.iotkit.data.IProductModelData;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.device.message.ThingModelMessage;
 import cc.iotkit.model.product.ProductModel;
@@ -20,6 +32,9 @@ public class TransparentConverter {
     private final Map<String, IScripter> scripters = new HashMap<>();
     private final Map<String, String> scripts = new HashMap<>();
 
+    private IDeviceInfoData deviceInfoData;
+    private IProductModelData productModelData;
+
     /**
      * 透传解码
      */
@@ -50,12 +65,20 @@ public class TransparentConverter {
     }
 
     private ProductModel getScript(String model) {
-        return ProductCache.getInstance().getProductScriptByModel(model);
+        if (productModelData == null) {
+            productModelData = SpringUtils.getBean("productModelDataCache");
+        }
+
+        return productModelData.findByModel(model);
     }
 
     private DeviceInfo getGatewayInfo(String subPk, String subDn) {
-        String parentId = DeviceCache.getInstance().getDeviceInfo(subPk, subDn).getParentId();
-        return DeviceCache.getInstance().get(parentId);
+        if (deviceInfoData == null) {
+            deviceInfoData = SpringUtils.getBean("deviceInfoDataCache");
+        }
+
+        String parentId = deviceInfoData.findByProductKeyAndDeviceName(subPk, subDn).getParentId();
+        return deviceInfoData.findByDeviceId(parentId);
     }
 
     /**

+ 4 - 4
iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentMsg.java

@@ -3,7 +3,7 @@
   <parent>
     <artifactId>iot-components</artifactId>
     <groupId>cc.iotkit</groupId>
-    <version>0.3.3-SNAPSHOT</version>
+    <version>0.4.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>iot-http-biz-component</artifactId>
@@ -36,8 +36,8 @@
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-          <source>8</source>
-          <target>8</target>
+          <source>11</source>
+          <target>11</target>
         </configuration>
       </plugin>
     </plugins>
@@ -58,7 +58,7 @@
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-component-base</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
   </dependencies>

+ 3 - 3
iot-components/iot-http-biz-component/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-components</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -66,8 +66,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>8</source>
-                    <target>8</target>
+                    <source>11</source>
+                    <target>11</target>
                 </configuration>
             </plugin>
         </plugins>

+ 6 - 6
iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java

@@ -3,7 +3,7 @@
   <parent>
     <artifactId>iot-components</artifactId>
     <groupId>cc.iotkit</groupId>
-    <version>0.3.3-SNAPSHOT</version>
+    <version>0.4.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>iot-mqtt-component</artifactId>
@@ -34,8 +34,8 @@
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-          <source>8</source>
-          <target>8</target>
+          <source>11</source>
+          <target>11</target>
         </configuration>
       </plugin>
     </plugins>
@@ -80,19 +80,19 @@
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-common</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-component-base</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>cc.iotkit</groupId>
       <artifactId>iot-dao</artifactId>
-      <version>0.3.3-SNAPSHOT</version>
+      <version>0.4.0-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>
   </dependencies>

+ 3 - 3
iot-components/iot-mqtt-component/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-components</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -89,8 +89,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>8</source>
-                    <target>8</target>
+                    <source>11</source>
+                    <target>11</target>
                 </configuration>
             </plugin>
         </plugins>

+ 17 - 4
iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/IScripter.java

@@ -10,11 +10,13 @@
 package cc.iotkit.comp.mqtt;
 
 
+import cc.iotkit.comp.utils.SpringUtils;
 import cc.iotkit.converter.Device;
 import cc.iotkit.converter.DeviceMessage;
 import cc.iotkit.common.thing.ThingService;
-import cc.iotkit.dao.DeviceCache;
 import cc.iotkit.dao.ProductCache;
+import cc.iotkit.data.IDeviceInfoData;
+import cc.iotkit.data.IProductModelData;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.device.message.ThingModelMessage;
 import cc.iotkit.model.product.ProductModel;
@@ -29,6 +31,9 @@ public class TransparentConverter {
     private final Map<String, IScripter> scripters = new HashMap<>();
     private final Map<String, String> scripts = new HashMap<>();
 
+    private IDeviceInfoData deviceInfoData;
+    private IProductModelData productModelData;
+
     /**
      * 透传解码
      */
@@ -59,12 +64,20 @@ public class TransparentConverter {
     }
 
     private ProductModel getScript(String model) {
-        return ProductCache.getInstance().getProductScriptByModel(model);
+        if (productModelData == null) {
+            productModelData = SpringUtils.getBean("productModelDataCache");
+        }
+
+        return productModelData.findByModel(model);
     }
 
     private DeviceInfo getGatewayInfo(String subPk, String subDn) {
-        String parentId = DeviceCache.getInstance().getDeviceInfo(subPk, subDn).getParentId();
-        return DeviceCache.getInstance().get(parentId);
+        if (deviceInfoData == null) {
+            deviceInfoData = SpringUtils.getBean("deviceInfoDataCache");
+        }
+
+        String parentId = deviceInfoData.findByProductKeyAndDeviceName(subPk, subDn).getParentId();
+        return deviceInfoData.findByDeviceId(parentId);
     }
 
     /**

+ 1 - 1
iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentMsg.java

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

+ 1 - 1
iot-components/readme.txt

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-data</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 0 - 43
iot-data/iot-dao/src/main/java/cc/iotkit/dao/CategoryCache.java

@@ -1,43 +0,0 @@
-/*
- * +----------------------------------------------------------------------
- * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
- * +----------------------------------------------------------------------
- * | Licensed 未经许可不能去掉「奇特物联」相关版权
- * +----------------------------------------------------------------------
- * | Author: xw2sy@163.com
- * +----------------------------------------------------------------------
- */
-package cc.iotkit.dao;
-
-import cc.iotkit.common.Constants;
-import cc.iotkit.data.ICategoryData;
-import cc.iotkit.model.product.Category;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Repository;
-
-import javax.annotation.PostConstruct;
-
-
-@Repository
-public class CategoryCache {
-
-    @Autowired
-    private ICategoryData categoryData;
-
-    private static CategoryCache INSTANCE;
-
-    @PostConstruct
-    public void init() {
-        INSTANCE = this;
-    }
-
-    public static CategoryCache getInstance() {
-        return INSTANCE;
-    }
-
-    @Cacheable(value = Constants.CATEGORY_CACHE, key = "#id")
-    public Category getById(String id) {
-        return categoryData.findById(id);
-    }
-}

+ 0 - 57
iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceCache.java

@@ -1,57 +0,0 @@
-/*
- * +----------------------------------------------------------------------
- * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
- * +----------------------------------------------------------------------
- * | Licensed 未经许可不能去掉「奇特物联」相关版权
- * +----------------------------------------------------------------------
- * | Author: xw2sy@163.com
- * +----------------------------------------------------------------------
- */
-package cc.iotkit.dao;
-
-import cc.iotkit.common.Constants;
-import cc.iotkit.data.IDeviceInfoData;
-import cc.iotkit.model.device.DeviceInfo;
-import cc.iotkit.model.stats.DataItem;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Repository;
-
-import javax.annotation.PostConstruct;
-import java.util.List;
-
-@Repository
-public class DeviceCache {
-
-    @Autowired
-    private IDeviceInfoData deviceInfoData;
-    @Autowired
-    private DeviceDao deviceDao;
-
-    private static DeviceCache INSTANCE;
-
-    @PostConstruct
-    public void init() {
-        INSTANCE = this;
-    }
-
-    public static DeviceCache getInstance() {
-        return INSTANCE;
-    }
-
-    @Cacheable(value = Constants.DEVICE_CACHE, key = "#pk+'_'+#dn")
-    public DeviceInfo getDeviceInfo(String pk, String dn) {
-        return deviceInfoData.findByProductKeyAndDeviceName(pk, dn);
-    }
-
-    @Cacheable(value = Constants.DEVICE_CACHE, key = "#deviceId")
-    public DeviceInfo get(String deviceId) {
-        return deviceInfoData.findByDeviceId(deviceId);
-    }
-
-    @Cacheable(value = Constants.DEVICE_STATS_CACHE, key = "#uid")
-    public List<DataItem> getDeviceStatsByCategory(String uid) {
-        return deviceInfoData.getDeviceStatsByCategory(uid);
-    }
-
-}

+ 2 - 3
iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceDao.java

@@ -10,7 +10,6 @@
 package cc.iotkit.dao;
 
 import cc.iotkit.data.ICategoryData;
-import cc.iotkit.data.IDeviceInfoData;
 import cc.iotkit.data.IProductData;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.product.Category;
@@ -23,6 +22,7 @@ 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.beans.factory.annotation.Qualifier;
 import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
 import org.springframework.data.elasticsearch.core.clients.elasticsearch7.ElasticsearchAggregations;
 import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
@@ -41,8 +41,7 @@ public class DeviceDao {
     private ElasticsearchRestTemplate elasticsearchRestTemplate;
 
     @Autowired
-    private IDeviceInfoData deviceInfoData;
-    @Autowired
+    @Qualifier("productDataCache")
     private IProductData productData;
     @Autowired
     private ICategoryData categoryData;

+ 0 - 43
iot-data/iot-dao/src/main/java/cc/iotkit/dao/OauthClientCache.java

@@ -1,43 +0,0 @@
-/*
- * +----------------------------------------------------------------------
- * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
- * +----------------------------------------------------------------------
- * | Licensed 未经许可不能去掉「奇特物联」相关版权
- * +----------------------------------------------------------------------
- * | Author: xw2sy@163.com
- * +----------------------------------------------------------------------
- */
-package cc.iotkit.dao;
-
-import cc.iotkit.common.Constants;
-import cc.iotkit.data.IOauthClientData;
-import cc.iotkit.model.OauthClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Repository;
-
-import javax.annotation.PostConstruct;
-
-@Repository
-public class OauthClientCache {
-
-    @Autowired
-    private IOauthClientData oauthClientData;
-
-    private static OauthClientCache INSTANCE;
-
-    @PostConstruct
-    public void init() {
-        INSTANCE = this;
-    }
-
-    public static OauthClientCache getInstance() {
-        return INSTANCE;
-    }
-
-    @Cacheable(value = Constants.OAUTH_CLIENT_CACHE, key = "#clientId")
-    public OauthClient getClient(String clientId) {
-        return oauthClientData.findByClientId(clientId);
-    }
-
-}

+ 0 - 62
iot-data/iot-dao/src/main/java/cc/iotkit/dao/ProductCache.java

@@ -1,62 +0,0 @@
-/*
- * +----------------------------------------------------------------------
- * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
- * +----------------------------------------------------------------------
- * | Licensed 未经许可不能去掉「奇特物联」相关版权
- * +----------------------------------------------------------------------
- * | Author: xw2sy@163.com
- * +----------------------------------------------------------------------
- */
-package cc.iotkit.dao;
-
-import cc.iotkit.common.Constants;
-import cc.iotkit.data.IProductModelData;
-import cc.iotkit.data.IProductData;
-import cc.iotkit.data.IThingModelData;
-import cc.iotkit.model.product.Product;
-import cc.iotkit.model.product.ProductModel;
-import cc.iotkit.model.product.ThingModel;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Repository;
-
-import javax.annotation.PostConstruct;
-
-@Repository
-public class ProductCache {
-
-    @Autowired
-    private IProductData productData;
-    @Autowired
-    private IThingModelData thingModelData;
-    @Autowired
-    private IProductModelData productModelData;
-
-    private static ProductCache INSTANCE;
-
-    @PostConstruct
-    public void init() {
-        INSTANCE = this;
-    }
-
-    public static ProductCache getInstance() {
-        return INSTANCE;
-    }
-
-    @Cacheable(value = Constants.PRODUCT_CACHE, key = "'product'+#pk")
-    public Product findById(String pk) {
-        return productData.findById(pk);
-    }
-
-    @Cacheable(value = Constants.THING_MODEL_CACHE, key = "'thing_model'+#pk")
-    public ThingModel getThingModel(String pk) {
-        return thingModelData.findByProductKey(pk);
-    }
-
-    @Cacheable(value = Constants.PRODUCT_SCRIPT_CACHE, key = "'product_script'+#model")
-    public ProductModel getProductScriptByModel(String model) {
-        return productModelData.findByModel(model);
-    }
-
-
-}

+ 1 - 1
iot-data/iot-dao/src/main/java/cc/iotkit/dao/SpaceCache.java

@@ -26,7 +26,7 @@ public class SpaceCache {
         return INSTANCE;
     }
 
-    @Cacheable(value = Constants.SPACE_CACHE, key = "#spaceId")
+    @Cacheable(value = Constants.CACHE_SPACE, key = "#spaceId")
     public Space getSpace(String spaceId) {
         return spaceData.findById(spaceId);
     }

+ 0 - 43
iot-data/iot-dao/src/main/java/cc/iotkit/dao/UserInfoCache.java

@@ -1,43 +0,0 @@
-/*
- * +----------------------------------------------------------------------
- * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
- * +----------------------------------------------------------------------
- * | Licensed 未经许可不能去掉「奇特物联」相关版权
- * +----------------------------------------------------------------------
- * | Author: xw2sy@163.com
- * +----------------------------------------------------------------------
- */
-package cc.iotkit.dao;
-
-import cc.iotkit.common.Constants;
-import cc.iotkit.data.IUserInfoData;
-import cc.iotkit.model.UserInfo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Repository;
-
-import javax.annotation.PostConstruct;
-
-@Repository
-public class UserInfoCache {
-
-    @Autowired
-    private IUserInfoData userInfoData;
-
-    private static UserInfoCache INSTANCE;
-
-    @PostConstruct
-    public void init() {
-        INSTANCE = this;
-    }
-
-    public static UserInfoCache getInstance() {
-        return INSTANCE;
-    }
-
-    @Cacheable(value = Constants.USER_CACHE, key = "#uid")
-    public UserInfo getUserInfo(String uid) {
-        return userInfoData.findById(uid);
-    }
-
-}

+ 19 - 5
iot-data/iot-data-cache/pom.xml

@@ -3,10 +3,9 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>iotkit-parent</artifactId>
+        <artifactId>iot-data</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
-        <relativePath>../../pom.xml</relativePath>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -20,8 +19,13 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.data</groupId>
-            <artifactId>spring-data-redis</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-cache</artifactId>
         </dependency>
 
         <dependency>
@@ -29,6 +33,16 @@
             <artifactId>iot-common</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>cc.iotkit</groupId>
+            <artifactId>iot-model</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cc.iotkit</groupId>
+            <artifactId>iot-data-service</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 14 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/CategoryCacheEvict.java

@@ -0,0 +1,14 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CategoryCacheEvict {
+
+    @CacheEvict(value = Constants.CACHE_CATEGORY, key = "#root.method.name+#s")
+    public void findById(String s) {
+    }
+
+}

+ 0 - 41
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceCacheService.java

@@ -1,41 +0,0 @@
-package cc.iotkit.data.cache;
-
-import cc.iotkit.common.utils.JsonUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.stereotype.Service;
-
-import java.util.Map;
-
-@Service
-public class DeviceCacheService {
-
-    private static final String PROPERTY_CACHE_KEY = "str:device:property:%s";
-
-    @Autowired
-    private StringRedisTemplate redisTemplate;
-
-    private String getPropertyCacheKey(String deviceId) {
-        return String.format(PROPERTY_CACHE_KEY, deviceId);
-    }
-
-    /**
-     * 保存设备属性到redis
-     *
-     * @param deviceId   设备id
-     * @param properties 设备属性map
-     */
-    public void saveProperties(String deviceId, Map<String, Object> properties) {
-        redisTemplate.opsForValue().set(getPropertyCacheKey(deviceId), JsonUtil.toJsonString(properties));
-    }
-
-    /**
-     * 获取设备属性map
-     *
-     * @param deviceId 设备id
-     */
-    public Map<String, Object> getProperties(String deviceId) {
-        return JsonUtil.parse(redisTemplate.opsForValue().get(getPropertyCacheKey(deviceId)), Map.class);
-    }
-
-}

+ 18 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCacheEvict.java

@@ -0,0 +1,18 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DeviceInfoCacheEvict {
+
+    @CacheEvict(value = Constants.CACHE_DEVICE_INFO, key = "#root.method.name+#deviceId")
+    public void findByDeviceId(String deviceId) {
+    }
+
+    @CacheEvict(value = Constants.CACHE_DEVICE_INFO, key = "#root.method.name+#productKey+#deviceName")
+    public void findByProductKeyAndDeviceName(String productKey, String deviceName) {
+    }
+
+}

+ 28 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCachePut.java

@@ -0,0 +1,28 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.model.device.DeviceInfo;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class DeviceInfoCachePut {
+
+    @CachePut(value = Constants.CACHE_DEVICE_INFO, key = "#root.method.name+#deviceId")
+    public DeviceInfo findByDeviceId(String deviceId, DeviceInfo deviceInfo) {
+        return deviceInfo;
+    }
+
+    @CachePut(value = Constants.CACHE_DEVICE_INFO, key = "#root.method.name+#productKey+#deviceName")
+    public DeviceInfo findByProductKeyAndDeviceName(String productKey, String deviceName, DeviceInfo deviceInfo) {
+        return deviceInfo;
+    }
+
+    @CachePut(value = Constants.CACHE_DEVICE_INFO, key = "#root.method.name+#parentId")
+    public List<String> findSubDeviceIds(String parentId, List<String> subDeviceIds) {
+        return subDeviceIds;
+    }
+
+}

+ 14 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/OauthClientCacheEvict.java

@@ -0,0 +1,14 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+@Component
+public class OauthClientCacheEvict {
+
+    @CacheEvict(value = Constants.CACHE_OAUTH_CLIENT, key = "#root.method.name+#clientId")
+    public void findByClientId(String clientId) {
+    }
+
+}

+ 14 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java

@@ -0,0 +1,14 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ProductCacheEvict {
+
+    @CacheEvict(value = Constants.CACHE_PRODUCT, key = "#root.method.name+#pk")
+    public void findById(String pk) {
+    }
+
+}

+ 14 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductModelCacheEvict.java

@@ -0,0 +1,14 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ProductModelCacheEvict {
+
+    @CacheEvict(value = Constants.CACHE_PRODUCT_SCRIPT, key = "#root.method.name+#model")
+    public void findByModel(String model) {
+    }
+
+}

+ 14 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/SpaceCacheEvict.java

@@ -0,0 +1,14 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SpaceCacheEvict {
+
+    @CacheEvict(value = Constants.CACHE_SPACE, key = "#root.method.name+#s")
+    public void findById(String s) {
+    }
+
+}

+ 14 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/UserInfoCacheEvict.java

@@ -0,0 +1,14 @@
+package cc.iotkit.data.cache;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserInfoCacheEvict {
+
+    @CacheEvict(value = Constants.CACHE_USER_INFO, key = "#root.method.name+#uid")
+    public void findByUid(String uid) {
+    }
+
+}

+ 46 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/config/CacheConfig.java

@@ -0,0 +1,46 @@
+package cc.iotkit.data.config;
+
+import cc.iotkit.common.Constants;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
+import org.springframework.data.redis.serializer.RedisSerializer;
+
+import java.time.Duration;
+import java.util.Map;
+import java.util.Set;
+
+@Configuration
+@EnableCaching
+public class CacheConfig {
+
+    @Bean
+    public RedisCacheConfiguration getRedisCacheConfiguration() {
+        RedisCacheConfiguration cacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
+        cacheConfiguration = cacheConfiguration.serializeValuesWith(RedisSerializationContext
+                .SerializationPair.fromSerializer(RedisSerializer.json()));
+        return cacheConfiguration;
+    }
+
+    @Bean
+    public CacheManager cacheManager(RedisConnectionFactory factory, RedisCacheConfiguration config) {
+        Set<String> cacheNames = Set.of(Constants.CACHE_DEVICE_INFO, Constants.CACHE_DEVICE_STATS);
+        Map<String, RedisCacheConfiguration> cacheConfigs = Map.of(
+                Constants.CACHE_DEVICE_INFO, config,
+                Constants.CACHE_PRODUCT, config,
+                Constants.CACHE_OAUTH_CLIENT, config,
+                Constants.CACHE_DEVICE_STATS, config.entryTtl(Duration.ofMinutes(5))
+        );
+
+        return RedisCacheManager.builder(factory)
+                .initialCacheNames(cacheNames)
+                .withInitialCacheConfigurations(cacheConfigs)
+                .build();
+    }
+
+}

+ 61 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java

@@ -0,0 +1,61 @@
+package cc.iotkit.data.service;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.data.ICategoryData;
+import cc.iotkit.data.cache.CategoryCacheEvict;
+import cc.iotkit.model.Paging;
+import cc.iotkit.model.product.Category;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Qualifier("categoryDataCache")
+public class CategoryDataCache implements ICategoryData {
+
+    @Autowired
+    private ICategoryData categoryData;
+    @Autowired
+    private CategoryCacheEvict categoryCacheEvict;
+
+    @Override
+    @Cacheable(value = Constants.CACHE_CATEGORY, key = "#root.method.name+#s", unless = "#result == null")
+    public Category findById(String s) {
+        return categoryData.findById(s);
+    }
+
+    @Override
+    public Category save(Category data) {
+        data = categoryData.save(data);
+        categoryCacheEvict.findById(data.getId());
+        return data;
+    }
+
+    @Override
+    public Category add(Category data) {
+        return categoryData.add(data);
+    }
+
+    @Override
+    public void deleteById(String s) {
+        categoryData.deleteById(s);
+    }
+
+    @Override
+    public long count() {
+        return categoryData.count();
+    }
+
+    @Override
+    public List<Category> findAll() {
+        return categoryData.findAll();
+    }
+
+    @Override
+    public Paging<Category> findAll(int page, int size) {
+        return categoryData.findAll(page, size);
+    }
+}

+ 253 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java

@@ -0,0 +1,253 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.service;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.common.utils.JsonUtil;
+import cc.iotkit.data.IDeviceInfoData;
+import cc.iotkit.data.cache.DeviceInfoCacheEvict;
+import cc.iotkit.data.cache.DeviceInfoCachePut;
+import cc.iotkit.model.Paging;
+import cc.iotkit.model.device.DeviceInfo;
+import cc.iotkit.model.stats.DataItem;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.SmartInitializingSingleton;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+@Qualifier("deviceInfoDataCache")
+public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSingleton {
+
+    private static final String PROPERTY_CACHE_KEY = "str:iotkit:device:property:%s";
+
+    @Autowired
+    private StringRedisTemplate redisTemplate;
+
+    @Autowired
+    private DeviceInfoCachePut deviceInfoCachePut;
+    @Autowired
+    private DeviceInfoCacheEvict deviceInfoCacheEvict;
+
+    @Autowired
+    private IDeviceInfoData deviceInfoData;
+
+
+    @Override
+    public void afterSingletonsInstantiated() {
+        if ("true".equals(System.getProperty("disabledEmbeddedRedis"))) {
+            return;
+        }
+
+        //需要等待缓存初始化
+        Timer timer = new Timer();
+        timer.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                //内嵌redis每次启动需要重新装载缓存
+                int page = 1;
+                Paging<DeviceInfo> paged;
+                List<String> parentIds = new ArrayList<>();
+                while ((paged = deviceInfoData.findAll(page++, 1000)).getData().size() > 0) {
+                    List<DeviceInfo> devices = paged.getData();
+                    for (DeviceInfo device : devices) {
+                        //装载设备信息缓存
+                        deviceInfoCachePut.findByDeviceId(device.getDeviceId(), device);
+                        deviceInfoCachePut.findByProductKeyAndDeviceName(device.getProductKey(), device.getDeviceName(), device);
+                        String parentId = device.getParentId();
+                        if (StringUtils.isBlank(parentId)) {
+                            parentIds.add(parentId);
+                        }
+                    }
+                }
+                //装载子设备id列表缓存
+                for (String parentId : parentIds) {
+                    putSubDeviceIds(parentId);
+                }
+            }
+        }, 100);
+    }
+
+    private String getPropertyCacheKey(String deviceId) {
+        return String.format(PROPERTY_CACHE_KEY, deviceId);
+    }
+
+    @Override
+    public void saveProperties(String deviceId, Map<String, Object> properties) {
+        redisTemplate.opsForValue().set(getPropertyCacheKey(deviceId), JsonUtil.toJsonString(properties));
+    }
+
+    @Override
+    public Map<String, Object> getProperties(String deviceId) {
+        return JsonUtil.parse(redisTemplate.opsForValue().get(getPropertyCacheKey(deviceId)), Map.class);
+    }
+
+    @Override
+    @Cacheable(value = Constants.CACHE_DEVICE_INFO, key = "#root.method.name+#deviceId", unless = "#result == null")
+    public DeviceInfo findByDeviceId(String deviceId) {
+        //不需要查数据库,在数据变更时更新到缓存
+        return null;
+    }
+
+    @Override
+    @Cacheable(value = Constants.CACHE_DEVICE_INFO, key = "#root.method.name+#productKey+#deviceName", unless = "#result == null")
+    public DeviceInfo findByProductKeyAndDeviceName(String productKey, String deviceName) {
+        //不需要查数据库,在数据变更时更新到缓存
+        return null;
+    }
+
+    @Override
+    public List<DeviceInfo> findByParentId(String parentId) {
+        return deviceInfoData.findByParentId(parentId);
+    }
+
+    @Override
+    public List<String> findSubDeviceIds(String parentId) {
+        return deviceInfoData.findSubDeviceIds(parentId);
+    }
+
+    @Override
+    public List<DeviceInfo> findByDeviceName(String deviceName) {
+        return deviceInfoData.findByDeviceName(deviceName);
+    }
+
+    @Override
+    public Paging<DeviceInfo> findByConditions(String uid, String subUid, String productKey,
+                                               String groupId, String state, String keyword, int page, int size) {
+        return deviceInfoData.findByConditions(uid, subUid, productKey, groupId, state, keyword, page, size);
+    }
+
+    @Override
+    public void updateTag(String deviceId, DeviceInfo.Tag tag) {
+        deviceInfoData.updateTag(deviceId, tag);
+        DeviceInfo data = deviceInfoData.findByDeviceId(deviceId);
+        putDeviceInfo(data);
+    }
+
+    @Override
+    @Cacheable(value = Constants.CACHE_DEVICE_STATS, key = "#root.method.name+#uid", unless = "#result == null")
+    public List<DataItem> getDeviceStatsByCategory(String uid) {
+        return deviceInfoData.getDeviceStatsByCategory(uid);
+    }
+
+    @Override
+    public long countByGroupId(String groupId) {
+        return deviceInfoData.countByGroupId(groupId);
+    }
+
+    @Override
+    public void addToGroup(String deviceId, DeviceInfo.Group group) {
+        deviceInfoData.addToGroup(deviceId, group);
+        DeviceInfo data = deviceInfoData.findByDeviceId(deviceId);
+        putDeviceInfo(data);
+    }
+
+    @Override
+    public void updateGroup(String groupId, DeviceInfo.Group group) {
+        deviceInfoData.updateGroup(groupId, group);
+    }
+
+    @Override
+    public void removeGroup(String deviceId, String groupId) {
+        deviceInfoData.removeGroup(deviceId, groupId);
+        DeviceInfo data = deviceInfoData.findByDeviceId(deviceId);
+        putDeviceInfo(data);
+    }
+
+    @Override
+    public void removeGroup(String groupId) {
+        deviceInfoData.removeGroup(groupId);
+    }
+
+    @Override
+    public List<DeviceInfo> findByUid(String uid) {
+        return deviceInfoData.findByUid(uid);
+    }
+
+    @Override
+    public Paging<DeviceInfo> findByUid(String uid, int page, int size) {
+        return deviceInfoData.findByUid(uid, page, size);
+    }
+
+    @Override
+    public long countByUid(String uid) {
+        return deviceInfoData.countByUid(uid);
+    }
+
+    @Override
+    public DeviceInfo findById(String s) {
+        return deviceInfoData.findById(s);
+    }
+
+    @Override
+    public DeviceInfo save(DeviceInfo data) {
+        DeviceInfo r = deviceInfoData.save(data);
+        //更新设备信息缓存
+        putDeviceInfo(data);
+        //更新子设备列表缓存
+        putSubDeviceIds(data.getParentId());
+        return r;
+    }
+
+    @Override
+    public DeviceInfo add(DeviceInfo data) {
+        return save(data);
+    }
+
+    @Override
+    public void deleteById(String s) {
+        DeviceInfo device = deviceInfoData.findById(s);
+        deviceInfoData.deleteById(s);
+        //清除缓存
+        deviceInfoCacheEvict.findByDeviceId(device.getDeviceId());
+        deviceInfoCacheEvict.findByProductKeyAndDeviceName(device.getProductKey(), device.getDeviceName());
+        //更新子设备列表缓存
+        putSubDeviceIds(device.getParentId());
+    }
+
+    @Override
+    public long count() {
+        return deviceInfoData.count();
+    }
+
+    @Override
+    public List<DeviceInfo> findAll() {
+        return deviceInfoData.findAll();
+    }
+
+    @Override
+    public Paging<DeviceInfo> findAll(int page, int size) {
+        return deviceInfoData.findAll(page, size);
+    }
+
+    /**
+     * 更新缓存
+     */
+    private void putDeviceInfo(DeviceInfo data) {
+        deviceInfoCachePut.findByDeviceId(data.getDeviceId(), data);
+        deviceInfoCachePut.findByProductKeyAndDeviceName(data.getProductKey(), data.getDeviceName(), data);
+    }
+
+    /**
+     * 更新子设备id列表
+     */
+    private void putSubDeviceIds(String parentId) {
+        if (StringUtils.isBlank(parentId)) {
+            return;
+        }
+        List<String> subDeviceIds = deviceInfoData.findSubDeviceIds(parentId);
+        deviceInfoCachePut.findSubDeviceIds(parentId, subDeviceIds);
+    }
+}

+ 67 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java

@@ -0,0 +1,67 @@
+package cc.iotkit.data.service;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.data.IOauthClientData;
+import cc.iotkit.data.cache.OauthClientCacheEvict;
+import cc.iotkit.model.OauthClient;
+import cc.iotkit.model.Paging;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Qualifier("oauthClientDataCache")
+public class OauthClientDataCache implements IOauthClientData {
+
+    @Autowired
+    private IOauthClientData oauthClientData;
+    @Autowired
+    private OauthClientCacheEvict oauthClientCacheEvict;
+
+    @Override
+    @Cacheable(value = Constants.CACHE_OAUTH_CLIENT, key = "#root.method.name+#clientId", unless = "#result == null")
+    public OauthClient findByClientId(String clientId) {
+        return oauthClientData.findByClientId(clientId);
+    }
+
+    @Override
+    public OauthClient findById(String s) {
+        return oauthClientData.findById(s);
+    }
+
+    @Override
+    public OauthClient save(OauthClient data) {
+        OauthClient oauthClient = oauthClientData.save(data);
+        //清除缓存
+        oauthClientCacheEvict.findByClientId(data.getClientId());
+        return oauthClient;
+    }
+
+    @Override
+    public OauthClient add(OauthClient data) {
+        return oauthClientData.add(data);
+    }
+
+    @Override
+    public void deleteById(String s) {
+        oauthClientData.deleteById(s);
+    }
+
+    @Override
+    public long count() {
+        return oauthClientData.count();
+    }
+
+    @Override
+    public List<OauthClient> findAll() {
+        return oauthClientData.findAll();
+    }
+
+    @Override
+    public Paging<OauthClient> findAll(int page, int size) {
+        return oauthClientData.findAll(page, size);
+    }
+}

+ 84 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java

@@ -0,0 +1,84 @@
+package cc.iotkit.data.service;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.data.IProductData;
+import cc.iotkit.data.cache.ProductCacheEvict;
+import cc.iotkit.model.Paging;
+import cc.iotkit.model.product.Product;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Qualifier("deviceInfoDataCache")
+public class ProductDataCache implements IProductData {
+
+    @Autowired
+    private IProductData productData;
+    @Autowired
+    private ProductCacheEvict productCacheEvict;
+
+    @Override
+    public List<Product> findByCategory(String category) {
+        return productData.findByCategory(category);
+    }
+
+    @Override
+    public List<Product> findByUid(String uid) {
+        return productData.findByUid(uid);
+    }
+
+    @Override
+    public Paging<Product> findByUid(String uid, int page, int size) {
+        return productData.findByUid(uid, page, size);
+    }
+
+    @Override
+    public long countByUid(String uid) {
+        return productData.countByUid(uid);
+    }
+
+    @Override
+    @Cacheable(value = Constants.CACHE_PRODUCT, key = "#root.method.name+#s", unless = "#result == null")
+    public Product findById(String s) {
+        return productData.findById(s);
+    }
+
+    @Override
+    public Product save(Product data) {
+        Product p = productData.save(data);
+        //清除缓存
+        productCacheEvict.findById(p.getId());
+        return p;
+    }
+
+    @Override
+    public Product add(Product data) {
+        return productData.add(data);
+    }
+
+    @Override
+    public void deleteById(String s) {
+        productData.deleteById(s);
+        //清除缓存
+        productCacheEvict.findById(s);
+    }
+
+    @Override
+    public long count() {
+        return productData.count();
+    }
+
+    @Override
+    public List<Product> findAll() {
+        return productData.findAll();
+    }
+
+    @Override
+    public Paging<Product> findAll(int page, int size) {
+        return productData.findAll(page, size);
+    }
+}

+ 71 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductModelDataCache.java

@@ -0,0 +1,71 @@
+package cc.iotkit.data.service;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.data.IProductModelData;
+import cc.iotkit.data.cache.ProductModelCacheEvict;
+import cc.iotkit.model.Paging;
+import cc.iotkit.model.product.ProductModel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Qualifier("productModelDataCache")
+public class ProductModelDataCache implements IProductModelData {
+
+    @Autowired
+    private IProductModelData productModelData;
+    @Autowired
+    private ProductModelCacheEvict productModelCacheEvict;
+
+    @Override
+    @Cacheable(value = Constants.CACHE_PRODUCT_SCRIPT, key = "#root.method.name+#model", unless = "#result == null")
+    public ProductModel findByModel(String model) {
+        return productModelData.findByModel(model);
+    }
+
+    @Override
+    public List<ProductModel> findByProductKey(String productKey) {
+        return productModelData.findByProductKey(productKey);
+    }
+
+    @Override
+    public ProductModel findById(String s) {
+        return productModelData.findById(s);
+    }
+
+    @Override
+    public ProductModel save(ProductModel data) {
+        ProductModel productModel = productModelData.save(data);
+        productModelCacheEvict.findByModel(data.getModel());
+        return productModel;
+    }
+
+    @Override
+    public ProductModel add(ProductModel data) {
+        return productModelData.add(data);
+    }
+
+    @Override
+    public void deleteById(String s) {
+        productModelData.deleteById(s);
+    }
+
+    @Override
+    public long count() {
+        return productModelData.count();
+    }
+
+    @Override
+    public List<ProductModel> findAll() {
+        return productModelData.findAll();
+    }
+
+    @Override
+    public Paging<ProductModel> findAll(int page, int size) {
+        return productModelData.findAll(page, size);
+    }
+}

+ 91 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/SpaceDataCache.java

@@ -0,0 +1,91 @@
+package cc.iotkit.data.service;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.data.ISpaceData;
+import cc.iotkit.data.cache.SpaceCacheEvict;
+import cc.iotkit.model.Paging;
+import cc.iotkit.model.space.Space;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Qualifier("spaceDataCache")
+public class SpaceDataCache implements ISpaceData {
+
+    @Autowired
+    private ISpaceData spaceData;
+    @Autowired
+    private SpaceCacheEvict spaceCacheEvict;
+
+    @Override
+    public List<Space> findByUidOrderByCreateAtDesc(String uid) {
+        return spaceData.findByUidOrderByCreateAtDesc(uid);
+    }
+
+    @Override
+    public List<Space> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId) {
+        return spaceData.findByUidAndHomeIdOrderByCreateAtDesc(uid, homeId);
+    }
+
+    @Override
+    public List<Space> findByHomeId(String homeId) {
+        return spaceData.findByHomeId(homeId);
+    }
+
+    @Override
+    public List<Space> findByUid(String uid) {
+        return spaceData.findByUid(uid);
+    }
+
+    @Override
+    public Paging<Space> findByUid(String uid, int page, int size) {
+        return spaceData.findByUid(uid, page, size);
+    }
+
+    @Override
+    public long countByUid(String uid) {
+        return spaceData.countByUid(uid);
+    }
+
+    @Override
+    @Cacheable(value = Constants.CACHE_SPACE, key = "#root.method.name+#s", unless = "#result == null")
+    public Space findById(String s) {
+        return spaceData.findById(s);
+    }
+
+    @Override
+    public Space save(Space data) {
+        data = spaceData.save(data);
+        spaceCacheEvict.findById(data.getId());
+        return data;
+    }
+
+    @Override
+    public Space add(Space data) {
+        return spaceData.add(data);
+    }
+
+    @Override
+    public void deleteById(String s) {
+        spaceData.deleteById(s);
+    }
+
+    @Override
+    public long count() {
+        return spaceData.count();
+    }
+
+    @Override
+    public List<Space> findAll() {
+        return spaceData.findAll();
+    }
+
+    @Override
+    public Paging<Space> findAll(int page, int size) {
+        return spaceData.findAll(page, size);
+    }
+}

+ 77 - 0
iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/UserInfoDataCache.java

@@ -0,0 +1,77 @@
+package cc.iotkit.data.service;
+
+import cc.iotkit.common.Constants;
+import cc.iotkit.data.IUserInfoData;
+import cc.iotkit.data.cache.UserInfoCacheEvict;
+import cc.iotkit.model.Paging;
+import cc.iotkit.model.UserInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@Qualifier("userInfoDataCache")
+public class UserInfoDataCache implements IUserInfoData {
+
+    @Autowired
+    private IUserInfoData userInfoData;
+    @Autowired
+    private UserInfoCacheEvict userInfoCacheEvict;
+
+    @Override
+    @Cacheable(value = Constants.CACHE_USER_INFO, key = "#root.method.name+#uid", unless = "#result == null")
+    public UserInfo findByUid(String uid) {
+        return userInfoData.findByUid(uid);
+    }
+
+    @Override
+    public List<UserInfo> findByType(int type) {
+        return userInfoData.findByType(type);
+    }
+
+    @Override
+    public List<UserInfo> findByTypeAndOwnerId(int type, String ownerId) {
+        return userInfoData.findByTypeAndOwnerId(type, ownerId);
+    }
+
+    @Override
+    public UserInfo findById(String s) {
+        return userInfoData.findById(s);
+    }
+
+    @Override
+    public UserInfo save(UserInfo data) {
+        UserInfo userInfo = userInfoData.save(data);
+        //清除缓存
+        userInfoCacheEvict.findByUid(data.getUid());
+        return userInfo;
+    }
+
+    @Override
+    public UserInfo add(UserInfo data) {
+        return userInfoData.add(data);
+    }
+
+    @Override
+    public void deleteById(String s) {
+        userInfoData.deleteById(s);
+    }
+
+    @Override
+    public long count() {
+        return userInfoData.count();
+    }
+
+    @Override
+    public List<UserInfo> findAll() {
+        return userInfoData.findAll();
+    }
+
+    @Override
+    public Paging<UserInfo> findAll(int page, int size) {
+        return userInfoData.findAll(page, size);
+    }
+}

+ 1 - 1
iot-data/iot-data-service/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-data</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 23 - 0
iot-data/iot-data-service/src/main/java/cc/iotkit/data/ICategoryData.java

@@ -14,9 +14,25 @@ import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.stats.DataItem;
 
 import java.util.List;
+import java.util.Map;
 
 public interface IDeviceInfoData extends IOwnedData<DeviceInfo, String> {
 
+    /**
+     * 保存设备属性
+     *
+     * @param deviceId   设备id
+     * @param properties 设备属性map
+     */
+    void saveProperties(String deviceId, Map<String, Object> properties);
+
+    /**
+     * 获取设备属性map
+     *
+     * @param deviceId 设备id
+     */
+    Map<String, Object> getProperties(String deviceId);
+
     /**
      * 根据设备ID取设备信息
      *
@@ -36,6 +52,13 @@ public interface IDeviceInfoData extends IOwnedData<DeviceInfo, String> {
      */
     List<DeviceInfo> findByParentId(String parentId);
 
+    /**
+     * 根据父设备ID取子设备ID列表
+     *
+     * @param parentId 父设备ID
+     */
+    List<String> findSubDeviceIds(String parentId);
+
     /**
      * 根据deviceName查找设备
      */

+ 1 - 0
iot-data/iot-data-service/src/main/java/cc/iotkit/data/IHomeData.java

@@ -3,4 +3,5 @@ package cc.iotkit.data;
 import cc.iotkit.model.protocol.ProtocolConverter;
 
 public interface IProtocolConverterData extends IOwnedData<ProtocolConverter, String> {
+
 }

+ 9 - 0
iot-data/iot-data-service/src/main/java/cc/iotkit/data/IRuleInfoData.java

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

+ 9 - 0
iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceDeviceData.java

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

+ 9 - 0
iot-data/iot-data-service/src/main/java/cc/iotkit/data/ITaskInfoData.java

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

+ 9 - 0
iot-data/iot-data-service/src/main/java/cc/iotkit/data/IVirtualDeviceData.java

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

+ 1 - 1
iot-data/iot-es-temporal-service/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>iot-data</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 2 - 1
iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/document/DevicePropertyDoc.java

@@ -17,6 +17,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
 import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -47,7 +48,7 @@ public class ThingModelMessageDataImpl implements IThingModelMessageData {
 
     @Override
     public List<TimeData> getDeviceMessageStatsWithUid(String uid, long start, long end) {
-        return null;
+        return new ArrayList<>();
     }
 
     @Override

+ 2 - 2
iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java

@@ -5,9 +5,9 @@
     <parent>
         <artifactId>iot-data</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
-    <version>0.3.3-SNAPSHOT</version>
+    <version>0.4.0-SNAPSHOT</version>
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>iot-model</artifactId>

+ 9 - 0
iot-data/iot-model/src/main/java/cc/iotkit/model/AppInfo.java

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

+ 9 - 0
iot-data/iot-model/src/main/java/cc/iotkit/model/InvokeResult.java

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

+ 9 - 0
iot-data/iot-model/src/main/java/cc/iotkit/model/product/ThingModel.java

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

+ 9 - 0
iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleLog.java

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

+ 2 - 2
iot-data/iot-model/src/main/java/cc/iotkit/model/rule/TaskInfo.java

@@ -5,9 +5,9 @@
     <parent>
         <artifactId>iot-data</artifactId>
         <groupId>cc.iotkit</groupId>
-        <version>0.3.3-SNAPSHOT</version>
+        <version>0.4.0-SNAPSHOT</version>
     </parent>
-    <version>0.3.3-SNAPSHOT</version>
+    <version>0.4.0-SNAPSHOT</version>
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>iot-rdb-data-service</artifactId>

+ 0 - 30
iot-data/iot-rdb-data-service/readme.md

@@ -1,30 +0,0 @@
-package cc.iotkit.data;
-
-import org.apache.commons.io.FileUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.util.ResourceUtils;
-
-import javax.annotation.PostConstruct;
-import java.io.File;
-import java.io.IOException;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-@Service
-public class DataBaseInit {
-
-    @Autowired
-    private JdbcTemplate template;
-
-//    @PostConstruct
-    public void initDb() throws IOException {
-        //执行初始化数据库脚本
-        File file = ResourceUtils.getFile("ddl.sql");
-        String ddl = FileUtils.readFileToString(file, UTF_8);
-
-        template.execute(ddl);
-    }
-
-}

+ 10 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/CategoryRepository.java

@@ -0,0 +1,10 @@
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbOauthClient;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface OauthClientRepository extends JpaRepository<TbOauthClient, String> {
+
+    TbOauthClient findByClientId(String clientId);
+
+}

+ 9 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductModelRepository.java

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

+ 19 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java

@@ -1,6 +1,17 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
 package cc.iotkit.data.dao;
 
 import cc.iotkit.data.model.TbProtocolComponent;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 
 import java.util.List;
@@ -9,4 +20,12 @@ public interface ProtocolComponentRepository extends JpaRepository<TbProtocolCom
 
     List<TbProtocolComponent> findByState(String state);
 
+    List<TbProtocolComponent> findByStateAndType(String state, String type);
+
+    List<TbProtocolComponent> findByUid(String uid);
+
+    Page<TbProtocolComponent> findByUid(String uid, Pageable pageable);
+
+    long countByUid(String uid);
+
 }

+ 18 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolConverterRepository.java

@@ -0,0 +1,18 @@
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbProtocolConverter;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface ProtocolConverterRepository extends JpaRepository<TbProtocolConverter, String> {
+
+    List<TbProtocolConverter> findByUid(String uid);
+
+    Page<TbProtocolConverter> findByUid(String uid, Pageable pageable);
+
+    long countByUid(String uid);
+
+}

+ 33 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/RuleInfoRepository.java

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

+ 36 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceDeviceRepository.java

@@ -0,0 +1,36 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbSpaceDevice;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface SpaceDeviceRepository extends JpaRepository<TbSpaceDevice, String> {
+
+    List<TbSpaceDevice> findByUid(String uid);
+
+    Page<TbSpaceDevice> findByUid(String uid, Pageable pageable);
+
+    List<TbSpaceDevice> findByUidOrderByUseAtDesc(String uid);
+
+    List<TbSpaceDevice> findByUidOrderByAddAtDesc(String uid);
+
+    List<TbSpaceDevice> findBySpaceIdOrderByAddAtDesc(String spaceId);
+
+    List<TbSpaceDevice> findByUidAndSpaceIdOrderByAddAtDesc(String uid, String spaceId);
+
+    TbSpaceDevice findByDeviceId(String deviceId);
+
+    TbSpaceDevice findByDeviceIdAndUid(String deviceId, String uid);
+}

+ 22 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceRepository.java

@@ -0,0 +1,22 @@
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbSpace;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface SpaceRepository extends JpaRepository<TbSpace, String> {
+
+    List<TbSpace> findByUidOrderByCreateAtDesc(String uid);
+
+    List<TbSpace> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId);
+
+    List<TbSpace> findByHomeId(String homeId);
+
+    List<TbSpace> findByUid(String uid);
+
+    Page<TbSpace> findByUid(String uid, Pageable pageable);
+
+}

+ 25 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/TaskInfoRepository.java

@@ -0,0 +1,25 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbTaskInfo;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface TaskInfoRepository extends JpaRepository<TbTaskInfo, String> {
+
+    List<TbTaskInfo> findByUid(String uid);
+
+    Page<TbTaskInfo> findByUid(String uid, Pageable pageable);
+
+}

+ 19 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ThingModelRepository.java

@@ -0,0 +1,19 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbThingModel;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface ThingModelRepository extends JpaRepository<TbThingModel, String> {
+
+    TbThingModel findByProductKey(String productKey);
+
+}

+ 25 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/UserInfoRepository.java

@@ -0,0 +1,25 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbUserInfo;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface UserInfoRepository extends JpaRepository<TbUserInfo, String> {
+
+    TbUserInfo findByUid(String uid);
+
+    List<TbUserInfo> findByType(int type);
+
+    List<TbUserInfo> findByTypeAndOwnerId(int type, String ownerId);
+
+}

+ 23 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceMappingRepository.java

@@ -0,0 +1,23 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbVirtualDeviceMapping;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface VirtualDeviceMappingRepository extends JpaRepository<TbVirtualDeviceMapping, String> {
+
+    List<TbVirtualDeviceMapping> findByVirtualId(String virtualId);
+
+    void deleteByVirtualId(String virtualId);
+
+}

+ 27 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceRepository.java

@@ -0,0 +1,27 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.dao;
+
+import cc.iotkit.data.model.TbVirtualDevice;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface VirtualDeviceRepository extends JpaRepository<TbVirtualDevice, String> {
+
+    List<TbVirtualDevice> findByUid(String uid);
+
+    Page<TbVirtualDevice> findByUid(String uid, Pageable pageable);
+
+    List<TbVirtualDevice> findByTriggerAndState(String trigger, String state);
+
+}

+ 9 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/CategoryMapper.java

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

+ 16 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceGroupMapper.java

@@ -0,0 +1,16 @@
+package cc.iotkit.data.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class DeviceIdGroup {
+
+    private String id;
+    private String deviceId;
+    private String name;
+
+}

+ 9 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceInfoMapper.java

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

+ 15 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/OauthClientMapper.java

@@ -0,0 +1,15 @@
+package cc.iotkit.data.model;
+
+import cc.iotkit.model.OauthClient;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+@Mapper
+public interface OauthClientMapper {
+
+    OauthClientMapper M = Mappers.getMapper(OauthClientMapper.class);
+
+    OauthClient toDto(TbOauthClient vo);
+
+    TbOauthClient toVo(OauthClient dto);
+}

+ 22 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProductMapper.java

@@ -0,0 +1,22 @@
+package cc.iotkit.data.model;
+
+import cc.iotkit.model.protocol.ProtocolConverter;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Mapper
+public interface ProtocolConverterMapper {
+
+    ProtocolConverterMapper M = Mappers.getMapper(ProtocolConverterMapper.class);
+
+    ProtocolConverter toDto(TbProtocolConverter vo);
+
+    TbProtocolConverter toVo(ProtocolConverter dto);
+
+    static List<ProtocolConverter> toDto(List<TbProtocolConverter> list) {
+        return list.stream().map(M::toDto).collect(Collectors.toList());
+    }
+}

+ 57 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/RuleInfoMapper.java

@@ -0,0 +1,57 @@
+package cc.iotkit.data.model;
+
+import cc.iotkit.common.utils.JsonUtil;
+import cc.iotkit.model.rule.RuleInfo;
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.Mappings;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Mapper
+public interface RuleInfoMapper {
+
+    RuleInfoMapper M = Mappers.getMapper(RuleInfoMapper.class);
+
+    @Mappings({
+            @Mapping(target = "listeners", ignore = true),
+            @Mapping(target = "filters", ignore = true),
+            @Mapping(target = "actions", ignore = true)
+    }
+    )
+    RuleInfo toDto(TbRuleInfo vo);
+
+    @Mappings({
+            @Mapping(target = "listeners", ignore = true),
+            @Mapping(target = "filters", ignore = true),
+            @Mapping(target = "actions", ignore = true)
+    }
+    )
+    TbRuleInfo toVo(RuleInfo dto);
+
+    static RuleInfo toDtoFix(TbRuleInfo vo) {
+        RuleInfo dto = M.toDto(vo);
+        dto.setListeners(JsonUtil.parse(vo.getListeners(), new TypeReference<>() {
+        }));
+        dto.setFilters(JsonUtil.parse(vo.getFilters(), new TypeReference<>() {
+        }));
+        dto.setActions(JsonUtil.parse(vo.getActions(), new TypeReference<>() {
+        }));
+        return dto;
+    }
+
+    static TbRuleInfo toVoFix(RuleInfo dto) {
+        TbRuleInfo vo = M.toVo(dto);
+        vo.setListeners(JsonUtil.toJsonString(dto.getListeners()));
+        vo.setFilters(JsonUtil.toJsonString(dto.getFilters()));
+        vo.setActions(JsonUtil.toJsonString(dto.getActions()));
+        return vo;
+    }
+
+    static List<RuleInfo> toDto(List<TbRuleInfo> list) {
+        return list.stream().map(RuleInfoMapper::toDtoFix).collect(Collectors.toList());
+    }
+}

+ 32 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceDeviceMapper.java

@@ -0,0 +1,32 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import cc.iotkit.model.space.SpaceDevice;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Mapper
+public interface SpaceDeviceMapper {
+
+    SpaceDeviceMapper M = Mappers.getMapper(SpaceDeviceMapper.class);
+
+    SpaceDevice toDto(TbSpaceDevice vo);
+
+    TbSpaceDevice toVo(SpaceDevice dto);
+
+    static List<SpaceDevice> toDto(List<TbSpaceDevice> list) {
+        return list.stream().map(M::toDto).collect(Collectors.toList());
+    }
+
+}

+ 24 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceMapper.java

@@ -0,0 +1,24 @@
+package cc.iotkit.data.model;
+
+import cc.iotkit.model.protocol.ProtocolComponent;
+import cc.iotkit.model.space.Space;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Mapper
+public interface SpaceMapper {
+
+    SpaceMapper M = Mappers.getMapper(SpaceMapper.class);
+
+    Space toDto(TbSpace vo);
+
+    TbSpace toVo(Space dto);
+
+    static List<Space> toDto(List<TbSpace> list) {
+        return list.stream().map(M::toDto).collect(Collectors.toList());
+    }
+
+}

+ 50 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TaskInfoMapper.java

@@ -0,0 +1,50 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import cc.iotkit.common.utils.JsonUtil;
+import cc.iotkit.model.rule.TaskInfo;
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Mapper
+public interface TaskInfoMapper {
+
+    TaskInfoMapper M = Mappers.getMapper(TaskInfoMapper.class);
+
+    @Mapping(target = "actions", ignore = true)
+    TaskInfo toDto(TbTaskInfo vo);
+
+    static TaskInfo toDtoFix(TbTaskInfo vo) {
+        TaskInfo dto = M.toDto(vo);
+        dto.setActions(JsonUtil.parse(vo.getActions(), new TypeReference<>() {
+        }));
+        return dto;
+    }
+
+    @Mapping(target = "actions", ignore = true)
+    TbTaskInfo toVo(TaskInfo dto);
+
+    static TbTaskInfo toVoFix(TaskInfo dto) {
+        TbTaskInfo vo = M.toVo(dto);
+        vo.setActions(JsonUtil.toJsonString(dto.getActions()));
+        return vo;
+    }
+
+    static List<TaskInfo> toDto(List<TbTaskInfo> list) {
+        return list.stream().map(TaskInfoMapper::toDtoFix).collect(Collectors.toList());
+    }
+
+}

+ 2 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbCategory.java

@@ -2,6 +2,7 @@ package cc.iotkit.data.model;
 
 import lombok.Data;
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
@@ -26,6 +27,7 @@ public class TbDeviceConfig {
     /**
      * 设备配置json内容
      */
+    @Column(columnDefinition = "text")
     private String config;
 
     private Long createAt;

+ 9 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroup.java

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

+ 9 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroupMapping.java

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

+ 27 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceTag.java

@@ -0,0 +1,27 @@
+package cc.iotkit.data.model;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "oauth_client")
+public class TbOauthClient {
+
+    @Id
+    private String id;
+
+    private String clientId;
+
+    private String name;
+
+    private String clientSecret;
+
+    private String allowUrl;
+
+    private Long createAt;
+
+}

+ 2 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProduct.java

@@ -2,6 +2,7 @@ package cc.iotkit.data.model;
 
 import lombok.Data;
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
@@ -25,6 +26,7 @@ public class TbProductModel {
 
     private String type;
 
+    @Column(columnDefinition = "text")
     private String script;
 
     /**

+ 2 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolComponent.java

@@ -2,6 +2,7 @@ package cc.iotkit.data.model;
 
 import lombok.Data;
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
@@ -27,6 +28,7 @@ public class TbProtocolComponent {
 
     private String jarFile;
 
+    @Column(columnDefinition = "text")
     private String config;
 
     private String converter;

+ 39 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolConverter.java

@@ -0,0 +1,39 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "protocol_converter")
+public class TbProtocolConverter {
+
+    @Id
+    private String id;
+
+    /**
+     * 所属性用户id
+     */
+    private String uid;
+
+    private String name;
+
+    @Column(name = "[desc]")
+    private String desc;
+
+    private Long createAt;
+
+}

+ 49 - 0
iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbRuleInfo.java

@@ -0,0 +1,49 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "rule_info")
+public class TbRuleInfo {
+
+    @Id
+    private String id;
+
+    private String name;
+
+    private String type;
+
+    @Column(columnDefinition = "text")
+    private String listeners;
+
+    @Column(columnDefinition = "text")
+    private String filters;
+
+    @Column(columnDefinition = "text")
+    private String actions;
+
+    private String uid;
+
+    private String state;
+
+    @Column(name = "[desc]")
+    private String desc;
+
+    private Long createAt;
+
+}

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است