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

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

Loading…
Cancel
Save