From ef6a2fb3b547190f35b3baf99280eaead42b4f57 Mon Sep 17 00:00:00 2001 From: wzp <2040239371@qq.com> Date: 星期五, 09 五月 2025 17:09:49 +0800 Subject: [PATCH] fix:y优化回调处理,和http请求超时处理 --- ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java | 2 +- ruoyi-ui/src/api/system/callbacklog.js | 5 +++-- ruoyi-ui/src/views/system/callbacklog/index.vue | 15 +++++++++++++-- ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java | 8 ++++++++ ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java | 4 ++-- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java index d639140..336143d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java @@ -19,8 +19,8 @@ */ public class HttpUtil { - private static final int CONNECT_TIMEOUT = 5000; - private static final int READ_TIMEOUT = 5000; + private static final int CONNECT_TIMEOUT = 60000; + private static final int READ_TIMEOUT = 60000; static { try { diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java index edbf719..feb555a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java @@ -32,6 +32,8 @@ { private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); + public static final int DEFAULT_READ_TIMEOUT = 60000; + /** * 鍚戞寚瀹� URL 鍙戦�丟ET鏂规硶鐨勮姹� * @@ -148,6 +150,12 @@ log.info("sendPost - {}", url); URL realUrl = new URL(url); URLConnection conn = realUrl.openConnection(); + + //璁剧疆杩炴帴瓒呮椂鏃堕棿 +// conn.setConnectTimeout(DEFAULT_READ_TIMEOUT); +// //璁剧疆璇诲彇瓒呮椂鏃堕棿 +// conn.setReadTimeout(DEFAULT_READ_TIMEOUT); + conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java index 2f76290..97cf811 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -161,7 +161,7 @@ map.put("plateNo",carLicense); map.put("driverMobile",driverMobiles.toString()); map.put("driverName", driverNames.toString()); - map.put("appId", tbOrders.getAppId()); +// map.put("appId", tbOrders.getAppId()); // 绗竴娆″皾璇� String response = sendCallback(callbackUrl, map); diff --git a/ruoyi-ui/src/api/system/callbacklog.js b/ruoyi-ui/src/api/system/callbacklog.js index 11c1758..19a7b0f 100644 --- a/ruoyi-ui/src/api/system/callbacklog.js +++ b/ruoyi-ui/src/api/system/callbacklog.js @@ -44,9 +44,10 @@ } // 閲嶈瘯鍥炶皟 -export function retryCallbacklog(ids) { +export function retryCallbacklog(ids, config = {}) { return request({ url: '/system/callbacklog/retry/' + ids, - method: 'post' + method: 'post', + ...config // 鍚堝苟閰嶇疆 }) } diff --git a/ruoyi-ui/src/views/system/callbacklog/index.vue b/ruoyi-ui/src/views/system/callbacklog/index.vue index 1a0b084..0735694 100644 --- a/ruoyi-ui/src/views/system/callbacklog/index.vue +++ b/ruoyi-ui/src/views/system/callbacklog/index.vue @@ -337,11 +337,22 @@ handleRetry(row) { const id = row.id; this.$modal.confirm('鏄惁纭閲嶈瘯璇ュ洖璋冭褰曪紵').then(function() { - return retryCallbacklog(id); + // 鍒涘缓甯︽湁瓒呮椂璁剧疆鐨勮姹傞厤缃� + const config = { + timeout: 60000 // 璁剧疆60绉掕秴鏃� + }; + return retryCallbacklog(id, config); }).then(() => { this.getList(); this.$modal.msgSuccess("瑙﹀彂閲嶈瘯鎴愬姛"); - }).catch(() => {}); + }).catch((error) => { + // 娣诲姞閿欒澶勭悊 + if (error.message.includes('timeout')) { + this.$modal.msgError("璇锋眰瓒呮椂锛岃绋嶅悗閲嶈瘯"); + } else { + this.$modal.msgError("閲嶈瘯澶辫触锛�" + error.message); + } + }); }, /** 鎵归噺瑙﹀彂鍥炶皟閲嶈瘯 */ handleBatchRetry() { -- Gitblit v1.9.1