From af2081423d57af2dfe4fe79fdab13b54c9bf5947 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Fri, 30 Aug 2024 09:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E9=A1=B9=E5=9F=BA=E6=9C=AC=E4=BF=A1?= =?UTF-8?q?=E6=81=AFIRS=E6=8E=A5=E5=8F=A3=E8=B6=85=E6=97=B6=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E9=87=8D=E6=96=B0=E8=AE=BE=E7=BD=AE=E7=AD=BE=E5=90=8D?= =?UTF-8?q?=E5=92=8C=E6=97=B6=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ningdatech/kqapi/irs/manage/IrsManage.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java b/kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java index a44f416..8d11f17 100644 --- a/kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java +++ b/kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java @@ -121,10 +121,15 @@ public class IrsManage { return responseBody; } - private static String retryAndGetResponseBody(String responseBody, HttpRequest request) { + private String retryAndGetResponseBody(String responseBody, HttpRequest request) { if (responseBody.contains("Read timed out")){ int retries = 3; for (int i = 0; i < retries; i++) { + // 重新设置签名和时间戳 + long timestamp = System.currentTimeMillis(); + String sign = MD5.create().digestHex(appKey + appSecret + timestamp); + request.header("requestTime", String.valueOf(timestamp)); + request.header("sign", sign); responseBody = request.execute().body(); ParserConfig config = new ParserConfig(); config.propertyNamingStrategy = PropertyNamingStrategy.PascalCase; @@ -138,6 +143,12 @@ public class IrsManage { if (i == retries - 1){ throw BizException.wrap("事项基本信息列表接口调用失败!"); } + // 等待一段时间后再次尝试 + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } } return responseBody;