lrj 1 день назад
Родитель
Сommit
27d279ee93

+ 9 - 7
src/main/java/cn/cslg/pas/common/core/annotation/LoggerAspect.java

@@ -12,6 +12,9 @@ import org.aspectj.lang.annotation.Pointcut;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
 @Order(3)
 @Aspect
 @Component
@@ -22,7 +25,7 @@ public class LoggerAspect {
     /**
      * 定义切点
      */
-    @Pointcut("execution( * cn.cslg.pas.controller..*.*(..))")
+    @Pointcut("execution( * cn.cslg.pas.service..*.*(..))")
     public void annotationPointcut() {
 
     }
@@ -48,12 +51,11 @@ public class LoggerAspect {
             }
         }
         try{
-            String str1 ="异常代码:" + e.getClass().getName();
-            String str2 ="异常信息:" + e.getMessage();
-            String str3="异常方法:" + (joinPoint.getTarget().getClass().getName() + "." + joinPoint.getSignature().getName() + "()");
-            String str4="请求参数:" + params; System.out.println("异常代码:" + e.getClass().getName());
-   log.error(str1+"\r"+str2+"\r"+str3+"\r"+str4);
-   log.error(e.getMessage());
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            e.printStackTrace(new PrintStream(baos)); // 将堆栈信息打印到流中
+            String exceptionStackTrace = baos.toString(); // 将流内容转换为字符串
+            log.error("发生异常,堆栈信息如下:\n{}", exceptionStackTrace); // 记录到日志
+
         }catch (Exception ex){
             //记录本地异常日志
             log.error("==异常通知异常==");

+ 5 - 1
src/main/java/cn/cslg/pas/service/dify/GenerateRejectionService.java

@@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.deepoove.poi.XWPFTemplate;
 import com.google.gson.Gson;
 import jakarta.json.Json;
+import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
 import okhttp3.Response;
 import org.apache.commons.lang3.ObjectUtils;
@@ -49,6 +50,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
 @Service
+@Slf4j
 public class GenerateRejectionService {
     @Autowired
     private DifyService difyService;
@@ -133,8 +135,8 @@ public class GenerateRejectionService {
 
                 @Override
                 public void onResponse(Call call, Response response) throws IOException {
-
                     if (!response.isSuccessful()) {
+                        log.error("请求驳回指导函异常:"+response.body());
                         emitter.error(new IOException("Unexpected code: " + response));
                         return;
                     }
@@ -178,12 +180,14 @@ public class GenerateRejectionService {
                                                 saveContent(confessionSession, dataObject);
                                             }
                                         } catch (Exception e) {
+                                            log.error("保存驳导函异常:"+e.getMessage());
                                             e.printStackTrace();
                                         }
                                     }
 
                                 }
                             } catch (Exception e) {
+                                log.error("获取驳导函信息异常:"+e.getMessage());
                                 e.printStackTrace();
                             }
                             emitter.next(line); // 将每行数据发送到 Flux