Commit b0405913 by yangyang

关联关系、4G轨迹提交(湖南)

parent c3cd21b7
......@@ -2,9 +2,11 @@ package com.founder.commonutils.util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
......@@ -27,7 +29,19 @@ import java.util.*;
import java.util.Map.Entry;
public class HttpUtil {
private static RequestConfig requestConfig = null;
private static String tokenPath="";
static{
// 设置请求和传输超时时间
//setConnectTimeout:设置连接超时时间,单位毫秒。
//setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
//setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒
requestConfig = RequestConfig.custom().setSocketTimeout(60000)
.setConnectTimeout(60000)
.setConnectionRequestTimeout(60000)
.setStaleConnectionCheckEnabled(true)
.build();
}
/**
* 获取网安数据
* @param url
......@@ -397,4 +411,49 @@ public class HttpUtil {
public static boolean ckeckEmpty(String string) {
return (null == string) || ("".equals(string));
}
/**
* 请求的参数类型为json
* @param url
* @param json
* @return {username:"",pass:""}
*/
public static String doPostJsonHunan(String url,Map<String, String> headers,String json) throws Exception {
// post请求返回结果
CloseableHttpClient httpClient = HttpClients.createDefault();
String jsonResult = null;
System.out.println(url);
HttpPost httpPost = new HttpPost(url);
// 设置请求和传输超时时间
httpPost.setConfig(requestConfig);
if(headers != null) {
for (String key : headers.keySet()) {
httpPost.setHeader(key, headers.get(key));
}
}
try{
//设置参数解决中文乱码
if (null != json){
StringEntity entity = new StringEntity(json,"utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
}
//发送请求
CloseableHttpResponse result = httpClient.execute(httpPost);
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
// 读取服务器返回的json数据(然后解析)
jsonResult = EntityUtils.toString(result.getEntity(), "utf-8");
}else{
return null;
}
}catch (Exception e){
e.printStackTrace();
throw new Exception();
}finally{
httpPost.releaseConnection();
}
return jsonResult;
}
}
......@@ -197,7 +197,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
public MapRestResult query(@RequestBody SkTrailParam sktrailParam,HttpServletRequest request) {
List<SkTrailVO> list = new ArrayList<>();
// 根据标识号查看是否为演示数据 演示数据直接走数据库
/*if(SkTextUtilServiceImpl.queryText(sktrailParam.getLikeValue()).size()>0){
if(SkTextUtilServiceImpl.queryText(sktrailParam.getLikeValue()).size()>0){
//分页
Page page = new Page(sktrailParam.getPage(), sktrailParam.getPageSize());
QueryWrapper queryWrapper = new QueryWrapper();
......@@ -226,7 +226,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
for (SkTrail skTrail : records) {
list.add(new SkTrailVO(skTrail, findByBh(skTrail.getObjectvalue(),skTrail.getObjecttype())));
}
}*/
}
// 真实API
if(sktrailParam.getLikeField().equals("wbgj")){
list = interfaceAPI.getWbXx(sktrailParam.getLikeValue(),sktrailParam.getKssj(),sktrailParam.getJssj(),request,sktrailParam.getPage(),sktrailParam.getPageSize());
......@@ -519,7 +519,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
public void export(HttpServletResponse response,@RequestBody SkTrailParam sktrailParam,HttpServletRequest request)throws Exception{
List<SkTrailVO> list = new ArrayList<>();
// 根据标识号查看是否为演示数据 演示数据直接走数据库
/*if(SkTextUtilServiceImpl.queryText(sktrailParam.getLikeValue()).size()>0){
if(SkTextUtilServiceImpl.queryText(sktrailParam.getLikeValue()).size()>0){
//分页
Page page = new Page(sktrailParam.getPage(), sktrailParam.getPageSize());
QueryWrapper queryWrapper = new QueryWrapper();
......@@ -543,7 +543,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
for (SkTrail skTrail : records) {
list.add(new SkTrailVO(skTrail, findByBh(skTrail.getObjectvalue(),skTrail.getObjecttype())));
}
}*/
}
// 真实API
if(sktrailParam.getLikeField().equals("wbgj")){
list = interfaceAPI.getWbXx(sktrailParam.getLikeValue(),sktrailParam.getKssj(),sktrailParam.getJssj(),request,sktrailParam.getPage(),sktrailParam.getPageSize());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment