Procházet zdrojové kódy

修改了文件路径

wuweihao před 5 roky
rodič
revize
0f6200398e

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 11 - 18
src/main/java/com/fd/constant/Command.java


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

@@ -54,6 +54,9 @@ public class ModelServerImpl implements ModelServer  {
     @Value("${config.path}")
     private String CONFIG_JSON_PATH;
 
+    @Value("${base.path}")
+    private String BASE_PATH;
+
     // config.json  teileset 的相对路径
     @Value("${config.tileset}")
     private String CONFIG_TILESET;
@@ -227,9 +230,6 @@ public class ModelServerImpl implements ModelServer  {
     }
 
 
-//
-
-
     @Override
     public R moveFileToServer(Long fileId, ConfigJsonDto param) {
         Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
@@ -346,13 +346,6 @@ public class ModelServerImpl implements ModelServer  {
         return null;
     }
 
-//    @Override
-//    public R findByType(String fileTypeModel, PageDto pageDto) {
-//        Page<OutputFileEntity> page = outputFileRepository.findByType(fileTypeModel, PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
-//        return new R(200, page);
-//    }
-//
-
     @Override
     public R findByType(String fileTypeModel, PageDto pageDto) {
         Page<OutputFileEntity> page = outputFileRepository.findByTypeAndResStatus(fileTypeModel, 0,PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
@@ -360,28 +353,6 @@ public class ModelServerImpl implements ModelServer  {
     }
 
 
-
-    /**
-     * 修改config.json 文件
-     */
-//    public void writeJsonFile(){
-//
-//        String s = FileUtils.readFile(CONFIG_JSON_PATH);
-//
-//        JSONObject original = JSON.parseObject(s);
-//        // 修改tileset value
-//        original.put("tileset", CONFIG_TILESET);
-//        log.info(original.toJSONString());
-//
-//        try {
-//            FileUtils.fileWriter(JSON.toJSONString(original), CONFIG_JSON_PATH);
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
-//
-//    }
-
-
     private void writeJsonFile(ConfigJsonDto param,  OutputFileEntity entity) {
         String s = FileUtils.readFile(CONFIG_JSON_PATH);
 
@@ -412,7 +383,9 @@ public class ModelServerImpl implements ModelServer  {
         subJson.put("show", true);
 
         String slicePath = entity.getSlicePath();
-        slicePath = slicePath.replace("/root/gis/cesium", "");
+//        slicePath = slicePath.replace("/root/gis/data", "");
+        slicePath = slicePath.replace(BASE_PATH, "");
+
         subJson.put("url", slicePath);
 
         layers.add(subJson);

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

@@ -63,6 +63,9 @@ public class RasterServerImpl implements RasterServer {
     @Value("${config.tileset}")
     private String CONFIG_TILESET;
 
+    @Value("${base.path}")
+    private String BASE_PATH;
+
     @Autowired
     private FileRepository fileRepository;
 
@@ -160,48 +163,6 @@ public class RasterServerImpl implements RasterServer {
 
     }
 
-
-//    @Override
-//    public R moveFileToServer(Long fileId, ConfigJsonDto param) {
-//        Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
-//        if (!o.isPresent()) {
-//            log.info("id:{} 不存在", fileId);
-//            return new R(50002, MsgCode.E50002);
-//        }
-//
-//        // 把数据移动到指定服务位置
-//        OutputFileEntity entity = o.get();
-//        FileUtils.createDir(MOVE_FILE_TO_SERVER);
-//
-//        try {
-//            org.apache.commons.io.FileUtils.copyDirectoryToDirectory(new File(entity.getSlicePath()), new File(MOVE_FILE_TO_SERVER));
-//            // 修改前端的config.json 文件
-//            String lastName = StringUtils.substringAfterLast(entity.getSlicePath(), "/");
-//            log.info("lastName: {}", lastName);
-//            writeJsonFile(param, lastName, entity);
-//
-//            //修改linux 文件权限
-//            String cmd = Command.CMD_CHOMD_755;
-//            String slice = MOVE_FILE_TO_SERVER + lastName;
-//            cmd = cmd.replace("@path", slice);
-//            log.info("cmd: {}", cmd);
-//            cmdServer.exeCmdInt(cmd);
-//
-//            // 成功,更新状态
-//            entity.setStatus(8);
-//            entity.setUpdateTime(new Date());
-//            outputFileRepository.save(entity);
-//            return new R(200, MsgCode.SUCCESS);
-//        } catch (IOException e) {
-//
-//            entity.setStatus(10);
-//            entity.setUpdateTime(new Date());
-//            outputFileRepository.save(entity);
-//            e.printStackTrace();
-//            return new R(51004, MsgCode.E51004, e);
-//        }
-//    }
-
     @Override
     public R moveFileToServer(Long fileId, ConfigJsonDto param) {
         Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
@@ -574,7 +535,8 @@ public class RasterServerImpl implements RasterServer {
         subJson.put("show", true);
 
         String slicePath = entity.getSlicePath();
-        slicePath = slicePath.replace("/root/gis/cesium", "");
+//        slicePath = slicePath.replace("/root/gis/data", "");
+        slicePath = slicePath.replace(BASE_PATH, "");
         subJson.put("url", slicePath);
 
         layers.add(subJson);

+ 5 - 166
src/main/java/com/fd/server/impl/VectorServerImpl.java

@@ -63,6 +63,9 @@ public class VectorServerImpl implements VectorServer {
     @Value("${config.tileset}")
     private String CONFIG_TILESET;
 
+    @Value("${base.path}")
+    private String BASE_PATH;
+
     @Autowired
     private FileRepository fileRepository;
 
@@ -75,45 +78,6 @@ public class VectorServerImpl implements VectorServer {
     @Autowired
     private StyleRepository styleRepository;
 
-//    @Override
-//    public R moveFileToServer(Long fileId, ConfigJsonDto param) {
-//        Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
-//        if (!o.isPresent()) {
-//            log.info("id:{} 不存在", fileId);
-//            return new R(50002, MsgCode.E50002);
-//        }
-//        OutputFileEntity entity = o.get();
-//        FileUtils.createDir(MOVE_FILE_TO_SERVER);
-//
-//        try {
-//            org.apache.commons.io.FileUtils.copyDirectoryToDirectory(new File(entity.getSlicePath()), new File(MOVE_FILE_TO_SERVER));
-//            // 修改前端的config.json 文件
-//            writeJsonFile(param, entity.getDirectory(), entity);
-//
-//            //修改linux 文件权限
-//            String cmd = Command.CMD_CHOMD_755;
-//            String slice = MOVE_FILE_TO_SERVER + entity.getDirectory();
-//            cmd = cmd.replace("@path", slice);
-//            log.info("cmd: {}", cmd);
-//            cmdServer.exeCmdInt(cmd);
-//
-//
-//            entity.setStatus(8);
-//            entity.setServicePath(slice);
-//            entity.setUpdateTime(new Date());
-//            outputFileRepository.save(entity);
-//            return new R(200, MsgCode.SUCCESS);
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//            // 服务发布失败
-//            entity.setStatus(10);
-//            entity.setUpdateTime(new Date());
-//            outputFileRepository.save(entity);
-//            return new R(51004, MsgCode.E51004, e);
-//        }
-//    }
-
-
 
     @Override
     public R moveFileToServer(Long fileId, ConfigJsonDto param) {
@@ -230,71 +194,6 @@ public class VectorServerImpl implements VectorServer {
     }
 
 
-//    @Override
-//    public R uploadDirectoryFile(MultipartFile file, String directoryName, String coord) {
-//
-//        log.warn("run uploadBigFile");
-//        long start = System.currentTimeMillis();
-//        if (file.isEmpty() || file.getSize() <= 0) {
-//            log.info("文件为空");
-//            return new R(50001, MsgCode.E50001);
-//        }
-//
-//        // 文件名全名
-//        String fullFileName = file.getOriginalFilename();
-//
-//        // 创建目录路径
-//        String filePath = INPUT_FILE_PATH + directoryName + File.separator;
-//        FileUtils.createDir(filePath);
-//
-//
-//        // 文件保存路径
-//        filePath = filePath + fullFileName;
-//
-//        // 写文件到本地
-//
-//        try {
-//            FileUtils.bigFileWrite(file.getInputStream(), filePath);
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
-//        log.info("filePath: {}", filePath);
-//
-//        // 保存信息到db
-//        FileEntity entity = new FileEntity();
-//        entity.setFileName(fullFileName);
-//        entity.setDirectory(directoryName);
-//        entity.setFileUrl(filePath);
-//        entity.setCreateTime(new Date());
-//        entity.setUpdateTime(new Date());
-//        entity.setType(TypeCode.FILE_TYPE_VECTOR);
-//        entity.setCoord(coord);
-//        entity.setStatus(2);
-//        fileRepository.save(entity);
-//
-//        OutputFileEntity outputFile = null;
-//        String s = StringUtils.substringAfterLast(fullFileName, ".");
-//        if ("shp".equals(s)) {
-//
-//            outputFile = new OutputFileEntity();
-//            outputFile.setUploadId(entity.getId());
-//            outputFile.setUploadPath(entity.getFileUrl());
-//            outputFile.setFileName(entity.getFileName());
-//            outputFile.setStatus(2);
-//            outputFile.setType(TypeCode.FILE_TYPE_VECTOR);
-//            outputFile.setCoord(entity.getCoord());
-//            outputFile.setCreateTime(new Date());
-//            outputFile.setUpdateTime(new Date());
-//
-//            outputFile = outputFileRepository.save(outputFile);
-//        }
-//
-//
-//        long end = System.currentTimeMillis();
-//        log.info("end uploadBigFile, total time: {} s", (end - start) / 1000);
-//        return new R(200, outputFile);
-//    }
-
     @Override
     public R uploadDirectoryFileMul(MultipartFile[] files, String directoryName, String coord) {
 
@@ -405,12 +304,6 @@ public class VectorServerImpl implements VectorServer {
         return new R(200, outputFile);
     }
 
-//    @Override
-//    public R findByType(String type, PageDto pageDto) {
-//        Page<OutputFileEntity> page = outputFileRepository.findByType(type, PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
-//        return new R(200, page);
-//    }
-
     @Override
     public R findByType(String type, PageDto pageDto) {
         Page<OutputFileEntity> page = outputFileRepository.findByTypeAndResStatus(type, 0, PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
@@ -719,8 +612,6 @@ public class VectorServerImpl implements VectorServer {
         return isCmd;
     }
 
-
-
     /**
      * 获取经纬度平均值
      *
@@ -772,59 +663,6 @@ public class VectorServerImpl implements VectorServer {
         return outputFileRepository.save(fileSchedule);
     }
 
-
-    /**
-     * 发布服务
-     * 修改config.json
-     */
-//    private void writeJsonFile(ConfigJsonDto param, String lastName, OutputFileEntity entity) {
-//
-//        StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getId());
-//
-//        String s = FileUtils.readFile(CONFIG_JSON_PATH);
-//
-//        JSONObject original = JSON.parseObject(s);
-//
-//        log.info("original: {}", s);
-//
-//        JSONArray layers = JSON.parseArray(original.getString("layers"));
-//
-//        JSONObject subJson = new JSONObject();
-//        long cu = System.currentTimeMillis();
-//        String name = "vector_" + cu;
-//        // 需要唯一
-//        subJson.put("name", name);
-//
-//        subJson.put("text", param.getText());
-//        // vector 就用这个类型geodata
-//        subJson.put("type", "geodata");
-//        subJson.put("checked", false);
-//        subJson.put("show", true);
-//        subJson.put("url", "../data/" + lastName);
-////        subJson.put("style", JSON.parse(styleEntity.getContent()));
-//        layers.add(subJson);
-//
-//        original.put("layers", layers);
-//
-//        log.info("original update: {}", original.toJSONString());
-//        try {
-//            FileUtils.fileWriter(JSON.toJSONString(original), CONFIG_JSON_PATH);
-//
-//            // 将图层信息保存到db
-//            // 前端需要layer信息
-//            styleEntity.setLayer(subJson.toJSONString());
-//            styleEntity.setUpdateTime(new Date());
-//            styleEntity.setName(name);
-////            log.info("check test 2");
-//            styleRepository.save(styleEntity);
-////            log.info("check test 3");
-//
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
-//    }
-
-
     private void writeJsonFile(ConfigJsonDto param, String lastName, OutputFileEntity entity) {
 
         StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getId());
@@ -850,7 +688,8 @@ public class VectorServerImpl implements VectorServer {
         subJson.put("show", true);
 //        subJson.put("url", "../data/" + lastName);
         String slicePath = entity.getSlicePath();
-        slicePath = slicePath.replace("/root/gis/cesium", "");
+//        slicePath = slicePath.replace("/root/gis/data", "");
+        slicePath = slicePath.replace(BASE_PATH, "");
         subJson.put("url", slicePath);
         layers.add(subJson);
 

+ 8 - 6
src/main/resources/application-uat.properties

@@ -6,14 +6,16 @@ spring.datasource.password=123456
 
 logging.file=/root/java/apache-tomcat_8082_cesium/log/cesium.log
 
-input.file.path.model=/root/gis/cesium/input/model/
-output.file.path.model=/root/gis/cesium/output/model/
+base.path=/root/gis/data
 
-input.file.path.vector=/root/gis/cesium/input/vector/
-output.file.path.vector=/root/gis/cesium/output/vector/
+input.file.path.model=${base.path}/input/model/
+output.file.path.model=${base.path}/output/model/
 
-input.file.path.raster=/root/gis/cesium/input/raster/
-output.file.path.raster=/root/gis/cesium/output/raster/
+input.file.path.vector=${base.path}/input/vector/
+output.file.path.vector=${base.path}/output/vector/
+
+input.file.path.raster=${base.path}/input/raster/
+output.file.path.raster=${base.path}/output/raster/
 
 
 #·¢²¼·þÎñµØÖ·