获取地址调整

master^2
wj 2 years ago
parent 71152f3352
commit a0d847ec98

@ -1,6 +1,7 @@
package com.glxp.sale.admin.controller.sync; package com.glxp.sale.admin.controller.sync;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -73,15 +74,15 @@ public class SyncController {
} else { } else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getLocalAddr() + "服务缺少上级服务IP"); return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getLocalAddr() + "服务缺少上级服务IP");
} }
JSONObject jsonObject = null; String str = null;
try { try {
jsonObject = redirect(request, upperServerHost); str = HttpUtil.get(upperServerHost);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getLocalAddr() + "服务访问上级服务" + upperServerHost + "异常"); return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getLocalAddr() + "服务访问上级服务" + upperServerHost + "异常");
} }
BaseResponse response = JSONUtil.toBean(jsonObject.toJSONString(), BaseResponse.class); BaseResponse response = JSONUtil.toBean(str, BaseResponse.class);
if ("20000".equals(response.getCode())) { if (response.getCode().equals(20000)) {
return ResultVOUtils.success("连接成功"); return ResultVOUtils.success("连接成功");
} else { } else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), response.getMessage()); return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), response.getMessage());

Loading…
Cancel
Save