From 9d0acfb65c80c4948c305ca01338f894b87346a0 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 08 四月 2024 09:44:37 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java |   60 ++++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
index 8af863f..7454ef6 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
@@ -4,9 +4,9 @@
 import com.zy.asrs.common.utils.IpTools;
 import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.wcs.common.annotation.OperationLog;
-import com.zy.asrs.wcs.sys.entity.OperationRecord;
-import com.zy.asrs.wcs.sys.entity.User;
-import com.zy.asrs.wcs.sys.service.OperationRecordService;
+import com.zy.asrs.wcs.system.entity.OperationRecord;
+import com.zy.asrs.wcs.system.entity.User;
+import com.zy.asrs.wcs.system.service.OperationRecordService;
 import com.zy.asrs.wcs.utils.Utils;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.*;
@@ -23,6 +23,7 @@
 import javax.servlet.http.HttpServletResponse;
 import java.lang.reflect.Method;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -66,8 +67,23 @@
      * 淇濆瓨鎿嶄綔璁板綍
      */
     private void saveLog(JoinPoint joinPoint, Object result, Exception e) {
+        // 璁板綍妯″潡鍚嶃�佹搷浣滃姛鑳姐�佽姹傛柟娉曘�佽姹傚弬鏁般�佽繑鍥炵粨鏋�
+        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+        Method method = signature.getMethod();
+        if (null == method) {
+            return;
+        }
+        OperationLog ol = method.getAnnotation(OperationLog.class);
+        if (null == ol) {
+            return;
+        }
+        String desc = getDescription(method, ol);
+        if (Cools.isEmpty(desc)) {
+            return;
+        }
         OperationRecord record = new OperationRecord();
         Long endTime = startTime.get();
+        record.setCreateTime(new Date());
         // 璁板綍鎿嶄綔鑰楁椂
         if (endTime != null) {
             record.setSpendTime((int) (System.currentTimeMillis() - endTime));
@@ -77,7 +93,7 @@
         User user = getLoginUser();
         if (user != null) {
             record.setUserId(user.getId());
-            record.setHostId(user.getHostId());
+//            record.setHostId(user.getHostId());
         }
         // 璁板綍璇锋眰鍦板潃銆佽姹傛柟寮忋�乮p
         ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
@@ -93,29 +109,21 @@
         } else {
             record.setResult(1);
         }
-        // 璁板綍妯″潡鍚嶃�佹搷浣滃姛鑳姐�佽姹傛柟娉曘�佽姹傚弬鏁般�佽繑鍥炵粨鏋�
-        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
-        Method method = signature.getMethod();
-        if (method != null) {
-            OperationLog ol = method.getAnnotation(OperationLog.class);
-            if (ol != null) {
-                // 璁板綍鎿嶄綔鍔熻兘
-                record.setNamespace(getDescription(method, ol));
-                // 璁板綍澶囨敞
-                if (!Cools.isEmpty(ol.comments())) {
-                    record.setMemo(ol.comments());
-                }
-                // 璁板綍璇锋眰鍙傛暟
-                if (ol.param() && request != null) {
-                    record.setRequest(Utils.sub(getParams(joinPoint, request), MAX_LENGTH));
-                }
-                // 璁板綍璇锋眰缁撴灉
-                if (ol.result() && result != null) {
-                    record.setResponse(Utils.sub(JSON.toJSONString(result), MAX_LENGTH));
-                }
-            }
+        // 璁板綍鎿嶄綔鍔熻兘
+        record.setNamespace(desc);
+        // 璁板綍澶囨敞
+        if (!Cools.isEmpty(ol.comments())) {
+            record.setMemo(ol.comments());
         }
-        operationRecordService.save(record);
+        // 璁板綍璇锋眰鍙傛暟
+        if (ol.param() && request != null) {
+            record.setRequest(Utils.sub(getParams(joinPoint, request), MAX_LENGTH));
+        }
+        // 璁板綍璇锋眰缁撴灉
+        if (ol.result() && result != null) {
+            record.setResponse(Utils.sub(JSON.toJSONString(result), MAX_LENGTH));
+        }
+        operationRecordService.saveAsync(record);
     }
 
     /**

--
Gitblit v1.9.1