自动化立体仓库 - WMS系统
cl
5 小时以前 07be92908945addb68cb82f4c954fe82a7d6720b
src/main/java/com/zy/common/config/ControllerResAdvice.java
@@ -54,10 +54,12 @@
                }
                Object reqCache = request.getAttribute("cache");
                boolean success = String.valueOf(((R) o).get("code")).equalsIgnoreCase("200");
                String uri = request.getRequestURI();
                if (!skipOpenAsrsHighFrequencyApiLog(uri)) {
                if (success) {
                    apiLogService.save(
                            String.valueOf(appAuth),
                            request.getRequestURI(),
                                uri,
                            appkey,
                            IpTools.gainRealIp(request),
                            reqCache == null ? "" : JSON.toJSONString(reqCache),
@@ -67,12 +69,13 @@
                } else {
                    beforeBodyWriteCallApiLogSave(
                            String.valueOf(appAuth),
                            request.getRequestURI(),
                                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,11 +84,13 @@
                }
                Object reqCache = request.getAttribute("cache");
                boolean success = String.valueOf(((R) o).get("code")).equalsIgnoreCase("200");
                String ns = inboundNamespace(request.getRequestURI());
                String uri = request.getRequestURI();
                String ns = inboundNamespace(uri);
                if (!skipOpenAsrsHighFrequencyApiLog(uri)) {
                if (success) {
                    apiLogService.save(
                            ns,
                            request.getRequestURI(),
                                uri,
                            appkey,
                            IpTools.gainRealIp(request),
                            reqCache == null ? "" : JSON.toJSONString(reqCache),
@@ -95,7 +100,7 @@
                } else {
                    beforeBodyWriteCallApiLogSave(
                            ns,
                            request.getRequestURI(),
                                uri,
                            appkey,
                            IpTools.gainRealIp(request),
                            reqCache == null ? "" : JSON.toJSONString(reqCache),
@@ -104,7 +109,31 @@
                }
            }
        }
        }
        return o;
    }
    /** 电视机/看板等高频查询,不落 api_log(context-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{