From 4eabb493da653519a772c96a31ff01cd5e592e31 Mon Sep 17 00:00:00 2001
From: 31353 <31353751672@qq.com>
Date: Sat, 13 Apr 2024 13:31:41 +0800
Subject: [PATCH] 11
---
pom.xml | 231 +++++++++++
src/main/java/com/muyu/MqttApplication.java | 15 +
.../java/com/muyu/common/RedisService.java | 270 +++++++++++++
src/main/java/com/muyu/common/Result.java | 111 ++++++
.../muyu/common/contents/CreateContents.java | 14 +
.../muyu/common/contents/MessageConstant.java | 86 +++++
.../com/muyu/common/domain/ApifoxModel.java | 55 +++
.../java/com/muyu/common/domain/CPUInfo.java | 30 ++
.../java/com/muyu/common/domain/CreateVo.java | 32 ++
.../com/muyu/common/domain/DeleteServer.java | 32 ++
.../java/com/muyu/common/domain/FlowInfo.java | 28 ++
.../java/com/muyu/common/domain/Icreate.java | 48 +++
.../java/com/muyu/common/domain/JVMInfo.java | 58 +++
.../java/com/muyu/common/domain/MqttInfo.java | 63 +++
.../com/muyu/common/domain/NodeRegReq.java | 28 ++
src/main/java/com/muyu/common/ip/IpUtils.java | 362 ++++++++++++++++++
.../muyu/controller/LoadCenterController.java | 129 +++++++
.../muyu/controller/VehicleController.java | 43 +++
.../com/muyu/demos/web/BasicController.java | 67 ++++
.../demos/web/PathVariableController.java | 44 +++
src/main/java/com/muyu/demos/web/User.java | 43 +++
.../java/com/muyu/instance/ClientConfig.java | 23 ++
src/main/java/com/muyu/instance/CreateAn.java | 330 ++++++++++++++++
src/main/java/com/muyu/instance/test.java | 16 +
.../com/muyu/server/ClientRegController.java | 113 ++++++
src/main/java/com/muyu/server/MttClient.java | 45 +++
src/main/java/com/muyu/server/NodeRegReq.java | 24 ++
src/main/java/com/muyu/test/fluxmqTest.java | 115 ++++++
src/main/resources/application.yml | 9 +
src/main/resources/static/index.html | 6 +
.../java/com/muyu/MqttApplicationTests.java | 13 +
31 files changed, 2483 insertions(+)
create mode 100644 pom.xml
create mode 100644 src/main/java/com/muyu/MqttApplication.java
create mode 100644 src/main/java/com/muyu/common/RedisService.java
create mode 100644 src/main/java/com/muyu/common/Result.java
create mode 100644 src/main/java/com/muyu/common/contents/CreateContents.java
create mode 100644 src/main/java/com/muyu/common/contents/MessageConstant.java
create mode 100644 src/main/java/com/muyu/common/domain/ApifoxModel.java
create mode 100644 src/main/java/com/muyu/common/domain/CPUInfo.java
create mode 100644 src/main/java/com/muyu/common/domain/CreateVo.java
create mode 100644 src/main/java/com/muyu/common/domain/DeleteServer.java
create mode 100644 src/main/java/com/muyu/common/domain/FlowInfo.java
create mode 100644 src/main/java/com/muyu/common/domain/Icreate.java
create mode 100644 src/main/java/com/muyu/common/domain/JVMInfo.java
create mode 100644 src/main/java/com/muyu/common/domain/MqttInfo.java
create mode 100644 src/main/java/com/muyu/common/domain/NodeRegReq.java
create mode 100644 src/main/java/com/muyu/common/ip/IpUtils.java
create mode 100644 src/main/java/com/muyu/controller/LoadCenterController.java
create mode 100644 src/main/java/com/muyu/controller/VehicleController.java
create mode 100644 src/main/java/com/muyu/demos/web/BasicController.java
create mode 100644 src/main/java/com/muyu/demos/web/PathVariableController.java
create mode 100644 src/main/java/com/muyu/demos/web/User.java
create mode 100644 src/main/java/com/muyu/instance/ClientConfig.java
create mode 100644 src/main/java/com/muyu/instance/CreateAn.java
create mode 100644 src/main/java/com/muyu/instance/test.java
create mode 100644 src/main/java/com/muyu/server/ClientRegController.java
create mode 100644 src/main/java/com/muyu/server/MttClient.java
create mode 100644 src/main/java/com/muyu/server/NodeRegReq.java
create mode 100644 src/main/java/com/muyu/test/fluxmqTest.java
create mode 100644 src/main/resources/application.yml
create mode 100644 src/main/resources/static/index.html
create mode 100644 src/test/java/com/muyu/MqttApplicationTests.java
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..0f996d3
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,231 @@
+
+
+ 4.0.0
+ com.muyu
+ mqtt
+ 0.0.1-SNAPSHOT
+ mqtt
+ Demo project for Spring Boot
+
+ 1.8
+ UTF-8
+ UTF-8
+ 2.6.13
+
+
+
+
+
+
+
+ com.aliyun
+ darabonba-string
+ 0.0.3
+
+
+ com.aliyun
+ tea
+ [1.0.3, 2.0.0)
+
+
+
+ com.aliyun
+ ecs20140526
+ 3.1.2
+
+
+ com.aliyun
+ tea-openapi
+ 0.3.2
+
+
+ com.aliyun
+ tea-util
+ 0.2.21
+
+
+ com.aliyun
+ tea-console
+ 0.0.1
+
+
+ com.aliyun
+ darabonba-env
+ 0.1.1
+
+
+ com.aliyun
+ tea
+ 1.1.14
+
+
+
+
+ com.aliyun
+ credentials-java
+ LATEST
+
+
+ com.aliyun
+ tea-openapi
+ 0.2.8
+
+
+ com.aliyun
+ dysmsapi20170525
+ 2.0.24
+
+
+
+ com.aliyun
+ ecs20140526
+ 3.1.12
+
+
+
+ com.aliyun
+ aliyun-java-sdk-core
+ 4.6.3
+
+
+ com.aliyun
+ aliyun-java-sdk-ecs
+ 4.24.59
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.projectlombok
+ lombok
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.eclipse.paho
+ org.eclipse.paho.client.mqttv3
+ 1.2.5
+
+
+
+ com.alibaba.fastjson2
+ fastjson2
+ 2.0.47
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework
+ spring-tx
+ 5.3.31
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+ 16
+ 16
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.3
+ true
+
+ sonatype-nexus-staging
+ https://s01.oss.sonatype.org/
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.1.1
+
+ UTF-8
+ none
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.1
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 2.4.1
+
+
+ jar-with-dependencies
+
+
+
+ true
+ com.aliyun.sample.Sample
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/muyu/MqttApplication.java b/src/main/java/com/muyu/MqttApplication.java
new file mode 100644
index 0000000..f59e26d
--- /dev/null
+++ b/src/main/java/com/muyu/MqttApplication.java
@@ -0,0 +1,15 @@
+package com.muyu;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@EnableScheduling
+@SpringBootApplication
+public class MqttApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(MqttApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/com/muyu/common/RedisService.java b/src/main/java/com/muyu/common/RedisService.java
new file mode 100644
index 0000000..f4ecc1a
--- /dev/null
+++ b/src/main/java/com/muyu/common/RedisService.java
@@ -0,0 +1,270 @@
+package com.muyu.common;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.*;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * spring redis 工具类
+ *
+ * @author muyu
+ **/
+@SuppressWarnings(value = {"unchecked", "rawtypes"})
+@Component
+public class RedisService {
+ @Autowired
+ public RedisTemplate redisTemplate;
+
+ /**
+ * 缓存基本的对象,Integer、String、实体类等
+ *
+ * @param key 缓存的键值
+ * @param value 缓存的值
+ */
+ public void setCacheObject (final String key, final T value) {
+ redisTemplate.opsForValue().set(key, value);
+ }
+
+
+ // 判断 key 是否存在
+ public boolean exists(String key) {
+ return redisTemplate.hasKey(key);
+ }
+ public ZSetOperations opsForZSet() {
+ return redisTemplate.opsForZSet();
+ }
+
+ public ValueOperations opsForValue() {
+ return redisTemplate.opsForValue();
+ }
+ /**
+ * 缓存基本的对象,Integer、String、实体类等
+ *
+ * @param key 缓存的键值
+ * @param value 缓存的值
+ * @param timeout 时间
+ * @param timeUnit 时间颗粒度
+ */
+ public void setCacheObject (final String key, final T value, final Long timeout, final TimeUnit timeUnit) {
+ redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
+ }
+
+ /**
+ * 设置有效时间
+ *
+ * @param key Redis键
+ * @param timeout 超时时间
+ *
+ * @return true=设置成功;false=设置失败
+ */
+ public boolean expire (final String key, final long timeout) {
+ return expire(key, timeout, TimeUnit.SECONDS);
+ }
+
+ /**
+ * 设置有效时间
+ *
+ * @param key Redis键
+ * @param timeout 超时时间
+ * @param unit 时间单位
+ *
+ * @return true=设置成功;false=设置失败
+ */
+ public boolean expire (final String key, final long timeout, final TimeUnit unit) {
+ return redisTemplate.expire(key, timeout, unit);
+ }
+
+ /**
+ * 获取有效时间
+ *
+ * @param key Redis键
+ *
+ * @return 有效时间
+ */
+ public long getExpire (final String key) {
+ return redisTemplate.getExpire(key);
+ }
+
+ /**
+ * 判断 key是否存在
+ *
+ * @param key 键
+ *
+ * @return true 存在 false不存在
+ */
+ public Boolean hasKey (String key) {
+ return redisTemplate.hasKey(key);
+ }
+
+ /**
+ * 获得缓存的基本对象。
+ *
+ * @param key 缓存键值
+ *
+ * @return 缓存键值对应的数据
+ */
+ public T getCacheObject (final String key) {
+ ValueOperations operation = redisTemplate.opsForValue();
+ return operation.get(key);
+ }
+
+ /**
+ * 删除单个对象
+ *
+ * @param key
+ */
+ public boolean deleteObject (final String key) {
+ return redisTemplate.delete(key);
+ }
+
+ /**
+ * 删除集合对象
+ *
+ * @param collection 多个对象
+ *
+ * @return
+ */
+ public boolean deleteObject (final Collection collection) {
+ return redisTemplate.delete(collection) > 0;
+ }
+
+ /**
+ * 缓存List数据
+ *
+ * @param key 缓存的键值
+ * @param dataList 待缓存的List数据
+ *
+ * @return 缓存的对象
+ */
+ public long setCacheList (final String key, final List dataList) {
+ Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
+ return count == null ? 0 : count;
+ }
+
+ /**
+ * 获得缓存的list对象
+ *
+ * @param key 缓存的键值
+ *
+ * @return 缓存键值对应的数据
+ */
+ public List getCacheList (final String key) {
+ return redisTemplate.opsForList().range(key, 0, -1);
+ }
+
+ /**
+ * 缓存Set
+ *
+ * @param key 缓存键值
+ * @param dataSet 缓存的数据
+ *
+ * @return 缓存数据的对象
+ */
+ public BoundSetOperations setCacheSet (final String key, final Set dataSet) {
+ BoundSetOperations setOperation = redisTemplate.boundSetOps(key);
+ Iterator it = dataSet.iterator();
+ while (it.hasNext()) {
+ setOperation.add(it.next());
+ }
+ return setOperation;
+ }
+
+
+
+
+ /**
+ * 获得缓存的set
+ *
+ * @param key
+ *
+ * @return
+ */
+ public Set getCacheSet (final String key) {
+ return redisTemplate.opsForSet().members(key);
+ }
+
+ /**
+ * 缓存Map
+ *
+ * @param key
+ * @param dataMap
+ */
+ public void setCacheMap (final String key, final Map dataMap) {
+ if (dataMap != null) {
+ redisTemplate.opsForHash().putAll(key, dataMap);
+ }
+ }
+
+ /**
+ * 获得缓存的Map
+ *
+ * @param key
+ *
+ * @return
+ */
+ public Map getCacheMap (final String key) {
+ return redisTemplate.opsForHash().entries(key);
+ }
+
+ /**
+ * 往Hash中存入数据
+ *
+ * @param key Redis键
+ * @param hKey Hash键
+ * @param value 值
+ */
+ public void setCacheMapValue (final String key, final String hKey, final T value) {
+ redisTemplate.opsForHash().put(key, hKey, value);
+ }
+
+ /**
+ * 获取Hash中的数据
+ *
+ * @param key Redis键
+ * @param hKey Hash键
+ *
+ * @return Hash中的对象
+ */
+ public T getCacheMapValue (final String key, final String hKey) {
+ HashOperations opsForHash = redisTemplate.opsForHash();
+ return opsForHash.get(key, hKey);
+ }
+
+ /**
+ * 获取多个Hash中的数据
+ *
+ * @param key Redis键
+ * @param hKeys Hash键集合
+ *
+ * @return Hash对象集合
+ */
+ public List getMultiCacheMapValue (final String key, final Collection