From 5575818556096be1dadaf5ff356b5db4c832aaa2 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 26 May 2021 19:27:09 +0800
Subject: [PATCH] modify

---
 src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java b/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java
index 3ce3ed5..85e1226 100644
--- a/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java
+++ b/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java
@@ -46,6 +46,9 @@
     @Value("${spring.profiles.active}")
     private String profiles;
 
+    @Value("${app.project}")
+    private String projectName;
+
     @Pointcut("execution(* com.xcong.excoin..*.*(..))")
     public void exceptionCatch() {
     }
@@ -60,7 +63,7 @@
             throw ex;
         }
 
-        if (profiles.equals("dev")) {
+        if (profiles.equals("dev") || profiles.equals("test")) {
             throw ex;
         }
 
@@ -72,13 +75,19 @@
                 try {
                     log.info("插入");
                     exceptionData.setCreateTime(new Date());
-                    exceptionData.setMachine(InetAddress.getLocalHost().getHostName() + "-" + profiles);
+                    exceptionData.setMachine(projectName + "-" + InetAddress.getLocalHost().getHostName() + "-" + profiles);
                     exceptionData.setAddress(InetAddress.getLocalHost().getHostAddress());
                     exceptionData.setExceptionMsg(exStr);
                     exceptionData.setSimpleMsg(ex.getMessage());
                     sysExceptionDetailDao.insert(exceptionData);
 
-                    DingTalkUtils.sendMsg(profiles + "--" + ex.getMessage(), exStr.substring(0, 200), exceptionData.getId());
+                    String msg = "";
+                    if (exStr.length() > 200) {
+                        msg = exStr.substring(0, 200);
+                    } else {
+                        msg = exStr;
+                    }
+                    DingTalkUtils.sendMsg(projectName + "-" +profiles + "--" + ex.getMessage(), msg, exceptionData.getId());
                 } catch (Exception e) {
                     log.error("exception aop", e);
                 }

--
Gitblit v1.9.1