测试联通接口调整

master^2
wj 2 years ago
parent 8b6c1e2d6e
commit 87de4fa821

@ -1,10 +1,12 @@
package com.glxp.sale.admin.controller.sync;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.constant.ConstantStatus;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity;
import com.glxp.sale.admin.idc.utils.UriUtils;
@ -12,9 +14,11 @@ import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.service.sync.BasicUploadService;
import com.glxp.sale.admin.util.*;
import com.glxp.sale.common.enums.ResultEnum;
import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
@ -61,8 +65,28 @@ public class SyncController {
* @return
*/
@PostMapping("/udispsync/sync/testConnection")
public BaseResponse testConnection() {
return ResultVOUtils.success("连接成功");
public BaseResponse testConnection(HttpServletRequest request) {
String uri = uriUtils.parseUri(request.getRequestURL().toString());
String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip");
if (StrUtil.isNotEmpty(upperServerHost)) {
uri = upperServerHost + "/" + uri;
} else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getRemoteHost() + "服务缺少上级服务IP");
}
uri = changeUri(uri);
JSONObject jsonObject = null;
try {
jsonObject = redirect(request, uri);
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), request.getRemoteHost() + "服务访问上级服务" + upperServerHost + "异常");
}
BaseResponse response = JSONUtil.toBean(jsonObject.toJSONString(), BaseResponse.class);
if ("20000".equals(response.getCode())) {
return ResultVOUtils.success("连接成功");
} else {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), response.getMessage());
}
}
//单据接口直连--扫码单据

Loading…
Cancel
Save