feat:迁移plugin-core到iot-core
parent
ef0de940f1
commit
1fcf5035dc
|
@ -5,9 +5,9 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>iot-data-model</artifactId>
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<artifactId>iot-data-service</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<artifactId>iot-data-serviceImpl-cache</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>iot-data-serviceImpl-rdb</artifactId>
|
||||
<description>
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<artifactId>iot-temporal-service</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<artifactId>iot-temporal-serviceImpl-td</artifactId>
|
||||
|
||||
<description>
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
<parent>
|
||||
<artifactId>iot-dao</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<artifactId>iot-temporal-serviceImpl-ts</artifactId>
|
||||
|
||||
<description>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iotkit-parent</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-module</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import cc.iotkit.common.enums.ErrCode;
|
|||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.common.utils.file.FileUtils;
|
||||
import cc.iotkit.data.manager.IPluginInfoData;
|
||||
import cc.iotkit.manager.dto.bo.plugin.PluginInfoBo;
|
||||
import cc.iotkit.manager.dto.vo.plugin.PluginInfoVo;
|
||||
|
@ -20,14 +19,11 @@ import com.gitee.starblues.integration.operator.PluginOperator;
|
|||
import com.gitee.starblues.integration.operator.upload.UploadParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.jar.JarEntry;
|
||||
|
@ -53,11 +49,15 @@ public class PluginServiceImpl implements IPluginService {
|
|||
public void upload(MultipartFile file, Long id) {
|
||||
try {
|
||||
PluginInfo plugin = pluginInfoData.findById(id);
|
||||
if (plugin == null) {
|
||||
if (file == null || plugin == null) {
|
||||
throw new BizException(ErrCode.DATA_NOT_EXIST);
|
||||
}
|
||||
String pluginId = plugin.getPluginId();
|
||||
|
||||
if (!file.getName().contains(pluginId)) {
|
||||
throw new BizException(ErrCode.PLUGIN_INSTALL_FAILED, "文件名与原插件id不匹配");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(pluginId)) {
|
||||
//停止卸载旧的插件
|
||||
com.gitee.starblues.core.PluginInfo pluginInfo = pluginOperator.getPluginInfo(pluginId);
|
||||
|
@ -78,11 +78,12 @@ public class PluginServiceImpl implements IPluginService {
|
|||
throw new BizException(ErrCode.PLUGIN_INSTALL_FAILED);
|
||||
}
|
||||
|
||||
JarFile jarFile = new JarFile(pluginInfo.getPluginPath());
|
||||
String configJson = "";
|
||||
String script = "";
|
||||
try (JarFile jarFile = new JarFile(pluginInfo.getPluginPath())) {
|
||||
// 获取config文件在jar包中的路径
|
||||
String configFile = "classes/config.json";
|
||||
JarEntry configEntry = jarFile.getJarEntry(configFile);
|
||||
String configJson = "";
|
||||
|
||||
if (configEntry != null) {
|
||||
//读取配置文件
|
||||
|
@ -93,12 +94,12 @@ public class PluginServiceImpl implements IPluginService {
|
|||
//读取script.js脚本
|
||||
String scriptFile = "classes/script.js";
|
||||
JarEntry scriptEntity = jarFile.getJarEntry(scriptFile);
|
||||
String script = "";
|
||||
if (scriptEntity != null) {
|
||||
//读取脚本文件
|
||||
script = IoUtil.read(jarFile.getInputStream(scriptEntity), Charset.defaultCharset());
|
||||
log.info("script:{}", script);
|
||||
}
|
||||
}
|
||||
|
||||
PluginState pluginState = pluginInfo.getPluginState();
|
||||
if (pluginState == PluginState.STARTED) {
|
||||
|
@ -113,6 +114,8 @@ public class PluginServiceImpl implements IPluginService {
|
|||
plugin.setVersion(pluginDescriptor.getPluginVersion());
|
||||
plugin.setDescription(pluginDescriptor.getDescription());
|
||||
pluginInfoData.save(plugin);
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new BizException(ErrCode.PLUGIN_INSTALL_FAILED, e);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-module</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
|
|||
@Slf4j
|
||||
@Component
|
||||
public class DingTalkEventListener implements MessageEventListener {
|
||||
WebClient client = WebClient.create(VertxManager.INSTANCE.getVertx());
|
||||
|
||||
@Override
|
||||
@EventListener(classes = MessageEvent.class, condition = "#event.message.channel=='DingTalk'")
|
||||
|
@ -27,13 +28,14 @@ public class DingTalkEventListener implements MessageEventListener {
|
|||
String channelConfig = message.getChannelConfig();
|
||||
DingTalkConfig dingTalkConfig = JsonUtils.parse(channelConfig, DingTalkConfig.class);
|
||||
|
||||
WebClient client = WebClient.create(VertxManager.INSTANCE.getVertx());
|
||||
DingTalkMessage qyWechatMessage = DingTalkMessage.builder()
|
||||
.msgtype("text")
|
||||
.text(DingTalkMessage.MessageContent.builder().content(message.getFormatContent()).build())
|
||||
.build();
|
||||
client.post(dingTalkConfig.getDingTalkWebhook()).sendJson(qyWechatMessage)
|
||||
|
||||
client.getAbs(dingTalkConfig.getDingTalkWebhook()).sendJson(qyWechatMessage)
|
||||
.onSuccess(response -> log.info("Received response with status code" + response.statusCode()))
|
||||
.onFailure(err -> log.error("Something went wrong " + err.getMessage()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
|
|||
@Slf4j
|
||||
@Component
|
||||
public class QyWechatEventListener implements MessageEventListener {
|
||||
WebClient client = WebClient.create(VertxManager.INSTANCE.getVertx());
|
||||
|
||||
@Override
|
||||
@EventListener(classes = MessageEvent.class, condition = "#event.message.channel=='QyWechat'")
|
||||
|
@ -27,12 +28,12 @@ public class QyWechatEventListener implements MessageEventListener {
|
|||
String channelConfig = message.getChannelConfig();
|
||||
QyWechatConfig qyWechatConfig = JsonUtils.parse(channelConfig, QyWechatConfig.class);
|
||||
|
||||
WebClient client = WebClient.create(VertxManager.INSTANCE.getVertx());
|
||||
QyWechatMessage qyWechatMessage = QyWechatMessage.builder()
|
||||
.msgtype("text")
|
||||
.text(QyWechatMessage.MessageContent.builder().content(message.getFormatContent()).build())
|
||||
.build();
|
||||
client.post(qyWechatConfig.getQyWechatWebhook()).sendJson(qyWechatMessage)
|
||||
|
||||
client.getAbs(qyWechatConfig.getQyWechatWebhook()).sendJson(qyWechatMessage)
|
||||
.onSuccess(response -> log.info("Received response with status code" + response.statusCode()))
|
||||
.onFailure(err -> log.error("Something went wrong " + err.getMessage()));
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-module</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>iot-plugin</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>iot-plugin-core</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-script-engine</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-message-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-data-service</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--====================第三方库===================-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.gitee.starblues</groupId>
|
||||
<artifactId>spring-brick</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,22 +0,0 @@
|
|||
package cc.iotkit.plugin.core;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 插件接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface IPlugin {
|
||||
|
||||
/**
|
||||
* 获取设备连接信息,如连接mqtt的ip、端口、账号、密码。。。
|
||||
*
|
||||
* @param pk 产品key
|
||||
* @param dn 设备dn
|
||||
* @return 连接配置项
|
||||
*/
|
||||
Map<String, Object> getLinkInfo(String pk, String dn);
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cc.iotkit.plugin.core;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 插件配置接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface IPluginConfig {
|
||||
|
||||
/**
|
||||
* 获取系统中配置的插件配置项
|
||||
*
|
||||
* @param pluginId 插件id
|
||||
* @return config
|
||||
*/
|
||||
Map<String, Object> getConfig(String pluginId);
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package cc.iotkit.plugin.core;
|
||||
|
||||
import cc.iotkit.script.IScriptEngine;
|
||||
|
||||
/**
|
||||
* 插件宿主接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface IPluginScript {
|
||||
|
||||
/**
|
||||
* 获取插件对应的脚本引擎
|
||||
*
|
||||
* @param pluginId 插件id
|
||||
* @return IScriptEngine
|
||||
*/
|
||||
IScriptEngine getScriptEngine(String pluginId);
|
||||
|
||||
/**
|
||||
* 重新加载脚本
|
||||
*
|
||||
* @param pluginId 插件id
|
||||
*/
|
||||
void reloadScript(String pluginId);
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cc.iotkit.plugin.core;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 本地独立运行的插件配置
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public class LocalPluginConfig implements IPluginConfig {
|
||||
@Override
|
||||
public Map<String, Object> getConfig(String pluginId) {
|
||||
//本地的直接用程序中默认值
|
||||
return new HashMap<>(0);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package cc.iotkit.plugin.core;
|
||||
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.common.utils.file.FileUtils;
|
||||
import cc.iotkit.script.IScriptEngine;
|
||||
import cc.iotkit.script.ScriptEngineFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* 本地独立运行的插件脚本实现
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public class LocalPluginScript implements IPluginScript {
|
||||
|
||||
private IScriptEngine scriptEngine;
|
||||
|
||||
public LocalPluginScript(String scriptPath) {
|
||||
if (StringUtils.isBlank(scriptPath)) {
|
||||
return;
|
||||
}
|
||||
URL resource = LocalPluginScript.class.getClassLoader().getResource(scriptPath);
|
||||
if (resource == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String script = FileUtils.readString(resource.getFile(), Charset.defaultCharset());
|
||||
initScriptEngine(script);
|
||||
}
|
||||
|
||||
public IScriptEngine initScriptEngine(String script) {
|
||||
if (StringUtils.isBlank(script)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
scriptEngine = ScriptEngineFactory.getJsEngine(script);
|
||||
return scriptEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScriptEngine getScriptEngine(String pluginId) {
|
||||
return scriptEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadScript(String pluginId) {
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing;
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionResult;
|
||||
import cc.iotkit.plugin.core.thing.actions.down.DeviceConfig;
|
||||
import cc.iotkit.plugin.core.thing.actions.down.PropertyGet;
|
||||
import cc.iotkit.plugin.core.thing.actions.down.PropertySet;
|
||||
import cc.iotkit.plugin.core.thing.actions.down.ServiceInvoke;
|
||||
|
||||
|
||||
/**
|
||||
* 设备接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface IDevice {
|
||||
|
||||
/**
|
||||
* 执行设备配置动作
|
||||
*
|
||||
* @param action 动作
|
||||
* @return result
|
||||
*/
|
||||
ActionResult config(DeviceConfig action);
|
||||
|
||||
/**
|
||||
* 执行设备属性获取动作
|
||||
*
|
||||
* @param action 动作
|
||||
* @return result
|
||||
*/
|
||||
ActionResult propertyGet(PropertyGet action);
|
||||
|
||||
/**
|
||||
* 执行设备属性设置动作
|
||||
*
|
||||
* @param action 动作
|
||||
* @return result
|
||||
*/
|
||||
ActionResult propertySet(PropertySet action);
|
||||
|
||||
/**
|
||||
* 执行设备服务调用动作
|
||||
*
|
||||
* @param action 动作
|
||||
* @return result
|
||||
*/
|
||||
ActionResult serviceInvoke(ServiceInvoke action);
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing;
|
||||
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.product.Product;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionResult;
|
||||
import cc.iotkit.plugin.core.thing.actions.IDeviceAction;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 设备服务接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface IThingService {
|
||||
|
||||
/**
|
||||
* 提交设备行为
|
||||
*
|
||||
* @param action IDeviceAction
|
||||
* @return result
|
||||
*/
|
||||
ActionResult post(String pluginId, IDeviceAction action);
|
||||
|
||||
/**
|
||||
* 获取产品信息
|
||||
*
|
||||
* @param pk 产品key
|
||||
* @return Product
|
||||
*/
|
||||
Product getProduct(String pk);
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
*
|
||||
* @param deviceName 设备dn
|
||||
* @return DeviceInfo
|
||||
*/
|
||||
DeviceInfo getDevice(String deviceName);
|
||||
|
||||
/**
|
||||
* 获取设备当前属性数据
|
||||
*
|
||||
* @param deviceName 设备dn
|
||||
* @return 当前属性
|
||||
*/
|
||||
Map<String, ?> getProperty(String deviceName);
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author sjg
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@ToString(callSuper = true)
|
||||
public abstract class AbstractAction implements IDeviceAction {
|
||||
|
||||
protected String id;
|
||||
|
||||
protected ActionType type;
|
||||
|
||||
protected String productKey;
|
||||
|
||||
protected String deviceName;
|
||||
|
||||
protected Long time;
|
||||
|
||||
public AbstractAction() {
|
||||
}
|
||||
|
||||
public AbstractAction(ActionType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 动作执行结果
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class ActionResult {
|
||||
|
||||
/**
|
||||
* 状态码,0:成功,x:其它错误码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 设备物行为类型
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ActionType {
|
||||
|
||||
//注册
|
||||
REGISTER("register"),
|
||||
//设备拓扑更新
|
||||
TOPOLOGY("topology"),
|
||||
//在离线状态变更
|
||||
STATE_CHANGE("state_change"),
|
||||
//属性上报
|
||||
PROPERTY_REPORT("property_report"),
|
||||
//事件上报
|
||||
EVENT_REPORT("event_report"),
|
||||
//服务回复
|
||||
SERVICE_REPLY("service_reply"),
|
||||
|
||||
//属性设置
|
||||
PROPERTY_SET("property_set"),
|
||||
//属性获取
|
||||
PROPERTY_GET("property_get"),
|
||||
//服务调用
|
||||
SERVICE_INVOKE("service_invoke"),
|
||||
//配置
|
||||
CONFIG("config");
|
||||
|
||||
private final String type;
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
* @author sjg
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DeviceState {
|
||||
|
||||
//在线
|
||||
ONLINE("online"),
|
||||
//离线
|
||||
OFFLINE("offline");
|
||||
|
||||
private final String state;
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 事件级别
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum EventLevel {
|
||||
|
||||
//信息
|
||||
INFO("info"),
|
||||
//告警
|
||||
WARN("warn"),
|
||||
//错误
|
||||
ERROR("error");
|
||||
|
||||
private final String type;
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions;
|
||||
|
||||
/**
|
||||
* 设备行为
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface IDeviceAction {
|
||||
|
||||
/**
|
||||
* 获取唯一标识id
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* 设置id
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void setId(String id);
|
||||
|
||||
/**
|
||||
* 获取类型
|
||||
*
|
||||
* @return ActionType
|
||||
*/
|
||||
ActionType getType();
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*
|
||||
* @param type type
|
||||
*/
|
||||
void setType(ActionType type);
|
||||
|
||||
/**
|
||||
* 获取产品key
|
||||
*
|
||||
* @return ProductKey
|
||||
*/
|
||||
String getProductKey();
|
||||
|
||||
/**
|
||||
* 设置产品key
|
||||
*
|
||||
* @param productKey pk
|
||||
*/
|
||||
void setProductKey(String productKey);
|
||||
|
||||
/**
|
||||
* 获取设备DN
|
||||
*
|
||||
* @return DN
|
||||
*/
|
||||
String getDeviceName();
|
||||
|
||||
/**
|
||||
* 设置设备DN
|
||||
*
|
||||
* @param deviceName dn
|
||||
*/
|
||||
void setDeviceName(String deviceName);
|
||||
|
||||
/**
|
||||
* 获取时间
|
||||
*
|
||||
* @return timespan
|
||||
*/
|
||||
Long getTime();
|
||||
|
||||
/**
|
||||
* 设置时间
|
||||
*
|
||||
* @param time timestamp
|
||||
*/
|
||||
void setTime(Long time);
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.down;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 设备配置
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
public class DeviceConfig extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 配置模块
|
||||
*/
|
||||
private String module;
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
private Map<String, Object> config;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.CONFIG;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.down;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 属性获取
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
public class PropertyGet extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 属性列表
|
||||
*/
|
||||
private List<String> keys;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.PROPERTY_GET;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.down;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 属性设置
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
public class PropertySet extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 属性参数
|
||||
*/
|
||||
private Map<String, ?> params;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.PROPERTY_SET;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.down;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 服务调用
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
public class ServiceInvoke extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 服务名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 服务参数
|
||||
*/
|
||||
private Map<String, ?> params;
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
private Map<String, ?> config;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.SERVICE_INVOKE;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.up;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 设备注册动作
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@ToString(callSuper = true)
|
||||
public class DeviceRegister extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.REGISTER;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.up;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import cc.iotkit.plugin.core.thing.actions.DeviceState;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 设备在线状态变更
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@ToString(callSuper = true)
|
||||
public class DeviceStateChange extends AbstractAction {
|
||||
|
||||
private DeviceState state;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.STATE_CHANGE;
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.up;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备拓扑更新
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@ToString(callSuper = true)
|
||||
public class DeviceTopology extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 父设备下的子设备列表
|
||||
*/
|
||||
private List<String> subDevices;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.TOPOLOGY;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.up;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import cc.iotkit.plugin.core.thing.actions.EventLevel;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 事件上报
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@ToString(callSuper = true)
|
||||
public class EventReport extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 事件名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 事件级别
|
||||
*/
|
||||
private EventLevel level;
|
||||
|
||||
/**
|
||||
* 事件参数
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.EVENT_REPORT;
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.up;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 属性上报
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@ToString(callSuper = true)
|
||||
public class PropertyReport extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 属性参数
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.PROPERTY_REPORT;
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.actions.up;
|
||||
|
||||
|
||||
import cc.iotkit.plugin.core.thing.actions.AbstractAction;
|
||||
import cc.iotkit.plugin.core.thing.actions.ActionType;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 服务回复
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@ToString(callSuper = true)
|
||||
public class ServiceReply extends AbstractAction {
|
||||
|
||||
/**
|
||||
* 服务名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 回复服务id
|
||||
*/
|
||||
private String replyId;
|
||||
|
||||
/**
|
||||
* 状态码,0:成功,x:失败错误码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 服务回复参数
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
@Override
|
||||
public ActionType getType() {
|
||||
return ActionType.SERVICE_REPLY;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 设备信息
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@Data
|
||||
public class ThingDevice {
|
||||
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 产品key
|
||||
*/
|
||||
private String productKey;
|
||||
|
||||
/**
|
||||
* 设备dn
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 设备密钥
|
||||
*/
|
||||
private String secret;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package cc.iotkit.plugin.core.thing.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 产品信息
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
@Data
|
||||
public class ThingProduct {
|
||||
|
||||
private String productKey;
|
||||
|
||||
private String productSecret;
|
||||
|
||||
private String name;
|
||||
|
||||
private String category;
|
||||
|
||||
private Integer nodeType;
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-plugin</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -13,11 +13,6 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-common-thing</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-plugin-core</artifactId>
|
||||
|
@ -28,6 +23,11 @@
|
|||
<artifactId>iot-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-data-service</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-temporal-service</artifactId>
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -16,6 +16,8 @@ import cc.iotkit.mq.MqProducer;
|
|||
import cc.iotkit.plugin.core.thing.IThingService;
|
||||
import cc.iotkit.plugin.core.thing.actions.*;
|
||||
import cc.iotkit.plugin.core.thing.actions.up.*;
|
||||
import cc.iotkit.plugin.core.thing.model.ThingDevice;
|
||||
import cc.iotkit.plugin.core.thing.model.ThingProduct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -56,7 +58,7 @@ public class ThingServiceImpl implements IThingService {
|
|||
//添加设备路由
|
||||
deviceRouter.putRouter(deviceName, new PluginRouter(IPluginMain.MAIN_ID, pluginId));
|
||||
|
||||
DeviceInfo device = getDevice(deviceName);
|
||||
DeviceInfo device = getDeviceInfo(deviceName);
|
||||
if (device == null) {
|
||||
log.warn("device:{} is not found.", deviceName);
|
||||
}
|
||||
|
@ -121,17 +123,26 @@ public class ThingServiceImpl implements IThingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Product getProduct(String pk) {
|
||||
public ThingProduct getProduct(String pk) {
|
||||
try {
|
||||
return productData.findByProductKey(pk);
|
||||
Product product = productData.findByProductKey(pk);
|
||||
if(product==null){
|
||||
return null;
|
||||
}
|
||||
return ThingProduct.builder()
|
||||
.category(product.getCategory())
|
||||
.productKey(product.getProductKey())
|
||||
.name(product.getName())
|
||||
.nodeType(product.getNodeType())
|
||||
.productSecret(product.getProductSecret())
|
||||
.build();
|
||||
} catch (Throwable e) {
|
||||
log.error("get product error", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo getDevice(String dn) {
|
||||
public DeviceInfo getDeviceInfo(String dn) {
|
||||
try {
|
||||
return deviceInfoData.findByDeviceName(dn);
|
||||
} catch (Throwable e) {
|
||||
|
@ -140,9 +151,24 @@ public class ThingServiceImpl implements IThingService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingDevice getDevice(String dn) {
|
||||
DeviceInfo deviceInfo = getDeviceInfo(dn);
|
||||
if(deviceInfo==null){
|
||||
return null;
|
||||
}
|
||||
return ThingDevice.builder()
|
||||
.deviceId(deviceInfo.getDeviceId())
|
||||
.deviceName(deviceInfo.getDeviceName())
|
||||
.model(deviceInfo.getModel())
|
||||
.productKey(deviceInfo.getProductKey())
|
||||
.secret(deviceInfo.getSecret())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ?> getProperty(String deviceName) {
|
||||
DeviceInfo device = getDevice(deviceName);
|
||||
DeviceInfo device = getDeviceInfo(deviceName);
|
||||
if (device == null) {
|
||||
return new HashMap<>(0);
|
||||
}
|
||||
|
@ -153,7 +179,7 @@ public class ThingServiceImpl implements IThingService {
|
|||
String productKey = register.getProductKey();
|
||||
//指定了pk需验证
|
||||
if (StringUtils.isNotBlank(productKey)) {
|
||||
Product product = getProduct(productKey);
|
||||
ThingProduct product = getProduct(productKey);
|
||||
if (product == null) {
|
||||
throw new BizException(ErrCode.PRODUCT_NOT_FOUND);
|
||||
}
|
||||
|
@ -163,21 +189,21 @@ public class ThingServiceImpl implements IThingService {
|
|||
log.info("device already registered");
|
||||
} else {
|
||||
//不存在,注册新设备
|
||||
device = new DeviceInfo();
|
||||
device.setId(DeviceUtil.newDeviceId(register.getDeviceName()));
|
||||
device.setDeviceId(device.getId());
|
||||
device.setProductKey(productKey);
|
||||
device.setDeviceName(register.getDeviceName());
|
||||
device.setModel(register.getModel());
|
||||
device.setSecret(RandomStringUtils.randomAlphabetic(16));
|
||||
DeviceInfo deviceInfo = new DeviceInfo();
|
||||
deviceInfo.setId(DeviceUtil.newDeviceId(register.getDeviceName()));
|
||||
deviceInfo.setDeviceId(deviceInfo.getId());
|
||||
deviceInfo.setProductKey(productKey);
|
||||
deviceInfo.setDeviceName(register.getDeviceName());
|
||||
deviceInfo.setModel(register.getModel());
|
||||
deviceInfo.setSecret(RandomStringUtils.randomAlphabetic(16));
|
||||
//默认离线
|
||||
device.setState(new DeviceInfo.State(false, null, null));
|
||||
device.setCreateAt(System.currentTimeMillis());
|
||||
deviceInfoData.save(device);
|
||||
deviceInfo.setState(new DeviceInfo.State(false, null, null));
|
||||
deviceInfo.setCreateAt(System.currentTimeMillis());
|
||||
deviceInfoData.save(deviceInfo);
|
||||
|
||||
log.info("device registered:{}", JsonUtils.toJsonString(device));
|
||||
publishMsg(
|
||||
device,
|
||||
deviceInfo,
|
||||
register,
|
||||
ThingModelMessage.builder()
|
||||
.type(ThingModelMessage.TYPE_LIFETIME)
|
||||
|
@ -210,7 +236,7 @@ public class ThingServiceImpl implements IThingService {
|
|||
private void deviceTopologyUpdate(DeviceInfo device, DeviceTopology topology) {
|
||||
//设备拓扑关系更新
|
||||
for (String deviceName : topology.getSubDevices()) {
|
||||
DeviceInfo subDevice = getDevice(deviceName);
|
||||
DeviceInfo subDevice = getDeviceInfo(deviceName);
|
||||
subDevice.setParentId(device.getDeviceId());
|
||||
deviceInfoData.save(subDevice);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-module</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>iot-plugin-core</module>
|
||||
<module>iot-plugin-main</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-module</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-module</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-module</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iotkit-parent</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iotkit-parent</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -13,6 +13,16 @@
|
|||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-web-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-common-tenant</artifactId>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iot-test-tool</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>iotkit-parent</artifactId>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -12,7 +12,7 @@
|
|||
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iotkit-parent</artifactId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.2-SNAPSHOT</version>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>奇特物联是一个开源的物联网基础开发平台,提供了物联网及相关业务开发的常见基础功能,
|
||||
能帮助你快速搭建自己的物联网相关业务平台。
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
<iot-iita-core.version>1.0.1</iot-iita-core.version>
|
||||
<iot-iita-core.version>1.0.2</iot-iita-core.version>
|
||||
<spring-boot.version>2.7.11</spring-boot.version>
|
||||
<vertx.version>4.2.2</vertx.version>
|
||||
<satoken.version>1.34.0</satoken.version>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<lang3.version>3.7</lang3.version>
|
||||
<hutool.version>5.8.18</hutool.version>
|
||||
<mapstruct-plus.version>1.3.1</mapstruct-plus.version>
|
||||
<spring-brick.version>3.1.3</spring-brick.version>
|
||||
<spring-brick.version>3.1.4</spring-brick.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -391,7 +391,7 @@
|
|||
<dependency>
|
||||
<groupId>cc.iotkit</groupId>
|
||||
<artifactId>iot-plugin-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>${iot-iita-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
Loading…
Reference in New Issue