wuweihao 5 anni fa
parent
commit
c98432b4f6

+ 10 - 0
src/main/java/com/fd/controller/VtsModelController.java

@@ -1,5 +1,6 @@
 package com.fd.controller;
 
+import com.fd.Dto.FdageDto;
 import com.fd.Dto.PageDto;
 import com.fd.constant.CommandMsg;
 import com.fd.constant.ErrorCode;
@@ -304,6 +305,15 @@ public class VtsModelController {
     }
 
 
+    @ApiOperation("update 4dage")
+    @PostMapping("update/fdage")
+    private ResponseResult updateFdage(@RequestBody FdageDto param){
+        log.info("run updateFdage");
+        jsonServer.updateFdage(param);
+        return new ResponseResult(200,"success");
+    }
+
+
 
 
 

+ 20 - 0
src/main/java/com/fd/controller/VtsVectorController.java

@@ -1,6 +1,8 @@
 package com.fd.controller;
 
+import com.fd.Dto.FdageDto;
 import com.fd.Dto.PageDto;
+import com.fd.Dto.ResourcesJsonDto;
 import com.fd.constant.CommandMsg;
 import com.fd.constant.ErrorCode;
 import com.fd.constant.TypeCode;
@@ -163,4 +165,22 @@ public class VtsVectorController {
         return fileServer.deleteFileById(fileId);
     }
 
+
+    @ApiOperation("update 4dage")
+    @PostMapping("update/fdage")
+    private ResponseResult updateFdage(@RequestBody FdageDto param){
+        log.info("run updateFdage");
+        jsonServer.updateFdage(param);
+        return new ResponseResult(200,"success");
+    }
+
+
+    @ApiOperation("update resources.json")
+    @PostMapping("update/resources")
+    private ResponseResult updateResources(@RequestBody ResourcesJsonDto param){
+        log.info("run updateResources");
+        jsonServer.updateResourcesJson(param);
+        return new ResponseResult(200,"success");
+    }
+
 }

+ 0 - 192
src/main/java/com/fd/util/CmdUtils.java

