关系数据库存储实现
0
data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/iot-mqtt-component-0.3.1-SNAPSHOT.jar
Normal file → Executable file
|
@ -1,13 +1,13 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id": "iotkit",
|
"clientId": "iotkit",
|
||||||
"name": "奇特物联",
|
"name": "奇特物联",
|
||||||
"clientSecret": "b86cb53d-c005-48a3-bb02-3c262151b68c",
|
"clientSecret": "b86cb53d-c005-48a3-bb02-3c262151b68c",
|
||||||
"allowUrl": "*",
|
"allowUrl": "*",
|
||||||
"createAt": 1652840868485
|
"createAt": 1652840868485
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "dueros",
|
"clientId": "dueros",
|
||||||
"name": "小度音箱",
|
"name": "小度音箱",
|
||||||
"clientSecret": "750c67c2-29cb-40c3-bf4d-c0b9bf3eed88",
|
"clientSecret": "750c67c2-29cb-40c3-bf4d-c0b9bf3eed88",
|
||||||
"allowUrl": "*",
|
"allowUrl": "*",
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
|
"jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
|
||||||
"config": "{\"port\":\"8086\"}",
|
"config": "{\"port\":\"8086\"}",
|
||||||
"converter": "6260396d67aced2696184053",
|
"converter": "6260396d67aced2696184053",
|
||||||
"state": "running",
|
"state": "stopped",
|
||||||
"createAt": 1652238780184
|
"createAt": 1652238780184
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
"jarFile": "emqx-component-0.2.1-SNAPSHOT.jar",
|
"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\"}",
|
"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",
|
"converter": "6260396d67aced2696184053",
|
||||||
"state": "running",
|
"state": "stopped",
|
||||||
"createAt": 1653180468724
|
"createAt": 1653180468724
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
"jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
|
"jarFile": "http-biz-component-0.1.0-SNAPSHOT.jar",
|
||||||
"config": "{\"port\":\"8084\"}",
|
"config": "{\"port\":\"8084\"}",
|
||||||
"converter": "",
|
"converter": "",
|
||||||
"state": "running",
|
"state": "stopped",
|
||||||
"createAt": 1650685502665
|
"createAt": 1650685502665
|
||||||
}
|
}
|
||||||
]
|
]
|
Before Width: | Height: | Size: 317 KiB After Width: | Height: | Size: 317 KiB |
Before Width: | Height: | Size: 497 KiB After Width: | Height: | Size: 497 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iotkit-parent</artifactId>
|
<artifactId>iotkit-parent</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
24
iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthClientController.java
Normal file → Executable file
|
@ -1,10 +1,19 @@
|
||||||
|
/*
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Author: xw2sy@163.com
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
package cc.iotkit.oauth.controller;
|
package cc.iotkit.oauth.controller;
|
||||||
|
|
||||||
import cc.iotkit.common.Constants;
|
import cc.iotkit.common.Constants;
|
||||||
import cc.iotkit.common.utils.CodecUtil;
|
import cc.iotkit.common.utils.CodecUtil;
|
||||||
import cc.iotkit.common.utils.ReflectUtil;
|
import cc.iotkit.common.utils.ReflectUtil;
|
||||||
import cc.iotkit.dao.OauthClientCache;
|
import cc.iotkit.data.IOauthClientData;
|
||||||
import cc.iotkit.dao.UserInfoCache;
|
import cc.iotkit.data.IUserInfoData;
|
||||||
import cc.iotkit.model.OauthClient;
|
import cc.iotkit.model.OauthClient;
|
||||||
import cc.iotkit.model.UserInfo;
|
import cc.iotkit.model.UserInfo;
|
||||||
import cc.iotkit.oauth.vo.UserInfoVo;
|
import cc.iotkit.oauth.vo.UserInfoVo;
|
||||||
|
@ -16,6 +25,7 @@ import com.ejlchina.okhttps.OkHttps;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cglib.beans.BeanMap;
|
import org.springframework.cglib.beans.BeanMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -36,16 +46,18 @@ public class AuthClientController {
|
||||||
private String serverUrl;
|
private String serverUrl;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OauthClientCache oauthClientCache;
|
@Qualifier("oauthClientDataCache")
|
||||||
|
private IOauthClientData oauthClientData;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserInfoCache userInfoCache;
|
@Qualifier("userInfoDataCache")
|
||||||
|
private IUserInfoData userInfoData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据Code码进行登录,获取 Access-Token 和 用户信息
|
* 根据Code码进行登录,获取 Access-Token 和 用户信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/codeLogin")
|
@RequestMapping("/codeLogin")
|
||||||
public SaResult codeLogin(String code, String clientId) {
|
public SaResult codeLogin(String code, String clientId) {
|
||||||
OauthClient oauthClient = oauthClientCache.getClient(clientId);
|
OauthClient oauthClient = oauthClientData.findByClientId(clientId);
|
||||||
if (oauthClient == null) {
|
if (oauthClient == null) {
|
||||||
return SaResult.error("clientId does not exist");
|
return SaResult.error("clientId does not exist");
|
||||||
}
|
}
|
||||||
|
@ -117,7 +129,7 @@ public class AuthClientController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserInfoVo getUserInfo(String uid) {
|
private UserInfoVo getUserInfo(String uid) {
|
||||||
UserInfo userInfo = userInfoCache.getUserInfo(uid);
|
UserInfo userInfo = userInfoData.findById(uid);
|
||||||
UserInfoVo userVo = new UserInfoVo();
|
UserInfoVo userVo = new UserInfoVo();
|
||||||
ReflectUtil.copyNoNulls(userInfo, userVo);
|
ReflectUtil.copyNoNulls(userInfo, userVo);
|
||||||
return userVo;
|
return userVo;
|
||||||
|
|
0
iot-auth-server/src/main/java/cc/iotkit/oauth/controller/AuthServerController.java
Normal file → Executable file
8
iot-auth-server/src/main/java/cc/iotkit/oauth/service/SaOAuth2TemplateImpl.java
Normal file → Executable file
|
@ -11,25 +11,27 @@ package cc.iotkit.oauth.service;
|
||||||
|
|
||||||
import cc.iotkit.common.Constants;
|
import cc.iotkit.common.Constants;
|
||||||
import cc.iotkit.common.utils.CodecUtil;
|
import cc.iotkit.common.utils.CodecUtil;
|
||||||
import cc.iotkit.dao.OauthClientCache;
|
import cc.iotkit.data.IOauthClientData;
|
||||||
import cc.iotkit.model.OauthClient;
|
import cc.iotkit.model.OauthClient;
|
||||||
import cn.dev33.satoken.oauth2.logic.SaOAuth2Template;
|
import cn.dev33.satoken.oauth2.logic.SaOAuth2Template;
|
||||||
import cn.dev33.satoken.oauth2.model.SaClientModel;
|
import cn.dev33.satoken.oauth2.model.SaClientModel;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SaOAuth2TemplateImpl extends SaOAuth2Template {
|
public class SaOAuth2TemplateImpl extends SaOAuth2Template {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OauthClientCache oauthClientCache;
|
@Qualifier("oauthClientDataCache")
|
||||||
|
private IOauthClientData oauthClientData;
|
||||||
|
|
||||||
// 根据 id 获取 Client 信息
|
// 根据 id 获取 Client 信息
|
||||||
@Override
|
@Override
|
||||||
public SaClientModel getClientModel(String clientId) {
|
public SaClientModel getClientModel(String clientId) {
|
||||||
OauthClient client = oauthClientCache.getClient(clientId);
|
OauthClient client = oauthClientData.findByClientId(clientId);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
10
iot-auth-server/src/main/java/cc/iotkit/oauth/service/StpInterfaceImpl.java
Normal file → Executable file
|
@ -9,10 +9,11 @@
|
||||||
*/
|
*/
|
||||||
package cc.iotkit.oauth.service;
|
package cc.iotkit.oauth.service;
|
||||||
|
|
||||||
import cc.iotkit.dao.UserInfoCache;
|
import cc.iotkit.data.IUserInfoData;
|
||||||
import cc.iotkit.model.UserInfo;
|
import cc.iotkit.model.UserInfo;
|
||||||
import cn.dev33.satoken.stp.StpInterface;
|
import cn.dev33.satoken.stp.StpInterface;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -21,14 +22,15 @@ import java.util.List;
|
||||||
public class StpInterfaceImpl implements StpInterface {
|
public class StpInterfaceImpl implements StpInterface {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserInfoCache userInfoCache;
|
@Qualifier("userInfoDataCache")
|
||||||
|
private IUserInfoData userInfoData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回一个账号所拥有的权限码集合
|
* 返回一个账号所拥有的权限码集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||||
UserInfo userInfo = userInfoCache.getUserInfo(loginId.toString());
|
UserInfo userInfo = userInfoData.findById(loginId.toString());
|
||||||
return userInfo.getPermissions();
|
return userInfo.getPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +39,7 @@ public class StpInterfaceImpl implements StpInterface {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getRoleList(Object loginId, String loginType) {
|
public List<String> getRoleList(Object loginId, String loginType) {
|
||||||
UserInfo userInfo = userInfoCache.getUserInfo(loginId.toString());
|
UserInfo userInfo = userInfoData.findById(loginId.toString());
|
||||||
return userInfo.getRoles();
|
return userInfo.getRoles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
iot-auth-server/src/main/java/cc/iotkit/oauth/service/TokenRequestHandler.java
Normal file → Executable file
|
@ -1,3 +1,12 @@
|
||||||
|
/*
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Author: xw2sy@163.com
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
package cc.iotkit.oauth.service;
|
package cc.iotkit.oauth.service;
|
||||||
|
|
||||||
import cn.dev33.satoken.context.SaHolder;
|
import cn.dev33.satoken.context.SaHolder;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iotkit-parent</artifactId>
|
<artifactId>iotkit-parent</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
@ -15,21 +15,21 @@ public interface Constants {
|
||||||
|
|
||||||
String ACCOUNT_SECRET = "3n1z33kzvpgz1foijpkepyd3e8tw84us";
|
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 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";
|
String WECHAT_APP_ID = "wx791cb7bf75950e0c";
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public interface Constants {
|
||||||
|
|
||||||
String APP_DESIGN_CACHE = "app_design_cache";
|
String APP_DESIGN_CACHE = "app_design_cache";
|
||||||
|
|
||||||
String PRODUCT_SCRIPT_CACHE = "product_script_cache";
|
String CACHE_PRODUCT_SCRIPT = "product_script_cache";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理员角色
|
* 管理员角色
|
||||||
|
|
0
iot-common/src/main/java/cc/iotkit/common/exception/BizException.java
Normal file → Executable file
0
iot-common/src/main/java/cc/iotkit/common/exception/NotFoundException.java
Normal file → Executable file
0
iot-common/src/main/java/cc/iotkit/common/exception/OfflineException.java
Normal file → Executable file
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iot-components</artifactId>
|
<artifactId>iot-components</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/AbstractDeviceComponent.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/CompConfig.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IComponent.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IDeviceComponent.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IMessageHandler.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/AuthInfo.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/DeviceState.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/ReceiveResult.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/model/RegisterInfo.java
Normal file → Executable file
0
iot-components/iot-component-base/src/main/java/cc/iotkit/comp/utils/SpringUtils.java
Normal file → Executable file
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iot-components</artifactId>
|
<artifactId>iot-components</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
0
iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/Device.java
Normal file → Executable file
0
iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/DeviceMessage.java
Normal file → Executable file
0
iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/IConverter.java
Normal file → Executable file
0
iot-components/iot-component-converter/src/main/java/cc/iotkit/converter/ScriptConverter.java
Normal file → Executable file
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iot-components</artifactId>
|
<artifactId>iot-components</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ApiTool.java
Normal file → Executable file
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/BizComponentManager.java
Normal file → Executable file
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/ComponentManager.java
Normal file → Executable file
21
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java
Normal file → Executable file
|
@ -23,8 +23,8 @@ import cc.iotkit.converter.Device;
|
||||||
import cc.iotkit.converter.DeviceMessage;
|
import cc.iotkit.converter.DeviceMessage;
|
||||||
import cc.iotkit.converter.ScriptConverter;
|
import cc.iotkit.converter.ScriptConverter;
|
||||||
import cc.iotkit.common.thing.ThingService;
|
import cc.iotkit.common.thing.ThingService;
|
||||||
import cc.iotkit.dao.DeviceCache;
|
import cc.iotkit.data.IDeviceInfoData;
|
||||||
import cc.iotkit.dao.ProductCache;
|
import cc.iotkit.data.IProductData;
|
||||||
import cc.iotkit.data.IProtocolComponentData;
|
import cc.iotkit.data.IProtocolComponentData;
|
||||||
import cc.iotkit.model.device.DeviceInfo;
|
import cc.iotkit.model.device.DeviceInfo;
|
||||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||||
|
@ -34,6 +34,7 @@ import cc.iotkit.model.protocol.ProtocolConverter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -62,25 +63,27 @@ public class DeviceComponentManager {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IProtocolComponentData protocolComponentData;
|
private IProtocolComponentData protocolComponentData;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceCache deviceCache;
|
@Qualifier("productDataCache")
|
||||||
|
IProductData productData;
|
||||||
@Autowired
|
@Autowired
|
||||||
ProductCache productCache;
|
@Qualifier("deviceInfoDataCache")
|
||||||
|
private IDeviceInfoData deviceInfoData;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRouter deviceRouter;
|
private DeviceRouter deviceRouter;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
try {
|
|
||||||
List<ProtocolComponent> componentList = protocolComponentData.findByStateAndType(
|
List<ProtocolComponent> componentList = protocolComponentData.findByStateAndType(
|
||||||
ProtocolComponent.STATE_RUNNING, ProtocolComponent.TYPE_DEVICE);
|
ProtocolComponent.STATE_RUNNING, ProtocolComponent.TYPE_DEVICE);
|
||||||
for (ProtocolComponent component : componentList) {
|
for (ProtocolComponent component : componentList) {
|
||||||
|
try {
|
||||||
register(component);
|
register(component);
|
||||||
start(component.getId());
|
start(component.getId());
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("init protocol components error", e);
|
log.error("init protocol components error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void register(ProtocolComponent component) {
|
public void register(ProtocolComponent component) {
|
||||||
String id = component.getId();
|
String id = component.getId();
|
||||||
|
@ -170,14 +173,14 @@ public class DeviceComponentManager {
|
||||||
throw new BizException("there is no components");
|
throw new BizException("there is no components");
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceInfo deviceInfo = deviceCache.getDeviceInfo(service.getProductKey(), service.getDeviceName());
|
DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(service.getProductKey(), service.getDeviceName());
|
||||||
Product product = productCache.findById(service.getProductKey());
|
Product product = productData.findById(service.getProductKey());
|
||||||
String linkPk = service.getProductKey();
|
String linkPk = service.getProductKey();
|
||||||
String linkDn = service.getDeviceName();
|
String linkDn = service.getDeviceName();
|
||||||
|
|
||||||
if (product.isTransparent()) {
|
if (product.isTransparent()) {
|
||||||
//如果是透传设备,取父级设备进行链路查找
|
//如果是透传设备,取父级设备进行链路查找
|
||||||
DeviceInfo parent = deviceCache.get(deviceInfo.getParentId());
|
DeviceInfo parent = deviceInfoData.findByDeviceId(deviceInfo.getParentId());
|
||||||
linkPk = parent.getProductKey();
|
linkPk = parent.getProductKey();
|
||||||
linkDn = parent.getDeviceName();
|
linkDn = parent.getDeviceName();
|
||||||
}
|
}
|
||||||
|
|
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java
Normal file → Executable file
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceRouter.java
Normal file → Executable file
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/config/CacheKey.java
Normal file → Executable file
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/config/ComponentConfig.java
Normal file → Executable file
21
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java
Normal file → Executable file
|
@ -16,7 +16,6 @@ import cc.iotkit.common.utils.JsonUtil;
|
||||||
import cc.iotkit.common.utils.UniqueIdUtil;
|
import cc.iotkit.common.utils.UniqueIdUtil;
|
||||||
import cc.iotkit.comp.model.DeviceState;
|
import cc.iotkit.comp.model.DeviceState;
|
||||||
import cc.iotkit.comp.model.RegisterInfo;
|
import cc.iotkit.comp.model.RegisterInfo;
|
||||||
import cc.iotkit.dao.*;
|
|
||||||
import cc.iotkit.data.IDeviceInfoData;
|
import cc.iotkit.data.IDeviceInfoData;
|
||||||
import cc.iotkit.data.IProductModelData;
|
import cc.iotkit.data.IProductModelData;
|
||||||
import cc.iotkit.data.IProductData;
|
import cc.iotkit.data.IProductData;
|
||||||
|
@ -28,6 +27,7 @@ import cc.iotkit.mq.MqProducer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -41,14 +41,12 @@ public class DeviceBehaviourService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IProductModelData productModelData;
|
private IProductModelData productModelData;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductCache productCache;
|
@Qualifier("deviceInfoDataCache")
|
||||||
@Autowired
|
|
||||||
private IDeviceInfoData deviceInfoData;
|
private IDeviceInfoData deviceInfoData;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceCache deviceCache;
|
|
||||||
@Autowired
|
|
||||||
private MqProducer<ThingModelMessage> producer;
|
private MqProducer<ThingModelMessage> producer;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Qualifier("productDataCache")
|
||||||
private IProductData productData;
|
private IProductData productData;
|
||||||
|
|
||||||
public void register(RegisterInfo info) {
|
public void register(RegisterInfo info) {
|
||||||
|
@ -187,13 +185,16 @@ public class DeviceBehaviourService {
|
||||||
}
|
}
|
||||||
deviceStateChange(device, online);
|
deviceStateChange(device, online);
|
||||||
|
|
||||||
|
//父设备ID不为空说明是子设备
|
||||||
if (device.getParentId() != null) {
|
if (device.getParentId() != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DeviceInfo> subDevices = deviceInfoData.findByParentId(device.getDeviceId());
|
//否则为父设备,同步透传子设备状态
|
||||||
for (DeviceInfo subDevice : subDevices) {
|
List<String> subDeviceIds = deviceInfoData.findSubDeviceIds(device.getDeviceId());
|
||||||
Product product = productCache.findById(subDevice.getProductKey());
|
for (String subDeviceId : subDeviceIds) {
|
||||||
|
DeviceInfo subDevice=deviceInfoData.findByDeviceId(subDeviceId);
|
||||||
|
Product product = productData.findById(subDevice.getProductKey());
|
||||||
Boolean transparent = product.getTransparent();
|
Boolean transparent = product.getTransparent();
|
||||||
//透传设备父设备上线,子设备也上线。非透传设备父设备离线,子设备才离线
|
//透传设备父设备上线,子设备也上线。非透传设备父设备离线,子设备才离线
|
||||||
if (transparent != null && transparent || !online) {
|
if (transparent != null && transparent || !online) {
|
||||||
|
@ -229,8 +230,8 @@ public class DeviceBehaviourService {
|
||||||
|
|
||||||
public void reportMessage(ThingModelMessage message) {
|
public void reportMessage(ThingModelMessage message) {
|
||||||
try {
|
try {
|
||||||
DeviceInfo device = deviceCache.getDeviceInfo(message.getProductKey(),
|
DeviceInfo device = deviceInfoData.findByProductKeyAndDeviceName(
|
||||||
message.getDeviceName());
|
message.getProductKey(), message.getDeviceName());
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigConsumer.java
Normal file → Executable file
0
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceMessageConsumer.java
Normal file → Executable file
16
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java
Normal file → Executable file
|
@ -1,10 +1,18 @@
|
||||||
|
/*
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Author: xw2sy@163.com
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
package cc.iotkit.comps.service;
|
package cc.iotkit.comps.service;
|
||||||
|
|
||||||
import cc.iotkit.common.Constants;
|
import cc.iotkit.common.Constants;
|
||||||
import cc.iotkit.common.utils.JsonUtil;
|
import cc.iotkit.common.utils.JsonUtil;
|
||||||
import cc.iotkit.dao.DeviceDao;
|
import cc.iotkit.dao.DeviceDao;
|
||||||
import cc.iotkit.data.IDeviceInfoData;
|
import cc.iotkit.data.IDeviceInfoData;
|
||||||
import cc.iotkit.data.cache.DeviceCacheService;
|
|
||||||
import cc.iotkit.model.device.message.DeviceProperty;
|
import cc.iotkit.model.device.message.DeviceProperty;
|
||||||
import cc.iotkit.model.device.message.ThingModelMessage;
|
import cc.iotkit.model.device.message.ThingModelMessage;
|
||||||
import cc.iotkit.mq.ConsumerHandler;
|
import cc.iotkit.mq.ConsumerHandler;
|
||||||
|
@ -12,6 +20,7 @@ import cc.iotkit.mq.MqConsumer;
|
||||||
import cc.iotkit.temporal.IDevicePropertyData;
|
import cc.iotkit.temporal.IDevicePropertyData;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
@ -33,9 +42,8 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDevicePropertyData devicePropertyData;
|
private IDevicePropertyData devicePropertyData;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Qualifier("deviceInfoDataCache")
|
||||||
private IDeviceInfoData deviceInfoData;
|
private IDeviceInfoData deviceInfoData;
|
||||||
@Autowired
|
|
||||||
private DeviceCacheService deviceCacheService;
|
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -81,7 +89,7 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
|
||||||
private void updateDeviceCurrentProperties(String deviceId, Map<String, Object> properties) {
|
private void updateDeviceCurrentProperties(String deviceId, Map<String, Object> properties) {
|
||||||
try {
|
try {
|
||||||
log.info("save device property,deviceId:{},property:{}", deviceId, JsonUtil.toJsonString(properties));
|
log.info("save device property,deviceId:{},property:{}", deviceId, JsonUtil.toJsonString(properties));
|
||||||
deviceCacheService.saveProperties(deviceId, properties);
|
deviceInfoData.saveProperties(deviceId, properties);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("save device current properties error", e);
|
log.error("save device current properties error", e);
|
||||||
}
|
}
|
||||||
|
|
0
iot-components/iot-ctwing-component/lib/ag-sdk-biz-84356.tar.gz-20220603.182201-SNAPSHOT.jar
Normal file → Executable file
0
iot-components/iot-ctwing-component/lib/ctg-ag-sdk-core-2.5.0-20220512.061430-51.jar
Normal file → Executable file
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iot-components</artifactId>
|
<artifactId>iot-components</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>11</source>
|
||||||
<target>8</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
0
iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingConfig.java
Normal file → Executable file
9
iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/CtwingDeviceComponent.java
Normal file → Executable file
|
@ -1,3 +1,12 @@
|
||||||
|
/*
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Author: xw2sy@163.com
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
package cc.iotkit.comp.http;
|
package cc.iotkit.comp.http;
|
||||||
|
|
||||||
import cc.iotkit.common.exception.BizException;
|
import cc.iotkit.common.exception.BizException;
|
||||||
|
|
9
iot-components/iot-ctwing-component/src/main/java/cc/iotkit/comp/http/ProtocolUtil.java
Normal file → Executable file
|
@ -1,3 +1,12 @@
|
||||||
|
/*
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Licensed 未经许可不能去掉「奇特物联」相关版权
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Author: xw2sy@163.com
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
package cc.iotkit.comp.http;
|
package cc.iotkit.comp.http;
|
||||||
|
|
||||||
import cc.iotkit.common.utils.HexUtil;
|
import cc.iotkit.common.utils.HexUtil;
|
||||||
|
|
0
iot-components/iot-ctwing-component/src/main/resources/component.spi
Normal file → Executable file
|
@ -3,7 +3,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iot-components</artifactId>
|
<artifactId>iot-components</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>iot-emqx-component</artifactId>
|
<artifactId>iot-emqx-component</artifactId>
|
||||||
|
@ -48,8 +48,8 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>11</source>
|
||||||
<target>8</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -82,25 +82,25 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<artifactId>iot-model</artifactId>
|
<artifactId>iot-model</artifactId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<artifactId>iot-dao</artifactId>
|
<artifactId>iot-dao</artifactId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<artifactId>iot-common</artifactId>
|
<artifactId>iot-common</artifactId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<artifactId>iot-component-base</artifactId>
|
<artifactId>iot-component-base</artifactId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>iot-components</artifactId>
|
<artifactId>iot-components</artifactId>
|
||||||
<groupId>cc.iotkit</groupId>
|
<groupId>cc.iotkit</groupId>
|
||||||
<version>0.3.3-SNAPSHOT</version>
|
<version>0.4.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -105,8 +105,8 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>11</source>
|
||||||
<target>8</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|