Browse Source

Merge branches 'dev' and 'dev_bugfix' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_bugfix

dev_shibei_match
yinzuomei 5 years ago
parent
commit
78c654162d
  1. 44
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java
  2. 19
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java
  3. 73
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java
  4. 2
      epmet-gateway/deploy/docker-compose-dev.yml
  5. 2
      epmet-gateway/pom.xml
  6. 5
      epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
  7. 2
      epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml
  8. 10
      epmet-module/data-statistical/data-statistical-server/pom.xml
  9. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  10. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
  11. 9
      epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml
  12. 2
      epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml
  13. 10
      epmet-module/epmet-job/epmet-job-server/pom.xml
  14. 33
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java
  15. 5
      epmet-module/epmet-job/epmet-job-server/src/main/resources/bootstrap.yml
  16. 9
      epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml
  17. 2
      epmet-module/resi-group/resi-group-server/deploy/docker-compose-dev.yml
  18. 2
      epmet-module/resi-group/resi-group-server/pom.xml
  19. 2
      epmet-user/epmet-user-server/deploy/docker-compose-dev.yml
  20. 2
      epmet-user/epmet-user-server/pom.xml

44
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java

@ -0,0 +1,44 @@
package com.epmet.commons.tools.enums;
/**
* 系统环境变量枚举类
* dev|test|prod
*
* @author jianjun liu
* @date 2020-07-03 11:14
**/
public enum EnvEnum {
DEV("dev", "开发环境"),
TEST("test", "体验环境"),
PROD("prod", "生产环境"),
UN_KNOWN("un_known", "未知"),
;
private String code;
private String name;
EnvEnum(String code, String name) {
this.code = code;
this.name = name;
}
public static EnvEnum getEnum(String code) {
EnvEnum[] values = EnvEnum.values();
for (EnvEnum value : values) {
if (code != null && value.getCode().equals(code)) {
return value;
}
}
return EnvEnum.UN_KNOWN;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
}

19
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java

@ -7,6 +7,7 @@ import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.core.spi.FilterReply;
import com.epmet.commons.tools.dto.form.DingTalkTextMsg;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.utils.DingdingMsgSender;
import com.epmet.commons.tools.utils.IpUtils;
import org.apache.commons.lang3.StringUtils;
@ -26,6 +27,8 @@ public class LogMsgSendFilter extends LevelFilter {
private DingdingMsgSender msgSender = new DingdingMsgSender();
private String webHook;
private String secret;
private String activeEnv;
private String appName;
@Override
public FilterReply decide(ILoggingEvent event) {
@ -39,6 +42,14 @@ public class LogMsgSendFilter extends LevelFilter {
stringBuilder.append("告警级别:" + event.getLevel());
stringBuilder.append("\n");
if (StringUtils.isNotBlank(appName)) {
stringBuilder.append("服务名称:" + appName);
stringBuilder.append("\n");
}
if (StringUtils.isNotBlank(activeEnv)) {
stringBuilder.append("告警环境:" + EnvEnum.getEnum(activeEnv).getName());
stringBuilder.append("\n");
}
String serverIp = IpUtils.getServerIp();
if (StringUtils.isNotBlank(serverIp)) {
stringBuilder.append("IP地址:" + serverIp);
@ -112,6 +123,14 @@ public class LogMsgSendFilter extends LevelFilter {
return dateFormat.format(timestamp);
}
public void setActiveEnv(String activeEnv) {
this.activeEnv = activeEnv;
}
public void setAppName(String appName) {
this.appName = appName;
}
public void setWebHook(String webHook) {
this.webHook = webHook;
}

73
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java

@ -2,6 +2,7 @@ package com.epmet.commons.tools.utils;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.dto.form.DingTalkTextMsg;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.google.common.collect.Lists;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
@ -12,7 +13,12 @@ import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.concurrent.ArrayBlockingQueue;
@ -48,7 +54,7 @@ public class DingdingMsgSender {
//阻塞取元素
msg = msgQueue.take();
if (msg != null) {
sendPostByJSON(msg);
sendMsg(msg);
} else {
Thread.sleep(1000);
}
@ -81,7 +87,7 @@ public class DingdingMsgSender {
DingTalkTextMsg param = new DingTalkTextMsg();
param.setContent("待发送消息队列已满,当前队列个数" + msgQueue.size() + "\n" + "最新消息内容:" + JSON.toJSONString(messageParam));
param.setWebHook(messageParam.getWebHook());
sendPostByJSON(param);
sendMsg(param);
}
return flag;
}
@ -94,7 +100,7 @@ public class DingdingMsgSender {
* @throws IOException
*/
public Result<String> sendMsgSync(DingTalkTextMsg messageParam) {
return sendPostByJSON(messageParam);
return sendMsg(messageParam);
}
private Thread getThread() {
@ -121,7 +127,7 @@ public class DingdingMsgSender {
* @param param 请求参数JSON格式
* @return
*/
private Result<String> sendPostByJSON(DingTalkTextMsg param) {
private Result<String> sendMsg(DingTalkTextMsg param) {
if (StringUtils.isBlank(param.getWebHook())) {
param.setWebHook(webHook);
}
@ -139,13 +145,70 @@ public class DingdingMsgSender {
String url = param.getWebHook();
url = url.concat("&timestamp=" + timestamp + "&sign=" + sign);
String jsonStrParam = param.getMsgContent();
result = HttpClientManager.getInstance().sendPostByJSON(url, jsonStrParam);
result = this.sendPostByJSON(url, jsonStrParam);
} catch (Exception e) {
logger.warn("sendPostByJSON error", e);
}
return result;
}
/**
* 发送POST 请求
*
* @param url 发送请求的 URL
* @param param 请求参数JSON格式
* @return
*/
public Result<String> sendPostByJSON(String url, String param) throws IOException {
if (StringUtils.isEmpty(url) || StringUtils.isEmpty(param)) {
throw new IllegalArgumentException("参数不能为空");
}
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
logger.warn("sendPostByJSON error", e);
return new Result<String>().error(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage());
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
}
}
return new Result<String>().ok(result);
}
public static void main(String[] args) {
for (int i = 0; i < 50; i++) {

2
epmet-gateway/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-gateway-server:
container_name: epmet-gateway-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-gateway:0.3.19
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-gateway:0.3.20
ports:
- "8080:8080"
network_mode: host # 使用现有网络

2
epmet-gateway/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.19</version>
<version>0.3.20</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId>

5
epmet-gateway/src/main/java/com/epmet/GatewayApplication.java

@ -8,11 +8,13 @@
package com.epmet;
import com.epmet.commons.tools.aspect.ServletExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
/**
* 网关服务
@ -20,9 +22,10 @@ import org.springframework.context.annotation.ComponentScan;
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@SpringBootApplication
@SpringBootApplication()
@EnableDiscoveryClient
@EnableFeignClients
@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {ServletExceptionHandler.class}))
public class GatewayApplication {
public static void main(String[] args) {

2
epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
data-statistical-server:
container_name: data-statistical-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.33
image: 192.168.1.130:10080/epmet-cloud-dev/data-statistical-server:0.3.34
ports:
- "8108:8108"
network_mode: host # 使用现有网络

10
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.33</version>
<version>0.3.34</version>
<parent>
<artifactId>data-statistical</artifactId>
<groupId>com.epmet</groupId>
@ -175,6 +175,10 @@
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19</dingTalk.robot.secret>
</properties>
</profile>
<profile>
@ -257,6 +261,10 @@
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1</dingTalk.robot.secret>
</properties>
</profile>
</profiles>

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -27,9 +27,9 @@ public class DemoController {
@GetMapping("testAlarm")
public void testAlarm() {
for (int i = 0; i < 20; i++) {
log.error("测试消息"+i);
}
//for (int i = 0; i < 20; i++) {
log.error("测试消息");
//}
}
@GetMapping("testtx")

7
epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml

@ -162,4 +162,9 @@ thread:
corePoolSize: @thread.pool.core-pool-size@
maxPoolSize: @thread.pool.max-pool-size@
queueCapacity: @thread.pool.queue-capacity@
keepAlive: @thread.pool.keep-alive@
keepAlive: @thread.pool.keep-alive@
dingTalk:
robot:
webHook: @dingTalk.robot.webHook@
secret: @dingTalk.robot.secret@

9
epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml

@ -5,6 +5,9 @@
<property name="log.path" value="logs/data-statistical"/>
<springProperty scope="context" name="appname" source="spring.application.name"/>
<springProperty scope="context" name="activeEnv" source="spring.profiles.active"/>
<springProperty scope="context" name="webHook" source="dingTalk.robot.webHook"/>
<springProperty scope="context" name="secret" source="dingTalk.robot.secret"/>
<!-- 日志上下文名称 -->
<contextName>${appname}</contextName>
@ -130,8 +133,10 @@
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
<webHook>https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c</webHook>
<secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19</secret>
<activeEnv>${activeEnv}</activeEnv>
<webHook>${webHook}</webHook>
<secret>${secret}</secret>
<appName>${appname}</appName>
</filter>
</appender>

2
epmet-module/epmet-job/epmet-job-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-job-server:
container_name: epmet-job-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-job-server:0.3.19
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-job-server:0.3.20
ports:
- "8084:8084"
network_mode: host # 使用现有网络

10
epmet-module/epmet-job/epmet-job-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.19</version>
<version>0.3.20</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-job</artifactId>
@ -130,11 +130,14 @@
<nacos.ip/>
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19</dingTalk.robot.secret>
</properties>
</profile>
<profile>
<id>test</id>
<!--<activation>
<!-- <activation>
<activeByDefault>true</activeByDefault>
</activation>-->
<properties>
@ -162,6 +165,9 @@
<nacos.ip/>
<spring.flyway.enabled>true</spring.flyway.enabled>
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1</dingTalk.robot.secret>
</properties>
</profile>
</profiles>

33
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java

@ -0,0 +1,33 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.controller;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 定时任务
*
* @author Mark sunlightcs@gmail.com
*/
@Slf4j
@RestController
@RequestMapping("demo")
@Api(tags="定时任务")
public class DemoController {
@GetMapping("testAlarm")
public void testAlarm() {
//for (int i = 0; i < 20; i++) {
log.error("测试消息");
//}
}
}

5
epmet-module/epmet-job/epmet-job-server/src/main/resources/bootstrap.yml

@ -113,3 +113,8 @@ hystrix:
ribbon:
ReadTimeout: 300000
ConnectTimeout: 300000
dingTalk:
robot:
webHook: @dingTalk.robot.webHook@
secret: @dingTalk.robot.secret@

9
epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml

@ -5,6 +5,9 @@
<property name="log.path" value="logs/job"/>
<springProperty scope="context" name="appname" source="spring.application.name"/>
<springProperty scope="context" name="activeEnv" source="spring.profiles.active"/>
<springProperty scope="context" name="webHook" source="dingTalk.robot.webHook"/>
<springProperty scope="context" name="secret" source="dingTalk.robot.secret"/>
<!-- 日志上下文名称 -->
<contextName>${appname}</contextName>
@ -129,8 +132,10 @@
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
<webHook>https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c</webHook>
<secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19</secret>
<activeEnv>${activeEnv}</activeEnv>
<webHook>${webHook}</webHook>
<secret>${secret}</secret>
<appName>${appname}</appName>
</filter>
</appender>

2
epmet-module/resi-group/resi-group-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
resi-group-server:
container_name: resi-group-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/resi-group-server:0.3.55
image: 192.168.1.130:10080/epmet-cloud-dev/resi-group-server:0.3.57
ports:
- "8095:8095"
network_mode: host # 使用现有网络

2
epmet-module/resi-group/resi-group-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.55</version>
<version>0.3.57</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>resi-group</artifactId>

2
epmet-user/epmet-user-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-user-server:
container_name: epmet-user-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.68
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.69
ports:
- "8087:8087"
network_mode: host # 不会创建新的网络

2
epmet-user/epmet-user-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.68</version>
<version>0.3.69</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-user</artifactId>

Loading…
Cancel
Save