feat:增加子设备注册

master
xiwa 2024-02-24 23:28:19 +08:00
parent 71e74d447e
commit b83f314c9d
27 changed files with 271 additions and 24 deletions

View File

@ -6,7 +6,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<artifactId>iot-common-core</artifactId> <artifactId>iot-common-core</artifactId>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -1,6 +1,9 @@
package cc.iotkit.common.oss.properties; package cc.iotkit.common.oss.properties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* OSS * OSS
@ -8,6 +11,9 @@ import lombok.Data;
* @author Lion Li * @author Lion Li
*/ */
@Data @Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OssProperties { public class OssProperties {
/** /**

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-message-bus</artifactId> <artifactId>iot-message-bus</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-message-bus</artifactId> <artifactId>iot-message-bus</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-message-bus</artifactId> <artifactId>iot-message-bus</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging> <packaging>pom</packaging>

55
iot-oss-local/pom.xml Normal file
View File

@ -0,0 +1,55 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cc.iotkit</groupId>
<artifactId>iot-iita-core</artifactId>
<version>1.0.3</version>
</parent>
<artifactId>iot-oss-local</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-core</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-redis</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-oss</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,78 @@
/*
* +----------------------------------------------------------------------
* | Copyright (c) 2021-2022 All rights reserved.
* +----------------------------------------------------------------------
* | Licensed
* +----------------------------------------------------------------------
* | Author: xw2sy@163.com
* +----------------------------------------------------------------------
*/
package cc.iotkit.oss;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Handler;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class HttpVerticle extends AbstractVerticle implements Handler<RoutingContext> {
private HttpServer httpServer;
@Override
public void start() {
Executors.newSingleThreadScheduledExecutor().schedule(this::initHttpServer, 3, TimeUnit.SECONDS);
}
private void initHttpServer() {
httpServer = vertx.createHttpServer();
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create()).handler(this);
httpServer.requestHandler(router).listen(1121, ar -> {
if (ar.succeeded()) {
log.info("http server is listening on port " + ar.result().actualPort());
} else {
log.error("Error on starting the server", ar.cause());
}
});
}
@Override
public void stop() {
}
@Override
public void handle(RoutingContext ctx) {
HttpServerResponse response = ctx.response();
response.putHeader("content-type", "application/json");
response.setStatusCode(200);
try {
HttpServerRequest request = ctx.request();
String path = request.path();
log.info("path:{}", path);
} catch (Exception e) {
log.error("消息处理失败", e);
response.setStatusCode(500);
end(response);
}
}
private void end(HttpServerResponse response) {
response.end(new JsonObject()
.put("code", response.getStatusCode() == 200 ? 0 : response.getStatusCode())
.toString());
}
}

View File

@ -0,0 +1,41 @@
package cc.iotkit.oss;
import cc.iotkit.common.oss.constant.OssConstant;
import cc.iotkit.common.oss.properties.OssProperties;
import cc.iotkit.common.redis.utils.RedisUtils;
import cn.hutool.core.util.RandomUtil;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Slf4j
@Component
public class OssServer {
private final int port = RandomUtil.randomInt(1660, 1880);
@PostConstruct
public void init() {
RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, OssProperties.builder()
.endpoint(String.format("http://127.0.0.1:%d", port))
.build());
}
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
HttpVerticle httpVerticle=new HttpVerticle();
Future<String> future = vertx.deployVerticle(httpVerticle);
future.onSuccess((s -> {
log.info("http plugin startup success");
}));
future.onFailure((e) -> {
log.error("http plugin startup failed", e);
});
}
}

View File

@ -0,0 +1,10 @@
package cc.iotkit.oss;
import cc.iotkit.common.oss.core.OssClient;
import cc.iotkit.common.oss.factory.OssFactory;
public class Test {
// public static void main(String[] args) {
// OssClient ossClient = new OssClient("", properties);
// }
}

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<artifactId>iot-plugin-core</artifactId> <artifactId>iot-plugin-core</artifactId>

