|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.glxp.sale.admin.controller.sync;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
@ -301,27 +302,28 @@ public class SpsSyncDataController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("sps/sync/upload/data")
|
|
|
|
|
public Object uploadData(HttpServletRequest request, @RequestBody SyncUpLoadRequest upLoadRequest) {
|
|
|
|
|
public Object uploadData(HttpServletRequest request) {
|
|
|
|
|
String uri = uriUtils.parseUri(request.getRequestURL().toString());
|
|
|
|
|
String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip");
|
|
|
|
|
if (StrUtil.isNotEmpty(upperServerHost)) {
|
|
|
|
|
uri = upperServerHost + "/" + uri;
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonObject = redirect(request, uri, upLoadRequest.getExportType());
|
|
|
|
|
JSONObject jsonObject = redirect(request, uri);
|
|
|
|
|
return jsonObject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject redirect(HttpServletRequest request, String uri, BasicExportTypeEnum exportType) {
|
|
|
|
|
private JSONObject redirect(HttpServletRequest request, String uri) {
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
HttpEntity<String> httpEntity = uriUtils.buildHeader(request);
|
|
|
|
|
String taskId = request.getHeader("taskId");
|
|
|
|
|
ResponseEntity<JSONObject> responseBody = null;
|
|
|
|
|
SyncUpLoadRequest bean = JSONUtil.toBean(httpEntity.getBody(), SyncUpLoadRequest.class);
|
|
|
|
|
if (request.getMethod().equals("POST")) {
|
|
|
|
|
//写入日志
|
|
|
|
|
writeUploadLog(taskId, httpEntity.getBody(), exportType);
|
|
|
|
|
writeUploadLog(taskId, httpEntity.getBody(), bean.getExportType());
|
|
|
|
|
responseBody = restTemplate.postForEntity(uri, httpEntity, JSONObject.class);
|
|
|
|
|
} else if (request.getMethod().equals("GET")) {
|
|
|
|
|
writeUploadLog(taskId, httpEntity.getBody(), exportType);
|
|
|
|
|
writeUploadLog(taskId, httpEntity.getBody(), bean.getExportType());
|
|
|
|
|
responseBody = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, JSONObject.class);
|
|
|
|
|
}
|
|
|
|
|
JSONObject result = responseBody.getBody();
|
|
|
|
|