diff --git a/pom.xml b/pom.xml
index 73b1973..f0d96a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.objecteye
viid-collector
- 1.0-SNAPSHOT
+ 1.0
8
@@ -49,14 +49,6 @@
spring-boot-starter-web
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-discovery
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-config
-
-
org.projectlombok
lombok
@@ -72,5 +64,41 @@
org.apache.commons
commons-pool2
+
+ org.apache.commons
+ commons-lang3
+
+
+ commons-codec
+ commons-codec
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ viid-collector
+ com.objecteye.VIIDCollectorApplication
+
+
+
+
+ repackage
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/objecteye/config/ApplicationConfigurationProperties.java b/src/main/java/com/objecteye/config/Gat1400Properties.java
index 57913b9..80a9c8e 100644
--- a/src/main/java/com/objecteye/config/ApplicationConfigurationProperties.java
+++ b/src/main/java/com/objecteye/config/Gat1400Properties.java
@@ -2,16 +2,22 @@ package com.objecteye.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
+import org.springframework.context.annotation.Configuration;
/**
* @author: liuhaoyu
- * @date: 2023/6/28
+ * @date: 2023/7/5
*/
@Data
-@Component
-@ConfigurationProperties(prefix = "config.application")
-public class ApplicationConfigurationProperties {
+@Configuration
+@ConfigurationProperties(prefix = "gat1400")
+public class Gat1400Properties {
- private String platformCode;
+ private String serverAddress;
+
+ private Integer port;
+
+ private String accessKey;
+
+ private String securityKey;
}
diff --git a/src/main/java/com/objecteye/config/ObjectMapperConfigure.java b/src/main/java/com/objecteye/config/ObjectMapperConfigure.java
deleted file mode 100644
index 0bd64ac..0000000
--- a/src/main/java/com/objecteye/config/ObjectMapperConfigure.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.objecteye.config;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.Data;
-import org.springframework.context.annotation.Bean;
-
-/**
- * @author: liuhaoyu
- * @date: 2023/6/28
- */
-@Data
-public class ObjectMapperConfigure {
-
- @Bean
- public ObjectMapper objectMapper() {
- return new ObjectMapper();
- }
-}
diff --git a/src/main/java/com/objecteye/content/VIIDApi.java b/src/main/java/com/objecteye/content/VIIDApi.java
index 8242342..a704ca2 100644
--- a/src/main/java/com/objecteye/content/VIIDApi.java
+++ b/src/main/java/com/objecteye/content/VIIDApi.java
@@ -6,7 +6,8 @@ package com.objecteye.content;
*/
public class VIIDApi {
- public static final String SYSTEM_PREFIX = "/VIID/System";
+ private static final String VIID = "/VIID";
+ public static final String SYSTEM_PREFIX = VIID + "/System";
/**
* 注册
*/
@@ -19,6 +20,12 @@ public class VIIDApi {
* 保活
*/
public static final String KEEPALIVE = SYSTEM_PREFIX + "/Keepalive";
+ /**
+ * 校时
+ */
+ public static final String TIME = SYSTEM_PREFIX + "/Time";
+
+ public static final String SUBSCRIBES = VIID + "/Subscribes";
private VIIDApi() {
}
diff --git a/src/main/java/com/objecteye/content/VIIDContent.java b/src/main/java/com/objecteye/content/VIIDContent.java
new file mode 100644
index 0000000..4928292
--- /dev/null
+++ b/src/main/java/com/objecteye/content/VIIDContent.java
@@ -0,0 +1,13 @@
+package com.objecteye.content;
+
+/**
+ * @author: liuhaoyu
+ * @date: 2023/7/5
+ */
+public class VIIDContent {
+
+ public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+
+ private VIIDContent() {
+ }
+}
diff --git a/src/main/java/com/objecteye/content/ViidCollectorRedisKey.java b/src/main/java/com/objecteye/content/ViidCollectorRedisKey.java
index 50ff7f5..bc00f0d 100644
--- a/src/main/java/com/objecteye/content/ViidCollectorRedisKey.java
+++ b/src/main/java/com/objecteye/content/ViidCollectorRedisKey.java
@@ -6,7 +6,7 @@ package com.objecteye.content;
*/
public class ViidCollectorRedisKey {
/**
- * 设备连接信息缓存
+ * 设备订阅信息
*/
public static final String DEVICE_CACHE = "vc:dc";
diff --git a/src/main/java/com/objecteye/controller/SubscribeController.java b/src/main/java/com/objecteye/controller/SubscribeController.java
new file mode 100644
index 0000000..93e7a90
--- /dev/null
+++ b/src/main/java/com/objecteye/controller/SubscribeController.java
@@ -0,0 +1,35 @@
+package com.objecteye.controller;
+
+import com.objecteye.handle.viid.SubscribeHandle;
+import com.objecteye.pojo.DeviceIdParams;
+import com.objecteye.pojo.Result;
+import com.objecteye.pojo.viid.subscribe.SubscribeNotificationRequestObject;
+import com.objecteye.utils.JSONUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author: liuhaoyu
+ * @date: 2023/7/6
+ */
+@Slf4j
+@RestController
+@RequiredArgsConstructor
+public class SubscribeController {
+ private final SubscribeHandle subscribeHandle;
+
+ @PostMapping("subscribe")
+ public Result subscribe(@RequestBody @Validated DeviceIdParams params) {
+ return Result.success(subscribeHandle.subscribe(params.getDeviceId()));
+ }
+
+ @PostMapping("receiver")
+ public Result receiver(@RequestBody SubscribeNotificationRequestObject subscribeNotificationRequestObject) {
+ log.info("notification: \n{}", JSONUtils.toPrettyJsonString(subscribeNotificationRequestObject));
+ return Result.success();
+ }
+}
diff --git a/src/main/java/com/objecteye/controller/SystemController.java b/src/main/java/com/objecteye/controller/SystemController.java
new file mode 100644
index 0000000..c8ccbea
--- /dev/null
+++ b/src/main/java/com/objecteye/controller/SystemController.java
@@ -0,0 +1,38 @@
+package com.objecteye.controller;
+
+import com.objecteye.handle.viid.CommonHandle;
+import com.objecteye.pojo.DeviceIdParams;
+import com.objecteye.pojo.Result;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author: liuhaoyu
+ * @date: 2023/7/6
+ */
+@RestController
+@RequestMapping("system")
+@RequiredArgsConstructor
+public class SystemController {
+
+ private final CommonHandle commonHandle;
+
+ @PostMapping("register")
+ public Result register(@RequestBody @Validated DeviceIdParams params) {
+ return Result.success(commonHandle.register(params.getDeviceId()));
+ }
+
+ @PostMapping("unregister")
+ public Result unregister(@RequestBody @Validated DeviceIdParams params) {
+ return Result.success(commonHandle.unregister(params.getDeviceId()));
+ }
+
+ @PostMapping("keepalive")
+ public Result keepalive(@RequestBody @Validated DeviceIdParams params) {
+ return Result.success(commonHandle.keepalive(params.getDeviceId()));
+ }
+}
diff --git a/src/main/java/com/objecteye/handle/StartUpAndShutdown.java b/src/main/java/com/objecteye/handle/StartUpAndShutdown.java
index 846ecc4..82f33ea 100644
--- a/src/main/java/com/objecteye/handle/StartUpAndShutdown.java
+++ b/src/main/java/com/objecteye/handle/StartUpAndShutdown.java
@@ -1,13 +1,8 @@
package com.objecteye.handle;
-import com.alibaba.nacos.common.utils.ExceptionUtil;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.objecteye.content.ViidCollectorRedisKey;
-import com.objecteye.handle.viid.VIIDCommonHandle;
-import com.objecteye.pojo.platform.DeviceRequestParams;
+import com.objecteye.handle.viid.CommonHandle;
import lombok.RequiredArgsConstructor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
@@ -26,32 +21,25 @@ import java.util.function.Consumer;
@Component
@RequiredArgsConstructor
public class StartUpAndShutdown implements DisposableBean, ApplicationRunner {
- private final VIIDCommonHandle viidCommonHandle;
+ private final CommonHandle commonHandle;
private final StringRedisTemplate stringRedisTemplate;
- private final ObjectMapper objectMapper;
-
- private final Logger logger = LoggerFactory.getLogger(StartUpAndShutdown.class);
@Override
public void destroy() throws Exception {
- allCacheHandle(viidCommonHandle::unregister);
+ allCacheHandle(commonHandle::unregister);
}
@Override
public void run(ApplicationArguments args) throws Exception {
- allCacheHandle(viidCommonHandle::register);
+ allCacheHandle(commonHandle::register);
}
- private void allCacheHandle(Consumer func) {
+ private void allCacheHandle(Consumer func) {
try (Cursor> cursor = stringRedisTemplate.boundHashOps(ViidCollectorRedisKey.DEVICE_CACHE)
.scan(ScanOptions.scanOptions().build())) {
while (cursor.hasNext()) {
Map.Entry