diff --git a/.gitignore b/.gitignore
index 56586457..b1006f56 100755
--- a/.gitignore
+++ b/.gitignore
@@ -23,7 +23,6 @@ hs_err_pid*
.idea
target
*.iml
-*.yml
log
data/elasticsearch
.init
diff --git a/data/converters/6260396d67aced2696184053/converter.js b/data/converters/6260396d67aced2696184053/converter.js
index a2353f39..1aaba5cd 100644
--- a/data/converters/6260396d67aced2696184053/converter.js
+++ b/data/converters/6260396d67aced2696184053/converter.js
@@ -63,6 +63,30 @@ this.decode = function (msg) {
time: new Date().getTime(),
code: payload.code
};
+ }else if(topic.endsWith("/config/set_reply")){
+ //设备配置设置回复
+ return {
+ mid: msg.mid,
+ productKey: msg.productKey,
+ deviceName: msg.deviceName,
+ type:"config",
+ identifier: "set_reply",
+ occur: new Date().getTime(),
+ time: new Date().getTime(),
+ code: payload.code
+ };
+ }else if(topic.endsWith("/config/get")){
+ //设备配置获取
+ return {
+ mid: msg.mid,
+ productKey: msg.productKey,
+ deviceName: msg.deviceName,
+ type:"config",
+ identifier: "get",
+ occur: new Date().getTime(),
+ time: new Date().getTime(),
+ data: {},
+ };
} else if (topic.endsWith("_reply")) {
//服务回复
return {
@@ -119,7 +143,12 @@ this.encode = function (service,device) {
}else if(type=="service"){
method+=identifier;
topic+=identifier;
+ }else if(type=="config"){
+ //设备配置下发
+ method+=identifier;
+ topic="/sys/"+service.productKey+"/"+service.deviceName+"/c/config/"+identifier;
}
+
for(var p in service.params){
params[p]=service.params[p];
}
diff --git a/iot-auth-server/pom.xml b/iot-auth-server/pom.xml
index 37c7953a..fb3111e3 100644
--- a/iot-auth-server/pom.xml
+++ b/iot-auth-server/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.1-SNAPSHOT
+ 0.3.2-SNAPSHOT
4.0.0
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
index 6cd9de0c..324c2e8f 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.oauth.controller;
import cc.iotkit.common.utils.JsonUtil;
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
index 1a266abb..a9fc09fc 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.oauth.service;
import cc.iotkit.common.Constants;
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
index 2ce9bd51..8294a72f 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.oauth.service;
import cc.iotkit.dao.UserInfoCache;
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
index 36190895..547090e4 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.oauth.vo;
import lombok.AllArgsConstructor;
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
index 06ed14bd..f7fdfe73 100644
--- a/iot-auth-server/src/main/java/cc/iotkit/utils/SoMap.java
+++ b/iot-auth-server/src/main/java/cc/iotkit/utils/SoMap.java
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.utils;
import java.lang.reflect.Field;
diff --git a/iot-common/pom.xml b/iot-common/pom.xml
index e1889e96..0904079d 100644
--- a/iot-common/pom.xml
+++ b/iot-common/pom.xml
@@ -5,7 +5,7 @@
iotkit-parent
cc.iotkit
- 0.3.1-SNAPSHOT
+ 0.3.2-SNAPSHOT
4.0.0
diff --git a/iot-common/src/main/java/cc/iotkit/common/Constants.java b/iot-common/src/main/java/cc/iotkit/common/Constants.java
index a48292f4..b8af04ab 100644
--- a/iot-common/src/main/java/cc/iotkit/common/Constants.java
+++ b/iot-common/src/main/java/cc/iotkit/common/Constants.java
@@ -74,6 +74,21 @@ public interface Constants {
*/
String THING_MODEL_MESSAGE_TOPIC = "device_thing";
+ /**
+ * 设备属性上报消息的topic
+ */
+ String DEVICE_PROPERTY_REPORT_TOPIC = "device_property_report";
+
+ /**
+ * 不含消息内容的设备上报记录的topic,用于统计
+ */
+ String DEVICE_REPORT_RECORD_TOPIC = "device_report_record";
+
+ /**
+ * 设备配置消息topic
+ */
+ String DEVICE_CONFIG_TOPIC = "device_config";
+
/**
* http消费设备信息的topic
*/
@@ -102,7 +117,7 @@ public interface Constants {
/**
* 三方平台openUid名称
*/
- enum ThirdOpenUid{
+ enum ThirdOpenUid {
duerosOpenUid("小度OpenUid"),
aligenieOpenUid("天猫精灵OpenUid"),
miiotOpenUid("小爱OpenUid");
@@ -191,7 +206,7 @@ public interface Constants {
String SET_OPEN_UID = "/setOpenUid";
}
- interface MQTT {
+ interface MQTT {
String DEVICE_SUBSCRIBE_TOPIC = "^/sys/.+/.+/c/#$";
}
}
diff --git a/iot-components/iot-component-base/pom.xml b/iot-components/iot-component-base/pom.xml
index 74b0a514..a36620e9 100644
--- 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.1-SNAPSHOT
+ 0.3.2-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
index 9a572914..07559f25 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comp;
import cc.iotkit.comp.model.AuthInfo;
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
index 8cc058af..ca7c960f 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comp;
import cc.iotkit.comp.model.AuthInfo;
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
index 3553337a..14d99ae4 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comp.utils;
import org.springframework.aop.framework.AopContext;
diff --git a/iot-components/iot-component-converter/pom.xml b/iot-components/iot-component-converter/pom.xml
index 9081ef3e..d6239425 100644
--- 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.1-SNAPSHOT
+ 0.3.2-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
index e8e5e712..e5d30661 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.converter;
import lombok.AllArgsConstructor;
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
index a5f3ce66..4967109c 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.converter;
import lombok.Data;
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
index 4281e3b0..361cf611 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.converter;
import cc.iotkit.common.thing.ThingService;
diff --git a/iot-components/iot-component-server/pom.xml b/iot-components/iot-component-server/pom.xml
index fd6e9792..f6ed763a 100644
--- 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.1-SNAPSHOT
+ 0.3.2-SNAPSHOT
4.0.0
@@ -92,6 +92,11 @@
iot-message-bus
+
+ cc.iotkit
+ iot-device-dao
+
+
\ No newline at end of file
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
index c2300535..54f2bcc4 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comps;
import cc.iotkit.common.Constants;
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
index 3d3a9113..09d98e13 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comps;
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
index 1827c632..653122f3 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comps;
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
index dc7c02fe..f3a25f97 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comps;
import cc.iotkit.common.exception.BizException;
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
index 51134a0e..2050443b 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comps;
import cc.iotkit.comp.IComponent;
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
index b8f0ffa2..489e2003 100644
--- 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
@@ -1,5 +1,6 @@
package cc.iotkit.comps.config;
+import cc.iotkit.model.device.message.DeviceReport;
import cc.iotkit.model.device.message.ThingModelMessage;
import cc.iotkit.mq.MqConsumer;
import cc.iotkit.mq.MqProducer;
@@ -53,4 +54,13 @@ public class ComponentConfig {
return new VertxMqConsumer<>(ThingModelMessage.class);
}
+ @Bean("deviceReportProducer")
+ public MqProducer getDeviceReportProducer() {
+ return new VertxMqProducer<>(DeviceReport.class);
+ }
+
+ @Bean("deviceReportConsumer")
+ public MqConsumer getDeviceReportConsumer() {
+ return new VertxMqConsumer<>(DeviceReport.class);
+ }
}
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
index 820c334b..668786e7 100644
--- 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
@@ -1,3 +1,12 @@
+/*
+ * +----------------------------------------------------------------------
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
+ * +----------------------------------------------------------------------
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
+ * +----------------------------------------------------------------------
+ * | Author: xw2sy@163.com
+ * +----------------------------------------------------------------------
+ */
package cc.iotkit.comps.service;
import cc.iotkit.common.Constants;
@@ -194,11 +203,9 @@ public class DeviceBehaviourService {
if (online) {
device.getState().setOnline(true);
device.getState().setOnlineTime(System.currentTimeMillis());
-// deviceStateHolder.online(device.getDeviceId());
} else {
device.getState().setOnline(false);
device.getState().setOfflineTime(System.currentTimeMillis());
-// deviceStateHolder.offline(device.getDeviceId());
}
deviceInfoRepository.save(device);
diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigService.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigService.java
new file mode 100644
index 00000000..ab224b75
--- /dev/null
+++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceConfigService.java
@@ -0,0 +1,75 @@
+/*
+ * +----------------------------------------------------------------------
+ * | 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.thing.ThingService;
+import cc.iotkit.common.utils.JsonUtil;
+import cc.iotkit.comps.DeviceComponentManager;
+import cc.iotkit.dao.DeviceConfigRepository;
+import cc.iotkit.model.device.DeviceConfig;
+import cc.iotkit.model.device.message.ThingModelMessage;
+import cc.iotkit.mq.ConsumerHandler;
+import cc.iotkit.mq.MqConsumer;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.Map;
+
+/**
+ * 设备配置服务
+ */
+@Slf4j
+@Service
+public class DeviceConfigService implements ConsumerHandler {
+
+ @Autowired
+ private MqConsumer configMessageConsumer;
+
+ @Autowired
+ public DeviceComponentManager deviceComponentManager;
+
+ @Autowired
+ private DeviceConfigRepository deviceConfigRepository;
+
+ @PostConstruct
+ public void init() {
+ configMessageConsumer.consume(Constants.DEVICE_CONFIG_TOPIC, this);
+ }
+
+ @Override
+ public void handler(ThingModelMessage msg) {
+ try {
+ String identifier = msg.getIdentifier();
+ if (ThingModelMessage.ID_CONFIG_GET.equals(identifier)) {
+ //收到设备获取配置消息,回复配置信息给设备
+ DeviceConfig deviceConfig = deviceConfigRepository.findByDeviceId(msg.getDeviceId());
+ if (deviceConfig == null) {
+ return;
+ }
+
+ Map config = JsonUtil.parse(deviceConfig.getConfig(), Map.class);
+ ThingService