浏览代码

model 发放服务成功

wuweihao 5 年之前
父节点
当前提交
42e1cbede3

+ 0 - 177
src/main/java/com/fd/controller/FdModelController.java

@@ -76,42 +76,6 @@ public class FdModelController {
     }
     }
 
 
 
 
-//    @ApiOperation("测试生成队列")
-//    @GetMapping("command/queProducer/{fileId}/")
-//    private R queProducer(@PathVariable("fileId") Long fileId) {
-//        log.info("run queProducer: {}", fileId);
-//
-//        // 命令产生的是文件夹
-//        FileEntity fileEntity = new FileEntity();
-//        fileEntity.setFileName(fileId.toString());
-//        fileEntity.setFileUrl("33");
-//        fileEntity.setCreateTime(new Date());
-//        fileEntity.setUpdateTime(new Date());
-//        fileEntity.setStatus(5);
-//
-//        fileEntity = fileServer.save(fileEntity);
-//
-//        MyQueue que = new MyQueue();
-//        que.setObj(fileEntity);
-//        que.setStr("cmd1");
-//
-//        // 将数据存入队列中
-//        boolean offer = false;
-//        try {
-//            offer = oQueue.offer(que, 2, TimeUnit.SECONDS);
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
-//        if (offer) {
-//            System.out.println("生产者,存入" + que.toString() + "到队列中,成功.");
-//        } else {
-//            System.out.println("生产者,存入" + que.toString()  + "到队列中,失败.");
-//        }
-//
-//        return new R(200, fileEntity);
-//
-//    }
-
     /**
     /**
      * 消费队列
      * 消费队列
      */
      */
