diff --git a/sensorbub-common/pom.xml b/sensorbub-common/pom.xml
index 6b0e15d..9856c17 100644
--- a/sensorbub-common/pom.xml
+++ b/sensorbub-common/pom.xml
@@ -41,6 +41,13 @@
${redis.version}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sensorbub-common/pom.xml b/sensorbub-common/pom.xml
index 6b0e15d..9856c17 100644
--- a/sensorbub-common/pom.xml
+++ b/sensorbub-common/pom.xml
@@ -41,6 +41,13 @@
${redis.version}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java b/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java
index 988f355..81a221a 100644
--- a/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java
+++ b/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java
@@ -1,127 +1,127 @@
-package com.casic.missiles.util;
-
-import lombok.AllArgsConstructor;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContexts;
-import org.apache.http.util.EntityUtils;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-@Component
-@AllArgsConstructor
-public class HttpClientUtil {
-
- public String sendHourGet() {
- String url = "http://123";
- Map param = new HashMap<>();
- param.put("key", "key");
- param.put("location", "apiloction");
- param.put("language", "zh-Hans");
- param.put("unit", "c");
- param.put("start", "1");
- param.put("hours", "24");
- // 创建Httpclient对象
- CloseableHttpClient httpclient = HttpClients.createDefault();
- String resultString = "";
- CloseableHttpResponse response = null;
- try {
- httpclient = HttpClients.custom()
- .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
- //忽略掉对服务器端证书的校验
- .loadTrustMaterial(null, new TrustSelfSignedStrategy())
- .build(), NoopHostnameVerifier.INSTANCE))
- .build();
- // 创建uri
- URIBuilder builder = new URIBuilder(url);
- if (param != null) {
- for (String key : param.keySet()) {
- builder.addParameter(key, param.get(key));
- }
- }
- URI uri = builder.build();
- // 创建http GET请求
- HttpGet httpGet = new HttpGet(uri);
- // 执行请求
- response = httpclient.execute(httpGet);
- // 判断返回状态是否为200
- if (response.getStatusLine().getStatusCode() == 200) {
- resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (response != null) {
- response.close();
- }
- httpclient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return resultString;
- }
-
- public String sendDayGet() {
- String url = "http://123";
- Map param = new HashMap<>();
- param.put("key", "key");
- param.put("location", "location");
- param.put("language", "zh-Hans");
- param.put("unit", "c");
- param.put("start", "0");
- param.put("hours", "24");
- // 创建Httpclient对象
- CloseableHttpClient httpclient = HttpClients.createDefault();
- String resultString = "";
- CloseableHttpResponse response = null;
- try {
- httpclient = HttpClients.custom()
- .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
- //忽略掉对服务器端证书的校验
- .loadTrustMaterial(null, new TrustSelfSignedStrategy())
- .build(), NoopHostnameVerifier.INSTANCE))
- .build();
- // 创建uri
- URIBuilder builder = new URIBuilder(url);
- if (param != null) {
- for (String key : param.keySet()) {
- builder.addParameter(key, param.get(key));
- }
- }
- URI uri = builder.build();
- // 创建http GET请求
- HttpGet httpGet = new HttpGet(uri);
- // 执行请求
- response = httpclient.execute(httpGet);
- // 判断返回状态是否为200
- if (response.getStatusLine().getStatusCode() == 200) {
- resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (response != null) {
- response.close();
- }
- httpclient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return resultString;
- }
-
-}
+//package com.casic.missiles.util;
+//
+//import lombok.AllArgsConstructor;
+//import org.apache.http.client.methods.CloseableHttpResponse;
+//import org.apache.http.client.methods.HttpGet;
+//import org.apache.http.client.utils.URIBuilder;
+//import org.apache.http.conn.ssl.NoopHostnameVerifier;
+//import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+//import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+//import org.apache.http.impl.client.CloseableHttpClient;
+//import org.apache.http.impl.client.HttpClients;
+//import org.apache.http.ssl.SSLContexts;
+//import org.apache.http.util.EntityUtils;
+//import org.springframework.stereotype.Component;
+//
+//import java.io.IOException;
+//import java.net.URI;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//@Component
+//@AllArgsConstructor
+//public class HttpClientUtil {
+//
+// public String sendHourGet() {
+// String url = "http://123";
+// Map param = new HashMap<>();
+// param.put("key", "key");
+// param.put("location", "apiloction");
+// param.put("language", "zh-Hans");
+// param.put("unit", "c");
+// param.put("start", "1");
+// param.put("hours", "24");
+// // 创建Httpclient对象
+// CloseableHttpClient httpclient = HttpClients.createDefault();
+// String resultString = "";
+// CloseableHttpResponse response = null;
+// try {
+// httpclient = HttpClients.custom()
+// .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
+// //忽略掉对服务器端证书的校验
+// .loadTrustMaterial(null, new TrustSelfSignedStrategy())
+// .build(), NoopHostnameVerifier.INSTANCE))
+// .build();
+// // 创建uri
+// URIBuilder builder = new URIBuilder(url);
+// if (param != null) {
+// for (String key : param.keySet()) {
+// builder.addParameter(key, param.get(key));
+// }
+// }
+// URI uri = builder.build();
+// // 创建http GET请求
+// HttpGet httpGet = new HttpGet(uri);
+// // 执行请求
+// response = httpclient.execute(httpGet);
+// // 判断返回状态是否为200
+// if (response.getStatusLine().getStatusCode() == 200) {
+// resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// } finally {
+// try {
+// if (response != null) {
+// response.close();
+// }
+// httpclient.close();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// return resultString;
+// }
+//
+// public String sendDayGet() {
+// String url = "http://123";
+// Map param = new HashMap<>();
+// param.put("key", "key");
+// param.put("location", "location");
+// param.put("language", "zh-Hans");
+// param.put("unit", "c");
+// param.put("start", "0");
+// param.put("hours", "24");
+// // 创建Httpclient对象
+// CloseableHttpClient httpclient = HttpClients.createDefault();
+// String resultString = "";
+// CloseableHttpResponse response = null;
+// try {
+// httpclient = HttpClients.custom()
+// .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
+// //忽略掉对服务器端证书的校验
+// .loadTrustMaterial(null, new TrustSelfSignedStrategy())
+// .build(), NoopHostnameVerifier.INSTANCE))
+// .build();
+// // 创建uri
+// URIBuilder builder = new URIBuilder(url);
+// if (param != null) {
+// for (String key : param.keySet()) {
+// builder.addParameter(key, param.get(key));
+// }
+// }
+// URI uri = builder.build();
+// // 创建http GET请求
+// HttpGet httpGet = new HttpGet(uri);
+// // 执行请求
+// response = httpclient.execute(httpGet);
+// // 判断返回状态是否为200
+// if (response.getStatusLine().getStatusCode() == 200) {
+// resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// } finally {
+// try {
+// if (response != null) {
+// response.close();
+// }
+// httpclient.close();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// return resultString;
+// }
+//
+//}
diff --git a/sensorbub-common/pom.xml b/sensorbub-common/pom.xml
index 6b0e15d..9856c17 100644
--- a/sensorbub-common/pom.xml
+++ b/sensorbub-common/pom.xml
@@ -41,6 +41,13 @@
${redis.version}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java b/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java
index 988f355..81a221a 100644
--- a/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java
+++ b/sensorbub-common/src/main/java/com/casic/missiles/util/HttpClientUtil.java
@@ -1,127 +1,127 @@
-package com.casic.missiles.util;
-
-import lombok.AllArgsConstructor;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContexts;
-import org.apache.http.util.EntityUtils;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-@Component
-@AllArgsConstructor
-public class HttpClientUtil {
-
- public String sendHourGet() {
- String url = "http://123";
- Map param = new HashMap<>();
- param.put("key", "key");
- param.put("location", "apiloction");
- param.put("language", "zh-Hans");
- param.put("unit", "c");
- param.put("start", "1");
- param.put("hours", "24");
- // 创建Httpclient对象
- CloseableHttpClient httpclient = HttpClients.createDefault();
- String resultString = "";
- CloseableHttpResponse response = null;
- try {
- httpclient = HttpClients.custom()
- .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
- //忽略掉对服务器端证书的校验
- .loadTrustMaterial(null, new TrustSelfSignedStrategy())
- .build(), NoopHostnameVerifier.INSTANCE))
- .build();
- // 创建uri
- URIBuilder builder = new URIBuilder(url);
- if (param != null) {
- for (String key : param.keySet()) {
- builder.addParameter(key, param.get(key));
- }
- }
- URI uri = builder.build();
- // 创建http GET请求
- HttpGet httpGet = new HttpGet(uri);
- // 执行请求
- response = httpclient.execute(httpGet);
- // 判断返回状态是否为200
- if (response.getStatusLine().getStatusCode() == 200) {
- resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (response != null) {
- response.close();
- }
- httpclient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return resultString;
- }
-
- public String sendDayGet() {
- String url = "http://123";
- Map param = new HashMap<>();
- param.put("key", "key");
- param.put("location", "location");
- param.put("language", "zh-Hans");
- param.put("unit", "c");
- param.put("start", "0");
- param.put("hours", "24");
- // 创建Httpclient对象
- CloseableHttpClient httpclient = HttpClients.createDefault();
- String resultString = "";
- CloseableHttpResponse response = null;
- try {
- httpclient = HttpClients.custom()
- .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
- //忽略掉对服务器端证书的校验
- .loadTrustMaterial(null, new TrustSelfSignedStrategy())
- .build(), NoopHostnameVerifier.INSTANCE))
- .build();
- // 创建uri
- URIBuilder builder = new URIBuilder(url);
- if (param != null) {
- for (String key : param.keySet()) {
- builder.addParameter(key, param.get(key));
- }
- }
- URI uri = builder.build();
- // 创建http GET请求
- HttpGet httpGet = new HttpGet(uri);
- // 执行请求
- response = httpclient.execute(httpGet);
- // 判断返回状态是否为200
- if (response.getStatusLine().getStatusCode() == 200) {
- resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (response != null) {
- response.close();
- }
- httpclient.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return resultString;
- }
-
-}
+//package com.casic.missiles.util;
+//
+//import lombok.AllArgsConstructor;
+//import org.apache.http.client.methods.CloseableHttpResponse;
+//import org.apache.http.client.methods.HttpGet;
+//import org.apache.http.client.utils.URIBuilder;
+//import org.apache.http.conn.ssl.NoopHostnameVerifier;
+//import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+//import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+//import org.apache.http.impl.client.CloseableHttpClient;
+//import org.apache.http.impl.client.HttpClients;
+//import org.apache.http.ssl.SSLContexts;
+//import org.apache.http.util.EntityUtils;
+//import org.springframework.stereotype.Component;
+//
+//import java.io.IOException;
+//import java.net.URI;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//@Component
+//@AllArgsConstructor
+//public class HttpClientUtil {
+//
+// public String sendHourGet() {
+// String url = "http://123";
+// Map param = new HashMap<>();
+// param.put("key", "key");
+// param.put("location", "apiloction");
+// param.put("language", "zh-Hans");
+// param.put("unit", "c");
+// param.put("start", "1");
+// param.put("hours", "24");
+// // 创建Httpclient对象
+// CloseableHttpClient httpclient = HttpClients.createDefault();
+// String resultString = "";
+// CloseableHttpResponse response = null;
+// try {
+// httpclient = HttpClients.custom()
+// .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
+// //忽略掉对服务器端证书的校验
+// .loadTrustMaterial(null, new TrustSelfSignedStrategy())
+// .build(), NoopHostnameVerifier.INSTANCE))
+// .build();
+// // 创建uri
+// URIBuilder builder = new URIBuilder(url);
+// if (param != null) {
+// for (String key : param.keySet()) {
+// builder.addParameter(key, param.get(key));
+// }
+// }
+// URI uri = builder.build();
+// // 创建http GET请求
+// HttpGet httpGet = new HttpGet(uri);
+// // 执行请求
+// response = httpclient.execute(httpGet);
+// // 判断返回状态是否为200
+// if (response.getStatusLine().getStatusCode() == 200) {
+// resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// } finally {
+// try {
+// if (response != null) {
+// response.close();
+// }
+// httpclient.close();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// return resultString;
+// }
+//
+// public String sendDayGet() {
+// String url = "http://123";
+// Map param = new HashMap<>();
+// param.put("key", "key");
+// param.put("location", "location");
+// param.put("language", "zh-Hans");
+// param.put("unit", "c");
+// param.put("start", "0");
+// param.put("hours", "24");
+// // 创建Httpclient对象
+// CloseableHttpClient httpclient = HttpClients.createDefault();
+// String resultString = "";
+// CloseableHttpResponse response = null;
+// try {
+// httpclient = HttpClients.custom()
+// .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContexts.custom()
+// //忽略掉对服务器端证书的校验
+// .loadTrustMaterial(null, new TrustSelfSignedStrategy())
+// .build(), NoopHostnameVerifier.INSTANCE))
+// .build();
+// // 创建uri
+// URIBuilder builder = new URIBuilder(url);
+// if (param != null) {
+// for (String key : param.keySet()) {
+// builder.addParameter(key, param.get(key));
+// }
+// }
+// URI uri = builder.build();
+// // 创建http GET请求
+// HttpGet httpGet = new HttpGet(uri);
+// // 执行请求
+// response = httpclient.execute(httpGet);
+// // 判断返回状态是否为200
+// if (response.getStatusLine().getStatusCode() == 200) {
+// resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// } finally {
+// try {
+// if (response != null) {
+// response.close();
+// }
+// httpclient.close();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// return resultString;
+// }
+//
+//}
diff --git a/sensorbub-common/src/main/java/com/casic/missiles/util/SpringContextUtil.java b/sensorbub-common/src/main/java/com/casic/missiles/util/SpringContextUtil.java
new file mode 100644
index 0000000..9b3ab90
--- /dev/null
+++ b/sensorbub-common/src/main/java/com/casic/missiles/util/SpringContextUtil.java
@@ -0,0 +1,106 @@
+package com.casic.missiles.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ForkJoinPool;
+import java.util.function.Function;
+
+/**
+ * @Description: Spring应用上下文工具
+ * @Author: wangpeng
+ * @Date: 2022/8/11 18:04
+ */
+@Component
+public class SpringContextUtil implements BeanFactoryPostProcessor, ApplicationContextAware {
+ /**
+ * Spring应用上下文环境
+ */
+ private static ApplicationContext applicationContext;
+
+ private static ConfigurableListableBeanFactory beanFactory;
+
+ /**
+ * 实现ApplicationContextAware接口的回调方法,设置上下文环境
+ */
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ SpringContextUtil.applicationContext = applicationContext;
+ }
+
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ SpringContextUtil.beanFactory = beanFactory;
+ }
+
+ public static ApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+// public static Object getBean(String beanId) throws BeansException {
+// return applicationContext.getBean(beanId);
+// }
+
+ public static T getBean(Class requiredType) {
+ return (T) applicationContext.getBean(requiredType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static T getBean(String name) throws BeansException {
+ return (T) beanFactory.getBean(name);
+ }
+
+ public static boolean containsBean(String name) {
+ return beanFactory.containsBean(name);
+ }
+
+ public static T registerBean(String beanName, Class clazz, Function function) {
+ // 生成bean定义
+ BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(clazz);
+ // 执行bean处理函数
+ AbstractBeanDefinition beanDefinition = function.apply(beanDefinitionBuilder);
+ BeanDefinitionRegistry beanFactory = (BeanDefinitionRegistry) SpringContextUtil.beanFactory;
+ // 判断是否通过beanName注册
+ if (StringUtils.isNotBlank(beanName) && !containsBean(beanName)) {
+ beanFactory.registerBeanDefinition(beanName, beanDefinition);
+ return getBean(beanName);
+ } else {
+ // 非命名bean注册
+ String name = BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, beanFactory);
+ return getBean(name);
+ }
+ }
+
+ public static T registerBean(String beanName, Class clazz, List