| | |
| | | */ |
| | | 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 { |
| | |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); |
| | | |
| | | public static final int DEFAULT_READ_TIMEOUT = 60000; |
| | | |
| | | /** |
| | | * 向指定 URL 发送GET方法的请求 |
| | | * |
| | |
| | | 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)"); |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | // 重试回调 |
| | | export function retryCallbacklog(ids) { |
| | | export function retryCallbacklog(ids, config = {}) { |
| | | return request({ |
| | | url: '/system/callbacklog/retry/' + ids, |
| | | method: 'post' |
| | | method: 'post', |
| | | ...config // 合并配置 |
| | | }) |
| | | } |
| | |
| | | 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() { |