@ResponseBody

version1
admin 2 years ago
parent 0a69167cb8
commit 436f57c8f2

@ -1,40 +1,22 @@
package com.glxp.sale.admin.idc.controller;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.glxp.sale.admin.idc.service.DownloadRestTemplate;
import com.glxp.sale.admin.idc.utils.UriUtils;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.*;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RequestCallback;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
@ -42,8 +24,13 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glxp.sale.admin.idc.dao.DbDao;
import com.glxp.sale.admin.idc.service.IdcService;
import com.glxp.sale.admin.idc.utils.UriUtils;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.common.res.BaseResponse;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
/**
*
@ -78,6 +65,7 @@ public class IdcController {
//@Log("数据同步任务列表拉取")
@RequestMapping(value = "/spssync/common/list")
@ResponseBody
public BaseResponse list(HttpServletRequest request, @RequestBody(required = false) Map<String, Object> params) {
return idcService.taskList(request, params);
}

@ -132,10 +132,10 @@ public class IdcServiceImpl implements IdcService {
@Override
public void asyncFetchTask() {
Map<String,Object> query = new HashMap<String,Object>();
String host = getNextHost();
logger.info("fetch from ip:"+host);
if(!StringUtils.isEmpty(host)) {
String result = post(host+"/spssync/common/list",query);
String result = post(host+"/spssync/common/list",null);
logger.info("fetchTask--->"+result);
if(IDCUtils.isJson(result)) {
JSONObject json = JSON.parseObject(result);
@ -145,7 +145,7 @@ public class IdcServiceImpl implements IdcService {
for(Map map:list) {
Map<String,Object> params = new HashMap<String,Object>();
params.put("taskId", map.get("taskId"));
fetchData(host+"/spssync/common/list",params);
fetchData(host+"/spssync/common/download",params);
}
}
}
@ -267,6 +267,7 @@ public class IdcServiceImpl implements IdcService {
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error("fetchData-->"+e.getMessage());
}
return result;
}
@ -275,7 +276,9 @@ public class IdcServiceImpl implements IdcService {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params));
RequestBody body = RequestBody.create(mediaType, "");
if(params!=null)
body = RequestBody.create(mediaType,JSON.toJSONString(params));
Request request = new Request.Builder()
.url(url)
.method("POST", body)

Loading…
Cancel
Save