From 2099c0737f71693afee697282646bc7ef43d98e0 Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Fri, 15 Sep 2023 18:54:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=96=B0=E5=A2=9E=E4=B8=89?= =?UTF-8?q?=E6=AC=A1=E9=87=8D=E8=AF=95=EF=BC=8C=E9=98=B2=E6=AD=A2=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E6=B3=A2=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ms/api/tool/TailorImgTool.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/tool/TailorImgTool.java b/ms-biz/src/main/java/com/ms/api/tool/TailorImgTool.java index fd69289d..c8febcc2 100644 --- a/ms-biz/src/main/java/com/ms/api/tool/TailorImgTool.java +++ b/ms-biz/src/main/java/com/ms/api/tool/TailorImgTool.java @@ -14,6 +14,7 @@ import javax.imageio.ImageIO; import cn.hutool.core.codec.Base64Decoder; import cn.hutool.core.img.ImgUtil; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ms.api.common.Ret; @@ -42,13 +43,19 @@ public class TailorImgTool { params.put("authCode", authCode); params.put("imgUrl", imgPath); String res = null; - try { - res = dsJsonRequestTemplate.execute("/micro_move/get_image_data", params); - } catch (Exception e) { - e.printStackTrace(); + JSONObject resObj = null; + for (int j = 0; j < 3; j++) { + try { + res = dsJsonRequestTemplate.execute("/micro_move/get_image_data", params); + } catch (Exception e) { + e.printStackTrace(); + } + if (ObjectUtil.isNotNull(res)) { + resObj = JSON.parseObject(res); + break; + } } - JSONObject resObj = JSON.parseObject(res); - if (resObj.getString("result").equals("fail")) { + if (ObjectUtil.isNull(resObj) || "fail".equals(resObj.getString("result"))) { return imgPath; } String imageData = resObj.getString("imageData");