Helius
2021-05-27 229e0ec1a577d604f15ed9659d7c2f0cd7edf8cd
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,6 +63,10 @@
            throw ex;
        }
        if (profiles.equals("dev") || profiles.equals("test")) {
            throw ex;
        }
        SysExceptionDetailEntity exceptionData = new SysExceptionDetailEntity();
        String exStr = printStackTraceToString(ex);
        ThreadPoolUtils.EXECUTOR.execute(new Runnable(){
@@ -68,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);
                }