diff --git a/.workflow/BranchPipeline.yml b/.workflow/BranchPipeline.yml
old mode 100644
new mode 100755
diff --git a/.workflow/MasterPipeline.yml b/.workflow/MasterPipeline.yml
old mode 100644
new mode 100755
diff --git a/.workflow/PRPipeline.yml b/.workflow/PRPipeline.yml
old mode 100644
new mode 100755
diff --git a/data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/component.js b/data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/component.js
old mode 100644
new mode 100755
diff --git a/data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/iot-mqtt-component-0.3.1-SNAPSHOT.jar b/data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/iot-mqtt-component-0.3.1-SNAPSHOT.jar
old mode 100644
new mode 100755
diff --git a/data/converters/6260396d67aced2696184053/converter.js b/data/converters/6260396d67aced2696184053/converter.js
old mode 100644
new mode 100755
diff --git a/data/init/category.json b/data/init/category.json
old mode 100644
new mode 100755
diff --git a/data/init/deviceGroup.json b/data/init/deviceGroup.json
old mode 100644
new mode 100755
diff --git a/data/init/deviceInfo.json b/data/init/deviceInfo.json
old mode 100644
new mode 100755
diff --git a/data/init/home.json b/data/init/home.json
old mode 100644
new mode 100755
diff --git a/data/init/oauthClient.json b/data/init/oauthClient.json
old mode 100644
new mode 100755
index 799624af..64adb29b
--- a/data/init/oauthClient.json
+++ b/data/init/oauthClient.json
@@ -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": "*",
diff --git a/data/init/product.json b/data/init/product.json
old mode 100644
new mode 100755
diff --git a/data/init/productModel.json b/data/init/productModel.json
old mode 100644
new mode 100755
diff --git a/data/init/protocolComponent.json b/data/init/protocolComponent.json
old mode 100644
new mode 100755
index 941b6c6f..5c597fa6
--- a/data/init/protocolComponent.json
+++ b/data/init/protocolComponent.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
}
]
\ No newline at end of file
diff --git a/data/init/protocolConverter.json b/data/init/protocolConverter.json
old mode 100644
new mode 100755
diff --git a/data/init/ruleInfo.json b/data/init/ruleInfo.json
old mode 100644
new mode 100755
diff --git a/data/init/space.json b/data/init/space.json
old mode 100644
new mode 100755
diff --git a/data/init/spaceDevice.json b/data/init/spaceDevice.json
old mode 100644
new mode 100755
diff --git a/data/init/taskInfo.json b/data/init/taskInfo.json
old mode 100644
new mode 100755
diff --git a/data/init/thingModel.json b/data/init/thingModel.json
old mode 100644
new mode 100755
diff --git a/data/init/userInfo.json b/data/init/userInfo.json
old mode 100644
new mode 100755
diff --git a/data/init/virtualDevice.json b/data/init/virtualDevice.json
old mode 100644
new mode 100755
diff --git a/doc/WechatIMG539.png b/doc/WechatIMG539.png
old mode 100644
new mode 100755
diff --git a/doc/mongodb安装配置.jpg b/doc/mongodb安装配置.jpg
old mode 100644
new mode 100755
diff --git a/doc/screenshot.jpg b/doc/screenshot.jpg
old mode 100644
new mode 100755
diff --git a/doc/安装Pulsar.jpg b/doc/安装Pulsar.jpg
old mode 100644
new mode 100755
diff --git a/iot-auth-server/pom.xml b/iot-auth-server/pom.xml
old mode 100644
new mode 100755
index 67ae1b22..1d1279c3
--- a/iot-auth-server/pom.xml
+++ b/iot-auth-server/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-auth-server/readme.txt b/iot-auth-server/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthClientController.java b/iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthClientController.java
old mode 100644
new mode 100755
index 57443b8a..b7588b69
--- a/iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthClientController.java
+++ b/iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthClientController.java
@@ -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;
diff --git a/iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthServerController.java b/iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthServerController.java
old mode 100644
new mode 100755
diff --git a/iot-auth-server/src/main/java/cc/iotkit/oauth/service/SaOAuth2TemplateImpl.java b/iot-auth-server/src/main/java/cc/iotkit/oauth/service/SaOAuth2TemplateImpl.java
old mode 100644
new mode 100755
index a9fc09fc..d6bc9638
--- a/iot-auth-server/src/main/java/cc/iotkit/oauth/service/SaOAuth2TemplateImpl.java
+++ b/iot-auth-server/src/main/java/cc/iotkit/oauth/service/SaOAuth2TemplateImpl.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;
}
diff --git a/iot-auth-server/src/main/java/cc/iotkit/oauth/service/StpInterfaceImpl.java b/iot-auth-server/src/main/java/cc/iotkit/oauth/service/StpInterfaceImpl.java
old mode 100644
new mode 100755
index 8294a72f..b3e350fb
--- a/iot-auth-server/src/main/java/cc/iotkit/oauth/service/StpInterfaceImpl.java
+++ b/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 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 getRoleList(Object loginId, String loginType) {
- UserInfo userInfo = userInfoCache.getUserInfo(loginId.toString());
+ UserInfo userInfo = userInfoData.findById(loginId.toString());
return userInfo.getRoles();
}
diff --git a/iot-auth-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java b/iot-auth-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java
old mode 100644
new mode 100755
index 8eaa971a..cb1f93f3
--- a/iot-auth-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java
+++ b/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;
diff --git a/iot-auth-server/src/main/java/cc/iotkit/oauth/vo/UserInfoVo.java b/iot-auth-server/src/main/java/cc/iotkit/oauth/vo/UserInfoVo.java
old mode 100644
new mode 100755
diff --git a/iot-auth-server/src/main/java/cc/iotkit/utils/AuthUtil.java b/iot-auth-server/src/main/java/cc/iotkit/utils/AuthUtil.java
old mode 100644
new mode 100755
diff --git a/iot-auth-server/src/main/java/cc/iotkit/utils/SoMap.java b/iot-auth-server/src/main/java/cc/iotkit/utils/SoMap.java
old mode 100644
new mode 100755
diff --git a/iot-auth-server/src/main/resources/templates/confirm.html b/iot-auth-server/src/main/resources/templates/confirm.html
old mode 100644
new mode 100755
diff --git a/iot-auth-server/src/main/resources/templates/login.html b/iot-auth-server/src/main/resources/templates/login.html
old mode 100644
new mode 100755
diff --git a/iot-auth-server/src/test/java/GenPwdSecret.java b/iot-auth-server/src/test/java/GenPwdSecret.java
old mode 100644
new mode 100755
diff --git a/iot-common/pom.xml b/iot-common/pom.xml
old mode 100644
new mode 100755
index 07ef57cd..2bfec4f3
--- a/iot-common/pom.xml
+++ b/iot-common/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-common/readme.txt b/iot-common/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/ComponentClassLoader.java b/iot-common/src/main/java/cc/iotkit/common/ComponentClassLoader.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/Constants.java b/iot-common/src/main/java/cc/iotkit/common/Constants.java
old mode 100644
new mode 100755
index b8af04ab..b123c877
--- a/iot-common/src/main/java/cc/iotkit/common/Constants.java
+++ b/iot-common/src/main/java/cc/iotkit/common/Constants.java
@@ -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";
/**
* 管理员角色
diff --git a/iot-common/src/main/java/cc/iotkit/common/exception/BizException.java b/iot-common/src/main/java/cc/iotkit/common/exception/BizException.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/exception/NotFoundException.java b/iot-common/src/main/java/cc/iotkit/common/exception/NotFoundException.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/exception/OfflineException.java b/iot-common/src/main/java/cc/iotkit/common/exception/OfflineException.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/thing/ThingService.java b/iot-common/src/main/java/cc/iotkit/common/thing/ThingService.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/utils/CodecUtil.java b/iot-common/src/main/java/cc/iotkit/common/utils/CodecUtil.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/utils/DeviceUtil.java b/iot-common/src/main/java/cc/iotkit/common/utils/DeviceUtil.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/utils/HexUtil.java b/iot-common/src/main/java/cc/iotkit/common/utils/HexUtil.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/utils/JsonUtil.java b/iot-common/src/main/java/cc/iotkit/common/utils/JsonUtil.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/utils/ReflectUtil.java b/iot-common/src/main/java/cc/iotkit/common/utils/ReflectUtil.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/utils/ThreadUtil.java b/iot-common/src/main/java/cc/iotkit/common/utils/ThreadUtil.java
old mode 100644
new mode 100755
diff --git a/iot-common/src/main/java/cc/iotkit/common/utils/UniqueIdUtil.java b/iot-common/src/main/java/cc/iotkit/common/utils/UniqueIdUtil.java
old mode 100644
new mode 100755
diff --git a/iot-components/.DS_Store b/iot-components/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/.DS_Store b/iot-components/iot-component-base/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/pom.xml b/iot-components/iot-component-base/pom.xml
old mode 100644
new mode 100755
index ba31f36f..d73eee5e
--- a/iot-components/iot-component-base/pom.xml
+++ b/iot-components/iot-component-base/pom.xml
@@ -5,7 +5,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/AbstractDeviceComponent.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/AbstractDeviceComponent.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/CompConfig.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/CompConfig.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IComponent.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IComponent.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IDeviceComponent.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IDeviceComponent.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IMessageHandler.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IMessageHandler.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/AuthInfo.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/AuthInfo.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/DeviceState.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/DeviceState.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/ReceiveResult.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/ReceiveResult.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/RegisterInfo.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/RegisterInfo.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/utils/SpringUtils.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/utils/SpringUtils.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-converter/.DS_Store b/iot-components/iot-component-converter/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-converter/pom.xml b/iot-components/iot-component-converter/pom.xml
old mode 100644
new mode 100755
index b668ac33..35283c03
--- a/iot-components/iot-component-converter/pom.xml
+++ b/iot-components/iot-component-converter/pom.xml
@@ -5,7 +5,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/Device.java b/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/Device.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/DeviceMessage.java b/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/DeviceMessage.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/IConverter.java b/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/IConverter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/ScriptConverter.java b/iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/ScriptConverter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/.DS_Store b/iot-components/iot-component-server/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/pom.xml b/iot-components/iot-component-server/pom.xml
old mode 100644
new mode 100755
index b5d7ed0a..5bd0aa49
--- a/iot-components/iot-component-server/pom.xml
+++ b/iot-components/iot-component-server/pom.xml
@@ -5,7 +5,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ApiTool.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ApiTool.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/BizComponentManager.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/BizComponentManager.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ComponentManager.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ComponentManager.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java
old mode 100644
new mode 100755
index 301209ab..a3b7e67e
--- a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java
+++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.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 componentList = protocolComponentData.findByStateAndType(
- ProtocolComponent.STATE_RUNNING, ProtocolComponent.TYPE_DEVICE);
- for (ProtocolComponent component : componentList) {
+ List 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();
}
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceRouter.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceRouter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/config/CacheKey.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/config/CacheKey.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/config/ComponentConfig.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/config/ComponentConfig.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java
old mode 100644
new mode 100755
index f9f78f72..3522f264
--- a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java
+++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.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 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 subDevices = deviceInfoData.findByParentId(device.getDeviceId());
- for (DeviceInfo subDevice : subDevices) {
- Product product = productCache.findById(subDevice.getProductKey());
+ //否则为父设备,同步透传子设备状态
+ List 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;
}
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigConsumer.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigConsumer.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceMessageConsumer.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceMessageConsumer.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java
old mode 100644
new mode 100755
index 86c85ff8..4b45b136
--- a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java
+++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.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 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);
}
diff --git a/iot-components/iot-ctwing-component/.DS_Store b/iot-components/iot-ctwing-component/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-ctwing-component/lib/ag-sdk-biz-84356.tar.gz-20220603.182201-SNAPSHOT.jar b/iot-components/iot-ctwing-component/lib/ag-sdk-biz-84356.tar.gz-20220603.182201-SNAPSHOT.jar
old mode 100644
new mode 100755
diff --git a/iot-components/iot-ctwing-component/lib/ctg-ag-sdk-core-2.5.0-20220512.061430-51.jar b/iot-components/iot-ctwing-component/lib/ctg-ag-sdk-core-2.5.0-20220512.061430-51.jar
old mode 100644
new mode 100755
diff --git a/iot-components/iot-ctwing-component/pom.xml b/iot-components/iot-ctwing-component/pom.xml
old mode 100644
new mode 100755
index e5f87e9d..01549882
--- a/iot-components/iot-ctwing-component/pom.xml
+++ b/iot-components/iot-ctwing-component/pom.xml
@@ -5,7 +5,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
@@ -82,8 +82,8 @@
org.apache.maven.plugins
maven-compiler-plugin
-
- 8
+
+ 11
diff --git a/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingConfig.java b/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingConfig.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingDeviceComponent.java b/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingDeviceComponent.java
old mode 100644
new mode 100755
index c0580da0..3e61a0c6
--- a/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingDeviceComponent.java
+++ b/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingDeviceComponent.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;
diff --git a/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/ProtocolUtil.java b/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/ProtocolUtil.java
old mode 100644
new mode 100755
index e0490c98..248386f6
--- a/iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/ProtocolUtil.java
+++ b/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;
diff --git a/iot-components/iot-ctwing-component/src/main/resources/component.js b/iot-components/iot-ctwing-component/src/main/resources/component.js
old mode 100644
new mode 100755
diff --git a/iot-components/iot-ctwing-component/src/main/resources/component.spi b/iot-components/iot-ctwing-component/src/main/resources/component.spi
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/.DS_Store b/iot-components/iot-emqx-component/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/dependency-reduced-pom.xml b/iot-components/iot-emqx-component/dependency-reduced-pom.xml
old mode 100644
new mode 100755
index 2b5eb562..83792b0b
--- a/iot-components/iot-emqx-component/dependency-reduced-pom.xml
+++ b/iot-components/iot-emqx-component/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
iot-emqx-component
@@ -48,8 +48,8 @@
maven-compiler-plugin
-
- 8
+
+ 11
@@ -82,25 +82,25 @@
cc.iotkit
iot-model
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
cc.iotkit
iot-dao
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
cc.iotkit
iot-common
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
cc.iotkit
iot-component-base
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
diff --git a/iot-components/iot-emqx-component/pom.xml b/iot-components/iot-emqx-component/pom.xml
old mode 100644
new mode 100755
index 1a06d708..5b2aa15b
--- a/iot-components/iot-emqx-component/pom.xml
+++ b/iot-components/iot-emqx-component/pom.xml
@@ -5,7 +5,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
@@ -105,8 +105,8 @@
org.apache.maven.plugins
maven-compiler-plugin
-
- 8
+
+ 11
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/AuthVerticle.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/AuthVerticle.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxConfig.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxConfig.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.java
old mode 100644
new mode 100755
index fdbb5245..6b810f7a
--- a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.java
+++ b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.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) {
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/IScripter.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/IScripter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/JsScripter.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/JsScripter.java
old mode 100644
new mode 100755
index 188bfc97..5971e499
--- a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/JsScripter.java
+++ b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/JsScripter.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;
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.java
old mode 100644
new mode 100755
index 48a62975..ea347a30
--- a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.java
+++ b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.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 scripters = new HashMap<>();
private final Map 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);
}
/**
diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentMsg.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentMsg.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/src/main/resources/component.js b/iot-components/iot-emqx-component/src/main/resources/component.js
old mode 100644
new mode 100755
diff --git a/iot-components/iot-emqx-component/src/main/resources/component.spi b/iot-components/iot-emqx-component/src/main/resources/component.spi
old mode 100644
new mode 100755
diff --git a/iot-components/iot-http-biz-component/.DS_Store b/iot-components/iot-http-biz-component/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-http-biz-component/dependency-reduced-pom.xml b/iot-components/iot-http-biz-component/dependency-reduced-pom.xml
old mode 100644
new mode 100755
index 5087ebc9..38bf4498
--- a/iot-components/iot-http-biz-component/dependency-reduced-pom.xml
+++ b/iot-components/iot-http-biz-component/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
iot-http-biz-component
@@ -36,8 +36,8 @@
maven-compiler-plugin
-
- 8
+
+ 11
@@ -58,7 +58,7 @@
cc.iotkit
iot-component-base
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
diff --git a/iot-components/iot-http-biz-component/pom.xml b/iot-components/iot-http-biz-component/pom.xml
old mode 100644
new mode 100755
index 425dcbca..52e0412a
--- a/iot-components/iot-http-biz-component/pom.xml
+++ b/iot-components/iot-http-biz-component/pom.xml
@@ -5,7 +5,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
@@ -66,8 +66,8 @@
org.apache.maven.plugins
maven-compiler-plugin
-
- 8
+
+ 11
diff --git a/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java b/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpConfig.java b/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpConfig.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-http-biz-component/src/main/resources/component.spi b/iot-components/iot-http-biz-component/src/main/resources/component.spi
old mode 100644
new mode 100755
diff --git a/iot-components/iot-http-biz-component/src/main/resources/onenet接入脚本示例.js b/iot-components/iot-http-biz-component/src/main/resources/onenet接入脚本示例.js
old mode 100644
new mode 100755
diff --git a/iot-components/iot-http-biz-component/src/main/resources/小度音箱接入脚本示例.js b/iot-components/iot-http-biz-component/src/main/resources/小度音箱接入脚本示例.js
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/.DS_Store b/iot-components/iot-mqtt-component/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/dependency-reduced-pom.xml b/iot-components/iot-mqtt-component/dependency-reduced-pom.xml
old mode 100644
new mode 100755
index 74e17596..e7e10eaf
--- a/iot-components/iot-mqtt-component/dependency-reduced-pom.xml
+++ b/iot-components/iot-mqtt-component/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
iot-mqtt-component
@@ -34,8 +34,8 @@
maven-compiler-plugin
-
- 8
+
+ 11
@@ -80,19 +80,19 @@
cc.iotkit
iot-common
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
cc.iotkit
iot-component-base
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
cc.iotkit
iot-dao
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
compile
diff --git a/iot-components/iot-mqtt-component/pom.xml b/iot-components/iot-mqtt-component/pom.xml
old mode 100644
new mode 100755
index 0c27a327..e57ccb0e
--- a/iot-components/iot-mqtt-component/pom.xml
+++ b/iot-components/iot-mqtt-component/pom.xml
@@ -5,7 +5,7 @@
iot-components
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
@@ -89,8 +89,8 @@
org.apache.maven.plugins
maven-compiler-plugin
-
- 8
+
+ 11
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/IScripter.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/IScripter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/JsScripter.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/JsScripter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/LuaScripter.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/LuaScripter.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttConfig.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttConfig.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttDeviceComponent.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttDeviceComponent.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttVerticle.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttVerticle.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.java
old mode 100644
new mode 100755
index 6db5db69..4569c3a1
--- a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.java
+++ b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.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 scripters = new HashMap<>();
private final Map 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);
}
/**
diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentMsg.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentMsg.java
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/resources/component.js b/iot-components/iot-mqtt-component/src/main/resources/component.js
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/resources/component.spi b/iot-components/iot-mqtt-component/src/main/resources/component.spi
old mode 100644
new mode 100755
diff --git a/iot-components/iot-mqtt-component/src/main/resources/converter.js b/iot-components/iot-mqtt-component/src/main/resources/converter.js
old mode 100644
new mode 100755
diff --git a/iot-components/pom.xml b/iot-components/pom.xml
old mode 100644
new mode 100755
index 7e213af7..fedc95d5
--- a/iot-components/pom.xml
+++ b/iot-components/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-components/readme.txt b/iot-components/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-data/.DS_Store b/iot-data/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-data/iot-dao/.DS_Store b/iot-data/iot-dao/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-data/iot-dao/pom.xml b/iot-data/iot-dao/pom.xml
old mode 100644
new mode 100755
index 65ba9685..81f0e0a3
--- a/iot-data/iot-dao/pom.xml
+++ b/iot-data/iot-dao/pom.xml
@@ -5,7 +5,7 @@
iot-data
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/CategoryCache.java b/iot-data/iot-dao/src/main/java/cc/iotkit/dao/CategoryCache.java
deleted file mode 100644
index 58dfffa8..00000000
--- a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/CategoryCache.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceCache.java b/iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceCache.java
deleted file mode 100644
index 3bd79464..00000000
--- a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceCache.java
+++ /dev/null
@@ -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 getDeviceStatsByCategory(String uid) {
- return deviceInfoData.getDeviceStatsByCategory(uid);
- }
-
-}
diff --git a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceDao.java b/iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceDao.java
old mode 100644
new mode 100755
index ca28c850..881200a4
--- a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/DeviceDao.java
+++ b/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;
diff --git a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/OauthClientCache.java b/iot-data/iot-dao/src/main/java/cc/iotkit/dao/OauthClientCache.java
deleted file mode 100644
index 769e63f9..00000000
--- a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/OauthClientCache.java
+++ /dev/null
@@ -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);
- }
-
-}
diff --git a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/ProductCache.java b/iot-data/iot-dao/src/main/java/cc/iotkit/dao/ProductCache.java
deleted file mode 100644
index 6e52753f..00000000
--- a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/ProductCache.java
+++ /dev/null
@@ -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);
- }
-
-
-}
diff --git a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/SpaceCache.java b/iot-data/iot-dao/src/main/java/cc/iotkit/dao/SpaceCache.java
old mode 100644
new mode 100755
index e0afb043..cad9647b
--- a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/SpaceCache.java
+++ b/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);
}
diff --git a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/UserInfoCache.java b/iot-data/iot-dao/src/main/java/cc/iotkit/dao/UserInfoCache.java
deleted file mode 100644
index 5b4b0b96..00000000
--- a/iot-data/iot-dao/src/main/java/cc/iotkit/dao/UserInfoCache.java
+++ /dev/null
@@ -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);
- }
-
-}
diff --git a/iot-data/iot-data-cache/pom.xml b/iot-data/iot-data-cache/pom.xml
old mode 100644
new mode 100755
index 5fcf688b..053c1931
--- a/iot-data/iot-data-cache/pom.xml
+++ b/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">
- iotkit-parent
+ iot-data
cc.iotkit
- 0.3.3-SNAPSHOT
- ../../pom.xml
+ 0.4.0-SNAPSHOT
4.0.0
@@ -20,8 +19,13 @@
- org.springframework.data
- spring-data-redis
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.springframework.boot
+ spring-boot-starter-cache
@@ -29,6 +33,16 @@
iot-common
+
+ cc.iotkit
+ iot-model
+
+
+
+ cc.iotkit
+ iot-data-service
+
+
\ No newline at end of file
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/CategoryCacheEvict.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/CategoryCacheEvict.java
new file mode 100644
index 00000000..c5492988
--- /dev/null
+++ b/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) {
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceCacheService.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceCacheService.java
deleted file mode 100644
index a6fbcab3..00000000
--- a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceCacheService.java
+++ /dev/null
@@ -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 properties) {
- redisTemplate.opsForValue().set(getPropertyCacheKey(deviceId), JsonUtil.toJsonString(properties));
- }
-
- /**
- * 获取设备属性map
- *
- * @param deviceId 设备id
- */
- public Map getProperties(String deviceId) {
- return JsonUtil.parse(redisTemplate.opsForValue().get(getPropertyCacheKey(deviceId)), Map.class);
- }
-
-}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCacheEvict.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCacheEvict.java
new file mode 100644
index 00000000..175ab779
--- /dev/null
+++ b/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) {
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCachePut.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/DeviceInfoCachePut.java
new file mode 100644
index 00000000..41be38fc
--- /dev/null
+++ b/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 findSubDeviceIds(String parentId, List subDeviceIds) {
+ return subDeviceIds;
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/OauthClientCacheEvict.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/OauthClientCacheEvict.java
new file mode 100644
index 00000000..4d66eabe
--- /dev/null
+++ b/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) {
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductCacheEvict.java
new file mode 100644
index 00000000..a145b65d
--- /dev/null
+++ b/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) {
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductModelCacheEvict.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/ProductModelCacheEvict.java
new file mode 100644
index 00000000..3a786f59
--- /dev/null
+++ b/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) {
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/SpaceCacheEvict.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/SpaceCacheEvict.java
new file mode 100644
index 00000000..9f361621
--- /dev/null
+++ b/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) {
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/UserInfoCacheEvict.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/cache/UserInfoCacheEvict.java
new file mode 100644
index 00000000..c6e9d9bf
--- /dev/null
+++ b/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) {
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/config/CacheConfig.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/config/CacheConfig.java
new file mode 100644
index 00000000..8116a65a
--- /dev/null
+++ b/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 cacheNames = Set.of(Constants.CACHE_DEVICE_INFO, Constants.CACHE_DEVICE_STATS);
+ Map 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();
+ }
+
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/CategoryDataCache.java
new file mode 100644
index 00000000..1de7704e
--- /dev/null
+++ b/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 findAll() {
+ return categoryData.findAll();
+ }
+
+ @Override
+ public Paging findAll(int page, int size) {
+ return categoryData.findAll(page, size);
+ }
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java
new file mode 100755
index 00000000..737f7424
--- /dev/null
+++ b/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 paged;
+ List parentIds = new ArrayList<>();
+ while ((paged = deviceInfoData.findAll(page++, 1000)).getData().size() > 0) {
+ List 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 properties) {
+ redisTemplate.opsForValue().set(getPropertyCacheKey(deviceId), JsonUtil.toJsonString(properties));
+ }
+
+ @Override
+ public Map 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 findByParentId(String parentId) {
+ return deviceInfoData.findByParentId(parentId);
+ }
+
+ @Override
+ public List findSubDeviceIds(String parentId) {
+ return deviceInfoData.findSubDeviceIds(parentId);
+ }
+
+ @Override
+ public List findByDeviceName(String deviceName) {
+ return deviceInfoData.findByDeviceName(deviceName);
+ }
+
+ @Override
+ public Paging 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 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 findByUid(String uid) {
+ return deviceInfoData.findByUid(uid);
+ }
+
+ @Override
+ public Paging 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 findAll() {
+ return deviceInfoData.findAll();
+ }
+
+ @Override
+ public Paging 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 subDeviceIds = deviceInfoData.findSubDeviceIds(parentId);
+ deviceInfoCachePut.findSubDeviceIds(parentId, subDeviceIds);
+ }
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/OauthClientDataCache.java
new file mode 100644
index 00000000..8fed95f1
--- /dev/null
+++ b/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 findAll() {
+ return oauthClientData.findAll();
+ }
+
+ @Override
+ public Paging findAll(int page, int size) {
+ return oauthClientData.findAll(page, size);
+ }
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java
new file mode 100644
index 00000000..67424fdc
--- /dev/null
+++ b/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 findByCategory(String category) {
+ return productData.findByCategory(category);
+ }
+
+ @Override
+ public List findByUid(String uid) {
+ return productData.findByUid(uid);
+ }
+
+ @Override
+ public Paging 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 findAll() {
+ return productData.findAll();
+ }
+
+ @Override
+ public Paging findAll(int page, int size) {
+ return productData.findAll(page, size);
+ }
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductModelDataCache.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/ProductModelDataCache.java
new file mode 100644
index 00000000..7febdb4c
--- /dev/null
+++ b/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 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 findAll() {
+ return productModelData.findAll();
+ }
+
+ @Override
+ public Paging findAll(int page, int size) {
+ return productModelData.findAll(page, size);
+ }
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/SpaceDataCache.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/SpaceDataCache.java
new file mode 100644
index 00000000..5aefab4e
--- /dev/null
+++ b/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 findByUidOrderByCreateAtDesc(String uid) {
+ return spaceData.findByUidOrderByCreateAtDesc(uid);
+ }
+
+ @Override
+ public List findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId) {
+ return spaceData.findByUidAndHomeIdOrderByCreateAtDesc(uid, homeId);
+ }
+
+ @Override
+ public List findByHomeId(String homeId) {
+ return spaceData.findByHomeId(homeId);
+ }
+
+ @Override
+ public List findByUid(String uid) {
+ return spaceData.findByUid(uid);
+ }
+
+ @Override
+ public Paging 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 findAll() {
+ return spaceData.findAll();
+ }
+
+ @Override
+ public Paging findAll(int page, int size) {
+ return spaceData.findAll(page, size);
+ }
+}
diff --git a/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/UserInfoDataCache.java b/iot-data/iot-data-cache/src/main/java/cc/iotkit/data/service/UserInfoDataCache.java
new file mode 100644
index 00000000..4bc609cd
--- /dev/null
+++ b/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 findByType(int type) {
+ return userInfoData.findByType(type);
+ }
+
+ @Override
+ public List 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 findAll() {
+ return userInfoData.findAll();
+ }
+
+ @Override
+ public Paging findAll(int page, int size) {
+ return userInfoData.findAll(page, size);
+ }
+}
diff --git a/iot-data/iot-data-service/pom.xml b/iot-data/iot-data-service/pom.xml
old mode 100644
new mode 100755
index 7b9342ab..1e6dba2b
--- a/iot-data/iot-data-service/pom.xml
+++ b/iot-data/iot-data-service/pom.xml
@@ -5,7 +5,7 @@
iot-data
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ICategoryData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ICategoryData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceConfigData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceConfigData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceGroupData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceGroupData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceInfoData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceInfoData.java
old mode 100644
new mode 100755
index d1864803..adfbd358
--- a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceInfoData.java
+++ b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IDeviceInfoData.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 {
+ /**
+ * 保存设备属性
+ *
+ * @param deviceId 设备id
+ * @param properties 设备属性map
+ */
+ void saveProperties(String deviceId, Map properties);
+
+ /**
+ * 获取设备属性map
+ *
+ * @param deviceId 设备id
+ */
+ Map getProperties(String deviceId);
+
/**
* 根据设备ID取设备信息
*
@@ -36,6 +52,13 @@ public interface IDeviceInfoData extends IOwnedData {
*/
List findByParentId(String parentId);
+ /**
+ * 根据父设备ID取子设备ID列表
+ *
+ * @param parentId 父设备ID
+ */
+ List findSubDeviceIds(String parentId);
+
/**
* 根据deviceName查找设备
*/
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IHomeData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IHomeData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IOauthClientData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IOauthClientData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IOwnedData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IOwnedData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProductData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProductData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProductModelData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProductModelData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProtocolComponentData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProtocolComponentData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProtocolConverterData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProtocolConverterData.java
old mode 100644
new mode 100755
index edc50788..8a2e91c1
--- a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProtocolConverterData.java
+++ b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IProtocolConverterData.java
@@ -3,4 +3,5 @@ package cc.iotkit.data;
import cc.iotkit.model.protocol.ProtocolConverter;
public interface IProtocolConverterData extends IOwnedData {
+
}
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IRuleInfoData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IRuleInfoData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceData.java
old mode 100644
new mode 100755
index 92057044..de395d24
--- a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceData.java
+++ b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceData.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;
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceDeviceData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceDeviceData.java
old mode 100644
new mode 100755
index d791182e..2c5331f7
--- a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ISpaceDeviceData.java
+++ b/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;
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ITaskInfoData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/ITaskInfoData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IThingModelData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IThingModelData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IUserInfoData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IUserInfoData.java
old mode 100644
new mode 100755
index 641e34df..4882dbb3
--- a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IUserInfoData.java
+++ b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IUserInfoData.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;
diff --git a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IVirtualDeviceData.java b/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IVirtualDeviceData.java
old mode 100644
new mode 100755
index 42b89f2a..c8abefec
--- a/iot-data/iot-data-service/src/main/java/cc/iotkit/data/IVirtualDeviceData.java
+++ b/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;
diff --git a/iot-data/iot-es-temporal-service/pom.xml b/iot-data/iot-es-temporal-service/pom.xml
old mode 100644
new mode 100755
index b639f6ad..e6d91565
--- a/iot-data/iot-es-temporal-service/pom.xml
+++ b/iot-data/iot-es-temporal-service/pom.xml
@@ -5,7 +5,7 @@
iot-data
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/document/DevicePropertyDoc.java b/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/document/DevicePropertyDoc.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/DevicePropertyDataImpl.java b/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/DevicePropertyDataImpl.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/RuleLogDataImpl.java b/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/RuleLogDataImpl.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/TaskLogDataImpl.java b/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/TaskLogDataImpl.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/ThingModelMessageDataImpl.java b/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/ThingModelMessageDataImpl.java
old mode 100644
new mode 100755
index c4821240..899731f4
--- a/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/ThingModelMessageDataImpl.java
+++ b/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/ThingModelMessageDataImpl.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 getDeviceMessageStatsWithUid(String uid, long start, long end) {
- return null;
+ return new ArrayList<>();
}
@Override
diff --git a/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java b/iot-data/iot-es-temporal-service/src/main/java/cc/iotkit/temporal/es/service/VirtualDeviceLogDataImpl.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/.DS_Store b/iot-data/iot-model/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/pom.xml b/iot-data/iot-model/pom.xml
old mode 100644
new mode 100755
index e9522dc8..07479ab6
--- a/iot-data/iot-model/pom.xml
+++ b/iot-data/iot-model/pom.xml
@@ -5,9 +5,9 @@
iot-data
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
iot-model
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/AppInfo.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/AppInfo.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/Id.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/Id.java
old mode 100644
new mode 100755
index 599bc93e..d4f87957
--- a/iot-data/iot-model/src/main/java/cc/iotkit/model/Id.java
+++ b/iot-data/iot-model/src/main/java/cc/iotkit/model/Id.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.model;
public interface Id {
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/InvokeResult.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/InvokeResult.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/OauthClient.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/OauthClient.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/Owned.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/Owned.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/Paging.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/Paging.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/Role.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/Role.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/SendCmd.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/SendCmd.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/UserInfo.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/UserInfo.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/alert/AlertConfig.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/alert/AlertConfig.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/device/DeviceConfig.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/device/DeviceConfig.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/device/DeviceGroup.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/device/DeviceGroup.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/device/DeviceInfo.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/device/DeviceInfo.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/device/VirtualDevice.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/device/VirtualDevice.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/device/VirtualDeviceLog.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/device/VirtualDeviceLog.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/device/message/DeviceProperty.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/device/message/DeviceProperty.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/device/message/ThingModelMessage.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/device/message/ThingModelMessage.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/product/AppDesign.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/product/AppDesign.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/product/Category.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/product/Category.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/product/Product.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/product/Product.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/product/ProductModel.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/product/ProductModel.java
old mode 100644
new mode 100755
index 4a172485..04817f07
--- a/iot-data/iot-model/src/main/java/cc/iotkit/model/product/ProductModel.java
+++ b/iot-data/iot-model/src/main/java/cc/iotkit/model/product/ProductModel.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;
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/product/ThingModel.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/product/ThingModel.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/protocol/ProtocolComponent.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/protocol/ProtocolComponent.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/protocol/ProtocolConverter.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/protocol/ProtocolConverter.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleAction.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleAction.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleInfo.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleInfo.java
old mode 100644
new mode 100755
index c61af219..b42c509b
--- a/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleInfo.java
+++ b/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleInfo.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;
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleLog.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleLog.java
old mode 100644
new mode 100755
index f7c948dc..b2a9dabd
--- a/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/RuleLog.java
+++ b/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;
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/TaskInfo.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/TaskInfo.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/TaskLog.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/rule/TaskLog.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/space/Home.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/space/Home.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/space/Space.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/space/Space.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/space/SpaceDevice.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/space/SpaceDevice.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/stats/DataItem.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/stats/DataItem.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-model/src/main/java/cc/iotkit/model/stats/TimeData.java b/iot-data/iot-model/src/main/java/cc/iotkit/model/stats/TimeData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/pom.xml b/iot-data/iot-rdb-data-service/pom.xml
old mode 100644
new mode 100755
index d7a2fb0b..9b6474e1
--- a/iot-data/iot-rdb-data-service/pom.xml
+++ b/iot-data/iot-rdb-data-service/pom.xml
@@ -5,9 +5,9 @@
iot-data
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
iot-rdb-data-service
diff --git a/iot-data/iot-rdb-data-service/readme.md b/iot-data/iot-rdb-data-service/readme.md
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/DataBaseInit.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/DataBaseInit.java
deleted file mode 100644
index 0502d552..00000000
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/DataBaseInit.java
+++ /dev/null
@@ -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);
- }
-
-}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/CategoryRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/CategoryRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceConfigRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceConfigRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceGroupMappingRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceGroupMappingRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceGroupRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceGroupRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceInfoRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceInfoRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceSubUserRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceSubUserRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceTagRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/DeviceTagRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/OauthClientRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/OauthClientRepository.java
new file mode 100755
index 00000000..7a98da29
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/OauthClientRepository.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 findByClientId(String clientId);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductModelRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductModelRepository.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductRepository.java
old mode 100644
new mode 100755
index 5d20de84..c47bbcca
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductRepository.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProductRepository.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;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java
old mode 100644
new mode 100755
index 620d5a39..166cb0dd
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java
+++ b/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 findByState(String state);
+ List findByStateAndType(String state, String type);
+
+ List findByUid(String uid);
+
+ Page findByUid(String uid, Pageable pageable);
+
+ long countByUid(String uid);
+
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolConverterRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ProtocolConverterRepository.java
new file mode 100755
index 00000000..fbfd19c0
--- /dev/null
+++ b/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 {
+
+ List findByUid(String uid);
+
+ Page findByUid(String uid, Pageable pageable);
+
+ long countByUid(String uid);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/RuleInfoRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/RuleInfoRepository.java
new file mode 100755
index 00000000..eef5012f
--- /dev/null
+++ b/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 {
+
+ List findByUid(String uid);
+
+ List findByUidAndType(String uid, String type);
+
+ Page findByUidAndType(String uid, String type, Pageable pageable);
+
+ Page findByUid(String uid, Pageable pageable);
+
+ Page findByType(String type, Pageable pageable);
+
+ long countByUid(String uid);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceDeviceRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceDeviceRepository.java
new file mode 100755
index 00000000..e79870bc
--- /dev/null
+++ b/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 {
+
+ List findByUid(String uid);
+
+ Page findByUid(String uid, Pageable pageable);
+
+ List findByUidOrderByUseAtDesc(String uid);
+
+ List findByUidOrderByAddAtDesc(String uid);
+
+ List findBySpaceIdOrderByAddAtDesc(String spaceId);
+
+ List findByUidAndSpaceIdOrderByAddAtDesc(String uid, String spaceId);
+
+ TbSpaceDevice findByDeviceId(String deviceId);
+
+ TbSpaceDevice findByDeviceIdAndUid(String deviceId, String uid);
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/SpaceRepository.java
new file mode 100755
index 00000000..b0a883dc
--- /dev/null
+++ b/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 {
+
+ List findByUidOrderByCreateAtDesc(String uid);
+
+ List findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId);
+
+ List findByHomeId(String homeId);
+
+ List findByUid(String uid);
+
+ Page findByUid(String uid, Pageable pageable);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/TaskInfoRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/TaskInfoRepository.java
new file mode 100755
index 00000000..690aa0e1
--- /dev/null
+++ b/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 {
+
+ List findByUid(String uid);
+
+ Page findByUid(String uid, Pageable pageable);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ThingModelRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/ThingModelRepository.java
new file mode 100755
index 00000000..4e9aa6fc
--- /dev/null
+++ b/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 findByProductKey(String productKey);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/UserInfoRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/UserInfoRepository.java
new file mode 100755
index 00000000..2e857a3a
--- /dev/null
+++ b/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 findByUid(String uid);
+
+ List findByType(int type);
+
+ List findByTypeAndOwnerId(int type, String ownerId);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceMappingRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceMappingRepository.java
new file mode 100755
index 00000000..b4c2dceb
--- /dev/null
+++ b/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 {
+
+ List findByVirtualId(String virtualId);
+
+ void deleteByVirtualId(String virtualId);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceRepository.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/dao/VirtualDeviceRepository.java
new file mode 100755
index 00000000..95592629
--- /dev/null
+++ b/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 {
+
+ List findByUid(String uid);
+
+ Page findByUid(String uid, Pageable pageable);
+
+ List findByTriggerAndState(String trigger, String state);
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/CategoryMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/CategoryMapper.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceConfigMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceConfigMapper.java
old mode 100644
new mode 100755
index eada56c0..5bbf04ab
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceConfigMapper.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceConfigMapper.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;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceGroupMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceGroupMapper.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceIdGroup.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceIdGroup.java
new file mode 100644
index 00000000..55494d97
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceIdGroup.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;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceInfoMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceInfoMapper.java
old mode 100644
new mode 100755
index 24d4905f..1e61bc69
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/DeviceInfoMapper.java
+++ b/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;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/OauthClientMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/OauthClientMapper.java
new file mode 100755
index 00000000..f177a689
--- /dev/null
+++ b/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);
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProductMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProductMapper.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProductModelMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProductModelMapper.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProtocolComponentMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProtocolComponentMapper.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProtocolConverterMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProtocolConverterMapper.java
new file mode 100755
index 00000000..96b9ceef
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ProtocolConverterMapper.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 toDto(List list) {
+ return list.stream().map(M::toDto).collect(Collectors.toList());
+ }
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/RuleInfoMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/RuleInfoMapper.java
new file mode 100755
index 00000000..622ec6d9
--- /dev/null
+++ b/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 toDto(List list) {
+ return list.stream().map(RuleInfoMapper::toDtoFix).collect(Collectors.toList());
+ }
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceDeviceMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceDeviceMapper.java
new file mode 100755
index 00000000..051de8e7
--- /dev/null
+++ b/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 toDto(List list) {
+ return list.stream().map(M::toDto).collect(Collectors.toList());
+ }
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/SpaceMapper.java
new file mode 100755
index 00000000..e8ed871f
--- /dev/null
+++ b/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 toDto(List list) {
+ return list.stream().map(M::toDto).collect(Collectors.toList());
+ }
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TaskInfoMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TaskInfoMapper.java
new file mode 100755
index 00000000..164a3c16
--- /dev/null
+++ b/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 toDto(List list) {
+ return list.stream().map(TaskInfoMapper::toDtoFix).collect(Collectors.toList());
+ }
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbCategory.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbCategory.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceConfig.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceConfig.java
old mode 100644
new mode 100755
index c9c7c2a5..c79fe928
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceConfig.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceConfig.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;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroup.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroup.java
old mode 100644
new mode 100755
index 2cd7b392..edb75960
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroup.java
+++ b/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;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroupMapping.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceGroupMapping.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceInfo.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceInfo.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceSubUser.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceSubUser.java
old mode 100644
new mode 100755
index 4ab94b4a..5c83f05c
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceSubUser.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceSubUser.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;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceTag.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbDeviceTag.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbOauthClient.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbOauthClient.java
new file mode 100644
index 00000000..4f1cc775
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbOauthClient.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;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProduct.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProduct.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProductModel.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProductModel.java
old mode 100644
new mode 100755
index 979e55b7..e99bfa9a
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProductModel.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProductModel.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;
/**
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolComponent.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolComponent.java
old mode 100644
new mode 100755
index 62e74cf8..7f1684bd
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolComponent.java
+++ b/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;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolConverter.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbProtocolConverter.java
new file mode 100644
index 00000000..3aa872ac
--- /dev/null
+++ b/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;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbRuleInfo.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbRuleInfo.java
new file mode 100644
index 00000000..d1fc6768
--- /dev/null
+++ b/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 --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbSpace.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbSpace.java
new file mode 100644
index 00000000..15ac4c34
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbSpace.java
@@ -0,0 +1,48 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "space")
+public class TbSpace {
+
+ @Id
+ private String id;
+
+ /**
+ * 关联家庭id
+ */
+ private String homeId;
+
+ /**
+ * 关联用户id
+ */
+ private String uid;
+
+ /**
+ * 空间名称
+ */
+ private String name;
+
+ /**
+ * 设备数量
+ */
+ private Integer deviceNum;
+
+ private Long createAt;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbSpaceDevice.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbSpaceDevice.java
new file mode 100644
index 00000000..9645a06d
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbSpaceDevice.java
@@ -0,0 +1,66 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "space_device")
+public class TbSpaceDevice {
+
+ @Id
+ private String id;
+
+ /**
+ * 关联用户id
+ */
+ private String uid;
+
+ /**
+ * 分享的用户id
+ */
+ private String sharedUid;
+
+ /**
+ * 空间中的设备id
+ */
+ private String deviceId;
+
+ /**
+ * 空间中的设备名称
+ */
+ private String name;
+
+ /**
+ * 所属家庭Id
+ */
+ private String homeId;
+
+ /**
+ * 空间id
+ */
+ private String spaceId;
+
+ /**
+ * 添加时间
+ */
+ private Long addAt;
+
+ /**
+ * 使用时间
+ */
+ private Long useAt;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbTaskInfo.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbTaskInfo.java
new file mode 100644
index 00000000..b02c68d8
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbTaskInfo.java
@@ -0,0 +1,70 @@
+/*
+ * +----------------------------------------------------------------------
+ * | 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 = "task_info")
+public class TbTaskInfo {
+
+ @Id
+ private String id;
+
+ private String name;
+
+ /**
+ * 任务类型
+ */
+ private String type;
+
+ /**
+ * 表达式
+ * 定时器使用cron表达式
+ * 延时器使用延时时长(秒)
+ */
+ private String expression;
+
+ /**
+ * 描述
+ */
+ @Column(name = "[desc]")
+ private String desc;
+
+ /**
+ * 任务输出
+ */
+ @Column(columnDefinition = "text")
+ private String actions;
+
+ /**
+ * 任务状态
+ */
+ private String state;
+
+ /**
+ * 创建者
+ */
+ private String uid;
+
+ private Long createAt;
+
+ /**
+ * 操作备注
+ */
+ private String reason;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbThingModel.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbThingModel.java
new file mode 100644
index 00000000..080b2682
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbThingModel.java
@@ -0,0 +1,32 @@
+/*
+ * +----------------------------------------------------------------------
+ * | 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 = "thing_model")
+public class TbThingModel {
+
+ @Id
+ private String id;
+
+ private String productKey;
+
+ @Column(columnDefinition = "text")
+ private String model;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbUserInfo.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbUserInfo.java
new file mode 100644
index 00000000..796a8a86
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbUserInfo.java
@@ -0,0 +1,81 @@
+package cc.iotkit.data.model;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "user_info")
+public class TbUserInfo {
+
+ @Id
+ private String id;
+
+ /**
+ * 用户账号
+ */
+ private String uid;
+
+ /**
+ * 归属账号
+ */
+ private String ownerId;
+
+ /**
+ * 密钥(密码加密后的内容)
+ */
+ private String secret;
+
+ /**
+ * 用户昵称
+ */
+ private String nickName;
+
+ /**
+ * 性别 0-未知 1-male,2-female
+ */
+ private Integer gender;
+
+ /**
+ * 头像地址
+ */
+ private String avatarUrl;
+
+ private String email;
+
+ private String address;
+
+ /**
+ * 当前家庭Id
+ */
+ private String currHomeId;
+
+ /**
+ * 用户类型
+ * 0:平台用户
+ * 1:终端用户
+ */
+ private Integer type;
+
+ /**
+ * 角色
+ */
+ private String roles;
+
+ /**
+ * 权限
+ */
+ private String permissions;
+
+ /**
+ * 用户使用的平台
+ * 见:Constants.THIRD_PLATFORM
+ */
+ private String usePlatforms;
+
+ private Long createAt;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbVirtualDevice.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbVirtualDevice.java
new file mode 100644
index 00000000..79ce7a80
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbVirtualDevice.java
@@ -0,0 +1,65 @@
+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 = "virtual_device")
+public class TbVirtualDevice {
+
+ @Id
+ private String id;
+
+ /**
+ * 所属用户
+ */
+ private String uid;
+
+ /**
+ * 虚拟设备名称
+ */
+ private String name;
+
+ /**
+ * 产品key
+ */
+ private String productKey;
+
+ /**
+ * 虚拟类型
+ */
+ private String type;
+
+ /**
+ * 设备行为脚本
+ */
+ @Column(columnDefinition = "text")
+ private String script;
+
+ /**
+ * 触发方式执行方式
+ */
+ @Column(name = "[trigger]")
+ private String trigger;
+
+ /**
+ * 触发表达式
+ */
+ private String triggerExpression;
+
+ /**
+ * 运行状态
+ */
+ private String state;
+
+ /**
+ * 创建时间
+ */
+ private Long createAt;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbVirtualDeviceMapping.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbVirtualDeviceMapping.java
new file mode 100644
index 00000000..821f5e12
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/TbVirtualDeviceMapping.java
@@ -0,0 +1,25 @@
+package cc.iotkit.data.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Entity
+@Table(name = "virtual_device_mapping")
+public class TbVirtualDeviceMapping {
+
+ @Id
+ private String id;
+
+ private String virtualId;
+
+ private String deviceId;
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ThingModelMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ThingModelMapper.java
new file mode 100755
index 00000000..e4c523e6
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/ThingModelMapper.java
@@ -0,0 +1,48 @@
+/*
+ * +----------------------------------------------------------------------
+ * | 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.product.ThingModel;
+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 ThingModelMapper {
+
+ ThingModelMapper M = Mappers.getMapper(ThingModelMapper.class);
+
+ @Mapping(target = "model", ignore = true)
+ ThingModel toDto(TbThingModel vo);
+
+ static ThingModel toDtoFix(TbThingModel vo) {
+ ThingModel dto = M.toDto(vo);
+ dto.setModel(JsonUtil.parse(vo.getModel(), ThingModel.Model.class));
+ return dto;
+ }
+
+ @Mapping(target = "model", ignore = true)
+ TbThingModel toVo(ThingModel dto);
+
+ static TbThingModel toVoFix(ThingModel dto) {
+ TbThingModel vo = M.toVo(dto);
+ vo.setModel(JsonUtil.toJsonString(dto.getModel()));
+ return vo;
+ }
+
+ static List toDto(List list) {
+ return list.stream().map(ThingModelMapper::toDtoFix).collect(Collectors.toList());
+ }
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/UserInfoMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/UserInfoMapper.java
new file mode 100755
index 00000000..3d80ffa7
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/UserInfoMapper.java
@@ -0,0 +1,79 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import cc.iotkit.model.UserInfo;
+import org.apache.commons.lang3.StringUtils;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.Mappings;
+import org.mapstruct.factory.Mappers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Mapper
+public interface UserInfoMapper {
+
+ UserInfoMapper M = Mappers.getMapper(UserInfoMapper.class);
+
+ @Mappings({
+ @Mapping(target = "roles", ignore = true),
+ @Mapping(target = "permissions", ignore = true),
+ @Mapping(target = "usePlatforms", ignore = true)
+ }
+ )
+ UserInfo toDto(TbUserInfo vo);
+
+ static UserInfo toDtoFix(TbUserInfo vo) {
+ UserInfo dto = M.toDto(vo);
+ dto.setRoles(splitToList(vo.getRoles()));
+ dto.setPermissions(splitToList(vo.getPermissions()));
+ dto.setUsePlatforms(splitToList(vo.getUsePlatforms()));
+ return dto;
+ }
+
+ @Mappings({
+ @Mapping(target = "roles", ignore = true),
+ @Mapping(target = "permissions", ignore = true),
+ @Mapping(target = "usePlatforms", ignore = true)
+ }
+ )
+ TbUserInfo toVo(UserInfo dto);
+
+ static TbUserInfo toVoFix(UserInfo dto) {
+ TbUserInfo vo = M.toVo(dto);
+ vo.setRoles(listToStr(dto.getRoles()));
+ vo.setPermissions(listToStr(dto.getPermissions()));
+ vo.setUsePlatforms(listToStr(dto.getUsePlatforms()));
+ return vo;
+ }
+
+ static List toDto(List list) {
+ return list.stream().map(UserInfoMapper::toDtoFix).collect(Collectors.toList());
+ }
+
+ static List splitToList(String str) {
+ if (StringUtils.isBlank(str)) {
+ return new ArrayList<>();
+ }
+ return Arrays.asList(str.split(","));
+ }
+
+ static String listToStr(List list) {
+ if (list == null || list.size() == 0) {
+ return "";
+ }
+ return String.join(",", list);
+ }
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/VirtualDeviceMapper.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/VirtualDeviceMapper.java
new file mode 100755
index 00000000..56a23dd0
--- /dev/null
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/model/VirtualDeviceMapper.java
@@ -0,0 +1,34 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
+package cc.iotkit.data.model;
+
+import cc.iotkit.model.device.VirtualDevice;
+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 VirtualDeviceMapper {
+
+ VirtualDeviceMapper M = Mappers.getMapper(VirtualDeviceMapper.class);
+
+ @Mapping(target = "devices", ignore = true)
+ VirtualDevice toDto(TbVirtualDevice vo);
+
+ TbVirtualDevice toVo(VirtualDevice dto);
+
+ static List toDto(List list) {
+ return list.stream().map(VirtualDeviceMapper.M::toDto).collect(Collectors.toList());
+ }
+
+}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java
old mode 100644
new mode 100755
index fd30a92a..0c25963a
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.ICategoryData;
@@ -7,12 +16,14 @@ import cc.iotkit.data.model.TbCategory;
import cc.iotkit.model.Paging;
import cc.iotkit.model.product.Category;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
+@Primary
@Service
public class CategoryDataImpl implements ICategoryData {
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CommonService.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CommonService.java
old mode 100644
new mode 100755
index 445bbef3..a7c586e1
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CommonService.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/CommonService.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.ICommonData;
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java
old mode 100644
new mode 100755
index 6cb519f0..1aa44a00
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.IDeviceConfigData;
@@ -8,6 +17,7 @@ import cc.iotkit.model.Paging;
import cc.iotkit.model.device.DeviceConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -16,6 +26,7 @@ import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
+@Primary
@Service
public class DeviceConfigDataImpl implements IDeviceConfigData {
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java
old mode 100644
new mode 100755
index 0bd73910..74822ec2
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java
@@ -8,6 +8,7 @@ import cc.iotkit.model.Paging;
import cc.iotkit.model.device.DeviceGroup;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -16,6 +17,7 @@ import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
+@Primary
@Service
public class DeviceGroupDataImpl implements IDeviceGroupData {
@@ -24,7 +26,8 @@ public class DeviceGroupDataImpl implements IDeviceGroupData {
@Override
public Paging findByNameLike(String name, int page, int size) {
- Page groups = deviceGroupRepository.findByNameLike(name, Pageable.ofSize(size).withPage(page - 1));
+ Page groups = deviceGroupRepository.findByNameLike("%" + name.trim() + "%",
+ Pageable.ofSize(size).withPage(page - 1));
return new Paging<>(groups.getTotalElements(), groups.getContent()
.stream().map(DeviceGroupMapper.M::toDto)
.collect(Collectors.toList()));
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java
old mode 100644
new mode 100755
index 772de679..0417608c
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java
@@ -7,9 +7,12 @@ import cc.iotkit.data.model.*;
import cc.iotkit.model.Paging;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.stats.DataItem;
-import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -17,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
+@Primary
@Service
public class DeviceInfoDataImpl implements IDeviceInfoData {
@@ -33,13 +37,21 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
@Autowired
private JdbcTemplate jdbcTemplate;
+ @Override
+ public void saveProperties(String deviceId, Map properties) {
+ }
+
+ @Override
+ public Map getProperties(String deviceId) {
+ return new HashMap<>();
+ }
+
@Override
public DeviceInfo findByDeviceId(String deviceId) {
TbDeviceInfo tbDeviceInfo = deviceInfoRepository.findByDeviceId(deviceId);
DeviceInfo dto = DeviceInfoMapper.M.toDto(tbDeviceInfo);
fillDeviceInfo(deviceId, tbDeviceInfo, dto);
-
return dto;
}
@@ -97,6 +109,9 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
* 将数据库中查出来的vo转为dto
*/
private DeviceInfo parseVoToDto(TbDeviceInfo vo) {
+ if (vo == null) {
+ return null;
+ }
DeviceInfo dto = DeviceInfoMapper.M.toDto(vo);
fillDeviceInfo(vo.getDeviceId(), vo, dto);
return dto;
@@ -123,6 +138,13 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
return parseVoToDto(deviceInfoRepository.findByParentId(parentId));
}
+ @Override
+ public List findSubDeviceIds(String parentId) {
+ return jdbcTemplate.queryForList(
+ "select device_id from device_info " +
+ "where parent_id=?", String.class, parentId);
+ }
+
@Override
public List findByDeviceName(String deviceName) {
return parseVoToDto(deviceInfoRepository.findByDeviceName(deviceName));
@@ -185,6 +207,7 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
keyword = "%" + keyword.trim() + "%";
sql += "and (a.device_id like ? or a.device_name like ?) ";
args.add(keyword);
+ args.add(keyword);//两个参数
}
sql += String.format("order by create_at desc limit %d,%d", (page - 1) * size, size);
@@ -206,32 +229,34 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
.createAt(rs.getLong("create_at"))
.build(), args.toArray());
- sql = sql.replaceAll("SELECT.*FROM", "SELECT count(*) FROM ");
+ sql = sql.replaceAll("SELECT[\\s\\S]+FROM", "SELECT count(*) FROM ");
sql = sql.replaceAll("order by create_at desc limit.*", "");
- Long total = jdbcTemplate.queryForObject(sql, Long.class, args);
+ Long total = jdbcTemplate.queryForObject(sql, Long.class, args.toArray());
//把当前页的deviceId串连起来作为in的参数
String deviceIds = list.stream().map(d -> "'" + d.getDeviceId() + "'").collect(Collectors.joining(","));
//取设备所属分组
- List groups = jdbcTemplate.queryForList("SELECT \n" +
- "a.id,\n" +
- "a.`name` \n" +
- "b.device_id as deviceId \n" +
- "FROM\n" +
- "device_group a \n" +
- "JOIN device_group_mapping b on a.id=b.group_id\n" +
- String.format("WHERE b.device_id in(%s)", deviceIds), DeviceIdGroup.class);
+ List groups = list.size() == 0 ? new ArrayList<>() :
+ jdbcTemplate.query("SELECT \n" +
+ "a.id,\n" +
+ "a.`name`, \n" +
+ "b.device_id as deviceId \n" +
+ "FROM\n" +
+ "device_group a \n" +
+ "JOIN device_group_mapping b on a.id=b.group_id\n" +
+ String.format("WHERE b.device_id in(%s)", deviceIds), new BeanPropertyRowMapper<>(DeviceIdGroup.class));
//取设备标签
- List tags = jdbcTemplate.queryForList("\n" +
- "SELECT\n" +
- "a.id,\n" +
- "a.`code`,\n" +
- "a.`name`,\n" +
- "a.`value`\n" +
- "FROM device_tag a " +
- String.format("WHERE a.device_id IN(%s)", deviceIds), TbDeviceTag.class);
+ List tags = list.size() == 0 ? new ArrayList<>() :
+ jdbcTemplate.query("\n" +
+ "SELECT\n" +
+ "a.id,\n" +
+ "a.`code`,\n" +
+ "a.`name`,\n" +
+ "a.`value`\n" +
+ "FROM device_tag a " +
+ String.format("WHERE a.device_id IN(%s)", deviceIds), new BeanPropertyRowMapper<>(TbDeviceTag.class));
for (DeviceInfo device : list) {
//设置设备分组
@@ -303,13 +328,13 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
@Override
public void updateGroup(String groupId, DeviceInfo.Group group) {
- deviceGroupRepository.save(new TbDeviceGroup());
+ //更新设备信息中的分组信息,关系数据库中不需要实现
}
@Override
@Transactional
public void removeGroup(String deviceId, String groupId) {
- jdbcTemplate.update("delete device_group_mapping " +
+ jdbcTemplate.update("delete from device_group_mapping " +
"where device_id=? and group_id=?", deviceId, groupId);
//更新设备数量
updateGroupDeviceCount(groupId);
@@ -318,7 +343,7 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
@Override
@Transactional
public void removeGroup(String groupId) {
- jdbcTemplate.update("delete device_group_mapping " +
+ jdbcTemplate.update("delete from device_group_mapping " +
"where group_id=?", groupId);
//更新设备数量
updateGroupDeviceCount(groupId);
@@ -402,13 +427,8 @@ public class DeviceInfoDataImpl implements IDeviceInfoData {
@Override
public Paging findAll(int page, int size) {
- return new Paging<>();
+ Page paged = deviceInfoRepository.findAll(Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(), parseVoToDto(paged.getContent()));
}
- @Data
- public static class DeviceIdGroup {
- private String id;
- private String deviceId;
- private String name;
- }
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/HomeDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/HomeDataImpl.java
old mode 100644
new mode 100755
index 89c0175d..8f07f2bf
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/HomeDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/HomeDataImpl.java
@@ -3,10 +3,12 @@ package cc.iotkit.data.service;
import cc.iotkit.data.IHomeData;
import cc.iotkit.model.Paging;
import cc.iotkit.model.space.Home;
+import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.util.List;
+@Primary
@Service
public class HomeDataImpl implements IHomeData {
@Override
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java
old mode 100644
new mode 100755
index 07e223cb..822aa184
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java
@@ -1,51 +1,77 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.IOauthClientData;
+import cc.iotkit.data.dao.OauthClientRepository;
+import cc.iotkit.data.model.OauthClientMapper;
import cc.iotkit.model.OauthClient;
import cc.iotkit.model.Paging;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class OauthClientDataImpl implements IOauthClientData {
+
+ @Autowired
+ private OauthClientRepository oauthClientRepository;
+
@Override
public OauthClient findByClientId(String clientId) {
- return null;
+ return OauthClientMapper.M.toDto(oauthClientRepository.findByClientId(clientId));
}
@Override
public OauthClient findById(String s) {
- return null;
+ return OauthClientMapper.M.toDto(oauthClientRepository.findById(s).orElse(null));
}
@Override
public OauthClient save(OauthClient data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setCreateAt(System.currentTimeMillis());
+ }
+ oauthClientRepository.save(OauthClientMapper.M.toVo(data));
+ return data;
}
@Override
public OauthClient add(OauthClient data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ oauthClientRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return oauthClientRepository.count();
}
@Override
public List findAll() {
- return null;
+ return new ArrayList<>();
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ return new Paging<>();
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductDataImpl.java
old mode 100644
new mode 100755
index 827c78fb..b14224c8
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductDataImpl.java
@@ -8,6 +8,7 @@ import cc.iotkit.model.Paging;
import cc.iotkit.model.product.Product;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;
+@Primary
@Service
public class ProductDataImpl implements IProductData {
@@ -52,9 +54,6 @@ public class ProductDataImpl implements IProductData {
@Override
public Product save(Product data) {
- if (StringUtils.isBlank(data.getId())) {
- data.setId(UUID.randomUUID().toString());
- }
productRepository.save(ProductMapper.M.toVo(data));
return data;
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java
old mode 100644
new mode 100755
index 67617af0..41dd4ae6
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProductModelDataImpl.java
@@ -7,12 +7,14 @@ import cc.iotkit.model.Paging;
import cc.iotkit.model.product.ProductModel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+@Primary
@Service
public class ProductModelDataImpl implements IProductModelData {
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java
old mode 100644
new mode 100755
index 3236ff4d..56671c2e
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java
@@ -3,14 +3,21 @@ package cc.iotkit.data.service;
import cc.iotkit.data.IProtocolComponentData;
import cc.iotkit.data.dao.ProtocolComponentRepository;
import cc.iotkit.data.model.ProtocolComponentMapper;
+import cc.iotkit.data.model.TbProtocolComponent;
import cc.iotkit.model.Paging;
import cc.iotkit.model.protocol.ProtocolComponent;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class ProtocolComponentDataImpl implements IProtocolComponentData {
@@ -24,56 +31,67 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData {
@Override
public List findByStateAndType(String state, String type) {
- return new ArrayList<>();
+ return ProtocolComponentMapper.toDto(protocolComponentRepository.findByStateAndType(state, type));
}
@Override
public List findByUid(String uid) {
- return null;
+ return ProtocolComponentMapper.toDto(protocolComponentRepository.findByUid(uid));
}
@Override
public Paging findByUid(String uid, int page, int size) {
- return null;
+ Page paged = protocolComponentRepository.findByUid(uid,
+ Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ ProtocolComponentMapper.toDto(paged.getContent()));
}
@Override
public long countByUid(String uid) {
- return 0;
+ return protocolComponentRepository.countByUid(uid);
}
@Override
public ProtocolComponent findById(String s) {
- return null;
+ return ProtocolComponentMapper.M.toDto(protocolComponentRepository.findById(s).orElse(null));
}
@Override
public ProtocolComponent save(ProtocolComponent data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setCreateAt(System.currentTimeMillis());
+ }
+ protocolComponentRepository.save(ProtocolComponentMapper.M.toVo(data));
+ return data;
}
@Override
public ProtocolComponent add(ProtocolComponent data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ protocolComponentRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return protocolComponentRepository.count();
}
@Override
public List findAll() {
- return null;
+ return ProtocolComponentMapper.toDto(protocolComponentRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ Page paged = protocolComponentRepository
+ .findAll(Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ ProtocolComponentMapper.toDto(paged.getContent()));
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java
old mode 100644
new mode 100755
index 86ef7a0d..335cd831
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java
@@ -1,61 +1,96 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.IProtocolConverterData;
+import cc.iotkit.data.dao.ProtocolConverterRepository;
+import cc.iotkit.data.model.ProtocolConverterMapper;
+import cc.iotkit.data.model.TbProtocolConverter;
import cc.iotkit.model.Paging;
import cc.iotkit.model.protocol.ProtocolConverter;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class ProtocolConverterDataImpl implements IProtocolConverterData {
+
+ @Autowired
+ private ProtocolConverterRepository protocolConverterRepository;
+
@Override
public List findByUid(String uid) {
- return null;
+ return ProtocolConverterMapper.toDto(protocolConverterRepository.findByUid(uid));
}
@Override
public Paging findByUid(String uid, int page, int size) {
- return null;
+ Page paged = protocolConverterRepository
+ .findByUid(uid, Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ ProtocolConverterMapper.toDto(paged.getContent()));
}
@Override
public long countByUid(String uid) {
- return 0;
+ return protocolConverterRepository.countByUid(uid);
}
@Override
public ProtocolConverter findById(String s) {
- return null;
+ return ProtocolConverterMapper.M.toDto(
+ protocolConverterRepository.findById(s).orElse(null));
}
@Override
public ProtocolConverter save(ProtocolConverter data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setCreateAt(System.currentTimeMillis());
+ }
+ protocolConverterRepository.save(ProtocolConverterMapper.M.toVo(data));
+ return data;
}
@Override
public ProtocolConverter add(ProtocolConverter data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ protocolConverterRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return protocolConverterRepository.count();
}
@Override
public List findAll() {
- return null;
+ return ProtocolConverterMapper.toDto(protocolConverterRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ Page paged = protocolConverterRepository
+ .findAll(Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ ProtocolConverterMapper.toDto(paged.getContent()));
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java
old mode 100644
new mode 100755
index 1fd5d3e4..feadaeda
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java
@@ -1,76 +1,116 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.IRuleInfoData;
+import cc.iotkit.data.dao.RuleInfoRepository;
+import cc.iotkit.data.model.RuleInfoMapper;
+import cc.iotkit.data.model.TbRuleInfo;
import cc.iotkit.model.Paging;
import cc.iotkit.model.rule.RuleInfo;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class RuleInfoDataImpl implements IRuleInfoData {
+
+ @Autowired
+ private RuleInfoRepository ruleInfoRepository;
+
@Override
public List findByUidAndType(String uid, String type) {
- return null;
+ return RuleInfoMapper.toDto(ruleInfoRepository.findByUidAndType(uid, type));
}
@Override
public Paging findByUidAndType(String uid, String type, int page, int size) {
- return null;
+ Page paged = ruleInfoRepository.findByUidAndType(uid, type,
+ Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ RuleInfoMapper.toDto(paged.getContent()));
}
@Override
public Paging findByType(String type, int page, int size) {
- return null;
+ Page paged = ruleInfoRepository.findByType(type,
+ Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ RuleInfoMapper.toDto(paged.getContent()));
}
@Override
public List findByUid(String uid) {
- return null;
+ return RuleInfoMapper.toDto(ruleInfoRepository.findByUid(uid));
}
@Override
public Paging findByUid(String uid, int page, int size) {
- return null;
+ Page paged = ruleInfoRepository.findByUid(uid,
+ Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ RuleInfoMapper.toDto(paged.getContent()));
}
@Override
public long countByUid(String uid) {
- return 0;
+ return ruleInfoRepository.countByUid(uid);
}
@Override
public RuleInfo findById(String s) {
- return null;
+ return RuleInfoMapper.toDtoFix(ruleInfoRepository.findById(s).orElse(null));
}
@Override
public RuleInfo save(RuleInfo data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setCreateAt(System.currentTimeMillis());
+ }
+ ruleInfoRepository.save(RuleInfoMapper.toVoFix(data));
+ return data;
}
@Override
public RuleInfo add(RuleInfo data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ ruleInfoRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return ruleInfoRepository.count();
}
@Override
public List findAll() {
- return null;
+ return RuleInfoMapper.toDto(ruleInfoRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ Page paged = ruleInfoRepository.
+ findAll(Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ RuleInfoMapper.toDto(paged.getContent()));
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java
old mode 100644
new mode 100755
index 8cf74302..53294f94
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java
@@ -1,37 +1,54 @@
package cc.iotkit.data.service;
import cc.iotkit.data.ISpaceData;
+import cc.iotkit.data.dao.SpaceRepository;
+import cc.iotkit.data.model.SpaceMapper;
+import cc.iotkit.data.model.TbSpace;
import cc.iotkit.model.Paging;
import cc.iotkit.model.space.Space;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class SpaceDataImpl implements ISpaceData {
+
+ @Autowired
+ private SpaceRepository spaceRepository;
+
@Override
public List findByUidOrderByCreateAtDesc(String uid) {
- return null;
+ return SpaceMapper.toDto(spaceRepository.findByUidOrderByCreateAtDesc(uid));
}
@Override
public List findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId) {
- return null;
+ return SpaceMapper.toDto(spaceRepository.findByUidAndHomeIdOrderByCreateAtDesc(uid, homeId));
}
@Override
public List findByHomeId(String homeId) {
- return null;
+ return SpaceMapper.toDto(spaceRepository.findByHomeId(homeId));
}
@Override
public List findByUid(String uid) {
- return null;
+ return SpaceMapper.toDto(spaceRepository.findByUid(uid));
}
@Override
public Paging findByUid(String uid, int page, int size) {
- return null;
+ Page paged = spaceRepository.findByUid(uid,
+ Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ SpaceMapper.toDto(paged.getContent()));
}
@Override
@@ -41,36 +58,40 @@ public class SpaceDataImpl implements ISpaceData {
@Override
public Space findById(String s) {
- return null;
+ return SpaceMapper.M.toDto(spaceRepository.findById(s).orElse(null));
}
@Override
public Space save(Space data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ }
+ spaceRepository.save(SpaceMapper.M.toVo(data));
+ return data;
}
@Override
public Space add(Space data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ spaceRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return spaceRepository.count();
}
@Override
public List findAll() {
- return null;
+ return SpaceMapper.toDto(spaceRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ return new Paging<>();
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java
old mode 100644
new mode 100755
index ceeb90b5..ee7df8b7
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java
@@ -1,52 +1,72 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.ISpaceDeviceData;
+import cc.iotkit.data.dao.SpaceDeviceRepository;
+import cc.iotkit.data.model.SpaceDeviceMapper;
import cc.iotkit.model.Paging;
import cc.iotkit.model.space.SpaceDevice;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class SpaceDeviceDataImpl implements ISpaceDeviceData {
+
+ @Autowired
+ private SpaceDeviceRepository spaceDeviceRepository;
+
@Override
public List findByUidOrderByUseAtDesc(String uid) {
- return null;
+ return SpaceDeviceMapper.toDto(spaceDeviceRepository.findByUidOrderByUseAtDesc(uid));
}
@Override
public List findByUidOrderByAddAtDesc(String uid) {
- return null;
+ return SpaceDeviceMapper.toDto(spaceDeviceRepository.findByUidOrderByAddAtDesc(uid));
}
@Override
public List findBySpaceIdOrderByAddAtDesc(String spaceId) {
- return null;
+ return SpaceDeviceMapper.toDto(spaceDeviceRepository.findBySpaceIdOrderByAddAtDesc(spaceId));
}
@Override
public List findByUidAndSpaceIdOrderByAddAtDesc(String uid, String spaceId) {
- return null;
+ return SpaceDeviceMapper.toDto(spaceDeviceRepository.findByUidAndSpaceIdOrderByAddAtDesc(uid, spaceId));
}
@Override
public SpaceDevice findByDeviceId(String deviceId) {
- return null;
+ return SpaceDeviceMapper.M.toDto(spaceDeviceRepository.findByDeviceId(deviceId));
}
@Override
public SpaceDevice findByDeviceIdAndUid(String deviceId, String uid) {
- return null;
+ return SpaceDeviceMapper.M.toDto(spaceDeviceRepository.findByDeviceIdAndUid(deviceId, uid));
}
@Override
public List findByUid(String uid) {
- return null;
+ return SpaceDeviceMapper.toDto(spaceDeviceRepository.findByUid(uid));
}
@Override
public Paging findByUid(String uid, int page, int size) {
- return null;
+ return new Paging<>();
}
@Override
@@ -56,36 +76,41 @@ public class SpaceDeviceDataImpl implements ISpaceDeviceData {
@Override
public SpaceDevice findById(String s) {
- return null;
+ return SpaceDeviceMapper.M.toDto(spaceDeviceRepository.findById(s).orElse(null));
}
@Override
public SpaceDevice save(SpaceDevice data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setAddAt(System.currentTimeMillis());
+ }
+ spaceDeviceRepository.save(SpaceDeviceMapper.M.toVo(data));
+ return data;
}
@Override
public SpaceDevice add(SpaceDevice data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ spaceDeviceRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return spaceDeviceRepository.count();
}
@Override
public List findAll() {
- return null;
+ return SpaceDeviceMapper.toDto(spaceDeviceRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ return new Paging<>();
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java
old mode 100644
new mode 100755
index 236372d4..06cddbea
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java
@@ -1,22 +1,48 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.ITaskInfoData;
+import cc.iotkit.data.dao.TaskInfoRepository;
+import cc.iotkit.data.model.TaskInfoMapper;
+import cc.iotkit.data.model.TbTaskInfo;
import cc.iotkit.model.Paging;
import cc.iotkit.model.rule.TaskInfo;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class TaskInfoDataImpl implements ITaskInfoData {
+
+ @Autowired
+ private TaskInfoRepository taskInfoRepository;
+
@Override
public List findByUid(String uid) {
- return null;
+ return TaskInfoMapper.toDto(taskInfoRepository.findByUid(uid));
}
@Override
public Paging findByUid(String uid, int page, int size) {
- return null;
+ Page paged = taskInfoRepository.findByUid(uid,
+ Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ TaskInfoMapper.toDto(paged.getContent()));
}
@Override
@@ -26,36 +52,42 @@ public class TaskInfoDataImpl implements ITaskInfoData {
@Override
public TaskInfo findById(String s) {
- return null;
+ return TaskInfoMapper.toDtoFix(taskInfoRepository.findById(s).orElse(null));
}
@Override
public TaskInfo save(TaskInfo data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setCreateAt(System.currentTimeMillis());
+ }
+ taskInfoRepository.save(TaskInfoMapper.toVoFix(data));
+ return data;
}
@Override
public TaskInfo add(TaskInfo data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ taskInfoRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return taskInfoRepository.count();
}
@Override
public List findAll() {
- return null;
+ return TaskInfoMapper.toDto(taskInfoRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ Page paged = taskInfoRepository.findAll(Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(), TaskInfoMapper.toDto(paged.getContent()));
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java
old mode 100644
new mode 100755
index b03fd883..2c938adf
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java
@@ -1,37 +1,61 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.data.service;
import cc.iotkit.data.IThingModelData;
+import cc.iotkit.data.dao.ThingModelRepository;
+import cc.iotkit.data.model.ThingModelMapper;
import cc.iotkit.model.Paging;
import cc.iotkit.model.product.ThingModel;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class ThingModelDataImpl implements IThingModelData {
+
+ @Autowired
+ private ThingModelRepository thingModelRepository;
+
@Override
public ThingModel findByProductKey(String productKey) {
- return null;
+ return ThingModelMapper.toDtoFix(thingModelRepository.findByProductKey(productKey));
}
@Override
public ThingModel findById(String s) {
- return null;
+ return ThingModelMapper.toDtoFix(thingModelRepository.findById(s).orElse(null));
}
@Override
public ThingModel save(ThingModel data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ }
+ thingModelRepository.save(ThingModelMapper.toVoFix(data));
+ return data;
}
@Override
public ThingModel add(ThingModel data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ thingModelRepository.deleteById(s);
}
@Override
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java
old mode 100644
new mode 100755
index f44c85d5..29f4b569
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java
@@ -1,61 +1,82 @@
package cc.iotkit.data.service;
import cc.iotkit.data.IUserInfoData;
+import cc.iotkit.data.dao.UserInfoRepository;
+import cc.iotkit.data.model.TbUserInfo;
+import cc.iotkit.data.model.UserInfoMapper;
import cc.iotkit.model.Paging;
import cc.iotkit.model.UserInfo;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
+@Primary
@Service
public class UserInfoDataImpl implements IUserInfoData {
+
+ @Autowired
+ private UserInfoRepository userInfoRepository;
+
@Override
public UserInfo findByUid(String uid) {
- return null;
+ return UserInfoMapper.toDtoFix(userInfoRepository.findByUid(uid));
}
@Override
public List findByType(int type) {
- return null;
+ return UserInfoMapper.toDto(userInfoRepository.findByType(type));
}
@Override
public List findByTypeAndOwnerId(int type, String ownerId) {
- return null;
+ return UserInfoMapper.toDto(userInfoRepository.findByTypeAndOwnerId(type, ownerId));
}
@Override
public UserInfo findById(String s) {
- return null;
+ return UserInfoMapper.toDtoFix(userInfoRepository.findById(s).orElse(null));
}
@Override
public UserInfo save(UserInfo data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setCreateAt(System.currentTimeMillis());
+ }
+ userInfoRepository.save(UserInfoMapper.toVoFix(data));
+ return data;
}
@Override
public UserInfo add(UserInfo data) {
- return null;
+ return save(data);
}
@Override
public void deleteById(String s) {
-
+ userInfoRepository.deleteById(s);
}
@Override
public long count() {
- return 0;
+ return userInfoRepository.count();
}
@Override
public List findAll() {
- return null;
+ return UserInfoMapper.toDto(userInfoRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ Page paged = userInfoRepository.findAll(Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ UserInfoMapper.toDto(paged.getContent()));
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java
old mode 100644
new mode 100755
index aa82d421..91eb04ac
--- a/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java
+++ b/iot-data/iot-rdb-data-service/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java
@@ -1,23 +1,46 @@
package cc.iotkit.data.service;
import cc.iotkit.data.IVirtualDeviceData;
+import cc.iotkit.data.dao.VirtualDeviceMappingRepository;
+import cc.iotkit.data.dao.VirtualDeviceRepository;
+import cc.iotkit.data.model.TbVirtualDevice;
+import cc.iotkit.data.model.TbVirtualDeviceMapping;
+import cc.iotkit.data.model.VirtualDeviceMapper;
import cc.iotkit.model.Paging;
import cc.iotkit.model.device.VirtualDevice;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
-import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+@Primary
@Service
public class VirtualDeviceDataImpl implements IVirtualDeviceData {
+
+ @Autowired
+ private VirtualDeviceRepository virtualDeviceRepository;
+
+ @Autowired
+ private VirtualDeviceMappingRepository virtualDeviceMappingRepository;
+
@Override
public List findByUid(String uid) {
- return null;
+ return VirtualDeviceMapper.toDto(virtualDeviceRepository.findByUid(uid));
}
@Override
public Paging findByUid(String uid, int size, int page) {
- return null;
+ Page paged = virtualDeviceRepository.findByUid(uid,
+ Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(),
+ VirtualDeviceMapper.toDto(paged.getContent()));
}
@Override
@@ -32,41 +55,72 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData {
@Override
public List findByTriggerAndState(String trigger, String state) {
- return new ArrayList<>();
+ List list = VirtualDeviceMapper.toDto(virtualDeviceRepository
+ .findByTriggerAndState(trigger, state));
+ for (VirtualDevice virtualDevice : list) {
+ virtualDevice.setDevices(getVirtualDeviceIds(virtualDevice.getId()));
+ }
+ return list;
}
@Override
public VirtualDevice findById(String s) {
- return null;
+ VirtualDevice dto = VirtualDeviceMapper.M.toDto(virtualDeviceRepository.findById(s).orElse(null));
+ dto.setDevices(getVirtualDeviceIds(s));
+ return dto;
+ }
+
+ private List getVirtualDeviceIds(String virtualId) {
+ List deviceMappings = virtualDeviceMappingRepository.findByVirtualId(virtualId);
+ return deviceMappings.stream().map(TbVirtualDeviceMapping::getDeviceId).collect(Collectors.toList());
}
@Override
+ @Transactional
public VirtualDevice save(VirtualDevice data) {
- return null;
+ if (StringUtils.isBlank(data.getId())) {
+ data.setId(UUID.randomUUID().toString());
+ data.setCreateAt(System.currentTimeMillis());
+ }
+ virtualDeviceRepository.save(VirtualDeviceMapper.M.toVo(data));
+
+ //删除旧的添加新的关联设备记录
+ virtualDeviceMappingRepository.deleteByVirtualId(data.getId());
+ virtualDeviceMappingRepository.saveAllAndFlush(
+ data.getDevices().stream().map(d -> new TbVirtualDeviceMapping(
+ UUID.randomUUID().toString(),
+ data.getId(),
+ d
+ )).collect(Collectors.toList())
+ );
+ return data;
}
@Override
public VirtualDevice add(VirtualDevice data) {
- return null;
+ return save(data);
}
@Override
+ @Transactional
public void deleteById(String s) {
-
+ virtualDeviceRepository.deleteById(s);
+ virtualDeviceMappingRepository.deleteByVirtualId(s);
}
@Override
public long count() {
- return 0;
+ return virtualDeviceRepository.count();
}
@Override
public List findAll() {
- return null;
+ return VirtualDeviceMapper.toDto(virtualDeviceRepository.findAll());
}
@Override
public Paging findAll(int page, int size) {
- return null;
+ Page paged = virtualDeviceRepository.findAll(Pageable.ofSize(size).withPage(page - 1));
+ return new Paging<>(paged.getTotalElements(), VirtualDeviceMapper.toDto(paged.getContent()));
}
}
diff --git a/iot-data/iot-rdb-data-service/src/main/resources/ddl.sql b/iot-data/iot-rdb-data-service/src/main/resources/ddl.sql
old mode 100644
new mode 100755
diff --git a/iot-data/iot-temporal-service/pom.xml b/iot-data/iot-temporal-service/pom.xml
old mode 100644
new mode 100755
index 366f38ab..c1e50209
--- a/iot-data/iot-temporal-service/pom.xml
+++ b/iot-data/iot-temporal-service/pom.xml
@@ -5,7 +5,7 @@
iot-data
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IDevicePropertyData.java b/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IDevicePropertyData.java
old mode 100644
new mode 100755
index 19d04a21..5777beeb
--- a/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IDevicePropertyData.java
+++ b/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IDevicePropertyData.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.temporal;
diff --git a/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IRuleLogData.java b/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IRuleLogData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/ITaskLogData.java b/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/ITaskLogData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IThingModelMessageData.java b/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IThingModelMessageData.java
old mode 100644
new mode 100755
diff --git a/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IVirtualDeviceLogData.java b/iot-data/iot-temporal-service/src/main/java/cc/iotkit/temporal/IVirtualDeviceLogData.java
old mode 100644
new mode 100755
diff --git a/iot-data/pom.xml b/iot-data/pom.xml
old mode 100644
new mode 100755
index b41bc873..b6e2519a
--- a/iot-data/pom.xml
+++ b/iot-data/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
pom
diff --git a/iot-data/readme.md b/iot-data/readme.md
old mode 100644
new mode 100755
diff --git a/iot-message-bus/.DS_Store b/iot-message-bus/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-message-bus/pom.xml b/iot-message-bus/pom.xml
old mode 100644
new mode 100755
index db7bef82..5e1dfcad
--- a/iot-message-bus/pom.xml
+++ b/iot-message-bus/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-message-bus/readme.txt b/iot-message-bus/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/main/java/cc/iotkit/mq/ConsumerHandler.java b/iot-message-bus/src/main/java/cc/iotkit/mq/ConsumerHandler.java
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/main/java/cc/iotkit/mq/MqConsumer.java b/iot-message-bus/src/main/java/cc/iotkit/mq/MqConsumer.java
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/main/java/cc/iotkit/mq/MqProducer.java b/iot-message-bus/src/main/java/cc/iotkit/mq/MqProducer.java
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/BeanCodec.java b/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/BeanCodec.java
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/VertxManager.java b/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/VertxManager.java
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/VertxMqConsumer.java b/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/VertxMqConsumer.java
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/VertxMqProducer.java b/iot-message-bus/src/main/java/cc/iotkit/mq/vertx/VertxMqProducer.java
old mode 100644
new mode 100755
diff --git a/iot-message-bus/src/test/java/test/MsgPubConsumeTest.java b/iot-message-bus/src/test/java/test/MsgPubConsumeTest.java
old mode 100644
new mode 100755
diff --git a/iot-package/.DS_Store b/iot-package/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-package/pom.xml b/iot-package/pom.xml
old mode 100644
new mode 100755
index 17959ca1..b270d4e2
--- a/iot-package/pom.xml
+++ b/iot-package/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-package/readme.txt b/iot-package/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-package/src/main/resources/assemblies/standalone-package.xml b/iot-package/src/main/resources/assemblies/standalone-package.xml
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/.DS_Store b/iot-rule-engine/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/pom.xml b/iot-rule-engine/pom.xml
old mode 100644
new mode 100755
index 0febc8b8..3f27596e
--- a/iot-rule-engine/pom.xml
+++ b/iot-rule-engine/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-rule-engine/readme.txt b/iot-rule-engine/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/Action.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/Action.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/AlertAction.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/AlertAction.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/AlertService.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/AlertService.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/DeviceAction.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/DeviceAction.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/DeviceActionService.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/DeviceActionService.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpAction.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpAction.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpService.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpService.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/ScriptService.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/ScriptService.java
old mode 100644
new mode 100755
index 1dd0be57..4e9c1f3e
--- a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/ScriptService.java
+++ b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/action/ScriptService.java
@@ -10,7 +10,7 @@
package cc.iotkit.ruleengine.action;
import cc.iotkit.common.utils.JsonUtil;
-import cc.iotkit.dao.DeviceCache;
+import cc.iotkit.data.IDeviceInfoData;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.device.message.ThingModelMessage;
import jdk.nashorn.api.scripting.NashornScriptEngine;
@@ -32,7 +32,7 @@ public class ScriptService {
private ScriptObjectMirror scriptObject;
- private DeviceCache deviceCache;
+ private IDeviceInfoData deviceInfoData;
public Map execScript(ThingModelMessage msg) {
try {
@@ -40,7 +40,7 @@ public class ScriptService {
scriptObject = (ScriptObjectMirror) engine.eval("new (function(){" + script + "})()");
}
//取设备信息
- DeviceInfo deviceInfo = deviceCache.get(msg.getDeviceId());
+ DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(msg.getDeviceId());
//执行转换脚本
ScriptObjectMirror result = (ScriptObjectMirror) engine
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/alert/Alerter.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/alert/Alerter.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/alert/DingdRobotAlerter.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/alert/DingdRobotAlerter.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/alert/EmailAlerter.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/alert/EmailAlerter.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/config/JobFactory.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/config/JobFactory.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/config/QuartzConfiguration.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/config/QuartzConfiguration.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/config/RuleConfiguration.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/config/RuleConfiguration.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/BaseComparator.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/BaseComparator.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/Comparator.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/Comparator.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/EqComparator.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/EqComparator.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/Expression.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/Expression.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/GtComparator.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/GtComparator.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/LtComparator.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/LtComparator.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/NeqComparator.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/expression/NeqComparator.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceCondition.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceCondition.java
old mode 100644
new mode 100755
index 43056cde..a829bc9e
--- a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceCondition.java
+++ b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceCondition.java
@@ -9,7 +9,7 @@
*/
package cc.iotkit.ruleengine.filter;
-import cc.iotkit.dao.DeviceCache;
+import cc.iotkit.data.IDeviceInfoData;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.ruleengine.expression.Expression;
import lombok.Data;
@@ -29,7 +29,7 @@ public class DeviceCondition {
private String comparator;
- private DeviceCache deviceCache;
+ private IDeviceInfoData deviceInfoData;
public DeviceCondition clone() {
DeviceCondition con = new DeviceCondition();
@@ -38,7 +38,7 @@ public class DeviceCondition {
con.setIdentifier(identifier);
con.setValue(value);
con.setComparator(comparator);
- con.setDeviceCache(deviceCache);
+ con.setDeviceInfoData(deviceInfoData);
return con;
}
@@ -47,10 +47,10 @@ public class DeviceCondition {
String[] pkDn = device.split("/");
if (pkDn.length < 2) {
//用deviceId取
- deviceInfo = deviceCache.get(device);
+ deviceInfo = deviceInfoData.findByDeviceId(device);
} else {
//用pk/dn取
- deviceInfo = deviceCache.getDeviceInfo(pkDn[0], pkDn[1]);
+ deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(pkDn[0], pkDn[1]);
}
Object left = null;
if ("property".equals(type)) {
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceFilter.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceFilter.java
old mode 100644
new mode 100755
index 698dcfed..84907600
--- a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceFilter.java
+++ b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/DeviceFilter.java
@@ -9,7 +9,7 @@
*/
package cc.iotkit.ruleengine.filter;
-import cc.iotkit.dao.DeviceCache;
+import cc.iotkit.data.IDeviceInfoData;
import cc.iotkit.model.device.message.ThingModelMessage;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -25,7 +25,7 @@ public class DeviceFilter implements Filter {
private List conditions;
- private DeviceCache deviceCache;
+ private IDeviceInfoData deviceInfoData;
@Override
public String getType() {
@@ -45,7 +45,7 @@ public class DeviceFilter implements Filter {
con.setDevice(msg.getDeviceId());
}
- con.setDeviceCache(deviceCache);
+ con.setDeviceInfoData(deviceInfoData);
if (!con.matches()) {
return false;
}
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/Filter.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/filter/Filter.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/DeviceMessageHandler.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/DeviceMessageHandler.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/RuleDeviceConsumer.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/RuleDeviceConsumer.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceCondition.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceCondition.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceListener.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceListener.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/listener/Listener.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/listener/Listener.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/Rule.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/Rule.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleExecutor.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleExecutor.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java
old mode 100644
new mode 100755
index 884b2bef..6a681b90
--- a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java
+++ b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java
@@ -10,7 +10,7 @@
package cc.iotkit.ruleengine.rule;
import cc.iotkit.common.utils.JsonUtil;
-import cc.iotkit.dao.DeviceCache;
+import cc.iotkit.data.IDeviceInfoData;
import cc.iotkit.data.IRuleInfoData;
import cc.iotkit.model.Paging;
import cc.iotkit.model.rule.RuleAction;
@@ -24,12 +24,11 @@ import cc.iotkit.ruleengine.listener.Listener;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Sort;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -48,7 +47,8 @@ public class RuleManager {
private IRuleInfoData ruleInfoData;
@Autowired
- private DeviceCache deviceCache;
+ @Qualifier("deviceInfoDataCache")
+ private IDeviceInfoData deviceInfoData;
@Autowired
private DeviceActionService deviceActionService;
@@ -126,7 +126,7 @@ public class RuleManager {
private Filter> parseFilter(String type, String config) {
if (DeviceFilter.TYPE.equals(type)) {
DeviceFilter filter = parse(config, DeviceFilter.class);
- filter.setDeviceCache(deviceCache);
+ filter.setDeviceInfoData(deviceInfoData);
return filter;
}
return null;
@@ -140,7 +140,7 @@ public class RuleManager {
} else if (HttpAction.TYPE.equals(type)) {
HttpAction httpAction = parse(config, HttpAction.class);
for (HttpService service : httpAction.getServices()) {
- service.setDeviceCache(deviceCache);
+ service.setDeviceInfoData(deviceInfoData);
}
return httpAction;
}
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleMessageHandler.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleMessageHandler.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/ActionExecutor.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/ActionExecutor.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/ActionExecutorManager.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/ActionExecutorManager.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/CommonJob.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/CommonJob.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/DeviceActionExecutor.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/DeviceActionExecutor.java
old mode 100644
new mode 100755
index 81a45dd3..b7840651
--- a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/DeviceActionExecutor.java
+++ b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/DeviceActionExecutor.java
@@ -10,7 +10,6 @@
package cc.iotkit.ruleengine.task;
import cc.iotkit.common.utils.JsonUtil;
-import cc.iotkit.dao.DeviceCache;
import cc.iotkit.ruleengine.action.DeviceAction;
import cc.iotkit.ruleengine.action.DeviceActionService;
import lombok.extern.slf4j.Slf4j;
@@ -28,8 +27,6 @@ import java.util.concurrent.ConcurrentHashMap;
@Component
public class DeviceActionExecutor implements ActionExecutor {
- @Autowired
- private DeviceCache deviceCache;
@Autowired
private DeviceActionService deviceActionService;
@@ -47,9 +44,11 @@ public class DeviceActionExecutor implements ActionExecutor {
return;
}
//将执行的数据转换为动作配置
- DeviceAction action = actionMap.putIfAbsent(config.hashCode(), JsonUtil.parse(config, DeviceAction.class));
+ Integer code = config.hashCode();
+ DeviceAction action = actionMap.get(code);
if (action == null) {
- return;
+ action = JsonUtil.parse(config, DeviceAction.class);
+ actionMap.put(code, action);
}
log.info("start device service invoke,{}", JsonUtil.toJsonString(action));
diff --git a/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/TaskManager.java b/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/TaskManager.java
old mode 100644
new mode 100755
diff --git a/iot-rule-engine/src/main/resources/spring.factories b/iot-rule-engine/src/main/resources/spring.factories
old mode 100644
new mode 100755
diff --git a/iot-standalone/.DS_Store b/iot-standalone/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-standalone/pom.xml b/iot-standalone/pom.xml
old mode 100644
new mode 100755
index 601f7a87..a8d39278
--- a/iot-standalone/pom.xml
+++ b/iot-standalone/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
@@ -23,11 +23,6 @@
spring-boot-starter-web
-
- org.springframework.boot
- spring-boot-starter-cache
-
-
org.springframework.boot
spring-boot-starter-logging
@@ -44,11 +39,6 @@
log4j-core
-
- com.github.ben-manes.caffeine
- caffeine
-
-
org.projectlombok
lombok
@@ -155,6 +145,11 @@
iot-es-temporal-service
+
+ cc.iotkit
+ iot-data-cache
+
+
diff --git a/iot-standalone/readme.md b/iot-standalone/readme.md
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/Application.java b/iot-standalone/src/main/java/cc/iotkit/Application.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/AliyunConfig.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/AliyunConfig.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/CacheConfig.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/CacheConfig.java
deleted file mode 100644
index a9b74895..00000000
--- a/iot-standalone/src/main/java/cc/iotkit/manager/config/CacheConfig.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * +----------------------------------------------------------------------
- * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
- * +----------------------------------------------------------------------
- * | Licensed 未经许可不能去掉「奇特物联」相关版权
- * +----------------------------------------------------------------------
- * | Author: xw2sy@163.com
- * +----------------------------------------------------------------------
- */
-package cc.iotkit.manager.config;
-
-import cc.iotkit.common.Constants;
-import com.github.benmanes.caffeine.cache.Caffeine;
-import com.google.common.collect.Lists;
-import org.springframework.cache.CacheManager;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cache.caffeine.CaffeineCache;
-import org.springframework.cache.support.SimpleCacheManager;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.concurrent.TimeUnit;
-
-@Configuration
-@EnableCaching
-public class CacheConfig {
-
- /**
- * 配置本地缓存
- */
- @Bean
- public CacheManager cacheManager() {
- SimpleCacheManager manager = new SimpleCacheManager();
- manager.setCaches(Lists.newArrayList(new CaffeineCache(
- Constants.DEVICE_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ), new CaffeineCache(
- Constants.DEVICE_STATS_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ),
- new CaffeineCache(
- Constants.PRODUCT_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ),
- new CaffeineCache(
- Constants.APP_DESIGN_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ),
- new CaffeineCache(
- Constants.THING_MODEL_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ),
- new CaffeineCache(
- Constants.PRODUCT_SCRIPT_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ), new CaffeineCache(
- Constants.SPACE_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ), new CaffeineCache(
- Constants.CATEGORY_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ), new CaffeineCache(
- Constants.USER_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- ), new CaffeineCache(
- Constants.OAUTH_CLIENT_CACHE,
- Caffeine.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .build()
- )
- ));
- return manager;
- }
-
-}
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/CrossConfig.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/CrossConfig.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/EmbeddedElasticSearchConfig.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/EmbeddedElasticSearchConfig.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/EmbeddedRedisConfig.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/EmbeddedRedisConfig.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/GlobalExceptionHandler.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/GlobalExceptionHandler.java
old mode 100644
new mode 100755
index 226a3512..a03f6e8b
--- a/iot-standalone/src/main/java/cc/iotkit/manager/config/GlobalExceptionHandler.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/config/GlobalExceptionHandler.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.manager.config;
import cn.dev33.satoken.exception.NotLoginException;
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/ResponseResultHandler.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/ResponseResultHandler.java
old mode 100644
new mode 100755
index 49daa079..45c14d9d
--- a/iot-standalone/src/main/java/cc/iotkit/manager/config/ResponseResultHandler.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/config/ResponseResultHandler.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.manager.config;
import cn.dev33.satoken.util.SaResult;
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/config/SaTokenConfigure.java b/iot-standalone/src/main/java/cc/iotkit/manager/config/SaTokenConfigure.java
old mode 100644
new mode 100755
index 7b4e3379..9b443b4d
--- a/iot-standalone/src/main/java/cc/iotkit/manager/config/SaTokenConfigure.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/config/SaTokenConfigure.java
@@ -77,6 +77,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
})).addPathPatterns("/**")
.excludePathPatterns(
+ "/test","/put",
"/*.png",
"/oauth2/**", "/*.html",
"/favicon.ico", "/v2/api-docs",
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/DeviceController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/DeviceController.java
old mode 100644
new mode 100755
index c36a90f6..5c37bdd0
--- a/iot-standalone/src/main/java/cc/iotkit/manager/controller/DeviceController.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/controller/DeviceController.java
@@ -15,7 +15,6 @@ import cc.iotkit.common.utils.DeviceUtil;
import cc.iotkit.common.utils.ReflectUtil;
import cc.iotkit.common.utils.UniqueIdUtil;
import cc.iotkit.comps.service.DeviceBehaviourService;
-import cc.iotkit.dao.*;
import cc.iotkit.data.IDeviceConfigData;
import cc.iotkit.data.IDeviceGroupData;
import cc.iotkit.data.IDeviceInfoData;
@@ -39,6 +38,7 @@ import cc.iotkit.model.product.ThingModel;
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.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
@@ -54,8 +54,10 @@ public class DeviceController {
@Autowired
private DeviceService deviceService;
@Autowired
+ @Qualifier("deviceInfoDataCache")
private IDeviceInfoData deviceInfoData;
@Autowired
+ @Qualifier("productDataCache")
private IProductData productData;
@Autowired
private DataOwnerService dataOwnerService;
@@ -74,8 +76,6 @@ public class DeviceController {
@Autowired
private IDeviceGroupData deviceGroupData;
@Autowired
- private DeviceCache deviceCache;
- @Autowired
private IDeviceConfigData deviceConfigData;
@PostMapping(Constants.API_DEVICE.INVOKE_SERVICE)
@@ -334,7 +334,7 @@ public class DeviceController {
dataOwnerService.checkOwner(deviceGroup);
for (String device : devices) {
- DeviceInfo deviceInfo = deviceCache.get(device);
+ DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(device);
if (deviceInfo == null) {
continue;
}
@@ -362,7 +362,7 @@ public class DeviceController {
dataOwnerService.checkOwner(deviceGroup);
for (String device : devices) {
- DeviceInfo deviceInfo = deviceCache.get(device);
+ DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(device);
if (deviceInfo == null) {
continue;
}
@@ -383,7 +383,7 @@ public class DeviceController {
*/
@PostMapping("/config/{deviceId}/save")
public void saveConfig(@PathVariable("deviceId") String deviceId, String config) {
- DeviceInfo deviceInfo = deviceCache.get(deviceId);
+ DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(deviceId);
dataOwnerService.checkOwner(deviceInfo);
DeviceConfig deviceConfig = deviceConfigData.findByDeviceId(deviceId);
@@ -407,7 +407,7 @@ public class DeviceController {
*/
@GetMapping("/config/{deviceId}/get")
public DeviceConfig getConfig(@PathVariable("deviceId") String deviceId) {
- DeviceInfo deviceInfo = deviceCache.get(deviceId);
+ DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(deviceId);
dataOwnerService.checkOwner(deviceInfo);
return deviceConfigData.findByDeviceId(deviceId);
}
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProductController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProductController.java
old mode 100644
new mode 100755
index 09b37054..1ca7a0d1
--- a/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProductController.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProductController.java
@@ -30,6 +30,7 @@ import com.aliyun.oss.model.PutObjectResult;
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.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -42,6 +43,7 @@ import java.util.List;
public class ProductController {
@Autowired
+ @Qualifier("productDataCache")
private IProductData productData;
@Autowired
private IThingModelData thingModelData;
@@ -62,10 +64,10 @@ public class ProductController {
@PathVariable("size") int size,
@PathVariable("page") int page) {
if (!AuthUtil.isAdmin()) {
- return productData.findByUid(AuthUtil.getUserId(), page - 1, size);
+ return productData.findByUid(AuthUtil.getUserId(), page, size);
}
- return productData.findAll(page - 1, size);
+ return productData.findAll(page, size);
}
@PostMapping("/save")
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProtocolController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProtocolController.java
old mode 100644
new mode 100755
index 02b90996..12a5f46f
--- a/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProtocolController.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/controller/ProtocolController.java
@@ -196,7 +196,7 @@ public class ProtocolController {
public Paging getComponents(
@PathVariable("size") int size,
@PathVariable("page") int page) {
- Paging components = protocolComponentData.findAll(page - 1, size);
+ Paging components = protocolComponentData.findAll(page, size);
components.getData().forEach(c -> c.setState(
componentManager.isRunning(c.getId()) ?
ProtocolComponent.STATE_RUNNING : ProtocolComponent.STATE_STOPPED
@@ -208,7 +208,7 @@ public class ProtocolController {
public Paging getConverters(
@PathVariable("size") int size,
@PathVariable("page") int page) {
- return protocolConverterData.findAll(page - 1, size);
+ return protocolConverterData.findAll(page, size);
}
@PostMapping("/addConverter")
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/RuleEngineController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/RuleEngineController.java
old mode 100644
new mode 100755
index 0666463d..0d51444a
--- a/iot-standalone/src/main/java/cc/iotkit/manager/controller/RuleEngineController.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/controller/RuleEngineController.java
@@ -68,9 +68,9 @@ public class RuleEngineController {
RuleInfo ruleInfo = new RuleInfo();
ruleInfo.setType(type);
if (AuthUtil.isAdmin()) {
- return ruleInfoData.findByType(type, page - 1, size);
+ return ruleInfoData.findByType(type, page, size);
} else {
- return ruleInfoData.findByUidAndType(AuthUtil.getUserId(), type, page - 1, size);
+ return ruleInfoData.findByUidAndType(AuthUtil.getUserId(), type, page, size);
}
}
@@ -241,7 +241,7 @@ public class RuleEngineController {
) {
TaskLog taskLog = new TaskLog();
taskLog.setTaskId(taskId);
- return taskLogData.findByTaskId(taskId, page - 1, size);
+ return taskLogData.findByTaskId(taskId, page, size);
}
@DeleteMapping("/task/{taskId}/logs/clear")
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/SpaceController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/SpaceController.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java
old mode 100644
new mode 100755
index 3f415dd3..d6ddfdc9
--- a/iot-standalone/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java
@@ -11,11 +11,7 @@ package cc.iotkit.manager.controller;
import cc.iotkit.common.Constants;
import cc.iotkit.common.exception.BizException;
-import cc.iotkit.dao.*;
-import cc.iotkit.data.IDeviceInfoData;
-import cc.iotkit.data.ISpaceData;
-import cc.iotkit.data.ISpaceDeviceData;
-import cc.iotkit.data.IUserInfoData;
+import cc.iotkit.data.*;
import cc.iotkit.manager.model.vo.FindDeviceVo;
import cc.iotkit.manager.model.vo.SpaceDeviceVo;
import cc.iotkit.manager.service.DataOwnerService;
@@ -28,12 +24,12 @@ import cc.iotkit.model.space.Space;
import cc.iotkit.model.space.SpaceDevice;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.stream.Collectors;
@@ -44,16 +40,16 @@ public class SpaceDeviceController {
@Autowired
private ISpaceDeviceData spaceDeviceData;
@Autowired
+ @Qualifier("deviceInfoDataCache")
private IDeviceInfoData deviceInfoData;
@Autowired
- private DeviceCache deviceCache;
+ @Qualifier("productDataCache")
+ private IProductData productData;
@Autowired
- private ProductCache productCache;
- @Autowired
- private CategoryCache categoryCache;
- @Autowired
- private SpaceCache spaceCache;
+ @Qualifier("categoryDataCache")
+ private ICategoryData categoryData;
@Autowired
+ @Qualifier("spaceDataCache")
private ISpaceData spaceData;
@Autowired
private DataOwnerService dataOwnerService;
@@ -91,9 +87,9 @@ public class SpaceDeviceController {
private SpaceDeviceVo parseSpaceDevice(SpaceDevice sd) {
DeviceInfo device = deviceInfoData.findByDeviceId(sd.getDeviceId());
- Space space = spaceCache.getSpace(sd.getSpaceId());
- Product product = productCache.findById(device.getProductKey());
- Category category = categoryCache.getById(product.getCategory());
+ Space space = spaceData.findById(sd.getSpaceId());
+ Product product = productData.findById(device.getProductKey());
+ Category category = categoryData.findById(product.getCategory());
DeviceInfo.State state = device.getState();
return SpaceDeviceVo.builder()
@@ -169,8 +165,8 @@ public class SpaceDeviceController {
.productKey(device.getProductKey())
.build();
- Product product = productCache.findById(device.getProductKey());
- Category category = categoryCache.getById(product.getCategory());
+ Product product = productData.findById(device.getProductKey());
+ Category category = categoryData.findById(product.getCategory());
findDeviceVo.setProductName(product.getName());
findDeviceVo.setProductImg(product.getImg());
findDeviceVo.setCategoryName(category.getName());
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/StatsController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/StatsController.java
old mode 100644
new mode 100755
index dfecb930..6e7c54ce
--- a/iot-standalone/src/main/java/cc/iotkit/manager/controller/StatsController.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/controller/StatsController.java
@@ -9,7 +9,6 @@
*/
package cc.iotkit.manager.controller;
-import cc.iotkit.dao.*;
import cc.iotkit.data.ICategoryData;
import cc.iotkit.data.IDeviceInfoData;
import cc.iotkit.data.IProductData;
@@ -18,6 +17,7 @@ import cc.iotkit.temporal.IThingModelMessageData;
import cc.iotkit.utils.AuthUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -30,13 +30,13 @@ public class StatsController {
@Autowired
private ICategoryData ICategoryData;
@Autowired
+ @Qualifier("productDataCache")
private IProductData productData;
@Autowired
+ @Qualifier("deviceInfoDataCache")
private IDeviceInfoData deviceInfoData;
@Autowired
private IThingModelMessageData thingModelMessageData;
- @Autowired
- private DeviceCache deviceCache;
@GetMapping("/main")
public MainStats getMainStats() {
@@ -52,7 +52,7 @@ public class StatsController {
//上报数据统计
mainStats.setReportDataStats(thingModelMessageData.getDeviceMessageStatsWithUid(null, now - 48 * 3600 * 1000, now));
//产品数量统计
- mainStats.setDeviceStatsOfCategory(deviceCache.getDeviceStatsByCategory(""));
+ mainStats.setDeviceStatsOfCategory(deviceInfoData.getDeviceStatsByCategory(""));
} else {
mainStats.setCategoryTotal(ICategoryData.count());
mainStats.setProductTotal(productData.countByUid(uid));
@@ -61,7 +61,7 @@ public class StatsController {
//上报数据统计
mainStats.setReportDataStats(thingModelMessageData.getDeviceMessageStatsWithUid(uid, now - 48 * 3600 * 1000, now));
//产品数量统计
- mainStats.setDeviceStatsOfCategory(deviceCache.getDeviceStatsByCategory(uid));
+ mainStats.setDeviceStatsOfCategory(deviceInfoData.getDeviceStatsByCategory(uid));
}
return mainStats;
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/UserInfoController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/UserInfoController.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java b/iot-standalone/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java
old mode 100644
new mode 100755
index 35253121..58520c9b
--- a/iot-standalone/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java
@@ -44,7 +44,6 @@ public class VirtualDeviceController {
@PathVariable("size") int size,
@PathVariable("page") int page) {
String uid = AuthUtil.getUserId();
- page = page - 1;
if (AuthUtil.isAdmin()) {
return virtualDeviceData.findAll(page, size);
} else {
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/query/DeviceQuery.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/query/DeviceQuery.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/stats/MainStats.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/stats/MainStats.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/AppDesignVo.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/AppDesignVo.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/AppPageNode.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/AppPageNode.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/DeviceLog.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/DeviceLog.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/FindDeviceVo.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/FindDeviceVo.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/LoginResult.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/LoginResult.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/MessageVo.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/MessageVo.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/SpaceDeviceVo.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/SpaceDeviceVo.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/SpaceInfo.java b/iot-standalone/src/main/java/cc/iotkit/manager/model/vo/SpaceInfo.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/DataOwnerService.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/DataOwnerService.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/DeferredDataConsumer.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/DeferredDataConsumer.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/DeviceService.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/DeviceService.java
old mode 100644
new mode 100755
index 1fb53eb2..1c4150f9
--- a/iot-standalone/src/main/java/cc/iotkit/manager/service/DeviceService.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/service/DeviceService.java
@@ -24,6 +24,7 @@ import cc.iotkit.temporal.IThingModelMessageData;
import cc.iotkit.virtualdevice.VirtualManager;
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 java.util.Map;
@@ -33,6 +34,7 @@ import java.util.Map;
public class DeviceService {
@Autowired
+ @Qualifier("deviceInfoDataCache")
private IDeviceInfoData deviceInfoData;
@Autowired
private DataOwnerService dataOwnerService;
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/DeviceStateCheckTask.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/DeviceStateCheckTask.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/ExampleDataInit.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/ExampleDataInit.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/SpaceDeviceService.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/SpaceDeviceService.java
old mode 100644
new mode 100755
index 80e66b51..12684ed4
--- a/iot-standalone/src/main/java/cc/iotkit/manager/service/SpaceDeviceService.java
+++ b/iot-standalone/src/main/java/cc/iotkit/manager/service/SpaceDeviceService.java
@@ -9,8 +9,8 @@
*/
package cc.iotkit.manager.service;
-import cc.iotkit.dao.DeviceCache;
-import cc.iotkit.dao.ProductCache;
+import cc.iotkit.data.IDeviceInfoData;
+import cc.iotkit.data.IProductData;
import cc.iotkit.data.ISpaceDeviceData;
import cc.iotkit.manager.model.vo.SpaceDeviceVo;
import cc.iotkit.model.device.DeviceInfo;
@@ -18,6 +18,7 @@ import cc.iotkit.model.product.Product;
import cc.iotkit.model.space.SpaceDevice;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -28,9 +29,11 @@ public class SpaceDeviceService {
@Autowired
private ISpaceDeviceData spaceDeviceData;
@Autowired
- private DeviceCache deviceCache;
+ @Qualifier("deviceInfoDataCache")
+ private IDeviceInfoData deviceInfoData;
@Autowired
- private ProductCache productCache;
+ @Qualifier("productDataCache")
+ private IProductData productData;
public List getUserDevices(String uid, String spaceId) {
SpaceDevice device = new SpaceDevice();
@@ -45,8 +48,8 @@ public class SpaceDeviceService {
List spaceDeviceVos = new ArrayList<>();
spaceDevices.forEach(sd -> {
- DeviceInfo deviceInfo = deviceCache.get(sd.getDeviceId());
- Product product = productCache.findById(deviceInfo.getProductKey());
+ DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(sd.getDeviceId());
+ Product product = productData.findById(deviceInfo.getProductKey());
spaceDeviceVos.add(SpaceDeviceVo.builder()
.uid(sd.getUid())
.deviceId(sd.getDeviceId())
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/ThingModelService.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/ThingModelService.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/service/WeChatService.java b/iot-standalone/src/main/java/cc/iotkit/manager/service/WeChatService.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/java/cc/iotkit/manager/utils/WeChatUtil.java b/iot-standalone/src/main/java/cc/iotkit/manager/utils/WeChatUtil.java
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/main/resources/application-dev.yml b/iot-standalone/src/main/resources/application-dev.yml
old mode 100644
new mode 100755
index 23886445..2b8cd76a
--- a/iot-standalone/src/main/resources/application-dev.yml
+++ b/iot-standalone/src/main/resources/application-dev.yml
@@ -8,7 +8,6 @@ spring:
max-file-size: 10MB
max-request-size: 12MB
-
# <<=======内置H2数据库连接设置开始==========
# jpa:
# show-sql: true
@@ -43,8 +42,8 @@ spring:
testOnBorrow: true
jpa:
database: MySQL
- database-platform: org.hibernate.dialect.MySQL5Dialect
- show-sql: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+# show-sql: true
hibernate:
ddl-auto: update
properties:
diff --git a/iot-standalone/src/main/resources/application.yml b/iot-standalone/src/main/resources/application.yml
old mode 100644
new mode 100755
index 52de4d44..d0f0efef
--- a/iot-standalone/src/main/resources/application.yml
+++ b/iot-standalone/src/main/resources/application.yml
@@ -8,7 +8,6 @@ spring:
max-file-size: 10MB
max-request-size: 12MB
-
# <<=======内置H2数据库连接设置开始==========
# jpa:
# show-sql: true
@@ -43,8 +42,8 @@ spring:
testOnBorrow: true
jpa:
database: MySQL
- database-platform: org.hibernate.dialect.MySQL5Dialect
- show-sql: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+# show-sql: true
hibernate:
ddl-auto: update
properties:
diff --git a/iot-standalone/src/main/resources/logback-spring.xml b/iot-standalone/src/main/resources/logback-spring.xml
old mode 100644
new mode 100755
diff --git a/iot-standalone/src/test/java/JsTest.java b/iot-standalone/src/test/java/JsTest.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/.DS_Store b/iot-test-tool/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/pom.xml b/iot-test-tool/iot-test-mqtt/pom.xml
old mode 100644
new mode 100755
index 9267c45d..ff099bb8
--- a/iot-test-tool/iot-test-mqtt/pom.xml
+++ b/iot-test-tool/iot-test-mqtt/pom.xml
@@ -5,7 +5,7 @@
iot-test-tool
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/Simulator.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/Simulator.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/config/Mqtt.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/config/Mqtt.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/model/Request.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/model/Request.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/model/Response.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/model/Response.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/performance/ConnectionTest.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/performance/ConnectionTest.java
old mode 100644
new mode 100755
index ac18efaa..b2cb5a44
--- a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/performance/ConnectionTest.java
+++ b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/performance/ConnectionTest.java
@@ -33,7 +33,7 @@ public class ConnectionTest {
Mqtt.brokerHost = args[0];
}
- int total = 500;
+ int total = 1000;
if (args.length > 1) {
total = Integer.parseInt(args[1]);
}
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/performance/ReportTest.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/performance/ReportTest.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/Device.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/Device.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/Gateway.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/Gateway.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/MessageHandler.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/MessageHandler.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/ReportTask.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/ReportTask.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/Vertxs.java b/iot-test-tool/iot-test-mqtt/src/main/java/cc/iotkit/test/mqtt/service/Vertxs.java
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/resources/log4j2.xml b/iot-test-tool/iot-test-mqtt/src/main/resources/log4j2.xml
old mode 100644
new mode 100755
diff --git a/iot-test-tool/iot-test-mqtt/src/main/resources/vertx-default-jul-logging.properties b/iot-test-tool/iot-test-mqtt/src/main/resources/vertx-default-jul-logging.properties
old mode 100644
new mode 100755
diff --git a/iot-test-tool/pom.xml b/iot-test-tool/pom.xml
old mode 100644
new mode 100755
index 38146f3a..348ce62e
--- a/iot-test-tool/pom.xml
+++ b/iot-test-tool/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
pom
diff --git a/iot-test-tool/readme.txt b/iot-test-tool/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-virtual-device/.DS_Store b/iot-virtual-device/.DS_Store
old mode 100644
new mode 100755
diff --git a/iot-virtual-device/pom.xml b/iot-virtual-device/pom.xml
old mode 100644
new mode 100755
index d74aeaf8..e89ab3b7
--- a/iot-virtual-device/pom.xml
+++ b/iot-virtual-device/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
4.0.0
diff --git a/iot-virtual-device/readme.txt b/iot-virtual-device/readme.txt
old mode 100644
new mode 100755
diff --git a/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualExecutor.java b/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualExecutor.java
old mode 100644
new mode 100755
index df625b91..24859136
--- a/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualExecutor.java
+++ b/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualExecutor.java
@@ -46,6 +46,9 @@ public class VirtualExecutor implements Job {
try {
for (DeviceInfo device : devices) {
+ if (device == null) {
+ continue;
+ }
log.info("invoke virtual device report,jobKey:{},deviceId:{}", jobKey, device.getDeviceId());
virtualManager.invokeReport(device);
}
diff --git a/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java b/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java
old mode 100644
new mode 100755
index a861de4b..06521559
--- a/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java
+++ b/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java
@@ -12,7 +12,7 @@ package cc.iotkit.virtualdevice;
import cc.iotkit.common.thing.ThingService;
import cc.iotkit.common.utils.JsonUtil;
import cc.iotkit.comps.service.DeviceBehaviourService;
-import cc.iotkit.dao.DeviceCache;
+import cc.iotkit.data.IDeviceInfoData;
import cc.iotkit.data.IVirtualDeviceData;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.device.VirtualDevice;
@@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import javax.annotation.PostConstruct;
import javax.script.ScriptEngineManager;
@@ -42,7 +43,8 @@ public class VirtualManager {
@Autowired
private IVirtualDeviceData virtualDeviceData;
@Autowired
- private DeviceCache deviceCache;
+ @Qualifier("deviceInfoDataCache")
+ private IDeviceInfoData deviceInfoData;
@Autowired
private Scheduler scheduler;
@Autowired
@@ -53,10 +55,15 @@ public class VirtualManager {
@PostConstruct
public void init() {
- List virtualDevices = getAllVirtualDevices();
- for (VirtualDevice virtualDevice : virtualDevices) {
- addTask(virtualDevice);
- }
+ new Timer().schedule(new TimerTask() {
+ @Override
+ public void run() {
+ List virtualDevices = getAllVirtualDevices();
+ for (VirtualDevice virtualDevice : virtualDevices) {
+ addTask(virtualDevice);
+ }
+ }
+ }, 8000);
}
/**
@@ -70,7 +77,7 @@ public class VirtualManager {
* 调用虚拟设备下发
*/
public void send(ThingService> service) {
- DeviceInfo deviceInfo = deviceCache.getDeviceInfo(service.getProductKey(), service.getDeviceName());
+ DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(service.getProductKey(), service.getDeviceName());
String deviceId = deviceInfo.getDeviceId();
//根据设备Id取虚拟设备列表
@@ -116,7 +123,7 @@ public class VirtualManager {
try {
Object scriptObj = engine.eval(String.format("new (function () {\n%s})()", virtualDevice.getScript()));
for (String deviceId : devices) {
- DeviceInfo device = deviceCache.get(deviceId);
+ DeviceInfo device = deviceInfoData.findByDeviceId(deviceId);
processReport(invokeMethod(scriptObj, "report", device));
}
} catch (Throwable e) {
@@ -157,7 +164,7 @@ public class VirtualManager {
virtualScripts.put(id, engine.eval(String.format("new (function () {\n%s})()", script)));
List devices = new ArrayList<>();
for (String deviceId : virtualDevice.getDevices()) {
- devices.add(deviceCache.get(deviceId));
+ devices.add(deviceInfoData.findByDeviceId(deviceId));
//更新deviceId的虚拟设备Id对应关系
Set virtualIds = deviceIdToVirtualId.getOrDefault(deviceId, new HashSet<>());
virtualIds.add(id);
diff --git a/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/config/VirtualConfig.java b/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/config/VirtualConfig.java
old mode 100644
new mode 100755
diff --git a/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/trigger/RandomScheduleBuilder.java b/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/trigger/RandomScheduleBuilder.java
old mode 100644
new mode 100755
diff --git a/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/trigger/RandomTrigger.java b/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/trigger/RandomTrigger.java
old mode 100644
new mode 100755
diff --git a/iot-virtual-device/src/main/resources/spring.factories b/iot-virtual-device/src/main/resources/spring.factories
old mode 100644
new mode 100755
diff --git a/pom.xml b/pom.xml
index 037409fd..3603f6a4 100755
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
cc.iotkit
iotkit-parent
- 0.3.3-SNAPSHOT
+ 0.4.0-SNAPSHOT
iotkit-parent
iotkit parent