From 14190ef94c4eb13041556fb3c9ce04906e83cd71 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 09:19:14 +0800
Subject: [PATCH 001/172] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=87=BA=E4=BA=8B?=
=?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 31 +++
Dockerfile | 10 +
pom.xml | 127 +++++++++++
rzl_adapter_run.sh | 30 +++
setup_dev.sh | 27 +++
setup_production.sh | 20 ++
setup_test.sh | 27 +++
.../DipperPositionApplication.java | 24 +++
.../controller/DipperPositionController.java | 30 +++
src/main/resources/bootstrap-dev.yaml | 10 +
src/main/resources/bootstrap-pro.yaml | 10 +
src/main/resources/bootstrap-test.yaml | 10 +
src/main/resources/bootstrap.yaml | 10 +
src/main/resources/log/logback-spring.xml | 197 ++++++++++++++++++
14 files changed, 563 insertions(+)
create mode 100644 .gitignore
create mode 100644 Dockerfile
create mode 100644 pom.xml
create mode 100644 rzl_adapter_run.sh
create mode 100644 setup_dev.sh
create mode 100644 setup_production.sh
create mode 100644 setup_test.sh
create mode 100644 src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
create mode 100644 src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
create mode 100644 src/main/resources/bootstrap-dev.yaml
create mode 100644 src/main/resources/bootstrap-pro.yaml
create mode 100644 src/main/resources/bootstrap-test.yaml
create mode 100644 src/main/resources/bootstrap.yaml
create mode 100644 src/main/resources/log/logback-spring.xml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d4dfde6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..839622d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,10 @@
+FROM java:8
+MAINTAINER king <1609724385@qq.com>
+VOLUME /tmp
+COPY target/dipperposition.jar dipperposition.jar
+COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas
+ENV TimeZone=Asia/Shanghai
+ENV active=dev
+ENV JAVA_OPTS="-Xmx256M -Xms256M"
+RUN ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone
+ENTRYPOINT java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /dipperposition.jar --spring.profiles.active=$active
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..3a9aa0a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,127 @@
+
+
+ 4.0.0
+ com.telpo
+ dipperposition
+ 1.0-SNAPSHOT
+ dipperposition
+ 北斗定位服务
+ jar
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.5.RELEASE
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ UTF-8
+ 2.2.0.RELEASE
+ Hoxton.RELEASE
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.10
+
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ 2.2.4
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.28
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ ${spring-cloud-alibaba.version}
+ pom
+ import
+
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ true
+
+
+
+
+ repackage
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rzl_adapter_run.sh b/rzl_adapter_run.sh
new file mode 100644
index 0000000..a50a29f
--- /dev/null
+++ b/rzl_adapter_run.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+environment=$1
+version=$2
+echo "环境变量为${environment},版本为$version!"
+if [[ ${environment} == 'production' ]]; then
+ echo "开始远程构建容器"
+ docker stop dipperposition_service || true
+ docker rm dipperposition_service || true
+ docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/telpo_platform/rzl_adapter | awk '{print $3}')
+ docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com
+ docker pull registry.cn-shanghai.aliyuncs.com/telpo_platform/dipperposition_service:$version
+ docker run -e active=pro -v /home/data/dipperposition/log:/var/log/dipperposition --restart=always -p 8092:8092 -d --name dipperposition_service registry.cn-shanghai.aliyuncs.com/telpo_platform/dipperposition_service:$version
+ #删除产生的None镜像
+ docker rmi -f $(docker images | grep none | awk '{print $3}')
+ docker ps -a
+else
+if [[ ${environment} == 'test' ]]; then
+ #echo "开始远程构建容器"
+ docker stop dipperposition_service || true
+ docker rm dipperposition_service || true
+
+ docker rmi -f $(docker images | grep 139.224.254.18:5000/dipperposition_service | awk '{print $3}')
+ docker pull 139.224.254.18:5000/rzl_adapter:$version
+ docker run -v /home/data/dipperposition/log:/var/log/dipperposition -e active=test --restart=always -d --network host --name dipperposition_service 139.224.254.18:5000/dipperposition_service:$version
+
+ #删除产生的None镜像
+ docker rmi -f $(docker images | grep none | awk '{print $3}')
+ docker ps -a
+fi
+fi
diff --git a/setup_dev.sh b/setup_dev.sh
new file mode 100644
index 0000000..9c709f8
--- /dev/null
+++ b/setup_dev.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+mvn clean
+mvn package -Dmaven.test.skip=true
+#image_version=$(date +%Y%m%d%H%M)
+image_version=$version
+docker stop dipperposition_service || true
+docker rm dipperposition_service || true
+
+# 删除镜像
+docker rmi -f $(docker images | grep telpo/dipperposition_service | awk '{print $3}')
+
+docker build . -t telpo/rzl_adapter:$image_version
+
+#TODO:推送镜像到私有仓库
+echo '=================开始推送镜像======================='
+docker tag telpo/dipperposition_service:$image_version 139.224.254.18:5000/dipperposition_service:$image_version
+docker push 139.224.254.18:5000/dipperposition_service:$image_version
+echo '=================推送镜像完成======================='
+
+#删除产生的None镜像
+docker rmi -f $(docker images | grep none | awk '{print $3}')
+# 查看镜像列表
+docker images
+# 启动容器
+docker run -v /home/data/dipperposition/log:/var/log/dipperposition -d -e active=dev --network host --restart=always --name dipperposition_service 139.224.254.18:5000/dipperposition_service:$image_version
+# 查看日志
+# docker logs dipperposition_service
diff --git a/setup_production.sh b/setup_production.sh
new file mode 100644
index 0000000..7de562d
--- /dev/null
+++ b/setup_production.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+mvn clean
+mvn package -Dmaven.test.skip=true
+image_version=$version
+# 删除镜像
+docker rmi -f $(
+ docker images | grep registry.cn-shanghai.aliyuncs.com/telpo_platform/dipperposition_service | awk '{print $3}'
+)
+# 构建telpo/mrp:$image_version镜像
+docker build . -t telpo/dipperposition_service:$image_version
+#TODO:推送镜像到阿里仓库
+echo '=================开始推送镜像======================='
+docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com
+docker tag telpo/dipperposition_service:$image_version registry.cn-shanghai.aliyuncs.com/telpo_platform/dipperposition_service:$image_version
+docker push registry.cn-shanghai.aliyuncs.com/telpo_platform/dipperposition_service:$image_version
+echo '=================推送镜像完成======================='
+#删除产生的None镜像
+docker rmi -f $(docker images | grep none | awk '{print $3}')
+# 查看镜像列表
+docker images
diff --git a/setup_test.sh b/setup_test.sh
new file mode 100644
index 0000000..19c0b24
--- /dev/null
+++ b/setup_test.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+mvn clean
+mvn package -Dmaven.test.skip=true
+#image_version=$(date +%Y%m%d%H%M)
+image_version=$version
+docker stop dipperposition_service || true
+docker rm dipperposition_service || true
+
+# 删除镜像
+docker rmi -f $(docker images | grep telpo/dipperposition_service | awk '{print $3}')
+
+docker build . -t telpo/dipperposition_service:$image_version
+
+#TODO:推送镜像到私有仓库
+echo '=================开始推送镜像======================='
+docker tag telpo/dipperposition_service:$image_version 139.224.254.18:5000/dipperposition_service:$image_version
+docker push 139.224.254.18:5000/dipperposition_service:$image_version
+echo '=================推送镜像完成======================='
+
+#删除产生的None镜像
+docker rmi -f $(docker images | grep none | awk '{print $3}')
+# 查看镜像列表
+docker images
+# 启动容器
+docker run -v /home/data/dipperposition/log:/var/log/dipperposition -d -e active=test --network host --restart=always --name dipperposition_service 139.224.254.18:5000/dipperposition_service:$image_version
+# 查看日志
+# docker logs dipperposition_service
diff --git a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
new file mode 100644
index 0000000..be9dc30
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
@@ -0,0 +1,24 @@
+package com.telpo.dipperposition;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+/**
+ * @program: gateway
+ * @description: 网关启动类
+ * @author: linwl
+ * @create: 2020-06-18 16:39
+ */
+@SpringBootApplication
+@EnableDiscoveryClient
+@Slf4j
+public class DipperPositionApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(DipperPositionApplication.class, args);
+ log.info("北斗定位服务启动!");
+ }
+}
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
new file mode 100644
index 0000000..dd96b62
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -0,0 +1,30 @@
+package com.telpo.dipperposition.controller;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @program: DipperPositionController
+ * @description: 北斗定位
+ * @author: linwl
+ * @create: 2020-07-10 14:01
+ */
+@RestController
+@Slf4j
+public class DipperPositionController {
+
+ @RequestMapping("/getPos")
+ public String getCampusListJson() {
+ return "Helle world!";
+ }
+}
diff --git a/src/main/resources/bootstrap-dev.yaml b/src/main/resources/bootstrap-dev.yaml
new file mode 100644
index 0000000..6f36d67
--- /dev/null
+++ b/src/main/resources/bootstrap-dev.yaml
@@ -0,0 +1,10 @@
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: dipperposition-service
+ cloud:
+ nacos:
+ config:
+ server-addr: 172.16.192.26:8848
+ file-extension: yml
\ No newline at end of file
diff --git a/src/main/resources/bootstrap-pro.yaml b/src/main/resources/bootstrap-pro.yaml
new file mode 100644
index 0000000..721abc4
--- /dev/null
+++ b/src/main/resources/bootstrap-pro.yaml
@@ -0,0 +1,10 @@
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: dipperposition-service
+ cloud:
+ nacos:
+ config:
+ server-addr: 172.19.42.38:8848
+ file-extension: yml
\ No newline at end of file
diff --git a/src/main/resources/bootstrap-test.yaml b/src/main/resources/bootstrap-test.yaml
new file mode 100644
index 0000000..e8e687a
--- /dev/null
+++ b/src/main/resources/bootstrap-test.yaml
@@ -0,0 +1,10 @@
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: dipperposition-service
+ cloud:
+ nacos:
+ config:
+ server-addr: 172.19.42.44:8848
+ file-extension: yml
\ No newline at end of file
diff --git a/src/main/resources/bootstrap.yaml b/src/main/resources/bootstrap.yaml
new file mode 100644
index 0000000..6f36d67
--- /dev/null
+++ b/src/main/resources/bootstrap.yaml
@@ -0,0 +1,10 @@
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: dipperposition-service
+ cloud:
+ nacos:
+ config:
+ server-addr: 172.16.192.26:8848
+ file-extension: yml
\ No newline at end of file
diff --git a/src/main/resources/log/logback-spring.xml b/src/main/resources/log/logback-spring.xml
new file mode 100644
index 0000000..e461b86
--- /dev/null
+++ b/src/main/resources/log/logback-spring.xml
@@ -0,0 +1,197 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ debug
+
+
+ ${CONSOLE_LOG_PATTERN}
+
+ UTF-8
+
+
+
+
+
+
+
+
+
+ ${log.path}/log_debug.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ debug
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/log_info.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ info
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/log_warn.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ warn
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+ ${log.path}/log_error.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 9cc4e1e36b5244595fc97de224f6863e5f9f95b7 Mon Sep 17 00:00:00 2001
From: wangjx <1609724385@qq.com>
Date: Tue, 12 Jan 2021 09:20:34 +0800
Subject: [PATCH 002/172] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=87=BA=E4=BA=8B?=
=?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/DipperPositionApplication.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
index be9dc30..0fc217b 100644
--- a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
+++ b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
@@ -18,6 +18,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public class DipperPositionApplication {
public static void main(String[] args) {
+ log.info("北斗定位服务开始!");
SpringApplication.run(DipperPositionApplication.class, args);
log.info("北斗定位服务启动!");
}
From 8d1994adcff1db78c1164278c677fb2ea78be7f2 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 09:28:36 +0800
Subject: [PATCH 003/172] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=87=BA=E4=BA=8B?=
=?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
rzl_adapter_run.sh => dipper_position_run.sh | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename rzl_adapter_run.sh => dipper_position_run.sh (100%)
diff --git a/rzl_adapter_run.sh b/dipper_position_run.sh
similarity index 100%
rename from rzl_adapter_run.sh
rename to dipper_position_run.sh
From 7363bae6f51a8202369fab46d1af0185ccf3a360 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 09:43:26 +0800
Subject: [PATCH 004/172] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=87=BA=E4=BA=8B?=
=?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/DipperPositionApplication.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
index 0fc217b..97c9f71 100644
--- a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
+++ b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
@@ -4,7 +4,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @program: gateway
From d9ef5220e40de582a50ca0064dab4eca2af4fb0e Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 09:49:13 +0800
Subject: [PATCH 005/172] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=87=BA=E4=BA=8B?=
=?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
setup_dev.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup_dev.sh b/setup_dev.sh
index 9c709f8..2ae931a 100644
--- a/setup_dev.sh
+++ b/setup_dev.sh
@@ -9,7 +9,7 @@ docker rm dipperposition_service || true
# 删除镜像
docker rmi -f $(docker images | grep telpo/dipperposition_service | awk '{print $3}')
-docker build . -t telpo/rzl_adapter:$image_version
+docker build . -t telpo/dipperposition_service:$image_version
#TODO:推送镜像到私有仓库
echo '=================开始推送镜像======================='
From d0b5bd068605ff74563e06a483f4030f2768d448 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 10:03:23 +0800
Subject: [PATCH 006/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DipperPositionApplication.java | 2 ++
.../dipperposition/config/PositionConfig.java | 26 +++++++++++++++++++
src/main/resources/log/logback-spring.xml | 4 +--
3 files changed, 30 insertions(+), 2 deletions(-)
create mode 100644 src/main/java/com/telpo/dipperposition/config/PositionConfig.java
diff --git a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
index 97c9f71..5bafebb 100644
--- a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
+++ b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
@@ -3,6 +3,7 @@ package com.telpo.dipperposition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
@@ -12,6 +13,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
* @create: 2020-06-18 16:39
*/
@SpringBootApplication
+@EnableConfigurationProperties
@EnableDiscoveryClient
@Slf4j
public class DipperPositionApplication {
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
new file mode 100644
index 0000000..d1ebbb0
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -0,0 +1,26 @@
+package com.telpo.dipperposition.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @program: gateway
+ * @description: jwt设置
+ * @author: linwl
+ * @create: 2020-06-18 17:45
+ */
+@Getter
+@Setter
+@ToString
+@ConfigurationProperties("position")
+@Configuration
+public class PositionConfig {
+
+ @Value("${hello}")
+ private String hello;
+
+}
diff --git a/src/main/resources/log/logback-spring.xml b/src/main/resources/log/logback-spring.xml
index e461b86..f4101af 100644
--- a/src/main/resources/log/logback-spring.xml
+++ b/src/main/resources/log/logback-spring.xml
@@ -7,7 +7,7 @@
-
+
@@ -172,7 +172,7 @@
-
+
From 12a8143c29e77245c76844dbb3255414b92f5b6f Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 10:25:09 +0800
Subject: [PATCH 007/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dipperposition/controller/DipperPositionController.java | 2 +-
src/main/resources/bootstrap-dev.yaml | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index dd96b62..9840242 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -24,7 +24,7 @@ import java.util.List;
public class DipperPositionController {
@RequestMapping("/getPos")
- public String getCampusListJson() {
+ public String getPos() {
return "Helle world!";
}
}
diff --git a/src/main/resources/bootstrap-dev.yaml b/src/main/resources/bootstrap-dev.yaml
index 6f36d67..9522e9b 100644
--- a/src/main/resources/bootstrap-dev.yaml
+++ b/src/main/resources/bootstrap-dev.yaml
@@ -1,4 +1,6 @@
spring:
+ profiles:
+ active: dev
main:
allow-bean-definition-overriding: true
application:
From 205257eb1e800d3aabb40ad46794c7c9e5c0c3f0 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 10:52:55 +0800
Subject: [PATCH 008/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/config/PositionConfig.java | 4 ++--
.../dipperposition/controller/DipperPositionController.java | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index d1ebbb0..fab2dfe 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -16,11 +16,11 @@ import org.springframework.context.annotation.Configuration;
@Getter
@Setter
@ToString
-@ConfigurationProperties("position")
@Configuration
+@ConfigurationProperties(prefix = "position")
public class PositionConfig {
- @Value("${hello}")
+ //@Value("${hello}")
private String hello;
}
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 9840242..e3d6fb4 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.context.ContextLoader;
import java.time.Duration;
import java.time.LocalDateTime;
@@ -25,6 +26,6 @@ public class DipperPositionController {
@RequestMapping("/getPos")
public String getPos() {
- return "Helle world!";
+ return "Helle world!" + ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From cc5e05c695d7d2ad8ef9dd1afa1baeb6ad1ca4ec Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:02:32 +0800
Subject: [PATCH 009/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/resources/bootstrap-dev.yaml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/resources/bootstrap-dev.yaml b/src/main/resources/bootstrap-dev.yaml
index 9522e9b..28b91ca 100644
--- a/src/main/resources/bootstrap-dev.yaml
+++ b/src/main/resources/bootstrap-dev.yaml
@@ -1,12 +1,12 @@
spring:
- profiles:
- active: dev
+
main:
allow-bean-definition-overriding: true
application:
- name: dipperposition-service
+ name: dipperposition-service.yaml
cloud:
nacos:
config:
+ service=${spring:application:name}:
server-addr: 172.16.192.26:8848
- file-extension: yml
\ No newline at end of file
+ file-extension: yaml
\ No newline at end of file
From 2bb4a8b56fdbc819cef745691263ffd674d2d74c Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:02:53 +0800
Subject: [PATCH 010/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/resources/bootstrap-dev.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/resources/bootstrap-dev.yaml b/src/main/resources/bootstrap-dev.yaml
index 28b91ca..4df2e42 100644
--- a/src/main/resources/bootstrap-dev.yaml
+++ b/src/main/resources/bootstrap-dev.yaml
@@ -3,7 +3,7 @@ spring:
main:
allow-bean-definition-overriding: true
application:
- name: dipperposition-service.yaml
+ name: dipperposition-service-dev.yaml
cloud:
nacos:
config:
From ea89686011aa5babab29431ac762eb28c53daf2b Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:04:23 +0800
Subject: [PATCH 011/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/resources/bootstrap-dev.yaml | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/main/resources/bootstrap-dev.yaml b/src/main/resources/bootstrap-dev.yaml
index 4df2e42..44b75f8 100644
--- a/src/main/resources/bootstrap-dev.yaml
+++ b/src/main/resources/bootstrap-dev.yaml
@@ -1,5 +1,4 @@
spring:
-
main:
allow-bean-definition-overriding: true
application:
@@ -7,6 +6,5 @@ spring:
cloud:
nacos:
config:
- service=${spring:application:name}:
server-addr: 172.16.192.26:8848
file-extension: yaml
\ No newline at end of file
From b1bcdc40275456d9aea1776cf80c48bc7b7c9b8f Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:08:26 +0800
Subject: [PATCH 012/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dipperposition/controller/DipperPositionController.java | 2 +-
src/main/resources/bootstrap-dev.yaml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index e3d6fb4..6a9b7bc 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -26,6 +26,6 @@ public class DipperPositionController {
@RequestMapping("/getPos")
public String getPos() {
- return "Helle world!" + ContextLoader.getCurrentWebApplicationContext().toString();
+ return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
diff --git a/src/main/resources/bootstrap-dev.yaml b/src/main/resources/bootstrap-dev.yaml
index 44b75f8..1656353 100644
--- a/src/main/resources/bootstrap-dev.yaml
+++ b/src/main/resources/bootstrap-dev.yaml
@@ -2,7 +2,7 @@ spring:
main:
allow-bean-definition-overriding: true
application:
- name: dipperposition-service-dev.yaml
+ name: dipperposition-service-dev
cloud:
nacos:
config:
From b51c9e1ff1092e47e0b096e4de30141e2c16629c Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:26:41 +0800
Subject: [PATCH 013/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 5 ++
.../controller/DipperPositionController.java | 58 +++++++++++++++----
2 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3a9aa0a..382d7f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,6 +51,11 @@
spring-cloud-starter-alibaba-nacos-config
+
+ com.alibaba.nacos
+ nacos-client
+
+
org.springframework.boot
spring-boot-starter-webflux
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 6a9b7bc..bb3f9d2 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -1,18 +1,16 @@
package com.telpo.dipperposition.controller;
+import com.alibaba.nacos.api.PropertyKeyConst;
+import com.alibaba.nacos.api.exception.NacosException;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.context.ContextLoader;
-import java.time.Duration;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.config.ConfigService;
+import com.alibaba.nacos.api.config.listener.Listener;
/**
* @program: DipperPositionController
@@ -25,7 +23,47 @@ import java.util.List;
public class DipperPositionController {
@RequestMapping("/getPos")
- public String getPos() {
+ public String getPos() throws NacosException, InterruptedException {
+ String serverAddr = "localhost";
+ String dataId = "dipperposition-service-dev";
+ String group = "DEFAULT_GROUP";
+
+ String positionId = "String.hello";
+ Properties properties = new Properties();
+ properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
+ ConfigService configService = NacosFactory.createConfigService(properties);
+ String content = configService.getConfig(dataId, group, 5000);
+ System.out.println(content);
+ configService.addListener(dataId, group, new Listener() {
+ @Override
+ public void receiveConfigInfo(String configInfo) {
+ log.info("recieve:" + configInfo);
+ }
+
+ @Override
+ public Executor getExecutor() {
+ return null;
+ }
+ });
+
+ boolean isPublishOk = configService.publishConfig(dataId, group, "content");
+ log.info(String.valueOf(isPublishOk));
+ Thread.sleep(3000);
+
+ content = configService.getConfig(dataId, group, 5000);
+ log.info(content);
+
+ content = configService.getConfig(dataId, group, 5000);
+ log.info(content);
+
+ boolean isRemoveOk = configService.removeConfig(dataId, group);
+ log.info(String.valueOf(isRemoveOk));
+ Thread.sleep(3000);
+
+ content = configService.getConfig(dataId, group, 5000);
+ log.info(content);
+ Thread.sleep(30000);
+
return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From 9f4859b0c30a210e356631fad0673ce1630fd6d7 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:36:03 +0800
Subject: [PATCH 014/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dipperposition/controller/DipperPositionController.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index bb3f9d2..7556c5c 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -53,7 +53,7 @@ public class DipperPositionController {
content = configService.getConfig(dataId, group, 5000);
log.info(content);
- content = configService.getConfig(dataId, group, 5000);
+ content = configService.getConfig(positionId, group, 5000);
log.info(content);
boolean isRemoveOk = configService.removeConfig(dataId, group);
@@ -64,6 +64,8 @@ public class DipperPositionController {
log.info(content);
Thread.sleep(30000);
+ System.out.println(content);
+
return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From f4273be9904f60ff4a13d6af1a73a6080926197d Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:49:24 +0800
Subject: [PATCH 015/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dipperposition/config/PositionConfig.java | 2 +-
.../controller/DipperPositionController.java | 21 ++++++++++---------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index fab2dfe..78fefbd 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "position")
public class PositionConfig {
- //@Value("${hello}")
+ @Value("${hello}")
private String hello;
}
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 7556c5c..74d6b59 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -32,7 +32,7 @@ public class DipperPositionController {
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
ConfigService configService = NacosFactory.createConfigService(properties);
- String content = configService.getConfig(dataId, group, 5000);
+ String content = configService.getConfig(dataId, group, 10000);
System.out.println(content);
configService.addListener(dataId, group, new Listener() {
@Override
@@ -50,21 +50,22 @@ public class DipperPositionController {
log.info(String.valueOf(isPublishOk));
Thread.sleep(3000);
- content = configService.getConfig(dataId, group, 5000);
+ configService = NacosFactory.createConfigService(properties);
+ content = configService.getConfig(dataId, group, 10000);
log.info(content);
- content = configService.getConfig(positionId, group, 5000);
+ content = configService.getConfig(positionId, group, 10000);
log.info(content);
- boolean isRemoveOk = configService.removeConfig(dataId, group);
- log.info(String.valueOf(isRemoveOk));
- Thread.sleep(3000);
+ //boolean isRemoveOk = configService.removeConfig(dataId, group);
+ //log.info(String.valueOf(isRemoveOk));
+ //Thread.sleep(3000);
- content = configService.getConfig(dataId, group, 5000);
- log.info(content);
- Thread.sleep(30000);
+ //content = configService.getConfig(dataId, group, 10000);
+ //log.info(content);
+ //Thread.sleep(30000);
- System.out.println(content);
+ //System.out.println(content);
return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
From 0f95841bde845f609706509c81c9819a211b293a Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 11:55:30 +0800
Subject: [PATCH 016/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dipperposition/config/PositionConfig.java | 7 +++-
.../controller/DipperPositionController.java | 40 ++-----------------
2 files changed, 9 insertions(+), 38 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 78fefbd..ed1f84e 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -1,5 +1,8 @@
package com.telpo.dipperposition.config;
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.PropertyKeyConst;
+import com.alibaba.nacos.api.config.ConfigService;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -7,6 +10,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
+import java.util.Properties;
+
/**
* @program: gateway
* @description: jwt设置
@@ -20,7 +25,7 @@ import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "position")
public class PositionConfig {
- @Value("${hello}")
+ //@Value("${hello}")
private String hello;
}
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 74d6b59..308655c 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -24,48 +24,14 @@ public class DipperPositionController {
@RequestMapping("/getPos")
public String getPos() throws NacosException, InterruptedException {
- String serverAddr = "localhost";
- String dataId = "dipperposition-service-dev";
String group = "DEFAULT_GROUP";
-
- String positionId = "String.hello";
+ String positionId = "position.hello";
Properties properties = new Properties();
+ String serverAddr = "172.16.192.26";
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
ConfigService configService = NacosFactory.createConfigService(properties);
- String content = configService.getConfig(dataId, group, 10000);
+ String content = configService.getConfig(positionId, group, 10000);
System.out.println(content);
- configService.addListener(dataId, group, new Listener() {
- @Override
- public void receiveConfigInfo(String configInfo) {
- log.info("recieve:" + configInfo);
- }
-
- @Override
- public Executor getExecutor() {
- return null;
- }
- });
-
- boolean isPublishOk = configService.publishConfig(dataId, group, "content");
- log.info(String.valueOf(isPublishOk));
- Thread.sleep(3000);
-
- configService = NacosFactory.createConfigService(properties);
- content = configService.getConfig(dataId, group, 10000);
- log.info(content);
-
- content = configService.getConfig(positionId, group, 10000);
- log.info(content);
-
- //boolean isRemoveOk = configService.removeConfig(dataId, group);
- //log.info(String.valueOf(isRemoveOk));
- //Thread.sleep(3000);
-
- //content = configService.getConfig(dataId, group, 10000);
- //log.info(content);
- //Thread.sleep(30000);
-
- //System.out.println(content);
return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
From 638a9703b0f285483a29f746e5213ca0a7e867ec Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 12:00:03 +0800
Subject: [PATCH 017/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/resources/bootstrap-dev.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/resources/bootstrap-dev.yaml b/src/main/resources/bootstrap-dev.yaml
index 1656353..8f21889 100644
--- a/src/main/resources/bootstrap-dev.yaml
+++ b/src/main/resources/bootstrap-dev.yaml
@@ -2,7 +2,7 @@ spring:
main:
allow-bean-definition-overriding: true
application:
- name: dipperposition-service-dev
+ name: dipperposition-service
cloud:
nacos:
config:
From 8ff69ce56f389348dee33d350c14f8119b72bd49 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 12:24:29 +0800
Subject: [PATCH 018/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/DipperPositionController.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 308655c..1202dc6 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -1,11 +1,14 @@
package com.telpo.dipperposition.controller;
+import com.alibaba.cloud.nacos.parser.NacosDataParserHandler;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.io.IOException;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import com.alibaba.nacos.api.NacosFactory;
@@ -23,16 +26,19 @@ import com.alibaba.nacos.api.config.listener.Listener;
public class DipperPositionController {
@RequestMapping("/getPos")
- public String getPos() throws NacosException, InterruptedException {
+ public String getPos() throws NacosException, InterruptedException, IOException {
String group = "DEFAULT_GROUP";
+ String dataId = "dipperposition-service";
String positionId = "position.hello";
Properties properties = new Properties();
String serverAddr = "172.16.192.26";
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
ConfigService configService = NacosFactory.createConfigService(properties);
- String content = configService.getConfig(positionId, group, 10000);
+ String content = configService.getConfig(dataId, group, 10000);
System.out.println(content);
-
- return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
+ //log.info(positionId + ":" + content.positionId)
+ Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
+ return dataMap == null ? "" : (String)dataMap.get(positionId);
+ //return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From f5c44b2d3f60c86ab0d1c8accc945653fb7abde5 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 12:27:25 +0800
Subject: [PATCH 019/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/config/PositionConfig.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index ed1f84e..b9cec6a 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -25,7 +25,7 @@ import java.util.Properties;
@ConfigurationProperties(prefix = "position")
public class PositionConfig {
- //@Value("${hello}")
+ @Value("${hello}")
private String hello;
}
From 4e7b6e5f34498719a4a7fc6ad16afaefc874aaba Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:06:21 +0800
Subject: [PATCH 020/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../telpo/dipperposition/co/RzlAccount.java | 19 +++++++++++++++++++
.../dipperposition/config/PositionConfig.java | 10 ++++++++++
2 files changed, 29 insertions(+)
create mode 100644 src/main/java/com/telpo/dipperposition/co/RzlAccount.java
diff --git a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
new file mode 100644
index 0000000..d332dd6
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
@@ -0,0 +1,19 @@
+package com.telpo.dipperposition.co;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @program: RzlAccount
+ * @description: 融智联账号配置
+ * @author: king
+ * @create: 2021-01-12 14:02
+ **/
+@Getter
+@Setter
+@ToString
+public class RzlAccount {
+
+ private String hello;
+}
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index b9cec6a..e64e98d 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -3,12 +3,14 @@ package com.telpo.dipperposition.config;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.config.ConfigService;
+import com.telpo.dipperposition.co.RzlAccount;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
import java.util.Properties;
@@ -28,4 +30,12 @@ public class PositionConfig {
@Value("${hello}")
private String hello;
+ @Scope("prototype")
+ public RzlAccount getRzlAccount() {
+
+ RzlAccount rzlAccount = new RzlAccount();
+ rzlAccount.setHello(hello);
+ return rzlAccount;
+ }
+
}
From 9a70fc4aee30d1a08afdff13768d71d0de5f73d5 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:08:53 +0800
Subject: [PATCH 021/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/config/PositionConfig.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index e64e98d..3bf2a0c 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -8,8 +8,10 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import java.util.Properties;
@@ -30,7 +32,8 @@ public class PositionConfig {
@Value("${hello}")
private String hello;
- @Scope("prototype")
+ @Lazy
+ @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
public RzlAccount getRzlAccount() {
RzlAccount rzlAccount = new RzlAccount();
From 31ec06a41dcd53797aa5f0413fafbb994b387c91 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:10:35 +0800
Subject: [PATCH 022/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/config/PositionConfig.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 3bf2a0c..6a81b21 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -22,6 +22,7 @@ import java.util.Properties;
* @author: linwl
* @create: 2020-06-18 17:45
*/
+@Lazy
@Getter
@Setter
@ToString
@@ -32,7 +33,6 @@ public class PositionConfig {
@Value("${hello}")
private String hello;
- @Lazy
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
public RzlAccount getRzlAccount() {
From 558005fd9aace61def5c80bff197d0c459994651 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:14:46 +0800
Subject: [PATCH 023/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../telpo/dipperposition/co/RzlAccount.java | 2 ++
.../controller/DipperPositionController.java | 30 +++++++++++--------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
index d332dd6..709f4da 100644
--- a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
+++ b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
@@ -3,6 +3,7 @@ package com.telpo.dipperposition.co;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
+import org.springframework.stereotype.Component;
/**
* @program: RzlAccount
@@ -13,6 +14,7 @@ import lombok.ToString;
@Getter
@Setter
@ToString
+@Component
public class RzlAccount {
private String hello;
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 1202dc6..157fc25 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -3,7 +3,9 @@ package com.telpo.dipperposition.controller;
import com.alibaba.cloud.nacos.parser.NacosDataParserHandler;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
+import com.telpo.dipperposition.co.RzlAccount;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -25,20 +27,24 @@ import com.alibaba.nacos.api.config.listener.Listener;
@Slf4j
public class DipperPositionController {
+ @Autowired RzlAccount rzlAccount;
+
@RequestMapping("/getPos")
public String getPos() throws NacosException, InterruptedException, IOException {
- String group = "DEFAULT_GROUP";
- String dataId = "dipperposition-service";
- String positionId = "position.hello";
- Properties properties = new Properties();
- String serverAddr = "172.16.192.26";
- properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
- ConfigService configService = NacosFactory.createConfigService(properties);
- String content = configService.getConfig(dataId, group, 10000);
- System.out.println(content);
- //log.info(positionId + ":" + content.positionId)
- Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
- return dataMap == null ? "" : (String)dataMap.get(positionId);
+// String group = "DEFAULT_GROUP";
+// String dataId = "dipperposition-service";
+// String positionId = "position.hello";
+// Properties properties = new Properties();
+// String serverAddr = "172.16.192.26";
+// properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
+// ConfigService configService = NacosFactory.createConfigService(properties);
+// String content = configService.getConfig(dataId, group, 10000);
+// System.out.println(content);
+// //log.info(positionId + ":" + content.positionId)
+// Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
+// return dataMap == null ? "" : (String)dataMap.get(positionId);
+
+ return rzlAccount.getHello();
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From d2cb1faa307d2036364a4a2d0bee64b863e0942d Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:17:13 +0800
Subject: [PATCH 024/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dipperposition/controller/DipperPositionController.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 157fc25..f69f1ec 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -4,6 +4,7 @@ import com.alibaba.cloud.nacos.parser.NacosDataParserHandler;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
import com.telpo.dipperposition.co.RzlAccount;
+import com.telpo.dipperposition.config.PositionConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -27,7 +28,8 @@ import com.alibaba.nacos.api.config.listener.Listener;
@Slf4j
public class DipperPositionController {
- @Autowired RzlAccount rzlAccount;
+ @Autowired
+ PositionConfig positionConfig;
@RequestMapping("/getPos")
public String getPos() throws NacosException, InterruptedException, IOException {
@@ -44,7 +46,7 @@ public class DipperPositionController {
// Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
// return dataMap == null ? "" : (String)dataMap.get(positionId);
- return rzlAccount.getHello();
+ return positionConfig.getHello();
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From 0e73159f60a4c261d247ff3e55ed5e776aa336ea Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:29:08 +0800
Subject: [PATCH 025/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../telpo/dipperposition/co/RzlAccount.java | 21 +++++++++++++++++++
.../controller/DipperPositionController.java | 6 ++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
index 709f4da..df5d1bc 100644
--- a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
+++ b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
@@ -3,6 +3,8 @@ package com.telpo.dipperposition.co;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
@@ -11,11 +13,30 @@ import org.springframework.stereotype.Component;
* @author: king
* @create: 2021-01-12 14:02
**/
+@Lazy
@Getter
@Setter
@ToString
@Component
public class RzlAccount {
+ @Value("${hello}")
private String hello;
+
+ RzlAccount()
+ {
+ }
+
+ private static RzlAccount instance;
+ public static RzlAccount getInstance(){
+ if (instance==null){
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ instance = new RzlAccount();
+ }
+ return instance;
+ }
}
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index f69f1ec..d31777a 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -28,8 +28,7 @@ import com.alibaba.nacos.api.config.listener.Listener;
@Slf4j
public class DipperPositionController {
- @Autowired
- PositionConfig positionConfig;
+ RzlAccount rzlAccount;
@RequestMapping("/getPos")
public String getPos() throws NacosException, InterruptedException, IOException {
@@ -45,8 +44,7 @@ public class DipperPositionController {
// //log.info(positionId + ":" + content.positionId)
// Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
// return dataMap == null ? "" : (String)dataMap.get(positionId);
-
- return positionConfig.getHello();
+ return RzlAccount.getInstance().getHello();
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From 5c13b0c2544210aad701b164a6dff7c2bbd86cdd Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:30:02 +0800
Subject: [PATCH 026/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/co/RzlAccount.java | 2 +-
.../telpo/dipperposition/config/PositionConfig.java | 11 -----------
2 files changed, 1 insertion(+), 12 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
index df5d1bc..5b589b4 100644
--- a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
+++ b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
@Component
public class RzlAccount {
- @Value("${hello}")
+ @Value("${position.hello}")
private String hello;
RzlAccount()
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 6a81b21..7e0b866 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -30,15 +30,4 @@ import java.util.Properties;
@ConfigurationProperties(prefix = "position")
public class PositionConfig {
- @Value("${hello}")
- private String hello;
-
- @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
- public RzlAccount getRzlAccount() {
-
- RzlAccount rzlAccount = new RzlAccount();
- rzlAccount.setHello(hello);
- return rzlAccount;
- }
-
}
From c3d71e8da5e71952679bcb2361371070829d7504 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:33:58 +0800
Subject: [PATCH 027/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dipperposition/config/PositionConfig.java | 18 ++++++++++++++++++
.../controller/DipperPositionController.java | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 7e0b866..0826f8d 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -29,5 +29,23 @@ import java.util.Properties;
@Configuration
@ConfigurationProperties(prefix = "position")
public class PositionConfig {
+ @Value("${position.hello}")
+ private String hello;
+ PositionConfig()
+ {
+ }
+
+ private static PositionConfig instance;
+ public static PositionConfig getInstance(){
+ if (instance==null){
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ instance = new PositionConfig();
+ }
+ return instance;
+ }
}
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index d31777a..619e305 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -44,7 +44,7 @@ public class DipperPositionController {
// //log.info(positionId + ":" + content.positionId)
// Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
// return dataMap == null ? "" : (String)dataMap.get(positionId);
- return RzlAccount.getInstance().getHello();
+ return PositionConfig.getInstance().getHello();
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From 6f91bc025aa0df70272138313bc86f9242819b46 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:39:26 +0800
Subject: [PATCH 028/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/telpo/dipperposition/config/PositionConfig.java | 6 ++++--
.../dipperposition/controller/DipperPositionController.java | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 0826f8d..4285ce0 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -27,11 +27,13 @@ import java.util.Properties;
@Setter
@ToString
@Configuration
-@ConfigurationProperties(prefix = "position")
public class PositionConfig {
- @Value("${position.hello}")
+ @Value(value = "${position.hello}")
private String hello;
+ @Value(value = "${spring.application.name}")
+ private String name;
+
PositionConfig()
{
}
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 619e305..24b744a 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -44,7 +44,9 @@ public class DipperPositionController {
// //log.info(positionId + ":" + content.positionId)
// Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
// return dataMap == null ? "" : (String)dataMap.get(positionId);
- return PositionConfig.getInstance().getHello();
+ String returnStr=
+ "return position = " + PositionConfig.getInstance().getHello() + "return name = " + PositionConfig.getInstance().getName();
+ return returnStr;
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}
From f2088a1404167bfab7659f848a5a605d28adf926 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:49:27 +0800
Subject: [PATCH 029/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../telpo/dipperposition/config/PositionConfig.java | 11 +++++++++--
.../controller/DipperPositionController.java | 1 +
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 4285ce0..223c64e 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -7,9 +7,11 @@ import com.telpo.dipperposition.co.RzlAccount;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
@@ -28,14 +30,19 @@ import java.util.Properties;
@ToString
@Configuration
public class PositionConfig {
- @Value(value = "${position.hello}")
+
+ @Autowired
+ private ConfigurableApplicationContext configurableApplicationContext;
+ //@Value(value = "${position.hello}")
private String hello;
- @Value(value = "${spring.application.name}")
+ //@Value(value = "${spring.application.name}")
private String name;
PositionConfig()
{
+ hello = configurableApplicationContext.getEnvironment().getProperty("position.hello");
+ name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name");
}
private static PositionConfig instance;
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 24b744a..22cba9b 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -46,6 +46,7 @@ public class DipperPositionController {
// return dataMap == null ? "" : (String)dataMap.get(positionId);
String returnStr=
"return position = " + PositionConfig.getInstance().getHello() + "return name = " + PositionConfig.getInstance().getName();
+
return returnStr;
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
From 507f5e1cc3d94d765b5be273cae898d619713e19 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:53:03 +0800
Subject: [PATCH 030/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/telpo/dipperposition/config/PositionConfig.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 223c64e..7153f46 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -24,7 +24,6 @@ import java.util.Properties;
* @author: linwl
* @create: 2020-06-18 17:45
*/
-@Lazy
@Getter
@Setter
@ToString
From 3c2cfdc8c0b35cb64e80f4661cbeb5a1982b348c Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Tue, 12 Jan 2021 14:56:16 +0800
Subject: [PATCH 031/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/telpo/dipperposition/config/PositionConfig.java | 4 ++--
.../controller/DipperPositionController.java | 9 +++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
index 7153f46..34b9059 100644
--- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
+++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java
@@ -40,8 +40,8 @@ public class PositionConfig {
PositionConfig()
{
- hello = configurableApplicationContext.getEnvironment().getProperty("position.hello");
- name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name");
+ //hello = configurableApplicationContext.getEnvironment().getProperty("position.hello");
+ //name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name");
}
private static PositionConfig instance;
diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
index 22cba9b..4783081 100644
--- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
+++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java
@@ -7,6 +7,7 @@ import com.telpo.dipperposition.co.RzlAccount;
import com.telpo.dipperposition.config.PositionConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -27,8 +28,9 @@ import com.alibaba.nacos.api.config.listener.Listener;
@RestController
@Slf4j
public class DipperPositionController {
-
- RzlAccount rzlAccount;
+ @Value(value = "${position.hello}")
+ private String hello;
+ //RzlAccount rzlAccount;
@RequestMapping("/getPos")
public String getPos() throws NacosException, InterruptedException, IOException {
@@ -44,8 +46,7 @@ public class DipperPositionController {
// //log.info(positionId + ":" + content.positionId)
// Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
// return dataMap == null ? "" : (String)dataMap.get(positionId);
- String returnStr=
- "return position = " + PositionConfig.getInstance().getHello() + "return name = " + PositionConfig.getInstance().getName();
+ String returnStr= "return position = " + hello;
return returnStr;
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
From 0d6b255922a4cfc4801a917ac06440da37cd7b67 Mon Sep 17 00:00:00 2001
From: linwl <304115325@qq.com>
Date: Fri, 15 Jan 2021 12:27:42 +0800
Subject: [PATCH 032/172] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 45 ++
.../DipperPositionApplication.java | 10 +
.../telpo/dipperposition/common/CSVUtil.java | 87 +++
.../dipperposition/common/HexConvert.java | 140 ++++
.../dipperposition/common/OkHttpUtil.java | 155 ++++
.../dipperposition/common/RedisUtil.java | 665 ++++++++++++++++++
.../dipperposition/common/SocketClient.java | 85 +++
.../dipperposition/common/TimeTools.java | 39 +
.../dipperposition/config/PositionConfig.java | 11 -
.../config/db/MongoDbContext.java | 66 ++
.../config/db/MongoListProperties.java | 30 +
.../config/db/MultiMongoTemplate.java | 26 +
.../controller/DipperPositionController.java | 32 +-
.../entity/mongo/IPProvinceEntity.java | 24 +
.../enums/DipperReturnValue.java | 53 ++
.../handler/NettyServerHandler.java | 145 ++++
.../handler/ServerChannelInitializer.java | 24 +
.../mapper/IPProvinceMapper.java | 52 ++
.../server/DipperPositionServer.java | 153 ++++
.../IDipperAstPosAsyncTaskService.java | 23 +
.../IDipperAstTimeAsyncTaskService.java | 17 +
.../service/IDipperDataAsyncTaskService.java | 26 +
.../service/IPProvinceService.java | 45 ++
.../DipperAstPosAsyncTaskServiceImpl.java | 251 +++++++
.../DipperAstTimeAsyncTaskServiceImpl.java | 104 +++
.../impl/DipperDataAsyncTaskServiceImpl.java | 73 ++
.../service/impl/IPProvinceServiceImpl.java | 62 ++
.../dipperposition/task/ScheduleService.java | 39 +
.../telpo/dipperposition/vo/IPProvinceVo.java | 20 +
src/main/resources/bootstrap.yaml | 26 +-
30 files changed, 2486 insertions(+), 42 deletions(-)
create mode 100644 src/main/java/com/telpo/dipperposition/common/CSVUtil.java
create mode 100644 src/main/java/com/telpo/dipperposition/common/HexConvert.java
create mode 100644 src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java
create mode 100644 src/main/java/com/telpo/dipperposition/common/RedisUtil.java
create mode 100644 src/main/java/com/telpo/dipperposition/common/SocketClient.java
create mode 100644 src/main/java/com/telpo/dipperposition/common/TimeTools.java
create mode 100644 src/main/java/com/telpo/dipperposition/config/db/MongoDbContext.java
create mode 100644 src/main/java/com/telpo/dipperposition/config/db/MongoListProperties.java
create mode 100644 src/main/java/com/telpo/dipperposition/config/db/MultiMongoTemplate.java
create mode 100644 src/main/java/com/telpo/dipperposition/entity/mongo/IPProvinceEntity.java
create mode 100644 src/main/java/com/telpo/dipperposition/enums/DipperReturnValue.java
create mode 100644 src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java
create mode 100644 src/main/java/com/telpo/dipperposition/handler/ServerChannelInitializer.java
create mode 100644 src/main/java/com/telpo/dipperposition/mapper/IPProvinceMapper.java
create mode 100644 src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/IDipperAstPosAsyncTaskService.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/IDipperAstTimeAsyncTaskService.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/IPProvinceService.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java
create mode 100644 src/main/java/com/telpo/dipperposition/service/impl/IPProvinceServiceImpl.java
create mode 100644 src/main/java/com/telpo/dipperposition/task/ScheduleService.java
create mode 100644 src/main/java/com/telpo/dipperposition/vo/IPProvinceVo.java
diff --git a/pom.xml b/pom.xml
index 382d7f3..20c8038 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,6 +87,51 @@
1.2.28
+
+ io.netty
+ netty-all
+ 4.1.13.Final
+
+
+
+ com.telpo
+ common
+ 1.1.19
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+
+ org.apache.commons
+ commons-pool2
+
+
+
+
+ com.squareup.okhttp3
+ okhttp
+ 4.8.0
+
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ 2.2.4
+
+
+
+
+ net.sourceforge.javacsv
+ javacsv
+ 2.0
+
+
diff --git a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
index 5bafebb..865170a 100644
--- a/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
+++ b/src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
@@ -1,11 +1,15 @@
package com.telpo.dipperposition;
+import com.telpo.dipperposition.server.DipperPositionServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import java.net.InetSocketAddress;
+
/**
* @program: gateway
* @description: 网关启动类
@@ -16,11 +20,17 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableConfigurationProperties
@EnableDiscoveryClient
@Slf4j
+@ConfigurationPropertiesScan
public class DipperPositionApplication {
public static void main(String[] args) {
log.info("北斗定位服务开始!");
SpringApplication.run(DipperPositionApplication.class, args);
log.info("北斗定位服务启动!");
+ //启动服务端
+ DipperPositionServer nettyServer = new DipperPositionServer();
+ nettyServer.startTimeAsnc();
+ nettyServer.startPosAsnc();
+ nettyServer.startStarsAsnc();
}
}
diff --git a/src/main/java/com/telpo/dipperposition/common/CSVUtil.java b/src/main/java/com/telpo/dipperposition/common/CSVUtil.java
new file mode 100644
index 0000000..e6d1ab0
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/common/CSVUtil.java
@@ -0,0 +1,87 @@
+package com.telpo.dipperposition.common;
+
+import com.csvreader.CsvReader;
+import com.csvreader.CsvWriter;
+
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+/**
+ * @program: dipperposition
+ * @description: CSV文件读取单元
+ * @author: linwl
+ * @create: 2021-01-14 11:19
+ **/
+public class CSVUtil {
+ /**
+ * 读取每行的数据
+ *
+ * @param readPath
+ * @return
+ */
+ public static List readCSV(String readPath) {
+ String filePath = readPath;
+ List listData = new ArrayList<>();
+ try {
+ filePath = readPath;
+ CsvReader csvReader = new CsvReader(filePath);
+ // 读表头
+ boolean re = csvReader.readHeaders();
+ while (csvReader.readRecord()) {
+ String rawRecord = csvReader.getRawRecord();
+ listData.add(rawRecord);
+ }
+ return listData;
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("文件未找到");
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ }
+
+ /**
+ * 写入文件头
+ * @param writePath
+ * @param header
+ */
+ public static void writeCSV(String writePath, String[] header) {
+ String filePath = writePath;
+ try {
+ CsvWriter csvWriter = new CsvWriter(writePath, ',', Charset.forName("UTF-8"));
+ //String [] header = {"SkuId","SsuId","图片地址","大小(bit)","高度","宽度"};
+ csvWriter.writeRecord(header);
+ csvWriter.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * 利用输入输出流持续写
+ * @param fileName
+ * @param content
+ */
+ public static void writeContent(String fileName, String content) {
+ FileWriter writer = null;
+ try {
+ // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
+ writer = new FileWriter(fileName, true);
+ writer.write(content + "\r\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (writer != null) {
+ writer.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/telpo/dipperposition/common/HexConvert.java b/src/main/java/com/telpo/dipperposition/common/HexConvert.java
new file mode 100644
index 0000000..8f79122
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/common/HexConvert.java
@@ -0,0 +1,140 @@
+package com.telpo.dipperposition.common;
+
+/**
+ * @program: dipperposition
+ * @description: 16进制处理
+ * @author: linwl
+ * @create: 2021-01-14 22:05
+ **/
+public class HexConvert {
+ public static String convertStringToHex(String str){
+
+ char[] chars = str.toCharArray();
+
+ StringBuffer hex = new StringBuffer();
+ for(int i = 0; i < chars.length; i++){
+ hex.append(Integer.toHexString((int)chars[i]));
+ }
+
+ return hex.toString();
+ }
+
+ public static String convertHexToString(String hex){
+
+ StringBuilder sb = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+
+ for( int i=0; i> 4));
+ hex += String.valueOf(hexStr.charAt(b & 0x0F));
+ result += hex + " ";
+ }
+ return result;
+ }
+
+ //將10進制轉換為16進制
+ public static String encodeHEX(long numb){
+
+ String hex= Long.toHexString(numb);
+ return hex;
+
+ }
+
+
+ //將16進制字符串轉換為10進制數字
+ public static long decodeHEX(String hexs){
+ long longValue= Long.parseLong("123ABC", 16);
+ return longValue;
+ }
+
+
+ /**
+ * 生成校验码的int值
+ * */
+ public static String makeChecksum(String data) {
+ if (data == null || data.equals("")) {
+ return "";
+ }
+ int total = 0;
+ int len = data.length();
+ int num = 0;
+ while (num < len) {
+ String s = data.substring(num, num + 2);
+ //System.out.println(s);
+ total += Integer.parseInt(s, 16);
+ num = num + 2;
+ }
+ /**
+ * 用256求余最大是255,即16进制的FF
+ */
+ int mod = total % 256;
+ String hex = Integer.toHexString(mod);
+ len = hex.length();
+ // 如果不够校验位的长度,补0,这里用的是两位校验
+ if (len < 2) {
+ hex = "0" + hex;
+ }
+ return hex;
+ }
+//
+// public static void main(String[] args) {
+//
+//
+// System.out.println("======ASCII码转换为16进制======");
+// String str = "*00007VERSION\\n1$";
+// System.out.println("字符串: " + str);
+// String hex = HexConvert.convertStringToHex(str);
+// System.out.println("====转换为16进制=====" + hex);
+//
+// System.out.println("======16进制转换为ASCII======");
+// System.out.println("Hex : " + hex);
+// System.out.println("ASCII : " + HexConvert.convertHexToString(hex));
+//
+// byte[] bytes = HexConvert.hexStringToBytes( hex );
+//
+// System.out.println(HexConvert.BinaryToHexString( bytes ));
+// }
+
+}
diff --git a/src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java b/src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java
new file mode 100644
index 0000000..a31eb99
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/common/OkHttpUtil.java
@@ -0,0 +1,155 @@
+package com.telpo.dipperposition.common;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @program: DataPushServer
+ * @description: okhttp工具类
+ * @author: linwl
+ * @create: 2020-07-17 15:43
+ */
+@Slf4j
+@Component
+public class OkHttpUtil {
+
+ @Autowired
+ private OkHttpClient okHttpClient;
+
+ /**
+ * 根据map获取get请求参数
+ *
+ * @param queries
+ * @return
+ */
+ public StringBuffer getQueryString(String url, Map queries) {
+ StringBuffer sb = new StringBuffer(url);
+ if (queries != null && queries.keySet().size() > 0) {
+ boolean firstFlag = true;
+ Iterator iterator = queries.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ if (firstFlag) {
+ sb.append("?" + entry.getKey() + "=" + entry.getValue());
+ firstFlag = false;
+ } else {
+ sb.append("&" + entry.getKey() + "=" + entry.getValue());
+ }
+ }
+ }
+ return sb;
+ }
+
+ /**
+ * get
+ *
+ * @param url 请求的url
+ * @param queries 请求的参数,在浏览器?后面的数据,没有可以传null
+ * @return
+ */
+ public String get(String url, Map queries) {
+ StringBuffer sb = getQueryString(url, queries);
+ Request request = new Request.Builder().url(sb.toString()).build();
+ log.debug(MessageFormat.format("发送Get to url<{0}>,参数为:{1}", url, queries));
+ return execNewCall(request);
+ }
+
+ /**
+ * post
+ *
+ * @param url 请求的url
+ * @param params post form 提交的参数
+ * @return
+ */
+ public String postFormParams(String url, Map params) {
+ FormBody.Builder builder = new FormBody.Builder();
+ // 添加参数
+ if (params != null && params.keySet().size() > 0) {
+ for (String key : params.keySet()) {
+ builder.add(key, params.get(key));
+ }
+ }
+ log.debug(MessageFormat.format("发送post from to url<{0}>,参数为:{1}", url, params));
+ Request request = new Request.Builder().url(url).post(builder.build()).build();
+ return execNewCall(request);
+ }
+
+ /** Post请求发送JSON数据....{"name":"zhangsan","pwd":"123456"} 参数一:请求Url 参数二:请求的JSON 参数三:请求回调 */
+ public String postJsonParams(String url, String jsonParams) {
+ RequestBody requestBody = RequestBody.create(jsonParams, MediaType.parse("application/json; charset=utf-8"));
+ Request request = new Request.Builder().url(url).post(requestBody).build();
+ log.debug(MessageFormat.format("发送post json to url<{0}>,参数为:{1}", url, jsonParams));
+ return execNewCall(request);
+ }
+
+ /** Post请求发送xml数据.... 参数一:请求Url 参数二:请求的xmlString 参数三:请求回调 */
+ public String postXmlParams(String url, String xml) {
+ RequestBody requestBody =
+ RequestBody.create(xml, MediaType.parse("application/xml; charset=utf-8"));
+ Request request = new Request.Builder().url(url).post(requestBody).build();
+ log.debug(MessageFormat.format("发送post xml to url<{0}>,参数为:{1}", url, xml));
+ return execNewCall(request);
+ }
+
+ /**
+ * 调用okhttp的newCall方法
+ *
+ * @param request
+ * @return
+ */
+ private String execNewCall(Request request) {
+ try (Response response = okHttpClient.newCall(request).execute()) {
+ if (response.isSuccessful()) {
+ return Objects.requireNonNull(response.body()).string();
+ }
+ } catch (Exception e) {
+ log.error("okhttp3 put error >> ex = {}", ExceptionUtils.getStackTrace(e));
+ }
+ return "FAIL";
+ }
+
+ /**
+ * Post请求发送JSON数据....{"name":"zhangsan","pwd":"123456"} 参数一:请求Url 参数二:请求的JSON 参数三:请求回调
+ */
+ public String postJsonParamsWithToken(String url, String token, String jsonParams) {
+ RequestBody requestBody =
+ RequestBody.create(jsonParams, MediaType.parse("application/json; charset=utf-8"));
+ Request request = new Request.Builder().url(url).
+ addHeader("Authorization", token).post(requestBody).build();
+ log.debug(MessageFormat.format("发送post json to url<{0}>,参数为:{1}", url, jsonParams));
+ return execNewCall(request);
+ }
+
+ public JSONObject postRequestWithJson(String url, String accessToken, JSONObject postData) {
+ String postResult;
+ if (ObjectUtils.isNotEmpty(accessToken)) {
+ postResult = postJsonParamsWithToken(url, accessToken, JSONObject.toJSONString(postData));
+ } else {
+ postResult = postJsonParams(url, JSONObject.toJSONString(postData));
+ }
+
+ if (postResult == null) {
+ log.error("访问错误");
+ return null;
+ } else {
+ log.debug(postResult);
+ if(("FAIL").equals(postResult.toString())) {
+ JSONObject object = new JSONObject();
+ object.put("result", "FAIL");
+ return object;
+ } else {
+ return JSONObject.parseObject(postResult);
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/telpo/dipperposition/common/RedisUtil.java b/src/main/java/com/telpo/dipperposition/common/RedisUtil.java
new file mode 100644
index 0000000..97933f0
--- /dev/null
+++ b/src/main/java/com/telpo/dipperposition/common/RedisUtil.java
@@ -0,0 +1,665 @@
+package com.telpo.dipperposition.common;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @program: DataPushServer
+ * @description: redis工具类
+ * @author: linwl
+ * @create: 2020-07-11 10:26
+ */
+@Component
+@Slf4j
+public class RedisUtil {
+
+ @Resource private RedisTemplate redisTemplate;
+
+ // =============================common============================
+ /**
+ * 指定缓存失效时间
+ *
+ * @param key 键
+ * @param time 时间(秒)
+ * @return
+ */
+ public boolean expire(String key, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.expire(key, time, TimeUnit.SECONDS);
+ }
+ return true;
+ } catch (Exception e) {
+ log.error(key, e);
+ return false;
+ }
+ }
+
+ /**
+ * 根据key 获取过期时间
+ *
+ * @param key 键 不能为null
+ * @return 时间(秒) 返回0代表为永久有效
+ */
+ public long getExpire(String key) {
+ return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+ }
+
+ /**
+ * 判断key是否存在
+ *
+ * @param key 键
+ * @return true 存在 false不存在
+ */
+ public boolean hasKey(String key) {
+ try {
+ return redisTemplate.hasKey(key);
+ } catch (Exception e) {
+ log.error(key, e);
+ return false;
+ }
+ }
+
+ /**
+ * 删除缓存
+ *
+ * @param key 可以传一个值 或多个
+ */
+ @SuppressWarnings("unchecked")
+ public void del(String... key) {
+ if (key != null && key.length > 0) {
+ if (key.length == 1) {
+ redisTemplate.delete(key[0]);
+ } else {
+ redisTemplate.delete(CollectionUtils.arrayToList(key));
+ }
+ }
+ }
+
+ // ============================String=============================
+ /**
+ * 普通缓存获取
+ *
+ * @param key 键
+ * @return 值
+ */
+ public Object get(String key) {
+ return key == null ? null : redisTemplate.opsForValue().get(key);
+ }
+
+ /**
+ * 普通缓存放入
+ *
+ * @param key 键
+ * @param value 值
+ * @return true成功 false失败
+ */
+ public boolean set(String key, Object value) {
+ try {
+ redisTemplate.opsForValue().set(key, value);
+ return true;
+ } catch (Exception e) {
+ log.error(key, e);
+ return false;
+ }
+ }
+
+ /**
+ * 普通缓存放入并设置时间
+ *
+ * @param key 键
+ * @param value 值
+ * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
+ * @return true成功 false 失败
+ */
+ public boolean set(String key, Object value, long time) {
+ try {
+ if (time > 0) {
+ redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+ } else {
+ set(key, value);
+ }
+ return true;
+ } catch (Exception e) {
+ log.error(key, e);
+ return false;
+ }
+ }
+
+ /**
+ * 递增 适用场景: https://blog.csdn.net/y_y_y_k_k_k_k/article/details/79218254 高并发生成订单号,秒杀类的业务逻辑等。。
+ *
+ * @param key 键
+ * @param delta 要增加几(大于0)
+ * @return
+ */
+ public long incr(String key, long delta) {
+ if (delta < 0) {
+ throw new RuntimeException("递增因子必须大于0");
+ }
+ return redisTemplate.opsForValue().increment(key, delta);
+ }
+
+ /**
+ * 递减
+ *
+ * @param key 键
+ * @param delta 要减少几(小于0)
+ * @return
+ */
+ public long decr(String key, long delta) {
+ if (delta < 0) {
+ throw new RuntimeException("递减因子必须大于0");
+ }
+ return redisTemplate.opsForValue().increment(key, -delta);
+ }
+
+ // ================================Map=================================
+ /**
+ * HashGet
+ *
+ * @param key 键 不能为null
+ * @param item 项 不能为null
+ * @return 值
+ */
+ public Object hget(String key, String item) {
+ return redisTemplate.opsForHash().get(key, item);
+ }
+
+ /**
+ * 获取hashKey对应的所有键值
+ *
+ * @param key 键
+ * @return 对应的多个键值
+ */
+ public Map