@@ -1,192 +0,0 @@
-package com.fd.util;
-
-import lombok.extern.log4j.Log4j2;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-/**
- * Created by Owen on 2019/10/31 0031 16:05
- */
-@Log4j2
-public class CmdUtils {
-
-
-
-    // linux 执行方法
-    public static String exeCmd(String commandStr) {
-
-        String result = null;
-        try {
-            String[] cmd = new String[]{"/bin/sh", "-c",commandStr};
-            Process ps = Runtime.getRuntime().exec(cmd);
-
-
-
-            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream(),"UTF-8"));
-            BufferedReader errorBuf = new BufferedReader(new InputStreamReader(ps.getErrorStream(), "UTF-8"));
-            log.info("===== br ========: {}", br == null);
-            StringBuffer sb = new StringBuffer();
-            StringBuffer errorStr = new StringBuffer();
-            String line;
-
-            while ((line = errorBuf.readLine()) != null) {
-                errorStr.append(line).append("\n");
-                System.out.println("error: "+line);
-            }
-            log.info("error result: {}", errorStr.toString());
-
-
-            while ((line = br.readLine()) != null) {
-                log.info("=====  br.readLine: ======== {}",  br.readLine());
-                //执行结果加上回车
-                System.out.println("br: "+line);
-                sb.append(line).append("\n");
-                log.info("line: {}", line);
-            }
-            result = sb.toString();
-            System.out.println("result: " + result);
-            log.info("result: {}", result);
-
-            // 结束命令行
-            int i = ps.waitFor();
-            log.info("wsitFore : {}", i);
-
-            // 关闭流
-            br.close();
-            errorBuf.close();
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        return result;
-
-    }
-
-
-    // linux 执行方法
-    public static String exeCmd2(String commandStr) {
-
-        String result = null;
-        try {
-            String[] cmd = new String[]{"/bin/sh", "-c",commandStr};
-            Process ps = Runtime.getRuntime().exec(cmd);
-
-
-
-            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream(),"UTF-8"));
-            BufferedReader errorBuf = new BufferedReader(new InputStreamReader(ps.getErrorStream(), "UTF-8"));
-
-            StringBuffer sb = new StringBuffer();
-            StringBuffer errorStr = new StringBuffer();
-
-
-            String errorLine;
-
-            String str = "";
-            String b= "";
-
-//            StringBuffer per = new StringBuffer();
-            ArrayList<Object> arrayList = new ArrayList<>();
-
-            while ((errorLine = errorBuf.readLine()) != null) {
-//                errorStr.append("\n"); // 为了打印日志好看,第一行先换行
-                errorStr.append(errorLine).append("\n");
-
-                if (errorLine.contains("Generated tile #")) {
-                    // 截取百分比
-                    str = errorLine.substring(errorLine.indexOf("% done)") - 7, errorLine.indexOf("% done)"));
-                    arrayList.add(str);
-                }
-
-
-//                b = errorLine.substring(0, errorLine.lastIndexOf("All done. {")+8);
-//
-//                if ("All done".equals(b)) {
-//                    arrayList.add(b);
-//                }
-            }
-            log.info("error result: {}", errorStr.toString());
-            log.info("per: {}", Arrays.toString(arrayList.toArray()));
-
-            String line;
-            while ((line = br.readLine()) != null) {
-                log.info("=====  br.readLine: ======== {}",  br.readLine());
-                //执行结果加上回车
-                System.out.println("br: "+line);
-                sb.append(line).append("\n");
-                log.info("line: {}", line);
-            }
-            result = sb.toString();
-            System.out.println("result: " + result);
-            log.info("result: {}", result);
-
-            // 结束命令行
-            int i = ps.waitFor();
-            log.info("wsitFore : {}", i);
-
-            // 关闭流
-            br.close();
-            errorBuf.close();
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        return result;
-
-    }
-
-    // 记录进度
-    public class PercentThread implements Runnable{
-
-        @Override
-        public void run() {
-
-        }
-    }
-
-    public static void main(String[] args) {
-//        StringBuffer buffer = new StringBuffer();
-//
-//        for (int i = 0; i < 10; i++) {
-//         buffer.append("ni hao:" + i).append("\n");
-//        }
-//        System.out.println(buffer.toString());
-
-        String a = "Generated tile #470 of 470 (  7.95 % done): 23-3419770-1832098 (pseudomerc, extents: 12637123.684560,2532482.957259:12637133.239189,2532492.511887) [mesh,atlas]. {encoder.cpp:process():304}";
-        String b = "All done. {";
-        System.out.println(a.substring(a.indexOf("% done)")-7, a.indexOf("% done)")));
-        System.out.println(b.substring(0, b.lastIndexOf("All done. {")+8));
-
-        System.out.println(a.contentEquals("Generated tile #"));
-        System.out.println(a.contains("Generated tile #"));
-        System.out.println(a.concat("Generated tile #"));
-    }
-
-
-//    // linux 执行方法
-//    public static String exeCmd(String commandStr) {
-//
-//        String result = null;
-//        try {
-//            String[] cmd = new String[]{"/bin/sh", "-c",commandStr};
-//            Process ps = Runtime.getRuntime().exec(cmd);
-//
-//            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
-//            log.info("===== br ========: {}", br == null);
-//            StringBuffer sb = new StringBuffer();
-//            log.info("===== sb ========");
-//
-//
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//
-//        return result;
-//
-//    }
-}

+ 0 - 130
src/main/java/com/fd/util/FileJsonUtils.java

