From 07be92908945addb68cb82f4c954fe82a7d6720b Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期四, 07 五月 2026 09:20:02 +0800
Subject: [PATCH] 过滤电视机请求 ,不计入apilog表

---
 src/main/java/com/zy/common/config/ControllerResAdvice.java |  110 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 71 insertions(+), 39 deletions(-)

diff --git a/src/main/java/com/zy/common/config/ControllerResAdvice.java b/src/main/java/com/zy/common/config/ControllerResAdvice.java
index 272a1ec..311fb01 100644
--- a/src/main/java/com/zy/common/config/ControllerResAdvice.java
+++ b/src/main/java/com/zy/common/config/ControllerResAdvice.java
@@ -54,25 +54,28 @@
                 }
                 Object reqCache = request.getAttribute("cache");
                 boolean success = String.valueOf(((R) o).get("code")).equalsIgnoreCase("200");
-                if (success) {
-                    apiLogService.save(
-                            String.valueOf(appAuth),
-                            request.getRequestURI(),
-                            appkey,
-                            IpTools.gainRealIp(request),
-                            reqCache == null ? "" : JSON.toJSONString(reqCache),
-                            JSON.toJSONString(o),
-                            success
-                    );
-                } else {
-                    beforeBodyWriteCallApiLogSave(
-                            String.valueOf(appAuth),
-                            request.getRequestURI(),
-                            appkey,
-                            IpTools.gainRealIp(request),
-                            reqCache == null ? "" : JSON.toJSONString(reqCache),
-                            JSON.toJSONString(o),
-                            success);
+                String uri = request.getRequestURI();
+                if (!skipOpenAsrsHighFrequencyApiLog(uri)) {
+                    if (success) {
+                        apiLogService.save(
+                                String.valueOf(appAuth),
+                                uri,
+                                appkey,
+                                IpTools.gainRealIp(request),
+                                reqCache == null ? "" : JSON.toJSONString(reqCache),
+                                JSON.toJSONString(o),
+                                success
+                        );
+                    } else {
+                        beforeBodyWriteCallApiLogSave(
+                                String.valueOf(appAuth),
+                                uri,
+                                appkey,
+                                IpTools.gainRealIp(request),
+                                reqCache == null ? "" : JSON.toJSONString(reqCache),
+                                JSON.toJSONString(o),
+                                success);
+                    }
                 }
             } else if (o instanceof R && isInboundThirdPartyUri(request.getRequestURI())) {
                 String appkey = request.getHeader("appkey");
@@ -81,30 +84,56 @@
                 }
                 Object reqCache = request.getAttribute("cache");
                 boolean success = String.valueOf(((R) o).get("code")).equalsIgnoreCase("200");
-                String ns = inboundNamespace(request.getRequestURI());
-                if (success) {
-                    apiLogService.save(
-                            ns,
-                            request.getRequestURI(),
-                            appkey,
-                            IpTools.gainRealIp(request),
-                            reqCache == null ? "" : JSON.toJSONString(reqCache),
-                            JSON.toJSONString(o),
-                            success
-                    );
-                } else {
-                    beforeBodyWriteCallApiLogSave(
-                            ns,
-                            request.getRequestURI(),
-                            appkey,
-                            IpTools.gainRealIp(request),
-                            reqCache == null ? "" : JSON.toJSONString(reqCache),
-                            JSON.toJSONString(o),
-                            success);
+                String uri = request.getRequestURI();
+                String ns = inboundNamespace(uri);
+                if (!skipOpenAsrsHighFrequencyApiLog(uri)) {
+                    if (success) {
+                        apiLogService.save(
+                                ns,
+                                uri,
+                                appkey,
+                                IpTools.gainRealIp(request),
+                                reqCache == null ? "" : JSON.toJSONString(reqCache),
+                                JSON.toJSONString(o),
+                                success
+                        );
+                    } else {
+                        beforeBodyWriteCallApiLogSave(
+                                ns,
+                                uri,
+                                appkey,
+                                IpTools.gainRealIp(request),
+                                reqCache == null ? "" : JSON.toJSONString(reqCache),
+                                JSON.toJSONString(o),
+                                success);
+                    }
                 }
             }
         }
         return o;
+    }
+
+    /** 鐢佃鏈�/鐪嬫澘绛夐珮棰戞煡璇紝涓嶈惤 api_log锛坈ontext-path 鍓嶇紑浠绘剰锛屽彧鍖归厤璺緞鍚庣紑锛� */
+    private static final String[] OPEN_ASRS_SKIP_LOG_URI_SUFFIXES = {
+            "/open/asrs/queryTask",
+            "/open/asrs/queryLoc",
+            "/open/asrs/line/charts/hourly",
+            "/open/asrs/line/charts",
+            "/open/asrs/locDetl/statistics",
+    };
+
+    private static boolean skipOpenAsrsHighFrequencyApiLog(String uri) {
+        if (uri == null) {
+            return false;
+        }
+        int cut = uri.indexOf(';');
+        String path = cut > 0 ? uri.substring(0, cut) : uri;
+        for (String suffix : OPEN_ASRS_SKIP_LOG_URI_SUFFIXES) {
+            if (path.endsWith(suffix)) {
+                return true;
+            }
+        }
+        return false;
     }
 
     private static boolean isInboundThirdPartyUri(String uri) {
@@ -131,6 +160,9 @@
     }
 
     public void beforeBodyWriteCallApiLogSave(String name, String url, String appkey, String ip, String request, String response, boolean success) {
+        if (skipOpenAsrsHighFrequencyApiLog(url)) {
+            return;
+        }
         ApiLogService apiLogService = SpringUtils.getBean(ApiLogService.class);
         String memo = response;
         try{

--
Gitblit v1.9.1