图片新增三次重试,防止网络波动

20230922-ljl-fixBug
daixiaogang 1 year ago
parent 3136410d4b
commit 2099c0737f

@ -14,6 +14,7 @@ import javax.imageio.ImageIO;
import cn.hutool.core.codec.Base64Decoder; import cn.hutool.core.codec.Base64Decoder;
import cn.hutool.core.img.ImgUtil; import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ms.api.common.Ret; import com.ms.api.common.Ret;
@ -42,13 +43,19 @@ public class TailorImgTool {
params.put("authCode", authCode); params.put("authCode", authCode);
params.put("imgUrl", imgPath); params.put("imgUrl", imgPath);
String res = null; String res = null;
try { JSONObject resObj = null;
res = dsJsonRequestTemplate.execute("/micro_move/get_image_data", params); for (int j = 0; j < 3; j++) {
} catch (Exception e) { try {
e.printStackTrace(); 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 (ObjectUtil.isNull(resObj) || "fail".equals(resObj.getString("result"))) {
if (resObj.getString("result").equals("fail")) {
return imgPath; return imgPath;
} }
String imageData = resObj.getString("imageData"); String imageData = resObj.getString("imageData");

Loading…
Cancel
Save