diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java
index 0b1295ab88..6857591ab3 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java
@@ -118,4 +118,9 @@ public interface ServiceConstant {
* 数据统计
*/
String DATA_STATISTICAL_SERVER = "data-statistical-server";
+
+ /**
+ * 微信第三方平台
+ */
+ String EPMET_THIRD_PLATFORM_SERVER = "epmet-third-platform-server";
}
diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml
index 94cd5f1f1f..387ded533e 100644
--- a/epmet-gateway/pom.xml
+++ b/epmet-gateway/pom.xml
@@ -185,6 +185,10 @@
lb://epmet-openapi-scan
+
+
+ http://localhost:8109
+
@@ -346,6 +350,8 @@
lb://data-statistical-server
lb://epmet-openapi-scan
+
+ lb://epmet-third-platform-server
diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml
index 4d910e0f02..b7c816c002 100644
--- a/epmet-gateway/src/main/resources/bootstrap.yml
+++ b/epmet-gateway/src/main/resources/bootstrap.yml
@@ -280,12 +280,21 @@ spring:
#内容审核服务
- id: epmet-openapi-scan
uri: @gateway.routes.epmet-openapi-scan.uri@
- order: 29
+ order: 30
predicates:
- Path=${server.servlet.context-path}/epmetscan/**
filters:
- StripPrefix=1
- CpAuth=true
+ #微信第三方平台
+ - id: epmet-third-platform-server
+ uri: @gateway.routes.epmet-third-platform-server.uri@
+ order: 31
+ predicates:
+ - Path=${server.servlet.context-path}/epmet/third/platform/**
+ filters:
+ - StripPrefix=1
+ - CpAuth=true
nacos:
discovery:
server-addr: @nacos.server-addr@
@@ -400,6 +409,7 @@ epmet:
- /gov/issue/**
- /gov/project/**
- /resi/home/**
+ - /epmet/third/platform/**
swaggerUrls:
jwt:
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-client/epmet-third-platform-client.iml b/epmet-module/epmet-third-platform/epmet-third-platform-client/epmet-third-platform-client.iml
new file mode 100644
index 0000000000..157930f00d
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-client/epmet-third-platform-client.iml
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-client/pom.xml b/epmet-module/epmet-third-platform/epmet-third-platform-client/pom.xml
new file mode 100644
index 0000000000..f17f962919
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-client/pom.xml
@@ -0,0 +1,37 @@
+
+
+ 4.0.0
+
+
+ epmet-third-platform
+ com.epmet
+ 2.0.0
+
+
+
+ epmet-third-platform-client
+ jar
+
+
+
+ com.epmet
+ epmet-commons-tools
+ 2.0.0
+
+
+ io.springfox
+ springfox-swagger2
+
+
+ io.springfox
+ springfox-swagger-ui
+
+
+
+
+ ${project.artifactId}
+
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/constant/ThirdPlatformConstant.java b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/constant/ThirdPlatformConstant.java
new file mode 100644
index 0000000000..09f8af7681
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/constant/ThirdPlatformConstant.java
@@ -0,0 +1,29 @@
+package com.epmet.constant;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:48
+ */
+public interface ThirdPlatformConstant {
+
+ /**
+ * 第三方平台appId
+ */
+ String PLATFORM_APP_ID = "****************";
+
+ /**
+ * 第三方平台 secret
+ */
+ String PLATFORM_APP_SECRET = "****************";
+
+ /**
+ * 第三方平台 消息加解密Key
+ */
+ String PLATFORM_AES_KEY = "****************";
+
+ /**
+ * 第三方平台 消息校验Token
+ */
+ String PLATFORM_COMPONENT_TOKEN = "****************";
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/dto/form/ThirdPlatformEventFormDTO.java b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/dto/form/ThirdPlatformEventFormDTO.java
new file mode 100644
index 0000000000..a81ca6033a
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/dto/form/ThirdPlatformEventFormDTO.java
@@ -0,0 +1,36 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:57
+ */
+@Data
+public class ThirdPlatformEventFormDTO implements Serializable {
+
+ private static final long serialVersionUID = -8855993636150332559L;
+
+ /**
+ * 时间戳
+ */
+ private String timeStamp;
+
+ /**
+ * 随机数
+ */
+ private String nonce;
+
+ /**
+ * 消息体签名
+ */
+ private String msgSignature;
+
+ /**
+ * 消息体
+ */
+ private String postData;
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/dto/result/ResultBean.java b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/dto/result/ResultBean.java
new file mode 100644
index 0000000000..5248dc8cb2
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/dto/result/ResultBean.java
@@ -0,0 +1,24 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:08
+ */
+@Data
+public class ResultBean implements Serializable {
+
+ private static final long serialVersionUID = -1528288965079007980L;
+
+ private Object data;
+
+ private String msg;
+
+ private String errorMsg;
+
+ private Integer code;
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/feign/EpmetThirdPlatformFeignClient.java b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/feign/EpmetThirdPlatformFeignClient.java
new file mode 100644
index 0000000000..f325488ebf
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/feign/EpmetThirdPlatformFeignClient.java
@@ -0,0 +1,16 @@
+package com.epmet.feign;
+
+import com.epmet.commons.tools.constant.ServiceConstant;
+import com.epmet.feign.fallback.EpmetThirdPlatformFeignClientFallback;
+import org.springframework.cloud.openfeign.FeignClient;
+
+/**
+ * 本服务对外开放的API,其他服务通过引用此client调用该服务
+ *
+ * @Author zxc
+ * @CreateTime 2020/7/5 14:45
+ */
+@FeignClient(name = ServiceConstant.EPMET_THIRD_PLATFORM_SERVER, fallback = EpmetThirdPlatformFeignClientFallback.class)
+
+public interface EpmetThirdPlatformFeignClient {
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/feign/fallback/EpmetThirdPlatformFeignClientFallback.java b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/feign/fallback/EpmetThirdPlatformFeignClientFallback.java
new file mode 100644
index 0000000000..c8826df8d6
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-client/src/main/java/com/epmet/feign/fallback/EpmetThirdPlatformFeignClientFallback.java
@@ -0,0 +1,12 @@
+package com.epmet.feign.fallback;
+
+import com.epmet.feign.EpmetThirdPlatformFeignClient;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/5 14:46
+ */
+@Component
+public class EpmetThirdPlatformFeignClientFallback implements EpmetThirdPlatformFeignClient {
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/.gitignore b/epmet-module/epmet-third-platform/epmet-third-platform-server/.gitignore
new file mode 100644
index 0000000000..a2a3040aa8
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/.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/
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-third-platform/epmet-third-platform-server/deploy/docker-compose-dev.yml
new file mode 100644
index 0000000000..61a96bd804
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/deploy/docker-compose-dev.yml
@@ -0,0 +1,17 @@
+version: "3.7"
+services:
+ epmet-third-platform-server:
+ container_name: epmet-third-platform-server-dev
+ image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-platform-server:0.0.1
+ ports:
+ - "8109:8109"
+ network_mode: host # 使用现有网络
+ volumes:
+ - "/opt/epmet-cloud-logs/dev:/logs"
+ environment:
+ RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./app.jar"
+ deploy:
+ resources:
+ limits:
+ cpus: '0.1'
+ memory: 250M
\ No newline at end of file
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/deploy/docker-compose-test.yml b/epmet-module/epmet-third-platform/epmet-third-platform-server/deploy/docker-compose-test.yml
new file mode 100644
index 0000000000..e3190c180c
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/deploy/docker-compose-test.yml
@@ -0,0 +1,17 @@
+version: "3.7"
+services:
+ epmet-third-platform-server:
+ container_name: epmet-third-platform-server-test
+ image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-third-platform-server:0.0.1
+ ports:
+ - "8109:8109"
+ network_mode: host # 使用现有网络
+ volumes:
+ - "/opt/epmet-cloud-logs/test:/logs"
+ environment:
+ RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./app.jar"
+ deploy:
+ resources:
+ limits:
+ cpus: '0.1'
+ memory: 250M
\ No newline at end of file
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/epmet-third-platform-server.iml b/epmet-module/epmet-third-platform/epmet-third-platform-server/epmet-third-platform-server.iml
new file mode 100644
index 0000000000..f42456d14c
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/epmet-third-platform-server.iml
@@ -0,0 +1,240 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/pom.xml b/epmet-module/epmet-third-platform/epmet-third-platform-server/pom.xml
new file mode 100644
index 0000000000..ecda6c12df
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/pom.xml
@@ -0,0 +1,211 @@
+
+
+ 4.0.0
+ 0.0.1
+
+
+ com.epmet
+ epmet-third-platform
+ 2.0.0
+
+
+ epmet-third-platform-server
+ jar
+
+
+ 3.2.2
+ 1.1.0
+ 1.0.5
+ 2.3.28
+
+
+
+
+ com.epmet
+ epmet-third-platform-client
+ 2.0.0
+
+
+ com.epmet
+ epmet-commons-tools
+ 2.0.0
+
+
+ com.epmet
+ epmet-commons-mybatis
+ 2.0.0
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework
+ spring-context-support
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+ com.aliyun
+ aliyun-java-sdk-core
+ ${aliyun.core.version}
+
+
+ com.aliyun
+ aliyun-java-sdk-dysmsapi
+ ${aliyun.dysmsapi.version}
+
+
+ com.github.qcloudsms
+ qcloudsms
+ ${qcloud.qcloudsms.version}
+
+
+ com.sun.mail
+ javax.mail
+
+
+ org.freemarker
+ freemarker
+ ${freemarker.version}
+
+
+
+ io.github.openfeign
+ feign-httpclient
+ 10.3.0
+
+
+
+ org.flywaydb
+ flyway-core
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ org.dom4j
+ dom4j
+ 2.1.3
+ compile
+
+
+ com.github.binarywang
+ weixin-java-common
+ 3.6.0
+ compile
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ ${project.basedir}/src/main/java
+
+
+ true
+ ${basedir}/src/main/resources
+
+
+
+
+
+ dev
+
+ true
+
+
+ 8109
+ dev
+
+
+
+
+
+ epmet_message_user
+ EpmEt-db-UsEr
+
+ 0
+ 192.168.1.130
+ 6379
+ 123456
+
+ false
+ 122.152.200.70:8848
+ fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b
+
+
+ false
+
+
+ false
+
+
+
+ test
+
+
+ 8109
+ test
+
+
+
+
+
+ epmet
+ elink@833066
+
+ 0
+ r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com
+ 6379
+ EpmEtrEdIs!q@w
+
+ true
+ 192.168.10.150:8848
+ 67e3c350-533e-4d7c-9f8f-faf1b4aa82ae
+
+
+ false
+
+
+ true
+
+
+
+
+
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/EpmetThirdPlatformApplication.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/EpmetThirdPlatformApplication.java
new file mode 100644
index 0000000000..5989404eff
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/EpmetThirdPlatformApplication.java
@@ -0,0 +1,17 @@
+package com.epmet;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients
+public class EpmetThirdPlatformApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(EpmetThirdPlatformApplication.class, args);
+ }
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/aspect/RequestLogAspect.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/aspect/RequestLogAspect.java
new file mode 100644
index 0000000000..49581cf63c
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/aspect/RequestLogAspect.java
@@ -0,0 +1,40 @@
+package com.epmet.aspect;
+
+import com.epmet.commons.tools.aspect.BaseRequestLogAspect;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 日志/异常处理切面实现,调用父类方法完成日志记录和异常处理。
+ */
+@Aspect
+@Component
+@Order(0)
+public class RequestLogAspect extends BaseRequestLogAspect {
+
+ @Override
+ @Around(value = "execution(* com.epmet.controller.*Controller*.*(..)) ")
+ public Object proceed(ProceedingJoinPoint point) throws Throwable {
+ return super.proceed(point, getRequest());
+ }
+
+ /**
+ * 获取Request对象
+ *
+ * @return
+ */
+ private HttpServletRequest getRequest() {
+ RequestAttributes ra = RequestContextHolder.getRequestAttributes();
+ ServletRequestAttributes sra = (ServletRequestAttributes) ra;
+ return sra.getRequest();
+ }
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/config/ModuleConfigImpl.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/config/ModuleConfigImpl.java
new file mode 100644
index 0000000000..2ea4a0b4c8
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/config/ModuleConfigImpl.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2018 人人开源 All rights reserved.
+ *
+ * https://www.renren.io
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.epmet.config;
+
+import com.epmet.commons.tools.config.ModuleConfig;
+import org.springframework.stereotype.Service;
+
+/**
+ * 模块配置信息
+ *
+ * @author Mark sunlightcs@gmail.com
+ * @since 1.0.0
+ */
+@Service
+public class ModuleConfigImpl implements ModuleConfig {
+ @Override
+ public String getName() {
+ return "epmetthirdplatform";
+ }
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/controller/ComponentVerifyTicketController.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/controller/ComponentVerifyTicketController.java
new file mode 100644
index 0000000000..001b78d1e4
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/controller/ComponentVerifyTicketController.java
@@ -0,0 +1,45 @@
+package com.epmet.controller;
+
+import com.epmet.dto.form.ThirdPlatformEventFormDTO;
+import com.epmet.dto.result.ResultBean;
+import com.epmet.service.DbyWechatExtService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:07
+ */
+@Slf4j
+@RestController
+public class ComponentVerifyTicketController {
+
+ private DbyWechatExtService dbyWechatExtService;
+
+ @PostMapping(value = "/event")
+ public ResponseEntity wechatPlatformEvent(@RequestBody ThirdPlatformEventFormDTO formDTO) {
+ ResultBean resultBean = new ResultBean();
+ ResponseEntity responseEntity;
+ log.info("授权事件接收URL,验证票据");
+ try {
+ resultBean.setData(dbyWechatExtService.parseRequest(formDTO));
+ responseEntity = new ResponseEntity(resultBean, HttpStatus.OK);
+ log.info("第三方平台授权事件接收URL,验证票据成功");
+ } catch (Exception e) {
+ log.error("第三方平台授权事件接收URL,验证票据异常", e.getMessage(), e);
+ ResultBean errorResultBean = new ResultBean();
+ errorResultBean.setMsg("第三方平台授权事件接收URL,验证票据异常");
+ errorResultBean.setErrorMsg(e.getMessage());
+ errorResultBean.setCode(422);
+ responseEntity = new ResponseEntity(errorResultBean, HttpStatus.UNPROCESSABLE_ENTITY);
+ }
+ return responseEntity;
+ }
+
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/exception/AesException.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/exception/AesException.java
new file mode 100644
index 0000000000..6b03534378
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/exception/AesException.java
@@ -0,0 +1,65 @@
+package com.epmet.exception;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 10:03
+ */
+@SuppressWarnings("serial")
+public class AesException extends Exception {
+
+ public final static int OK = 0;
+ public final static int ValidateSignatureError = -40001;
+ public final static int ParseXmlError = -40002;
+ public final static int ComputeSignatureError = -40003;
+ public final static int IllegalAesKey = -40004;
+ public final static int ValidateCorpidError = -40005;
+ public final static int EncryptAESError = -40006;
+ public final static int DecryptAESError = -40007;
+ public final static int IllegalBuffer = -40008;
+ public final static int EncodeBase64Error = -40009;
+ public final static int DecodeBase64Error = -40010;
+ public final static int GenReturnXmlError = -40011;
+
+ private int code;
+
+ private static String getMessage(int code) {
+ switch (code) {
+ case ValidateSignatureError:
+ return "签名验证错误";
+ case ParseXmlError:
+ return "xml解析失败";
+ case ComputeSignatureError:
+ return "sha加密生成签名失败";
+ case IllegalAesKey:
+ return "SymmetricKey非法";
+ case ValidateCorpidError:
+ return "corpid校验失败";
+ case EncryptAESError:
+ return "aes加密失败";
+ case DecryptAESError:
+ return "aes解密失败";
+ case IllegalBuffer:
+ return "解密后得到的buffer非法";
+ case EncodeBase64Error:
+ return "base64加密错误";
+ case DecodeBase64Error:
+ return "base64解密错误";
+ case GenReturnXmlError:
+ return "xml生成失败";
+ default:
+ return null; // cannot be
+ }
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public AesException(int code) {
+ super(getMessage(code));
+ this.code = code;
+ }
+
+}
+
+
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/service/DbyWechatExtService.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/service/DbyWechatExtService.java
new file mode 100644
index 0000000000..d8cdef3e1c
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/service/DbyWechatExtService.java
@@ -0,0 +1,24 @@
+package com.epmet.service;
+
+import com.epmet.dto.form.ThirdPlatformEventFormDTO;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:12
+ */
+public interface DbyWechatExtService {
+
+ /**
+ * 获得授权事件的票据
+ *
+ * @param timestamp 时间戳
+ * @param nonce 随机数
+ * @param msgSignature 消息体签名
+ * @param postData 消息体
+ * @return 如果获得只需要返回 SUCCESS
+ * @Author zxc
+ */
+ String parseRequest(ThirdPlatformEventFormDTO formDTO);
+
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/service/impl/DbyWechatExtServiceImpl.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/service/impl/DbyWechatExtServiceImpl.java
new file mode 100644
index 0000000000..fab5f0137d
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/service/impl/DbyWechatExtServiceImpl.java
@@ -0,0 +1,59 @@
+package com.epmet.service.impl;
+
+import com.epmet.constant.ThirdPlatformConstant;
+import com.epmet.dto.form.ThirdPlatformEventFormDTO;
+import com.epmet.exception.AesException;
+import com.epmet.service.DbyWechatExtService;
+import com.epmet.util.ModuleConstant;
+import com.epmet.util.WXBizMsgCrypt;
+import com.epmet.util.WXXmlToMapUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:13
+ */
+@Slf4j
+@Service
+public class DbyWechatExtServiceImpl implements DbyWechatExtService {
+
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ @Override
+ public String parseRequest(ThirdPlatformEventFormDTO formDTO) {
+ String msgSignature = formDTO.getMsgSignature();
+ String nonce = formDTO.getNonce();
+ String postData = formDTO.getPostData();
+ String timeStamp = formDTO.getTimeStamp();
+ log.info(ModuleConstant.START_RECEIVE);
+ try {
+ //这个类是微信官网提供的解密类,需要用到消息校验Token 消息加密Key和服务平台appid
+ WXBizMsgCrypt pc = new WXBizMsgCrypt(ThirdPlatformConstant.PLATFORM_COMPONENT_TOKEN, ThirdPlatformConstant.PLATFORM_AES_KEY, ThirdPlatformConstant.PLATFORM_APP_ID);
+ String xml = pc.decryptMsg(msgSignature, timeStamp, nonce, postData);
+ // 将xml转为map
+ Map result = WXXmlToMapUtil.xmlToMap(xml);
+ String componentVerifyTicket = MapUtils.getString(result,ModuleConstant.TICKET_KEY);
+ if (StringUtils.isNotEmpty(componentVerifyTicket)) {
+ // 存储平台授权票据,保存ticket
+ redisTemplate.opsForValue().set(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket, 60 * 10, TimeUnit.SECONDS);
+ String verifyTicket = redisTemplate.opsForValue().get(ModuleConstant.TICKET_UNDERLINE_KEY).toString();
+ log.info(String.format(ModuleConstant.AUTH_TICKET,verifyTicket));
+ } else {
+ throw new RuntimeException(ModuleConstant.ERROR_TICKET);
+ }
+ } catch (AesException e) {
+ e.printStackTrace();
+ }
+ log.info(ModuleConstant.SUCCESS_TICKET);
+ return ModuleConstant.SUCCESS;
+ }
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/ModuleConstant.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/ModuleConstant.java
new file mode 100644
index 0000000000..0706f08250
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/ModuleConstant.java
@@ -0,0 +1,23 @@
+package com.epmet.util;
+
+/**
+ * @Description
+ * @author zxc
+ */
+public interface ModuleConstant {
+
+ String START_RECEIVE = "==============================开始授权事件接收URL=================================";
+
+ String TICKET_KEY = "ComponentVerifyTicket";
+
+ String TICKET_UNDERLINE_KEY = "component_verify_ticket";
+
+ String AUTH_TICKET = "====================授权票据【ComponentVerifyTicket】:【%s】====================";
+
+ String ERROR_TICKET = "微信开放平台,第三方平台获取【验证票据】失败";
+
+ String SUCCESS_TICKET = "==============================结束授权事件接收URL=================================";
+
+ String SUCCESS = "success";
+
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/WXBizMsgCrypt.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/WXBizMsgCrypt.java
new file mode 100644
index 0000000000..332e363eaa
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/WXBizMsgCrypt.java
@@ -0,0 +1,246 @@
+package com.epmet.util;
+
+import com.epmet.exception.AesException;
+import me.chanjar.weixin.common.util.crypto.PKCS7Encoder;
+import org.apache.commons.codec.binary.Base64;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import java.io.StringReader;
+import java.nio.charset.Charset;
+import java.security.MessageDigest;
+import java.util.Arrays;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+/**
+ * 提供接收和推送给公众平台消息的加解密接口(UTF8编码的字符串).
+ * * - 第三方回复加密消息给公众平台
* - 第三方收到公众平台发送的消息,验证消息的安全性,并对消息进行解密。
+ *
+ * 说明:异常java.security.InvalidKeyException:illegal Key Size的解决方案
+ *
+ * - 在官方网站下载JCE无限制权限策略文件(JDK7的下载地址: *
+ * http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
+ * - 下载后解压,可以看到local_policy.jar和US_export_policy.jar以及readme.txt
+ * - 如果安装了JRE,将两个jar文件放到%JRE_HOME%\lib\security目录下覆盖原来的文件
+ * - 如果安装了JDK,将两个jar文件放到%JDK_HOME%\jre\lib\security目录下覆盖原来文件
+ *
+ *
+ */
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:51
+ */
+public class WXBizMsgCrypt {
+ static Charset CHARSET = Charset.forName("utf-8");
+ Base64 base64 = new Base64();
+ byte[] aesKey;
+ String token;
+ String appId;
+
+ /**
+ * 构造函数
+ * @param token 公众平台上,开发者设置的token
+ * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey
+ * @param appId 公众平台appid
+ *
+ * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息
+ */
+ public WXBizMsgCrypt(String token, String encodingAesKey, String appId) throws AesException {
+ if (encodingAesKey.length() != 43) {
+ throw new AesException(AesException.IllegalAesKey);
+ }
+
+ this.token = token;
+ this.appId = appId;
+ aesKey = Base64.decodeBase64(encodingAesKey + "=");
+ }
+
+ // 还原4个字节的网络字节序
+ int recoverNetworkBytesOrder(byte[] orderBytes) {
+ int sourceNumber = 0;
+ for (int i = 0; i < 4; i++) {
+ sourceNumber <<= 8;
+ sourceNumber |= orderBytes[i] & 0xff;
+ }
+ return sourceNumber;
+ }
+
+ /**
+ * 对密文进行解密.
+ * @param text 需要解密的密文
+ * @return 解密得到的明文
+ * @throws AesException aes解密失败
+ */
+ String decrypt(String text) throws AesException {
+ byte[] original;
+ try {
+ // 设置解密模式为AES的CBC模式
+ Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
+ SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES");
+ IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
+ cipher.init(Cipher.DECRYPT_MODE, key_spec, iv);
+
+ // 使用BASE64对密文进行解码
+ byte[] encrypted = Base64.decodeBase64(text);
+
+ // 解密
+ original = cipher.doFinal(encrypted);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new AesException(AesException.DecryptAESError);
+ }
+
+ String xmlContent, from_appid;
+ try {
+ // 去除补位字符
+ byte[] bytes = PKCS7Encoder.decode(original);
+
+ // 分离16位随机字符串,网络字节序和AppId
+ byte[] networkOrder = Arrays.copyOfRange(bytes, 16, 20);
+
+ int xmlLength = recoverNetworkBytesOrder(networkOrder);
+
+ xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET);
+ from_appid =
+ new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), CHARSET);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new AesException(AesException.IllegalBuffer);
+ }
+
+ // appid不相同的情况
+ if (!from_appid.equals(appId)) {
+ throw new AesException(AesException.ValidateSignatureError);
+ }
+ return xmlContent;
+
+ }
+
+ /**
+ * * 检验消息的真实性,并且获取解密后的明文.
+ *
+ * - 利用收到的密文生成安全签名,进行签名验证
+ * - 若验证通过,则提取xml中的加密消息
+ * - 对消息进行解密
+ *
+ *
+ * @param msgSignature 签名串,对应URL参数的msg_signature
+ * @param timeStamp 时间戳,对应URL参数的timestamp
+ * @param nonce 随机串,对应URL参数的nonce
+ * @param postData 密文,对应POST请求的数据
+ * @return 解密后的原文
+ * @throws AesException 执行失败,请查看该异常的错误码和具体的错误信息
+ */
+ public String decryptMsg(String msgSignature, String timeStamp, String nonce, String postData)
+ throws AesException {
+
+ // 密钥,公众账号的app secret
+ // 提取密文
+ Object[] encrypt = extract(postData);
+
+ // 验证安全签名
+ String signature = getSHA1(token, timeStamp, nonce, encrypt[1].toString());
+
+ // 和URL中的签名比较是否相等
+ // System.out.println("第三方收到URL中的签名:" + msg_sign);
+ // System.out.println("第三方校验签名:" + signature);
+ if (!signature.equals(msgSignature)) {
+ throw new AesException(AesException.ValidateSignatureError);
+ }
+
+ // 解密
+ String result = decrypt(encrypt[1].toString());
+ return result;
+ }
+
+ /**
+ * 提取出xml数据包中的加密消息
+ * @param xmltext 待提取的xml字符串
+ * @return 提取出的加密消息字符串
+ * @throws AesException
+ */
+ public static Object[] extract(String xmltext) throws AesException {
+ Object[] result = new Object[3];
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ dbf.setXIncludeAware(false);
+ dbf.setExpandEntityReferences(false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ StringReader sr = new StringReader(xmltext);
+ InputSource is = new InputSource(sr);
+ Document document = db.parse(is);
+
+ Element root = document.getDocumentElement();
+ NodeList nodelist1 = root.getElementsByTagName("Encrypt");
+ NodeList nodelist2 = root.getElementsByTagName("ToUserName");
+ result[0] = 0;
+ result[1] = nodelist1.item(0).getTextContent();
+
+ //注意这里,获取ticket中的xml里面没有ToUserName这个元素,官网原示例代码在这里会报空
+ //空指针,所以需要处理一下
+ if (nodelist2 != null) {
+ if (nodelist2.item(0) != null) {
+ result[2] = nodelist2.item(0).getTextContent();
+ }
+ }
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new AesException(AesException.ParseXmlError);
+ }
+ }
+
+ /**
+ * 用SHA1算法生成安全签名
+ * @param token 票据
+ * @param timestamp 时间戳
+ * @param nonce 随机字符串
+ * @param encrypt 密文
+ * @return 安全签名
+ * @throws
+ * AesException
+ */
+ public static String getSHA1(String token, String timestamp, String nonce, String encrypt)
+ throws AesException {
+ try {
+ String[] array = new String[]{token, timestamp, nonce, encrypt};
+ StringBuffer sb = new StringBuffer();
+ // 字符串排序
+ Arrays.sort(array);
+ for (int i = 0; i < 4; i++) {
+ sb.append(array[i]);
+ }
+ String str = sb.toString();
+ // SHA1签名生成
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ md.update(str.getBytes());
+ byte[] digest = md.digest();
+
+ StringBuffer hexstr = new StringBuffer();
+ String shaHex = "";
+ for (int i = 0; i < digest.length; i++) {
+ shaHex = Integer.toHexString(digest[i] & 0xFF);
+ if (shaHex.length() < 2) {
+ hexstr.append(0);
+ }
+ hexstr.append(shaHex);
+ }
+ return hexstr.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new AesException(AesException.ComputeSignatureError);
+ }
+ }
+}
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/WXXmlToMapUtil.java b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/WXXmlToMapUtil.java
new file mode 100644
index 0000000000..856e2da291
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/java/com/epmet/util/WXXmlToMapUtil.java
@@ -0,0 +1,230 @@
+package com.epmet.util;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.SAXReader;
+import org.dom4j.io.XMLWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+/**
+ * @Author zxc
+ * @CreateTime 2020/7/6 9:51
+ */
+public class WXXmlToMapUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(WXXmlToMapUtil.class);
+
+ /**
+ * XML格式字符串转换为Map
+ *
+ * @param xml XML字符串
+ * @return XML数据转换后的Map
+ */
+ public static Map xmlToMap(String xml) {
+ try {
+ Map data = new HashMap<>();
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ InputStream stream = new ByteArrayInputStream(xml.getBytes("UTF-8"));
+ org.w3c.dom.Document doc = documentBuilder.parse(stream);
+ doc.getDocumentElement().normalize();
+ NodeList nodeList = doc.getDocumentElement().getChildNodes();
+ for (int idx = 0; idx < nodeList.getLength(); ++idx) {
+ Node node = nodeList.item(idx);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ org.w3c.dom.Element element = (org.w3c.dom.Element) node;
+ data.put(element.getNodeName(), element.getTextContent());
+ }
+ }
+ stream.close();
+ return data;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * 将Map转换为XML格式的字符串
+ *
+ * @param data Map类型数据
+ * @return XML格式的字符串
+ */
+ public static String mapToXml(Map data) throws Exception {
+ try {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ org.w3c.dom.Document document = documentBuilder.newDocument();
+ org.w3c.dom.Element root = document.createElement("xml");
+ document.appendChild(root);
+ for (String key : data.keySet()) {
+ String value = data.get(key);
+ if (value == null) {
+ value = "";
+ }
+ value = value.trim();
+ org.w3c.dom.Element filed = document.createElement(key);
+ filed.appendChild(document.createTextNode(value));
+ root.appendChild(filed);
+ }
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ DOMSource source = new DOMSource(document);
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+ transformer.transform(source, result);
+ String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", "");
+ writer.close();
+ return output;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * (多层)xml格式字符串转换为map
+ *
+ * @param xml xml字符串
+ * @return 第一个为Root节点,Root节点之后为Root的元素,如果为多层,可以通过key获取下一层Map
+ */
+ public static Map multilayerXmlToMap(String xml) {
+ Document doc = null;
+ try {
+ doc = DocumentHelper.parseText(xml);
+ } catch (DocumentException e) {
+ logger.error("xml字符串解析,失败 --> {}", e);
+ }
+ Map map = new HashMap<>();
+ if (null == doc) {
+ return map;
+ }
+ // 获取根元素
+ Element rootElement = doc.getRootElement();
+ recursionXmlToMap(rootElement, map);
+ return map;
+ }
+
+ /**
+ * multilayerXmlToMap核心方法,递归调用
+ *
+ * @param element 节点元素
+ * @param outmap 用于存储xml数据的map
+ */
+ private static void recursionXmlToMap(Element element, Map outmap) {
+ // 得到根元素下的子元素列表
+ List list = element.elements();
+ int size = list.size();
+ if (size == 0) {
+ // 如果没有子元素,则将其存储进map中
+ outmap.put(element.getName(), element.getTextTrim());
+ } else {
+ // innermap用于存储子元素的属性名和属性值
+ Map innermap = new HashMap<>();
+ // 遍历子元素
+ list.forEach(childElement -> recursionXmlToMap(childElement, innermap));
+ outmap.put(element.getName(), innermap);
+ }
+ }
+
+ /**
+ * (多层)map转换为xml格式字符串
+ *
+ * @param map 需要转换为xml的map
+ * @param isCDATA 是否加入CDATA标识符 true:加入 false:不加入
+ * @return xml字符串
+ */
+ public static String multilayerMapToXml(Map map, boolean isCDATA) {
+ String parentName = "xml";
+ Document doc = DocumentHelper.createDocument();
+ doc.addElement(parentName);
+ String xml = recursionMapToXml(doc.getRootElement(), parentName, map, isCDATA);
+ return formatXML(xml);
+ }
+
+ /**
+ * multilayerMapToXml核心方法,递归调用
+ *
+ * @param element 节点元素
+ * @param parentName 根元素属性名
+ * @param map 需要转换为xml的map
+ * @param isCDATA 是否加入CDATA标识符 true:加入 false:不加入
+ * @return xml字符串
+ */
+ private static String recursionMapToXml(Element element, String parentName, Map map, boolean isCDATA) {
+ Element xmlElement = element.addElement(parentName);
+ map.keySet().forEach(key -> {
+ Object obj = map.get(key);
+ if (obj instanceof Map) {
+ recursionMapToXml(xmlElement, key, (Map) obj, isCDATA);
+ } else {
+ String value = obj == null ? "" : obj.toString();
+ if (isCDATA) {
+ xmlElement.addElement(key).addCDATA(value);
+ } else {
+ xmlElement.addElement(key).addText(value);
+ }
+ }
+ });
+ return xmlElement.asXML();
+ }
+
+ /**
+ * 格式化xml,显示为容易看的XML格式
+ *
+ * @param xml 需要格式化的xml字符串
+ */
+ public static String formatXML(String xml) {
+ String requestXML = null;
+ try {
+ // 拿取解析器
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(new StringReader(xml));
+ if (null != document) {
+ StringWriter stringWriter = new StringWriter();
+ // 格式化,每一级前的空格
+ OutputFormat format = new OutputFormat(" ", true);
+ // xml声明与内容是否添加空行
+ format.setNewLineAfterDeclaration(false);
+ // 是否设置xml声明头部
+ format.setSuppressDeclaration(false);
+ // 是否分行
+ format.setNewlines(true);
+ XMLWriter writer = new XMLWriter(stringWriter, format);
+ writer.write(document);
+ writer.flush();
+ writer.close();
+ requestXML = stringWriter.getBuffer().toString();
+ }
+ return requestXML;
+ } catch (Exception e) {
+ logger.error("格式化xml,失败 --> {}", e);
+ return null;
+ }
+ }
+}
+
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000000..6c385f79f8
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/resources/bootstrap.yml
@@ -0,0 +1,109 @@
+server:
+ port: @server.port@
+ servlet:
+ context-path: /epmet/third/platform
+
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: epmet-third-platform-server
+ # dev|test|prod
+ profiles:
+ active: dev
+ jackson:
+ time-zone: GMT+8
+ date-format: yyyy-MM-dd HH:mm:ss
+ redis:
+ database: @spring.redis.index@
+ host: @spring.redis.host@
+ port: @spring.redis.port@
+ password: @spring.redis.password@
+ timeout: 30s
+ datasource:
+ druid:
+ #MySQL
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: @spring.datasource.druid.url@
+ username: @spring.datasource.druid.username@
+ password: @spring.datasource.druid.password@
+ cloud:
+ nacos:
+ discovery:
+ server-addr: @nacos.server-addr@
+ #nacosռIDĬpublic
+ namespace: @nacos.discovery.namespace@
+ #Լעᵽעĵĵַ
+ register-enabled: @nacos.register-enabled@
+ ip: @nacos.ip@
+ config:
+ enabled: @nacos.config-enabled@
+ server-addr: @nacos.server-addr@
+ namespace: @nacos.config.namespace@
+ group: @nacos.config.group@
+ file-extension: yaml
+ # Ǩƹflyway
+ flyway:
+ enabled: @spring.flyway.enabled@
+ locations: classpath:db/migration
+ url: @spring.datasource.druid.url@
+ user: @spring.datasource.druid.username@
+ password: @spring.datasource.druid.password@
+ baseline-on-migrate: true
+ baseline-version: 0
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+ endpoint:
+ health:
+ show-details: ALWAYS
+
+mybatis-plus:
+ mapper-locations: classpath:/mapper/**/*.xml
+ #ʵɨ裬packageöŻ߷ֺŷָ
+ typeAliasesPackage: com.epmet.entity
+ global-config:
+ #ݿ
+ db-config:
+ # AUTO:"ݿID", INPUT:"ûID", ID_WORKER:"ȫΨһID (ΨһID)", UUID:"ȫΨһID UUID";
+ id-type: ID_WORKER
+ #ֶβ IGNORED:"ж",NOT_NULL:" NULL ж"),NOT_EMPTY:"ǿж"
+ field-strategy: NOT_NULL
+ #շ»ת
+ column-underline: true
+ banner: false
+ #ԭ
+ configuration:
+ map-underscore-to-camel-case: true
+ cache-enabled: false
+ call-setters-on-nulls: true
+ jdbc-type-for-null: 'null'
+
+feign:
+ hystrix:
+ enabled: true
+ client:
+ config:
+ default:
+ loggerLevel: BASIC
+ httpclient:
+ enabled: true
+
+hystrix:
+ command:
+ default:
+ execution:
+ isolation:
+ thread:
+ timeoutInMilliseconds: 60000 #ȱʡΪ1000
+
+ribbon:
+ ReadTimeout: 300000
+ ConnectTimeout: 300000
+
+#pageHelperҳ
+pagehelper:
+ helper-dialect: mysql
+ reasonable: false #ҳãҳΪ-1ԶתΪСҳ1
\ No newline at end of file
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/resources/logback-spring.xml b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000000..7ead25dd02
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform-server/src/main/resources/logback-spring.xml
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+ ${appname}
+
+
+
+
+
+
+
+
+ debug
+
+
+ ${CONSOLE_LOG_PATTERN}
+
+ UTF-8
+
+
+
+
+
+
+
+ ${log.path}/debug.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/debug-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ debug
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/info.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/info-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ info
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/warn.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/warn-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ warn
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/error.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/error-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/epmet-module/epmet-third-platform/epmet-third-platform.iml b/epmet-module/epmet-third-platform/epmet-third-platform.iml
new file mode 100644
index 0000000000..0d9345ff78
--- /dev/null
+++ b/epmet-module/epmet-third-platform/epmet-third-platform.iml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third-platform/pom.xml b/epmet-module/epmet-third-platform/pom.xml
new file mode 100644
index 0000000000..5a5fcef140
--- /dev/null
+++ b/epmet-module/epmet-third-platform/pom.xml
@@ -0,0 +1,21 @@
+
+
+
+ epmet-module
+ com.epmet
+ 2.0.0
+
+ 4.0.0
+
+ epmet-third-platform
+ pom
+
+
+ epmet-third-platform-client
+ epmet-third-platform-server
+
+
+
+
\ No newline at end of file