Browse Source

优化巡检下发计划点位arcgis查询接口
优化scada设备排序

linzhiwei 2 years ago
parent
commit
d588fc6abf

+ 5 - 1
ghrq-gis/pom.xml

@@ -50,7 +50,11 @@
             <artifactId>common-es</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
-
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.5.7</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-config</artifactId>

+ 1 - 1
ghrq-gis/src/main/java/com/tofly/ghrq/config/ApplicationRunnerConfig.java

@@ -17,7 +17,7 @@ public class ApplicationRunnerConfig implements ApplicationRunner {
     private CustomQrcodeController customQrcodeController;
     @Override
     public void run(ApplicationArguments args) throws Exception {
-        customQrcodeController.myInit();
+//        customQrcodeController.myInit();
     }
 
 

+ 24 - 4
ghrq-gis/src/main/java/com/tofly/ghrq/custom/service/impl/GisAboutServiceImpl.java

@@ -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();
+    }
 
 }

+ 1 - 0
ghrq-scada/src/main/resources/mapper/RealDataGhMapper.xml

@@ -15,6 +15,7 @@
     <select id="getUe" resultType="string">
         select 单位 as ue  from real_data_gh_eu
         where 描述 = #{tagDesc}
+        ORDER BY RAND() LIMIT 1
     </select>
 
     <resultMap id="yxUserMap" type="com.tofly.dyrqScada.entity.YxUser">