@@ -155,66 +119,6 @@ public class FdModelController {
 
 
 
 
 
 
-//    @ApiOperation("生成队列")
-//    @PostMapping(value = "test")
-//    private R test() {
-//        log.info("run test");
-//        // 将数据存入队列中
-//        String data = count.incrementAndGet() + "";
-//
-//        boolean offer = false;
-//        try {
-//            // 将数据存入队列中
-//            offer = queue.offer(data, 2, TimeUnit.SECONDS);
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
-//        if (offer) {
-//            System.out.println("生产者,存入" + data + "到队列中,成功.");
-//        } else {
-//            System.out.println("生产者,存入" + data + "到队列中,失败.");
-//        }
-//        return new R(200, data);
-//    }
-
-//    @ApiOperation("消费队列")
-//    @PostMapping(value = "test2")
-//    private R test2() {
-//        log.info("run test");
-//
-//
-//        String data = null;
-//        try {
-//            data = queue.poll(2, TimeUnit.SECONDS);
-//        } catch (InterruptedException e) {
-//            e.printStackTrace();
-//        }
-//        if (data != null) {
-//            System.out.println("消费者,拿到队列中的数据data:" + data);
-//        }
-//        return new R(200, data);
-//    }
-
-//    public class ConsumerThread implements Runnable{
-//
-//        @Override
-//        public void run() {
-//            log.warn("run ConsumerThread");
-//            while (true) {
-//                try {
-//                    String data = queue.poll(2, TimeUnit.SECONDS);
-//                    if (data != null) {
-//                        log.info("消费者,拿到队列中的数据data:" + data);
-//                    }
-//                    Thread.sleep(2000);
-//                } catch (InterruptedException e) {
-//                    e.printStackTrace();
-//                }
-//            }
-//        }
-//    }
-
-
     @ApiOperation("上传3D模型数据,只能上传zip文件")
     @ApiOperation("上传3D模型数据,只能上传zip文件")
     @PostMapping(value = "upload", consumes = {"multipart/form-data"})
     @PostMapping(value = "upload", consumes = {"multipart/form-data"})
     private R upload(@RequestParam("file") MultipartFile file) {
     private R upload(@RequestParam("file") MultipartFile file) {
@@ -323,87 +227,6 @@ public class FdModelController {
 
 
     }
     }
 
 
-//    @ApiOperation("倾斜摄影数据切片")
-//    @GetMapping("command/osgb/{fileId}/")
-//    private R cmdModelSlice(@PathVariable("fileId") Long fileId) {
-//        log.info("run cmdModelSlice: {}", fileId);
-//
-//
-////        // 将数据存入队列中
-////        String data = count.incrementAndGet() + "";
-////        boolean offer = false;
-////        try {
-////            // 将数据存入队列中
-////            offer = queue.offer(data, 2, TimeUnit.SECONDS);
-////        } catch (InterruptedException e) {
-////            e.printStackTrace();
-////        }
-////        if (offer) {
-////            System.out.println("生产者,存入" + data + "到队列中,成功.");
-////        } else {
-////            System.out.println("生产者,存入" + data + "到队列中,失败.");
-////        }
-//
-//
-//        FileEntity entity = fileServer.findById(fileId);
-//        // 传入的是目录
-//        String cmd = Command.MODEL_SLICE_OSGB;
-//        cmd = cmd.replace("@fileName", entity.getFileName());
-//        log.info("cmd: {}", cmd);
-//
-//        // 命令产生的是文件夹
-//        FileEntity fileEntity = new FileEntity();
-//        fileEntity.setFileName(entity.getFileName());
-//        fileEntity.setFileUrl(OUTPUT_FILE_PATH + entity.getFileName());
-//        fileEntity.setCreateTime(new Date());
-//        fileEntity.setUpdateTime(new Date());
-//        fileEntity.setStatus(5);
-//
-//        fileEntity = fileServer.save(fileEntity);
-//
-//        // 多线程运行切片
-//        new Thread(new ModelSliceThread(cmd, fileEntity)).start();
-//
-//
-//        return new R(200, fileEntity);
-//
-//    }
-
-
-//    public class ModelSliceThread implements Runnable {
-//
-//        private volatile boolean flag = true;
-//
-//        private String cmd;
-//
-//        private FileEntity entity;
-//
-//        private ModelSliceThread(String cmd, FileEntity entity) {
-//            this.cmd = cmd;
-//            this.entity = entity;
-//
-//        }
-//
-//        @Override
-//        public void run() {
-//            log.warn("run ModelSliceThread");
-//
-////            queue.poll(2, Ti)
-//
-//            Integer integer = cmdServer.exeCmdModelSlice(cmd);
-//            if (integer != 0) {
-//                log.info("error command exeCmdModelSlice");
-//                // 如果命令运行失败,删除刚才创建的实体类
-//                fileServer.deleteById(entity.getId());
-//                return;
-//            }
-//            log.warn("end RasterSliceThread");
-//        }
-//    }
-
-
-
-
 
 
     @ApiOperation("移动数据到服务器上")
     @ApiOperation("移动数据到服务器上")
     @GetMapping("move/{fileId}/")
     @GetMapping("move/{fileId}/")

+ 11 - 38
src/main/java/com/fd/controller/VectorController.java

@@ -200,6 +200,7 @@ public class VectorController {
         entity.setStatus(9);
         entity.setStatus(9);
         entity = vectorServer.save(entity);
         entity = vectorServer.save(entity);
 
 
+        // 坐标参数
         String coord = entity.getCoord();
         String coord = entity.getCoord();
         log.info("coord: {}", coord);
         log.info("coord: {}", coord);
 
 
@@ -220,40 +221,6 @@ public class VectorController {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
 
 
-//        Integer isJudge = cmdServer.exeCmdJudgeCoord(cmd);
-//
-////        FileEntity fileEntity = null;
-//        // 转换坐标 普通坐标转换
-//        if (isJudge == 1000){
-//            // 普通坐标转换
-//            log.info("need to general transform");
-//            if (coord == null) {
-//                // 没有坐标参数,执行普通坐标转换(ogrinfo)
-//                entity = generalCoordTransform(entity, Command.VECTOR_TRANSFORM_GENERAL);
-//
-//            } else {
-//                // 有坐标参数,执行严格坐标转换(CGCS2000转wgs80)
-//                entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS80);
-//            }
-//
-//        } else if (isJudge == 1001) {
-//            // 严格坐标转换 (西安80转wgs84),需要参数
-//            log.info("need to strict transform");
-//            if (coord == null) {
-//                log.info("error: {}", MsgCode.E50009);
-//                return new R(50009, MsgCode.E50009);
-//            }
-//            entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS84);
-//
-//        } else if (0 == isJudge){ // 不转换坐标
-//            log.info("not to transform");
-//            entity = entity;
-//        } else {
-//            log.info("error exeCmd");
-//            return new R(50005, MsgCode.E50005);
-//        }
-
-
         return new R(200, entity);
         return new R(200, entity);
     }
     }
 
 
@@ -287,24 +254,26 @@ public class VectorController {
                             log.info("need to general transform");
                             log.info("need to general transform");
                             if (entity.getCoord() == null) {
                             if (entity.getCoord() == null) {
                                 // 没有坐标参数,执行普通坐标转换(ogrinfo)
                                 // 没有坐标参数,执行普通坐标转换(ogrinfo)
+                                log.info("run generalCoordTransform");
                                 entity = generalCoordTransform(entity, Command.VECTOR_TRANSFORM_GENERAL);
                                 entity = generalCoordTransform(entity, Command.VECTOR_TRANSFORM_GENERAL);
 
 
                             } else {
                             } else {
                                 // 有坐标参数,执行严格坐标转换(CGCS2000转wgs80)
                                 // 有坐标参数,执行严格坐标转换(CGCS2000转wgs80)
+                                log.info("run strictCoordTransform");
                                 entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS80);
                                 entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS80);
                             }
                             }
 
 
                         } else if (isJudge == 1001) {
                         } else if (isJudge == 1001) {
+
                             // 严格坐标转换 (西安80转wgs84),需要参数
                             // 严格坐标转换 (西安80转wgs84),需要参数
-                            log.info("need to strict transform");
+                            log.info("need to strict transform, code: {}", isJudge);
                             if (entity.getCoord() == null) {
                             if (entity.getCoord() == null) {
                                 log.info("error: {}", MsgCode.E50009);
                                 log.info("error: {}", MsgCode.E50009);
-
                                 entity.setStatus(7);
                                 entity.setStatus(7);
                                 entity.setUpdateTime(new Date());
                                 entity.setUpdateTime(new Date());
                                 vectorServer.save(entity);
                                 vectorServer.save(entity);
                             } else {
                             } else {
-
+                                log.info("run strictCoordTransform");
                                 entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS84);
                                 entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS84);
                             }
                             }
 
 
