|
@@ -1,5 +1,8 @@
|
|
|
package com.tofly.ghrq.custom.service.impl;
|
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
@@ -13,6 +16,7 @@ import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -23,7 +27,10 @@ import java.util.*;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class GisAboutServiceImpl implements GisAboutService {
|
|
|
-
|
|
|
+
|
|
|
+ * 设置连接超时时间,单位毫秒
|
|
|
+ */
|
|
|
+ private static final int CONNECT_TIMEOUT = 3 * 60 * 1000;
|
|
|
@Override
|
|
|
@SneakyThrows
|
|
|
public String createFile(ExcelParam excelParam) {
|
|
@@ -87,10 +94,13 @@ public class GisAboutServiceImpl implements GisAboutService {
|
|
|
List<String[]> ids= StringUtil.stringSplittoList(excelParam.getObjectids(),",", ComConstans.REQUEST_MAXCOUNT);
|
|
|
JSONArray list=new JSONArray();
|
|
|
ids.stream().forEach(id->{
|
|
|
- String param="objectids="+StringUtil.join(id,",")+"&outfields="+excelParam.getOutfields()+
|
|
|
- "&returnGeometry="+"1".equals(excelParam.getGeometry())+"&f="+ComConstans.REQUEST_FORMAT;
|
|
|
+ Map map = new HashMap(12);
|
|
|
+ map.put("objectids",StringUtil.join(id,","));
|
|
|
+ map.put("outfields",excelParam.getOutfields());
|
|
|
+ map.put("returnGeometry",true);
|
|
|
+ map.put("f",ComConstans.REQUEST_FORMAT);
|
|
|
try{
|
|
|
- String countent= HttpURL.getContent(excelParam.getLayerurl()+"?"+param,"");
|
|
|
+ String countent= doPostJson(excelParam.getLayerurl(),new HashMap<>(),map);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(countent);
|
|
|
JSONArray features = jsonObject.getJSONArray("features");
|
|
|
|
|
@@ -102,5 +112,15 @@ public class GisAboutServiceImpl implements GisAboutService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ public static String doPostJson(String url, Map<String, String> headers, Map map) throws IOException {
|
|
|
+ HttpResponse execute = HttpRequest.post(url)
|
|
|
+ .addHeaders(headers)
|
|
|
+ .form(map)
|
|
|
+ .timeout(CONNECT_TIMEOUT)
|
|
|
+ .execute();
|
|
|
+
|
|
|
+
|
|
|
+ return execute.body();
|
|
|
+ }
|
|
|
|
|
|
}
|