View File

@ -14,6 +14,8 @@ public enum ActionType {
//注册 //注册
REGISTER("register"), REGISTER("register"),
//子注册
SUB_REGISTER("sub_register"),
//设备拓扑更新 //设备拓扑更新
TOPOLOGY("topology"), TOPOLOGY("topology"),
//在离线状态变更 //在离线状态变更

View File

@ -0,0 +1,43 @@
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 SubDeviceRegister extends AbstractAction {
/**
*
*/
private String model;
/**
*
*/
private String version;
/**
*
*/
private List<DeviceRegister> subs;
@Override
public ActionType getType() {
return ActionType.SUB_REGISTER;
}
}

View File

@ -6,7 +6,7 @@
<parent> <parent>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<artifactId>iot-script-engine</artifactId> <artifactId>iot-script-engine</artifactId>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<version>1.0.2</version> <version>1.0.3</version>
</parent> </parent>
<groupId>com.gitee.starblues</groupId> <groupId>com.gitee.starblues</groupId>

View File

@ -17,13 +17,11 @@
package com.gitee.starblues.integration; package com.gitee.starblues.integration;
import com.gitee.starblues.core.DefaultRealizeProvider; import com.gitee.starblues.core.DefaultRealizeProvider;
import com.gitee.starblues.core.RealizeProvider;; import com.gitee.starblues.core.RealizeProvider;
import com.gitee.starblues.core.classloader.CacheMainResourceMatcher;
import com.gitee.starblues.core.classloader.DefaultMainResourceMatcher; import com.gitee.starblues.core.classloader.DefaultMainResourceMatcher;
import com.gitee.starblues.core.classloader.MainResourceMatcher; import com.gitee.starblues.core.classloader.MainResourceMatcher;
import com.gitee.starblues.core.descriptor.decrypt.DefaultPluginDescriptorDecrypt; import com.gitee.starblues.core.descriptor.decrypt.DefaultPluginDescriptorDecrypt;
import com.gitee.starblues.core.descriptor.decrypt.PluginDescriptorDecrypt; import com.gitee.starblues.core.descriptor.decrypt.PluginDescriptorDecrypt;
import com.gitee.starblues.core.launcher.plugin.BasicMainResourcePatternDefiner;
import com.gitee.starblues.core.launcher.plugin.DefaultMainResourcePatternDefiner; import com.gitee.starblues.core.launcher.plugin.DefaultMainResourcePatternDefiner;
import com.gitee.starblues.integration.operator.DefaultPluginOperator; import com.gitee.starblues.integration.operator.DefaultPluginOperator;
import com.gitee.starblues.integration.operator.PluginOperator; import com.gitee.starblues.integration.operator.PluginOperator;
@ -31,11 +29,12 @@ import com.gitee.starblues.integration.operator.PluginOperatorWrapper;
import com.gitee.starblues.integration.user.DefaultPluginUser; import com.gitee.starblues.integration.user.DefaultPluginUser;
import com.gitee.starblues.integration.user.PluginUser; import com.gitee.starblues.integration.user.PluginUser;
import com.gitee.starblues.spring.extract.ExtractFactory; import com.gitee.starblues.spring.extract.ExtractFactory;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.support.GenericApplicationContext;
;
/** /**
* Bean * Bean
* @author starBlues * @author starBlues

15
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>cc.iotkit</groupId> <groupId>cc.iotkit</groupId>
<artifactId>iot-iita-core</artifactId> <artifactId>iot-iita-core</artifactId>
<version>1.0.2</version> <version>1.0.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
@ -25,6 +25,7 @@
<module>iot-common-thing</module> <module>iot-common-thing</module>
<module>iot-plugin-core</module> <module>iot-plugin-core</module>
<module>iot-spring-brick</module> <module>iot-spring-brick</module>
<module>iot-oss-local</module>
</modules> </modules>
<properties> <properties>
@ -45,6 +46,12 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
@ -321,6 +328,12 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-oss</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>