@@ -450,10 +419,14 @@ public class VectorController {
         return directory;
         return directory;
     }
     }
 
 
-    // 执行命令,创建对象
+    // 执行命令,创建对象, 坐标转换使用
     private OutputFileEntity runCmd(String cmd, OutputFileEntity entity, String generalPath, String strictPath){
     private OutputFileEntity runCmd(String cmd, OutputFileEntity entity, String generalPath, String strictPath){
         Integer integer = cmdServer.exeCmdInt(cmd);
         Integer integer = cmdServer.exeCmdInt(cmd);
+        // 转换坐标失败, 修改状态
         if (integer != 0) {
         if (integer != 0) {
+            entity.setUpdateTime(new Date());
+            entity.setStatus(7);
+            entity = vectorServer.save(entity);
             return null;
             return null;
         }
         }
 
 

+ 21 - 21
src/main/java/com/fd/server/impl/ModelServerImpl.java

@@ -43,6 +43,14 @@ public class ModelServerImpl implements ModelServer {
     @Value("${copy.file.path.model}")
     @Value("${copy.file.path.model}")
     private String MOVE_FILE_TO_SERVER;
     private String MOVE_FILE_TO_SERVER;
 
 
+    // config.json 地址
+    @Value("${config.path}")
+    private String CONFIG_JSON_PATH;
+
+    // config.json  teileset 的相对路径
+    @Value("${config.tileset}")
+    private String CONFIG_TILESET;
+
     @Autowired
     @Autowired
     private FileRepository fileRepository;
     private FileRepository fileRepository;
 
 
@@ -87,10 +95,14 @@ public class ModelServerImpl implements ModelServer {
         // 移动文件
         // 移动文件
         FileUtils.createDir(MOVE_FILE_TO_SERVER);
         FileUtils.createDir(MOVE_FILE_TO_SERVER);
         FileUtils.base64ToFileWriter(entity.getSlicePath(), MOVE_FILE_TO_SERVER);
         FileUtils.base64ToFileWriter(entity.getSlicePath(), MOVE_FILE_TO_SERVER);
-        entity.setStatus(8);
-        outputFileRepository.save(entity);
+
 
 
         // 修改前端的config.json 文件
         // 修改前端的config.json 文件
+        writeJsonFile();
+
+        // 成功,状态
+        entity.setStatus(8);
+        outputFileRepository.save(entity);
 
 
         return new R(200, MsgCode.SUCCESS);
         return new R(200, MsgCode.SUCCESS);
     }
     }
@@ -184,30 +196,18 @@ public class ModelServerImpl implements ModelServer {
 
 
     /**
     /**
      * 修改config.json 文件
      * 修改config.json 文件
-     * @param str
      */
      */
-    public static void writeJsonFile(String str){
-        JSONObject original = JSON.parseObject(str);
-
-        JSONArray layers = JSON.parseArray(original.getString("layers"));
-
-        JSONObject subJson = new JSONObject();
-        subJson.put("name", "111");
-        subJson.put("text", "222");
-        subJson.put("type", "3333");
-        subJson.put("checked", "444");
-        subJson.put("show", "555");
-        subJson.put("url", "6666");
-
-        layers.add(subJson);
+    public void writeJsonFile(){
 
 
-        original.put("layers", layers);
+        String s = FileUtils.readFile(CONFIG_JSON_PATH);
 
 
-        System.out.println();
-        System.out.println(original.toString());
+        JSONObject original = JSON.parseObject(s);
+        // 修改tileset value
+        original.put("tileset", CONFIG_TILESET);
+        log.info(original.toJSONString());
 
 
         try {
         try {
-            FileUtils.fileWriter(JSON.toJSONString(original), "F:\\test\\123.json");
+            FileUtils.fileWriter(JSON.toJSONString(original), CONFIG_JSON_PATH);
         } catch (IOException e) {
         } catch (IOException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }

+ 32 - 32
src/main/java/com/fd/server/impl/RasterServerImpl.java

@@ -44,8 +44,8 @@ public class RasterServerImpl implements RasterServer {
     @Value("${copy.file.path.raster}")
     @Value("${copy.file.path.raster}")
     private String MOVE_FILE_TO_SERVER;
     private String MOVE_FILE_TO_SERVER;
 
 
-    @Value("${json.path}")
-    private String JSON_PATH;
+//    @Value("${json.path}")
+//    private String JSON_PATH;
 
 
     @Autowired
     @Autowired
     private FileRepository fileRepository;
     private FileRepository fileRepository;
@@ -169,34 +169,34 @@ public class RasterServerImpl implements RasterServer {
         return outputFileRepository.save(fileSchedule);
         return outputFileRepository.save(fileSchedule);
     }
     }
 
 
-    private boolean writeJson(ConfigJsonDto param) {
-        String s = FileUtils.readJsonLinux(JSON_PATH);
-
-        log.info("original: {}", s);
-        JSONObject original = JSON.parseObject(s);
-
-        JSONArray layers = JSON.parseArray(original.getString("layers"));
-
-        JSONObject subJson = new JSONObject();
-        subJson.put("name", "111");
-        subJson.put("text", param.getText());
-        subJson.put("type", "3333");
-        subJson.put("checked", false);
-        subJson.put("show", true);
-        subJson.put("url", param.getUrl());
-
-        layers.add(subJson);
-
-        original.put("layers", layers);
-
-        log.info("original update: {}", original.toJSONString());
-        try {
-            FileUtils.fileWriter(JSON.toJSONString(original), JSON_PATH);
-            return true;
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return false;
-
-    }
+//    private boolean writeJson(ConfigJsonDto param) {
+//        String s = FileUtils.readJsonLinux(JSON_PATH);
+//
+//        log.info("original: {}", s);
+//        JSONObject original = JSON.parseObject(s);
+//
+//        JSONArray layers = JSON.parseArray(original.getString("layers"));
+//
+//        JSONObject subJson = new JSONObject();
+//        subJson.put("name", "111");
+//        subJson.put("text", param.getText());
+//        subJson.put("type", "3333");
+//        subJson.put("checked", false);
+//        subJson.put("show", true);
+//        subJson.put("url", param.getUrl());
+//
+//        layers.add(subJson);
+//
+//        original.put("layers", layers);
+//
+//        log.info("original update: {}", original.toJSONString());
+//        try {
+//            FileUtils.fileWriter(JSON.toJSONString(original), JSON_PATH);
+//            return true;
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//        return false;
+//
+//    }
 }
 }

+ 4 - 4
src/main/java/com/fd/util/FileUtils.java

@@ -236,10 +236,10 @@ public class FileUtils {
                 temp.delete();
                 temp.delete();
             }
             }
             if (temp.isDirectory()) {
             if (temp.isDirectory()) {
-//                delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
-//                delFolder(path + "/" + tempList[i]);//再删除空文件夹
-                delAllFile(path + tempList[i]);//先删除文件夹里面的文件
-                delFolder(path + tempList[i]);//再删除空文件夹
+                delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
+                delFolder(path + "/" + tempList[i]);//再删除空文件夹
+//                delAllFile(path + tempList[i]);//先删除文件夹里面的文件
+//                delFolder(path + tempList[i]);//再删除空文件夹
                 flag = true;
                 flag = true;
             }
             }
         }
         }

+ 5 - 1
src/main/resources/application-dev.properties

@@ -15,4 +15,8 @@ copy.file.path.model=/root/gis/cesium/output/copy/
 copy.file.path.raster=/root/gis/cesium/output/copy/
 copy.file.path.raster=/root/gis/cesium/output/copy/
 copy.file.path.vector=/root/gis/cesium/output/copy/
 copy.file.path.vector=/root/gis/cesium/output/copy/
 
 
-json.path=/root/gis/cesium/output/copy/
+#config.json λÖÃ
+config.path=/var/www/html/3dmap/config.json
+
+#config.jsonµÄ teileset µÄÏà¶Ô·¾¶
+config.tileset=../data/wuyidaxue/tileset.json

+ 4 - 2
src/main/resources/application-pro.properties

@@ -15,6 +15,8 @@ copy.file.path.model=/root/gis/cesium/output/copy/
 copy.file.path.raster=/root/gis/cesium/output/copy/
 copy.file.path.raster=/root/gis/cesium/output/copy/
 copy.file.path.vector=/root/gis/cesium/output/copy/
 copy.file.path.vector=/root/gis/cesium/output/copy/
 
 
-#config.json
-json.path=/var/www/html/3dmap/config.json
+#config.json λÖÃ
+config.path=/var/www/html/3dmap/config.json
 
 
+#config.jsonµÄ teileset µÄÏà¶Ô·¾¶
+config.tileset=../data/wuyidaxue/tileset.json

+ 5 - 2
src/main/resources/application-uat.properties

@@ -15,6 +15,9 @@ copy.file.path.model=/root/gis/cesium/output/copy/
 copy.file.path.raster=/root/gis/cesium/output/copy/
 copy.file.path.raster=/root/gis/cesium/output/copy/
 copy.file.path.vector=/root/gis/cesium/output/copy/
 copy.file.path.vector=/root/gis/cesium/output/copy/
 
 
-#config.json
-json.path=/var/www/html/3dmap/config.json
+#config.json λÖÃ
+config.path=/var/www/html/3dmap/config.json
+
+#config.jsonµÄ teileset µÄÏà¶Ô·¾¶
+config.tileset=../data/wuyidaxue/tileset.json
 
 

+ 1 - 1
src/main/resources/application.properties

@@ -1,7 +1,7 @@
 server.port=8082
 server.port=8082
 
 
 # file multipart
 # file multipart
-spring.profiles.active=uat
+spring.profiles.active=pro
 spring.servlet.multipart.enabled=true
 spring.servlet.multipart.enabled=true
 spring.servlet.multipart.max-file-size=51200MB
 spring.servlet.multipart.max-file-size=51200MB
 spring.servlet.multipart.max-request-size=51200MB
 spring.servlet.multipart.max-request-size=51200MB