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");