From 7f85ca5468e097f1749ab1ed812046cb8eb979b7 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期日, 27 四月 2025 17:58:48 +0800 Subject: [PATCH] 表阀一体机与测控一体阀协议中的阀门状态不兼容,做兼容处理。 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/GlExceptionAspect.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/GlExceptionAspect.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/GlExceptionAspect.java new file mode 100644 index 0000000..af6171a --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/GlExceptionAspect.java @@ -0,0 +1,44 @@ +package com.dy.common.webUtil; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.stereotype.Component; + +/** + * 鍏ㄥ眬寮傚父澶勭悊锛屽鐞嗗湪Controller涓姏鍑虹殑寮傚父锛屽湪Controller涔嬪墠锛堝Fileter锛夊彂鐢熺殑閿欒鎴栧紓甯哥敱GlErrorCtrl澶勭悊 + * 姝ょ被鏄熀浜庢敞瑙e垏闈㈠疄鐜帮紝 + * 鍙︿竴绉嶅疄鐜版柟寮忔槸鍩轰簬鎷︽埅鍣ㄥ拰瀹炵幇鎸囧畾鎺ュ彛锛圙lExceptionHandler锛� + */ +//@Tag(name = "鍏ㄥ眬寮傚父澶勭悊", description = "澶勭悊鍦–ontroller涓姏鍑虹殑寮傚父锛屽湪Controller涔嬪墠锛堝Fileter锛夊彂鐢熺殑閿欒鎴栧紓甯哥敱GlErrorCtrl澶勭悊") +//@Aspect +@Slf4j +//@Component +public class GlExceptionAspect { + + //@Pointcut("execution(* com.dy..*(..))") + private void traceExceptionAspect() { + } + + //@Around("traceExceptionAspect()") + public Object around(ProceedingJoinPoint joinPoint) { + String interfaceName = String.format("%s.%s", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName()); + Object result; + try { + result = joinPoint.proceed(); + } catch (Throwable ex) { + if (ex instanceof GlException) { + GlException e = (GlException) ex; + result = BaseResponseUtils.buildFail(e.getMsg()); + log.error(String.format("璋冪敤鎺ュ彛%s寮傚父锛岄敊璇俊鎭�:%s", interfaceName, e.getMsg()), e); + } else { + result = BaseResponseUtils.buildFail("鍦–ontroller涓垨鍚庝骇鐢熷紓甯革細" + ex.getMessage()); + log.error(String.format("璋冪敤鎺ュ彛%s寮傚父锛岄敊璇俊鎭�:%s", interfaceName, ex.toString()), ex); + } + } + return result; + } +} -- Gitblit v1.8.0