Răsfoiți Sursa

现场部署一系列适配提交

wanger 3 luni în urmă
părinte
comite
9545c1d908

+ 61 - 0
onemap-common/onemap-common-core/src/main/java/com/onemap/common/core/utils/StringUtils.java

@@ -1,5 +1,6 @@
 package com.onemap.common.core.utils;
 
+import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -700,4 +701,64 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
                 return "总体规划";
         }
     }
+
+    /**
+     * 搜索文件夹下指定文件名结尾的文件  默认返回第一个
+     *
+     * @param filepath
+     * @param endsWith
+     * @return String
+     */
+    public static String FileSearch(String filepath, String endsWith) {
+        File folder = new File(filepath);
+        File[] files = folder.listFiles(new FilenameFilter() {
+            @Override
+            public boolean accept(File dir, String name) {
+                return name.endsWith(endsWith);
+            }
+        });
+        if (files.length > 0) {
+            return files[0].getAbsolutePath();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * 读取txt文本文件
+     *
+     * @param filepath
+     * @return Map<String, String>
+     */
+    public static Map<String, String> readTxt(String filepath, String charset) {
+        Map<String, String> resMap = new HashMap<>();
+        try {
+            File file = new File(filepath);
+            charset = isEmpty(charset) ? "UTF-8" : charset;
+//            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));
+            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
+            String line;
+            while ((line = reader.readLine()) != null) {
+                if (StringUtils.isNotEmpty(line) && !line.contains("[")) {
+                    line = line.replace(" ", "");
+                    String[] curline = line.split("=");
+                    if (curline.length == 1) {
+                        continue;
+                    }
+                    System.out.println("newnewnew");
+                    System.out.println(curline[0]);
+                    System.out.println(curline[1]);
+                    if (curline[0].contains("项目名称")) {
+                        System.out.println("---XMMC---");
+                        resMap.put("xmmc", curline[1]);
+                    }
+                    resMap.put(curline[0], curline[1]);
+                }
+            }
+            reader.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return resMap;
+    }
 }

+ 25 - 5
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/task/PythonExecute.java

@@ -69,10 +69,13 @@ public class PythonExecute {
 //        } catch (Exception e) {
 //            e.printStackTrace();
 //        }
+        String platform = getSystem();
         //Runtime方式
         JSONObject json = new JSONObject(params);
-        String[] arguments = new String[]{"su", "-" , "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
-//        String[] arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        String[] arguments = new String[]{"su", "-", "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        if ("windows".equals(platform)) {
+            arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        }
         try {
             System.out.println(pythonexe);
             System.out.println(pythonfile);
@@ -106,8 +109,11 @@ public class PythonExecute {
         System.out.println(pythonfile);
         System.out.println(functionName);
         System.out.println(Base64Utils.base64Encode(json.toJSONString()));
-        String[] arguments = new String[]{"su", "-" , "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
-//        String[] arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        String[] arguments = new String[]{"su", "-", "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        String platform = getSystem();
+        if ("windows".equals(platform)) {
+            arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        }
         try {
             Process process = Runtime.getRuntime().exec(arguments);
             BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
@@ -141,7 +147,10 @@ public class PythonExecute {
         System.out.println(functionName);
         System.out.println(Base64Utils.base64Encode(json.toJSONString()));
         String[] arguments = new String[]{"su", "-", "geoscene", pythonexe, gisfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
-//        String[] arguments = new String[]{pythonexe, gisfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        String platform = getSystem();
+        if ("windows".equals(platform)) {
+            arguments = new String[]{pythonexe, gisfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
+        }
         try {
             Process process = Runtime.getRuntime().exec(arguments);
             BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
@@ -264,4 +273,15 @@ public class PythonExecute {
             this.value = value;
         }
     }
+
+    public static String getSystem() {
+        String osName = System.getProperty("os.name").toLowerCase();
+        if (osName.contains("win")) {
+            return "windows";
+        } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
+            return "linux";
+        } else {
+            return "";
+        }
+    }
 }

+ 27 - 0
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/cggl/CgglServiceImpl.java

@@ -48,6 +48,9 @@ import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+import static com.onemap.common.core.utils.StringUtils.FileSearch;
+import static com.onemap.common.core.utils.StringUtils.readTxt;
+
 
 @Service
 public class CgglServiceImpl implements CgglService {
@@ -94,6 +97,8 @@ public class CgglServiceImpl implements CgglService {
     private String cgscUrl;
     @Value("${Cggl.cgjc}")
     private String cgjcUrl;
+    @Value("${charset}")
+    private String charset;
 
 
     private String Authorization = "Basic c2FiZXI6c2FiZXJfc2VjcmV0";
@@ -204,6 +209,28 @@ public class CgglServiceImpl implements CgglService {
         {
             escalationDTO.setSczt("4");
         }
+        //TODO wanger 处理规划成果名称
+        QueryWrapper<EscalationFileDTO> filewrapper = new QueryWrapper<EscalationFileDTO>();
+        filewrapper.eq("id", escalationDTO.getFileid());
+        EscalationFileDTO fileDto = escalationFileMapper.selectOne(filewrapper);
+        if (fileDto != null) {
+            String filepath = fileDto.getUnzippath();
+            //解析txt
+            String txtFilePath = FileSearch(filepath, "基本信息.txt");
+            if (StringUtils.isNotEmpty(txtFilePath)) {
+                System.out.println("txtFilePath===" + txtFilePath);
+                Map<String, String> txtMap = null;
+                try {
+                    txtMap = readTxt(txtFilePath, charset);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                System.out.println("txtMap===" + txtMap);
+                if (StringUtils.isNotEmpty(txtMap.get("xmmc"))) {
+                    escalationDTO.setName(txtMap.get("xmmc"));
+                }
+            }
+        }
         escalationMapper.insert(escalationDTO);
         addCgglRz(escalationDTO);
 //        FixedThreadUtil.FIXED_THREAD_POOL.execute(() -> {

+ 1 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/sbjk/SbSearchServiceImpl.java

@@ -74,7 +74,7 @@ public class SbSearchServiceImpl implements SbSearchService {
         jsonObject.put("current", current);
         jsonObject.put("size", size);
         if (StringUtils.isNotEmpty(subject)) {
-            jsonObject.put("title", subject);
+            jsonObject.put("subject", subject);
         }
         if (StringUtils.isNotEmpty(divisionCode)) {
             jsonObject.put("divisionCode", divisionCode);

+ 30 - 10
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/sbjk/XzczghcgsbServiceImpl.java

@@ -31,6 +31,9 @@ import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
+import static com.onemap.common.core.utils.StringUtils.FileSearch;
+import static com.onemap.common.core.utils.StringUtils.readTxt;
+
 
 @Service
 public class XzczghcgsbServiceImpl implements XzczghcgsbService {
@@ -46,6 +49,8 @@ public class XzczghcgsbServiceImpl implements XzczghcgsbService {
     private String username;
     @Value("${Cggl.password}")
     private String password;
+    @Value("${charset}")
+    private String charset;
     @Value("${xzczghcgsb.xzczghcgsbUplaodUrl}")
     private String xzczghcgsbUplaodUrl;
     @Value("${xzczghcgsb.xzczghcgsbCompleteUrl}")
@@ -125,15 +130,15 @@ public class XzczghcgsbServiceImpl implements XzczghcgsbService {
     @Override
     public List<XzczghcgsbDTO> selectList(XzczghcgsbDTO xzczghcgsbDTO) {
         QueryWrapper<XzczghcgsbDTO> giswrapper = new QueryWrapper<>();
-        if (StringUtils.isNotEmpty(xzczghcgsbDTO.getCounty())) {
-            giswrapper.like("county", xzczghcgsbDTO.getCounty());
-        }
-        if (StringUtils.isNotEmpty(xzczghcgsbDTO.getTown())) {
-            giswrapper.like("town", xzczghcgsbDTO.getTown());
-        }
-        if (StringUtils.isNotEmpty(xzczghcgsbDTO.getVillage())) {
-            giswrapper.like("village", xzczghcgsbDTO.getVillage());
-        }
+//        if (StringUtils.isNotEmpty(xzczghcgsbDTO.getCounty())) {
+//            giswrapper.like("county", xzczghcgsbDTO.getCounty());
+//        }
+//        if (StringUtils.isNotEmpty(xzczghcgsbDTO.getTown())) {
+//            giswrapper.like("town", xzczghcgsbDTO.getTown());
+//        }
+//        if (StringUtils.isNotEmpty(xzczghcgsbDTO.getVillage())) {
+//            giswrapper.like("village", xzczghcgsbDTO.getVillage());
+//        }
         if (StringUtils.isNotEmpty(xzczghcgsbDTO.getXzqCode())) {
             giswrapper.like("xzq_code", xzczghcgsbDTO.getXzqCode());
         }
@@ -298,7 +303,22 @@ public class XzczghcgsbServiceImpl implements XzczghcgsbService {
             if (missfile.size() > 0) {
                 return AjaxResult.success("村庄规划成果上传失败:上传失败缺少以下文件或文件名称有误:", missfile);
             } else {
-                return AjaxResult.success(desc.getAbsolutePath());
+                //TODO wanger 获取规划文本中的项目名称
+                //解析txt
+                String txtFilePath = FileSearch(unzippath + File.separator + relFileName, "基本信息.txt");
+                if (StringUtils.isNotEmpty(txtFilePath)) {
+                    System.out.println("txtFilePath===" + txtFilePath);
+                    Map<String, String> txtMap = null;
+                    try {
+                        txtMap = readTxt(txtFilePath, charset);
+                    } catch (Exception e) {
+                    }
+                    System.out.println("txtMap===" + txtMap);
+                    if (StringUtils.isNotEmpty(txtMap.get("xmmc"))) {
+                        return AjaxResult.success(desc.getAbsolutePath() + "******" + txtMap.get("xmmc"));
+                    }
+                }
+                return AjaxResult.success(desc.getAbsolutePath() + "******" + relFileName);
             }
         } catch (IOException e) {
             e.printStackTrace();

+ 2 - 2
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/utils/RInterfaceUtil.java

@@ -112,8 +112,8 @@ public class RInterfaceUtil {
                 httpPost.setEntity(entity);
 //                httpPost.setEntity(new UrlEncodedFormEntity(list, "UTF-8"));
                 //配置请求时间、超时时间
-                RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();
-                httpPost.setConfig(requestConfig);
+//                RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();
+                httpPost.setConfig(config);
 
                 //开始发送请求
                 closeableHttpResponse = closeableHttpClient.execute(httpPost);

+ 2 - 2
onemap-modules/onemap-apply/src/main/resources/mapper/postgresql/yzt/XzqMapper.xml

@@ -11,7 +11,7 @@
         t.pid as "parent",
         case when (select count(*) from v_yzt_zysxcx p where p.pid = t.id) > 0 then '1'
         else '0' end as "isparent"
-        from v_yzt_zysxcx t where t.type = 'XZQ'
+        from v_yzt_zysxcx t where (t.type = 'XZQ' or t.type = 'xzq')
         <if test="city == null or city == false">
             and t.pid is not null
         </if>
@@ -26,7 +26,7 @@
         t.pid as "parent",
         case when (select count(1) from v_yzt_zysxcx p where p.pid = t.id) > 0 then '1'
         else '0' end as "isparent"
-        from v_yzt_zysxcx t where t.type = 'XZQ'
+        from v_yzt_zysxcx t where (t.type = 'XZQ' or t.type = 'xzq')
         and 9 >= length(t.id)
         order by t.id
 <!--        <if test="city == null or city == false">-->