@@ -1,130 +0,0 @@
-package com.fd.util;
-
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fd.Dto.FdageDto;
-import com.fd.Dto.ResourcesJsonDto;
-import lombok.extern.log4j.Log4j2;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-/**
- * Created by Owen on 2019/10/17 0017 16:02
- */
-
-
-@Log4j2
-public class FileJsonUtils {
-
-    private static String RESOURCESJSON_PATH = "json/resources.json";
-
-    private static String FDAGE_PATH = "json/4dage";
-
-    public static String readJson(String path){
-
-        String resource = FileUtils.getResource();
-
-        // 读取文件
-//        String param = FileUtils.readFile( resource+"json/data.json");
-        String param = FileUtils.readFile( resource+path);
-        return param;
-
-    }
-
-    public static void  updateResourcesJson(ResourcesJsonDto param) {
-        // 读取文件,获取结果集
-        String s = readJson(RESOURCESJSON_PATH);
-        // 转json数组
-        JSONArray originalArray  = JSON.parseArray(s);
-        // 获取第一个数组
-        Object index_0 = originalArray.get(0);
-
-        // 第一个数组的结果转json对象
-        JSONObject subelement = JSON.parseObject(index_0.toString());
-
-        // 自定义jsonString
-        String jRemoteUrl = "{'remoteUrl':'"+ param.getRemoteUrl() +"'}";
-//        log.info("jRemoteUrl: {}" + jRemoteUrl);
-//        String jRegistry = "{'credits':{'tianditu':{'id':"+param.getTiandituId()+",'notice':'"+param.getTiandituNotice()+"'}}}";
-
-
-
-        JSONObject tiandituSubJson = new JSONObject();
-        tiandituSubJson.put("id", param.getTiandituId());
-        tiandituSubJson.put("notice", param.getTiandituNotice());
-
-        JSONObject tiandituJson = new JSONObject();
-        tiandituJson.put("tianditu", tiandituSubJson);
-
-
-        JSONObject creditsJson = new JSONObject();
-        creditsJson.put("credits", tiandituJson);
-
-        // 更新值
-        subelement.put("id", param.getId());
-        subelement.put("definition", JSON.parse(jRemoteUrl));
-        subelement.put("registry", creditsJson);
-
-        // 修改的值设回去
-        originalArray.add(0, subelement);
-        log.info("update result:{}", originalArray.get(0) );
-        System.out.println(originalArray.get(0));
-
-        try {
-            FileUtils.fileWriter(JSON.toJSONString(originalArray),"F:\\test\\resources.json");
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-    }
-
-
-    public static void  updateFdage(FdageDto param) {
-        // 读取文件,获取结果集
-        String s = readJson(FDAGE_PATH);
-        // 转jsonObject
-        JSONObject original = JSON.parseObject(s);
-        System.out.println(original.toString());
-
-        // 获取子对象
-        JSONObject subFreeLayers = JSON.parseObject(original.getString("freeLayers"));
-        // 修改对象值
-        subFreeLayers.put("tiandi-surface", param.getTiandiSurface());
-
-        // 获取子对象
-        JSONObject subView = JSON.parseObject(original.getString("view"));
-        String jViewFreeLayers = "{\"tiandi-surface\":{\"boundLayers\":[\""+param.getViewTiandiSurface()+"\"]}}";
-        subView.put("freeLayers",JSON.parse(jViewFreeLayers));
-
-
-        // 自定义jsonString
-        String jTilesets = "['4dagecity','"+ param.getTiandi() +"']";
-        String jBoundLayers = "{'tiandi-map':'"+ param.getTiandiMap() +"'}";
-
-
-
-        original.put("freeLayers", subFreeLayers);
-        original.put("view", subView);
-        original.put("tilesets", JSON.parse(jTilesets));
-        original.put("boundLayers", JSON.parse(jBoundLayers));
-
-        System.out.println("========== :  " +original.toJSONString());
-
-        try {
-            FileUtils.fileWriter(JSON.toJSONString(original),"F:\\test\\4dage");
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void main(String[] args) {
-
-
-
-
-    }
-
-}