wuweihao 5 rokov pred
rodič
commit
492dd5f832
29 zmenil súbory, kde vykonal 2420 pridanie a 0 odobranie
  1. 101 0
      pom.xml
  2. 14 0
      src/main/java/com/fd/DataManagerApplication.java
  3. 22 0
      src/main/java/com/fd/Dto/FdageDto.java
  4. 17 0
      src/main/java/com/fd/Dto/PageDto.java
  5. 21 0
      src/main/java/com/fd/Dto/ResourcesJsonDto.java
  6. 44 0
      src/main/java/com/fd/config/Swagger2.java
  7. 26 0
      src/main/java/com/fd/constant/CommandMsg.java
  8. 26 0
      src/main/java/com/fd/constant/ErrorCode.java
  9. 404 0
      src/main/java/com/fd/controller/VtsController.java
  10. 37 0
      src/main/java/com/fd/entity/BaseEntity.java
  11. 40 0
      src/main/java/com/fd/entity/FileEntity.java
  12. 27 0
      src/main/java/com/fd/entity/ScheduleEntity.java
  13. 14 0
      src/main/java/com/fd/repository/FileRepository.java
  14. 21 0
      src/main/java/com/fd/repository/ScheduleRepository.java
  15. 46 0
      src/main/java/com/fd/result/ResponseMessage.java
  16. 183 0
      src/main/java/com/fd/result/ResponseResult.java
  17. 53 0
      src/main/java/com/fd/result/ResultData.java
  18. 16 0
      src/main/java/com/fd/server/CmdServer.java
  19. 19 0
      src/main/java/com/fd/server/FileServer.java
  20. 14 0
      src/main/java/com/fd/server/JsonServer.java
  21. 359 0
      src/main/java/com/fd/server/impl/CmdServerImpl.java
  22. 131 0
      src/main/java/com/fd/server/impl/FileServerImpl.java
  23. 161 0
      src/main/java/com/fd/server/impl/JsonServerImpl.java
  24. 61 0
      src/main/java/com/fd/server/impl/PercentThread.java
  25. 192 0
      src/main/java/com/fd/util/CmdUtils.java
  26. 130 0
      src/main/java/com/fd/util/FileJsonUtils.java
  27. 213 0
      src/main/java/com/fd/util/FileUtils.java
  28. 14 0
      src/main/resources/application-dev.properties
  29. 14 0
      src/main/resources/application-pro.properties

+ 101 - 0
pom.xml

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.1.0.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.fd</groupId>
+    <artifactId>data_manager</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>data_manager</name>
+    <packaging>war</packaging>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
+        <!--<swagger2.version>2.8.0</swagger2.version>-->
+        <swagger2.version>2.9.2</swagger2.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+        </dependency>
+
+        <!--swagger2核心包和swagger-ui界面包-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>${swagger2.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>${swagger2.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+
+        <!-- Alibaba fastjson-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.47</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!--需要这样配置才能打包-->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${maven-surefire-plugin.version}</version>
+                <configuration>
+                    <skipTests>true</skipTests>    <!--默认关掉单元测试 -->
+                </configuration>
+            </plugin>
+
+        </plugins>
+        <!--jar default name -->
+        <finalName>vts</finalName>
+    </build>
+
+</project>

+ 14 - 0
src/main/java/com/fd/DataManagerApplication.java

@@ -0,0 +1,14 @@
+package com.fd;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class DataManagerApplication extends SpringBootServletInitializer {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DataManagerApplication.class, args);
+    }
+
+}

+ 22 - 0
src/main/java/com/fd/Dto/FdageDto.java

@@ -0,0 +1,22 @@
+package com.fd.Dto;
+
+import lombok.Data;
+
+/**
+ * Created by Owen on 2019/10/30 0030 10:36
+ *
+ * ResourcesJson 请求参数
+ */
+@Data
+public class FdageDto {
+
+    private String tiandi;
+
+    private String tiandiMap;
+
+    private String tiandiSurface;
+
+    private String viewTiandiSurface;
+
+
+}

+ 17 - 0
src/main/java/com/fd/Dto/PageDto.java

@@ -0,0 +1,17 @@
+package com.fd.Dto;
+
+import lombok.Data;
+
+/**
+ * Created by Owen on 2019/10/28 0028 12:24
+ */
+@Data
+public class PageDto {
+
+    private Integer pageNum;
+
+    private Integer pageSize;
+
+
+
+}

+ 21 - 0
src/main/java/com/fd/Dto/ResourcesJsonDto.java

@@ -0,0 +1,21 @@
+package com.fd.Dto;
+
+import lombok.Data;
+
+/**
+ * Created by Owen on 2019/10/30 0030 10:36
+ *
+ * ResourcesJson 请求参数
+ */
+@Data
+public class ResourcesJsonDto {
+
+    private String id;
+
+    private String remoteUrl;
+
+    private Integer tiandituId;
+
+    private String tiandituNotice;
+
+}

+ 44 - 0
src/main/java/com/fd/config/Swagger2.java

@@ -0,0 +1,44 @@
+package com.fd.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+/**
+ * Created by owen on 2018/4/1
+ *
+ * 集成Swagger有3步:
+ * 1.pom.xml添加依赖
+ * 2.添加Swagger2.class
+ * 3.Application.class 加上注解@EnableSwagger2 表示开启Swagger
+ * 4.http://localhost:8080/swagger-ui.html#/
+ *
+ * 2.9.2 不需要字启动类配置注解
+ */
+@Configuration
+@EnableSwagger2
+public class Swagger2 {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.fd.controller"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("xx项目 RESTful APIs")
+                .description("xx项目后台api接口文档")
+                .version("1.0")
+                .build();
+    }
+}

+ 26 - 0
src/main/java/com/fd/constant/CommandMsg.java

@@ -0,0 +1,26 @@
+package com.fd.constant;
+
+/**
+ * Created by Owen on 2019/11/1 0001 9:33
+ *
+ */
+public class CommandMsg {
+
+    // 3d model slpk2vts 会生成文件
+    // "slpk2vts --input /var/vts/input/Production_13.slpk --output /var/vts/store/resources/tilesets/test_13 --tilesetId test_13 --referenceFrame melown2015";
+    public static String MODEL_SLPK2VTS = "slpk2vts --input /var/vts/input/@fileName.slpk --output /var/vts/store/resources/tilesets/@fileName --tilesetId @fileName --referenceFrame melown2015;" +
+            "chmod 755 -R /var/vts/store/resources/tilesets/@fileName/";
+
+    // 切换用户
+    public static String MODEL_USER = "sudo -iu vts";
+
+    // "vts /var/vts/store/stage.melown2015 --add --tileset local:/var/vts/store/resources/tilesets/@fileName --top";
+    public static String MODEL_VTS = "vts /var/vts/store/stage.melown2015 --add --tileset local:/var/vts/store/resources/tilesets/@fileName --top;" +
+        "chmod 755 -R /var/vts/store/stage.melown2015/tilesets/@fileName/;" +
+        "chmod 755 /var/vts/store/stage.melown2015/storage.conf";
+
+    // ogr2ogr -f "GeoJson" /var/vts/mapproxy/datasets/road2/road.geojson /var/vts/mapproxy/datasets/road2/Road.shp
+    public static String VECTOR_OGR2OGR = "ogr2ogr -f \"GeoJson\" @fileName.geojson @fileName.shp";
+
+    public static String VECTOR_TIPPECANOE  = "tippecanoe -o @fileName.mbtiles -z 19 -Z 8 -B 8 -ps @fileName.geojson";
+}

+ 26 - 0
src/main/java/com/fd/constant/ErrorCode.java

@@ -0,0 +1,26 @@
+package com.fd.constant;
+
+/**
+ * Created by Owen on 2019/10/25 0025 15:10
+ */
+public class ErrorCode {
+
+    public static final String E50001 = "文件为空";
+
+    public static final String E50002 = "Id不存在";
+
+    public static final String E50005 = "命令执行失败";
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 404 - 0
src/main/java/com/fd/controller/VtsController.java

@@ -0,0 +1,404 @@
+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.entity.FileEntity;
+import com.fd.entity.ScheduleEntity;
+import com.fd.repository.FileRepository;
+import com.fd.repository.ScheduleRepository;
+import com.fd.result.ResponseResult;
+import com.fd.server.CmdServer;
+import com.fd.server.FileServer;
+import com.fd.server.JsonServer;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created by Owen on 2019/10/25 0025 12:22
+ */
+@Log4j2
+@RestController
+@RequestMapping("api/vts")
+public class VtsController {
+
+    @Value("${uploadFile.fdmodelPath}")
+    private String fdmodelPath;
+
+    @Value("${uploadFile.vectorPath}")
+    private String vectorPath;
+
+    @Autowired
+    private FileServer fileServer;
+
+    @Autowired
+    private FileRepository fileRepository;
+
+    @Autowired
+    private JsonServer jsonServer;
+
+    @Autowired
+    private CmdServer cmdServer;
+
+    @Autowired
+    private ScheduleRepository scheduleRepository;
+
+
+    // 多线程共享变量
+    // false 表示完成
+    private static AtomicBoolean existsSlpk2vts = new AtomicBoolean(false);
+
+    private static AtomicBoolean existsVts = new AtomicBoolean(false);
+
+
+    /**
+     * 文件列表
+     * Sort.by("createTime"),createTime属性名
+     */
+    @ApiOperation("upload file list")
+    @PostMapping("list")
+    private ResponseResult list(@RequestBody PageDto param){
+        Page<FileEntity> page = fileRepository.findAll(PageRequest.of(param.getPageNum(), param.getPageSize(), Sort.by("createTime").descending()));
+        return new ResponseResult(200,page);
+    }
+
+    @ApiOperation(" delete fileId")
+    @GetMapping("delete/{fileId}/")
+    private ResponseResult delId(@PathVariable("fileId") Long fileId){
+        fileRepository.deleteById(fileId);
+        return new ResponseResult(200, "success");
+    }
+
+
+    /**
+     * 文件上传 到3d model
+     * 上传大文件
+     * @return
+     */
+    @ApiOperation("upload 3D model file")
+    @PostMapping(value = "upload/fdModel", consumes = { "multipart/form-data" })
+    private ResponseResult upload(@RequestParam("file") MultipartFile file){
+        return fileServer.uploadBigFile(file, fdmodelPath);
+    }
+
+    /**
+     * 文件上传
+     * 需要创建目录
+     * 不支持大文件上传
+     * @return
+     */
+    @ApiOperation("upload Vector file")
+    @PostMapping(value = "upload/vector/{directoryName}/", consumes = { "multipart/form-data" })
+    private ResponseResult uploadVector(@RequestParam("file") MultipartFile file, @PathVariable("directoryName") String directoryName){
+        return fileServer.upload2(file, vectorPath+directoryName+"/");
+    }
+
+
+    /**
+     * 可能运行1s -- 12h
+     * 需要记录进度
+     * 可能需要多前程运行
+     */
+    @ApiOperation("commandSlpk2vts")
+    @GetMapping("/command/model/slpk/{fileId}/")
+    private ResponseResult commandSlpk2vts(@PathVariable("fileId") Long fileId) {
+        log.info("run commandSlpk2vts : {}", fileId);
+//        String fileName = null;
+//        try {
+//            fileName = getFileName(fileId);
+//        } catch (Exception e) {
+//            return new ResponseResult(50002, ErrorCode.E50002);
+//        }
+//
+//
+//        String cmd = CommandMsg.MODEL_SLPK2VTS;
+//        cmd = cmd.replaceAll("@fileName", fileName);
+//        log.info("cmd: {}", cmd);
+
+//        Integer s = cmdServer.exeCmdSlpk2vts(cmd, fileId);
+//        if (s ==1) {
+//            log.info("cmd  run: {}", ErrorCode.E50005);
+//            return new ResponseResult(50005, ErrorCode.E50005);
+//        }
+//        log.info("cmd  run : success");
+
+        Optional<FileEntity> entity = fileRepository.findById(fileId);
+        if (!entity.isPresent()) {
+            return new ResponseResult(50002, ErrorCode.E50002);
+        }
+
+        FileEntity fileEntity = entity.get();
+        String fileName = fileEntity.getFileName();
+        fileName = fileName.substring(0, fileName.lastIndexOf("."));
+
+        String cmd = CommandMsg.MODEL_SLPK2VTS;
+        cmd = cmd.replaceAll("@fileName", fileName);
+        log.info("cmd: {}", cmd);
+        if (existsSlpk2vts.compareAndSet(false, true)) {
+            new Thread(new CmdSlpk2vtsThread(cmd, fileId, fileEntity)).start();
+        }
+
+        return new ResponseResult(200, "success");
+    }
+
+
+    public class CmdSlpk2vtsThread implements Runnable{
+
+        private String cmd;
+
+        private Long fileId;
+
+        private FileEntity fileEntity;
+
+        public CmdSlpk2vtsThread(String cmd, Long fileId, FileEntity fileEntity) {
+            this.cmd = cmd;
+            this.fileId = fileId;
+            this.fileEntity = fileEntity;
+        }
+
+        @Override
+        public void run() {
+            log.info("run CmdSlpk2vtsThread");
+            Integer s = cmdServer.exeCmdSlpk2vts(cmd, fileId);
+            if (s == 1) {
+                log.info("cmd  run: {}", ErrorCode.E50005);
+            }
+            log.info("cmd  run : success");
+            fileEntity.setStatus(1); // 1:表示文件执行完成
+            fileEntity.setUpdateTime(new Date());
+            fileRepository.save(fileEntity);
+            // 表示执行完成,释放锁
+            existsSlpk2vts.set(false);
+
+        }
+    }
+
+
+
+
+
+
+    /**
+     * 可能运行1s -- 12h
+     * 需要记录进度
+     * 可能需要多前程运行
+     */
+    @ApiOperation("commandVts")
+    @GetMapping("/command/model/vts/{fileId}/")
+    private ResponseResult commandVts(@PathVariable("fileId") Long fileId) {
+        log.info("run commandVts");
+//        String fileName = null;
+//        try {
+//            fileName = getFileName(fileId);
+//        } catch (Exception e) {
+//            return new ResponseResult(50002, ErrorCode.E50002);
+//        }
+//
+//        String cmd = CommandMsg.MODEL_VTS;
+//        cmd = cmd.replaceAll("@fileName", fileName);
+//        log.info("cmd: {}", cmd);
+//
+////        Integer s = cmdServer.exeCmdVts(cmd, fileId);
+////        if (s ==1) {
+////            log.info("cmd  run: {}", ErrorCode.E50005);
+////            return new ResponseResult(50005, ErrorCode.E50005);
+////        }
+//        log.info("cmd  run : success");
+
+        Optional<FileEntity> entity = fileRepository.findById(fileId);
+        if (!entity.isPresent()) {
+            return new ResponseResult(50002, ErrorCode.E50002);
+        }
+
+        FileEntity fileEntity = entity.get();
+        String fileName = fileEntity.getFileName();
+        fileName = fileName.substring(0, fileName.lastIndexOf("."));
+
+        String cmd = CommandMsg.MODEL_VTS;
+        cmd = cmd.replaceAll("@fileName", fileName);
+        log.info("cmd: {}", cmd);
+
+        if (existsVts.compareAndSet(false, true)) {
+            new Thread(new CmdVtsThread(cmd, fileId, fileEntity)).start();
+        }
+
+        return new ResponseResult(200, "success");
+    }
+
+
+    public class CmdVtsThread implements Runnable{
+
+        private String cmd;
+
+        private Long fileId;
+
+        private FileEntity fileEntity;
+
+        public CmdVtsThread(String cmd, Long fileId, FileEntity fileEntity) {
+            this.cmd = cmd;
+            this.fileId = fileId;
+            this.fileEntity = fileEntity;
+        }
+
+        @Override
+        public void run() {
+            log.info("run CmdVtsThread");
+            Integer s = cmdServer.exeCmdVts(cmd, fileId);
+            if (s == 1) {
+                log.info("cmd  run: {}", ErrorCode.E50005);
+            }
+            log.info("cmd  run : success");
+            fileEntity.setStatus(2); // 2:表示VTS命令执行完成
+            fileEntity.setUpdateTime(new Date());
+            fileRepository.save(fileEntity);
+            // 表示执行完成,释放锁
+            existsVts.set(false);
+
+        }
+    }
+
+
+    @ApiOperation("commandChangeUser")
+    @GetMapping("/command/model/changeUser")
+    private ResponseResult commandChangeUser() {
+        log.info("run commandChangeUser");
+
+        Integer s = cmdServer.exeCmd(CommandMsg.MODEL_USER);
+        if (s ==1) {
+            log.info("cmd  run: {}", ErrorCode.E50005);
+            return new ResponseResult(50005, ErrorCode.E50005);
+        }
+        log.info("cmd  run : success");
+
+        return new ResponseResult(200, "success");
+    }
+
+
+    @ApiOperation("commandOgr2ogr")
+    @GetMapping("/command/vector/ogr2ogr/{fileId}/")
+    private ResponseResult commandOgr2ogr(@PathVariable("fileId") Long fileId) {
+        log.info("run commandOgr2ogr");
+
+        Optional<FileEntity> entity = fileRepository.findById(fileId);
+        if (!entity.isPresent()) {
+            return new ResponseResult(50002, ErrorCode.E50002);
+        }
+
+        FileEntity fileEntity = entity.get();
+        String fileUrl = fileEntity.getFileUrl();
+        fileUrl = fileUrl.substring(0, fileUrl.lastIndexOf("."));
+
+        String cmd = CommandMsg.VECTOR_OGR2OGR;
+        cmd = cmd.replaceAll("@fileName", fileUrl);
+        log.info("cmd: {}", cmd);
+
+        Integer s = cmdServer.exeCmd(cmd, fileId);
+        if (s == 1) {
+            log.info("cmd  run: {}", ErrorCode.E50005);
+            return new ResponseResult(50005, ErrorCode.E50005);
+        }
+        log.info("cmd  run : success");
+
+        // 文件名
+        String fileName = fileEntity.getFileName();
+
+        // 把生成的文件信息写入数据库
+        FileEntity geojson = new FileEntity();
+        geojson.setFileName(fileName.replace(".shp",".geojson"));
+        geojson.setFileUrl(fileUrl+".geojson");
+        geojson.setRecStatus("A");
+        geojson.setCreateTime(new Date());
+        geojson.setUpdateTime(new Date());
+
+        geojson = fileRepository.save(geojson);
+
+        return new ResponseResult(200, geojson);
+    }
+
+
+    @ApiOperation("commandTippecanoe ")
+    @GetMapping("/command/vector/tippecanoe/{fileId}/")
+    private ResponseResult commandTippecanoe(@PathVariable("fileId") Long fileId) {
+        log.info("run commandTippecanoe");
+
+        Optional<FileEntity> entity = fileRepository.findById(fileId);
+        if (!entity.isPresent()) {
+            return new ResponseResult(50002, ErrorCode.E50002);
+        }
+
+        FileEntity fileEntity = entity.get();
+        String fileUrl = fileEntity.getFileUrl();
+        fileUrl = fileUrl.substring(0, fileUrl.lastIndexOf("."));
+
+
+        String cmd = CommandMsg.VECTOR_TIPPECANOE;
+        cmd = cmd.replaceAll("@fileName", fileUrl);
+        log.info("cmd: {}", cmd);
+        Integer s = cmdServer.exeCmd(cmd, fileId);
+        if (s ==1) {
+            log.info("cmd  run: {}", ErrorCode.E50005);
+            return new ResponseResult(50005, ErrorCode.E50005);
+        }
+        log.info("cmd  run : success");
+
+        return new ResponseResult(200, "success");
+    }
+    /**
+     * ==================================== base map =================================================
+     */
+
+    @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");
+    }
+
+    @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("query progress bar; type:vts / slpk")
+    @PostMapping("progress/{fileId}/{type}/")
+    private ResponseResult queryProgress(@PathVariable("fileId") Long fileId, @PathVariable("type") String type){
+        log.info("run queryProgress");
+        log.info("fileId: {} , type: {}", fileId, type);
+        ScheduleEntity results = scheduleRepository.findByFileIdAndType(fileId, type);
+        return new ResponseResult(200, results);
+    }
+
+
+    private String getFileName(Long fileId) throws Exception {
+        Optional<FileEntity> entity = fileRepository.findById(fileId);
+        if (!entity.isPresent()) {
+            throw new Exception("ErrorCode.E50002");
+        }
+
+        FileEntity fileEntity = entity.get();
+        String fileName = fileEntity.getFileName();
+        fileName = fileName.substring(0, fileName.lastIndexOf("."));
+        return fileName;
+    }
+
+
+}

+ 37 - 0
src/main/java/com/fd/entity/BaseEntity.java

@@ -0,0 +1,37 @@
+package com.fd.entity;
+
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@MappedSuperclass  // 表示是父类,不会映射到数据库
+public class BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = -3208275178665615559L;
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    @Column
+    private Date createTime;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    @Column
+    private Date updateTime;
+
+    @JsonIgnore
+    @Column
+    private String recStatus; // 记录 A:可用 I:禁用(假性删除)
+
+
+
+}

+ 40 - 0
src/main/java/com/fd/entity/FileEntity.java

@@ -0,0 +1,40 @@
+package com.fd.entity;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+
+/**
+ * Created by Owen on 2019/10/28 0028 11:15
+ */
+@Data
+@Entity
+@Table(name = "t_file")
+public class FileEntity extends BaseEntity implements Serializable {
+    private static final long serialVersionUID = 3663614649370191338L;
+
+//    @Id
+//    @GeneratedValue(strategy = GenerationType.IDENTITY)
+//    private Long id;
+
+    @Column
+    private String fileName; // 文件名称
+
+    @Column
+    private String fileUrl; // 文件路径
+
+    @Column
+    private String description; // 描述
+
+    @Column
+    private String version; // 版本
+
+    /**
+     * 状态
+     * model的.slpk文件 0:未完成 1:完成Slpk2vts命令 2:完成vts命令
+     */
+    @Column
+    private Integer status; // 状态,是否可用 1:完成, 0:未完成
+}

+ 27 - 0
src/main/java/com/fd/entity/ScheduleEntity.java

@@ -0,0 +1,27 @@
+package com.fd.entity;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * Created by Owen on 2019/11/4 0004 17:16
+ *
+ * 执行进度表
+ */
+@Data
+@Entity
+@Table(name = "t_schedule")
+public class ScheduleEntity extends BaseEntity implements Serializable {
+    private static final long serialVersionUID = 1484098355154716943L;
+
+    @Column
+    private Long fileId; // 文件id
+
+    @Column
+    private String percent; // 进度
+
+    @Column
+    private String type; // 类型 slpk / vts
+}

+ 14 - 0
src/main/java/com/fd/repository/FileRepository.java

@@ -0,0 +1,14 @@
+package com.fd.repository;
+
+import com.fd.entity.FileEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+ * Created by Owen on 2019/10/28 0028 11:36
+ *
+ * JpaSpecificationExecutor 条件分页查询
+ */
+public interface FileRepository extends JpaRepository<FileEntity, Long>, JpaSpecificationExecutor<FileEntity> {
+
+}

+ 21 - 0
src/main/java/com/fd/repository/ScheduleRepository.java

@@ -0,0 +1,21 @@
+package com.fd.repository;
+
+import com.fd.entity.ScheduleEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+/**
+ * Created by Owen on 2019/10/28 0028 11:36
+ *
+ */
+public interface ScheduleRepository extends JpaRepository<ScheduleEntity, Long> {
+
+    @Query(value = "select r from ScheduleEntity r where r.fileId=?1 order by r.createTime desc ")
+    List<ScheduleEntity> findByFileId(Long id);
+
+    // 返回创建日期
+    @Query(value = "select * from t_schedule r where r.file_id=?1 and r.type =?2 order by r.create_time desc LIMIT 0,1", nativeQuery = true)
+    ScheduleEntity findByFileIdAndType(Long id, String type);
+}

+ 46 - 0
src/main/java/com/fd/result/ResponseMessage.java

@@ -0,0 +1,46 @@
+package com.fd.result;
+
+
+
+public enum ResponseMessage {
+
+	/**
+	 * Success
+	 */
+	OK(200,"Success"),
+	
+	/**
+	 * Success
+	 */
+	NOCHANGE(200,"No changes have been made"),
+	
+	/**
+	 * Bad Request
+	 */
+	BAD_REQUEST(400,"Bad Request"),
+	
+	/**
+	 * Error Request
+	 */
+	NOTNULL_ID(400,"Request ID cannot be empty");
+	
+	
+	
+	private final int status;
+	
+	private final String message;
+	
+	ResponseMessage(int status, String message){
+		this.status = status;
+		this.message = message;
+	}
+	
+	public int getStatus() {
+		return status;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+	
+}

+ 183 - 0
src/main/java/com/fd/result/ResponseResult.java

@@ -0,0 +1,183 @@
+package com.fd.result;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import org.springframework.context.support.DefaultMessageSourceResolvable;
+import org.springframework.validation.BindingResult;
+
+import java.io.Serializable;
+import java.util.*;
+
+public class ResponseResult implements Serializable {
+
+	private static final long serialVersionUID = 2719931935414658118L;
+
+	private final Integer status;
+
+	private final String message;
+
+	@JsonInclude(value = Include.NON_NULL)
+	private final Object data;
+
+	@JsonInclude(value = Include.NON_EMPTY)
+	private final String[] exceptions;
+
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+	private final Date timestamp;
+
+	public ResponseResult(Integer status, String message) {
+
+		super();
+		this.status = status;
+		this.message = message;
+		this.data = null;
+		this.timestamp = addTime();
+		this.exceptions = null;
+
+	}
+
+	public ResponseResult(ResultData<?> result) {
+
+		super();
+
+		this.status = result.getState().getStatus();
+		this.message = result.getState().getMessage();
+		this.data = result.getData();
+		this.timestamp = addTime();
+		this.exceptions = null;
+	}
+
+	public ResponseResult(ResponseMessage rm){
+		super();
+		
+		this.status = rm.getStatus();
+		this.message = rm.getMessage();
+		this.data = null;
+		this.timestamp = addTime();
+		this.exceptions = null;
+	}
+
+	
+	public ResponseResult(Integer status, Object data) {
+
+		super();
+
+		this.status = status;
+		this.message = null;
+
+		this.data = data;
+		this.timestamp = addTime();
+		this.exceptions = null;
+
+	}
+	
+	public ResponseResult(ResponseMessage responseMessage, BindingResult result) {
+
+		super();
+		
+		List<Map<String, String>> errors = new ArrayList<Map<String, String>>();
+		
+		for(int i=0;i<result.getAllErrors().size();i++){
+			Map<String, String> map = new HashMap<String, String>();
+			DefaultMessageSourceResolvable dm = (DefaultMessageSourceResolvable) result.getAllErrors().get(i).getArguments()[0];
+			map.put("field", dm.getDefaultMessage());
+			map.put("message", result.getAllErrors().get(i).getDefaultMessage());
+			errors.add(map);
+		}
+		
+		this.status = responseMessage.getStatus();
+
+		this.message = responseMessage.getMessage();
+
+		this.data = errors;
+		this.timestamp = addTime();
+		this.exceptions = null;
+
+	}
+
+	public ResponseResult(Integer status, String message, String key, Object value) {
+
+		super();
+
+		this.status = status;
+
+		this.message = message;
+
+		Map<String, Object> map = new HashMap<String, Object>();
+
+		if (key == null || ("").equals(key)) {
+			map.put("key", value);
+		} else {
+			map.put(key, value);
+		}
+
+		this.data = map;
+
+		this.timestamp = addTime();
+		this.exceptions = null;
+
+	}
+
+	public ResponseResult(Integer status, Throwable ex) {
+
+		super();
+
+		this.status = status;
+		this.message = ex.getMessage();
+		this.data = null;
+		StackTraceElement[] stackTeanceElement = ex.getStackTrace();
+		this.exceptions = new String[stackTeanceElement.length];
+		for (int i = 0; i < stackTeanceElement.length; i++) {
+			this.exceptions[i] = stackTeanceElement[i].toString();
+		}
+		this.timestamp = addTime();
+	}
+
+	public ResponseResult(Integer status, String message, Throwable ex) {
+
+		super();
+
+		this.status = status;
+
+		this.message = message;
+
+		this.data = null;
+
+		StackTraceElement[] stackTeanceElement = ex.getStackTrace();
+		this.exceptions = new String[stackTeanceElement.length];
+		for (int i = 0; i < stackTeanceElement.length; i++) {
+			this.exceptions[i] = stackTeanceElement[i].toString();
+		}
+
+		this.timestamp = addTime();
+
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public Object getData() {
+		return data;
+	}
+
+	public String[] getExceptions() {
+		return exceptions;
+	}
+
+	public Date getTimestamp() {
+		return timestamp;
+	}
+
+	public Date addTime(){
+		Calendar nowTime= Calendar.getInstance();
+        nowTime.add(Calendar.MINUTE,15);
+        Date time = nowTime.getTime();
+        return time;
+	}
+}

+ 53 - 0
src/main/java/com/fd/result/ResultData.java

@@ -0,0 +1,53 @@
+
+package com.fd.result;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ResultData<T> {
+	private ResponseMessage state;
+	private Object data;
+	private List<T> dataList;
+	
+
+	public ResultData(ResponseMessage state) {
+
+		this.state = state;
+	}
+
+	public ResultData(ResponseMessage state, Object data) {
+		this.data = data;
+		this.state = state;
+	}
+	
+	public ResultData(ResponseMessage state, long data, boolean isId){
+		this.state = state;
+		Map<String, Long> map = new HashMap<String, Long>();
+		map.put("id", data);
+		this.data = map;
+	}
+	
+	public ResultData(ResponseMessage state, long id){
+		this.state = state;
+		Map<String, Long> map = new HashMap<String, Long>();
+		map.put("id", id);
+		this.data = map;
+	}
+	
+	/**
+	 * @return the data
+	 */
+	public Object getData() {
+		return data;
+	}
+	
+	public ResponseMessage getState(){
+		return state;
+	}
+	
+	public List<T> getDataList(){
+		return dataList;
+	}
+
+}

+ 16 - 0
src/main/java/com/fd/server/CmdServer.java

@@ -0,0 +1,16 @@
+package com.fd.server;
+
+
+/**
+ * Created by Owen on 2019/10/30 0030 17:16
+ */
+public interface CmdServer {
+
+    Integer exeCmd(String commandStr, Long id);
+
+    Integer exeCmd(String commandStr);
+
+    Integer exeCmdSlpk2vts(String cmd, Long fileId);
+
+    Integer exeCmdVts(String cmd, Long fileId);
+}

+ 19 - 0
src/main/java/com/fd/server/FileServer.java

@@ -0,0 +1,19 @@
+package com.fd.server;
+
+import com.fd.result.ResponseResult;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * Created by Owen on 2019/10/25 0025 16:05
+ */
+//@Component
+public interface FileServer {
+
+    // 大文件上传
+    ResponseResult uploadBigFile(MultipartFile file, String savePath);
+
+    // 普通文件上传,不支持大文件
+    ResponseResult upload2(MultipartFile file, String savePath);
+
+    boolean deleteById(Long id);
+}

+ 14 - 0
src/main/java/com/fd/server/JsonServer.java

@@ -0,0 +1,14 @@
+package com.fd.server;
+
+import com.fd.Dto.FdageDto;
+import com.fd.Dto.ResourcesJsonDto;
+
+/**
+ * Created by Owen on 2019/10/30 0030 17:16
+ */
+public interface JsonServer {
+
+    void updateResourcesJson(ResourcesJsonDto param);
+
+    void updateFdage(FdageDto param);
+}

+ 359 - 0
src/main/java/com/fd/server/impl/CmdServerImpl.java

@@ -0,0 +1,359 @@
+package com.fd.server.impl;
+
+import com.fd.entity.ScheduleEntity;
+import com.fd.repository.FileRepository;
+import com.fd.repository.ScheduleRepository;
+import com.fd.server.CmdServer;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.transaction.Transactional;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+
+/**
+ * Created by Owen on 2019/10/25 0025 16:06
+ */
+@Log4j2
+@Service
+@Transactional
+public class CmdServerImpl implements CmdServer {
+
+    @Autowired
+    private FileRepository fileRepository;
+
+    @Autowired
+    private ScheduleRepository scheduleRepository;
+
+    @Override
+    public Integer exeCmd(String commandStr, Long id) {
+        String result = null;
+        Integer isCmd = null; // 命令运行结果 1:失败, 0:成功
+        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 = "";
+
+
+
+            ArrayList<Object> arrayList = new ArrayList<>();
+
+            double percent;
+            int count = 1;
+            ScheduleEntity schedule = new ScheduleEntity();
+            while ((errorLine = errorBuf.readLine()) != null) {
+                errorStr.append(errorLine).append("\n");
+
+                if (errorLine.contains("Generated tile #")) {
+                    // 截取百分比
+                    str = errorLine.substring(errorLine.indexOf("% done)") - 7, errorLine.indexOf("% done)"));
+                    percent = Double.parseDouble(str);
+                    arrayList.add(percent);
+                    if (1 == count) {
+                        schedule.setFileId(id);
+                        schedule.setPercent(str);
+                        schedule.setCreateTime(new Date());
+                        schedule.setUpdateTime(new Date());
+//                        schedule.setRecStatus("A");
+                        count = count + 5;
+                        schedule = scheduleRepository.save(schedule);
+                        log.info("count 1: {}", count);
+                    }
+                    if (percent > count && percent == 100) {
+                        schedule.setPercent(str);
+                        schedule.setUpdateTime(new Date());
+                        schedule = scheduleRepository.save(schedule);
+                        count = count + 5;
+                        log.info("count 5: {}", count);
+                    }
+                }
+
+            }
+            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();
+            log.info("result: {}", result);
+
+            // 结束命令行
+            isCmd = ps.waitFor();
+            if (isCmd == 0) {
+                log.info("wsitFore cmd success : {}", isCmd);
+            } else {
+                log.info("wsitFore cmd run error : {}", isCmd);
+            }
+
+            // 关闭流
+            br.close();
+            errorBuf.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return isCmd;
+    }
+
+    @Override
+    public Integer exeCmd(String commandStr) {
+        String result = null;
+        Integer isCmd = null; // 命令运行结果 1:失败, 0:成功
+        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;
+
+            ArrayList<Object> arrayList = new ArrayList<>();
+
+            while ((errorLine = errorBuf.readLine()) != null) {
+                errorStr.append(errorLine).append("\n");
+            }
+            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());
+                //执行结果加上回车
+                sb.append(line).append("\n");
+                log.info("line: {}", line);
+            }
+            result = sb.toString();
+            log.info("result: {}", result);
+
+            // 结束命令行
+            isCmd = ps.waitFor();
+            if (isCmd == 0) {
+                log.info("wsitFore cmd success : {}", isCmd);
+            } else {
+                log.info("wsitFore cmd run error : {}", isCmd);
+            }
+
+            // 关闭流
+            br.close();
+            errorBuf.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return isCmd;
+    }
+
+    @Override
+    public Integer exeCmdSlpk2vts(String commandStr, Long id) {
+        String result = null;
+        Integer isCmd = null; // 命令运行结果 1:失败, 0:成功
+        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 = "";
+
+
+
+            ArrayList<Object> arrayList = new ArrayList<>();
+
+            double percent;
+            int count = 1;
+            ScheduleEntity schedule = new ScheduleEntity();
+            while ((errorLine = errorBuf.readLine()) != null) {
+                errorStr.append(errorLine).append("\n");
+                // All done. {slpk2vts.cpp:
+                if (errorLine.contains("Generated tile #")) {
+                    // 截取百分比
+                    str = errorLine.substring(errorLine.indexOf("% done)") - 7, errorLine.indexOf("% done)"));
+                    percent = Double.parseDouble(str);
+                    arrayList.add(percent);
+                    if (1 == count) {
+                        schedule.setFileId(id);
+                        schedule.setPercent(str);
+                        schedule.setCreateTime(new Date());
+                        schedule.setUpdateTime(new Date());
+                        schedule.setType("slpk");
+//                        schedule.setRecStatus("A");
+                        count = count + 5;
+                        schedule = scheduleRepository.save(schedule);
+                        log.info("count 1: {}", count);
+                    }
+                    if (percent > count && percent == 100) {
+                        schedule.setPercent(str);
+                        schedule.setUpdateTime(new Date());
+                        schedule = scheduleRepository.save(schedule);
+                        count = count + 5;
+                        log.info("count 5: {}", count);
+                    }
+                }
+
+            }
+            log.info("error result: {}", errorStr.toString());
+            log.info("exeCmdSlpk2vts 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();
+            log.info("result: {}", result);
+
+            // 结束命令行
+            isCmd = ps.waitFor();
+            if (isCmd == 0) {
+                log.info("wsitFore cmd success : {}", isCmd);
+            } else {
+                log.info("wsitFore cmd run error : {}", isCmd);
+            }
+
+            // 关闭流
+            br.close();
+            errorBuf.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return isCmd;
+    }
+
+    @Override
+    public Integer exeCmdVts(String commandStr, Long fileId) {
+        String result = null;
+        Integer isCmd = null; // 命令运行结果 1:失败, 0:成功
+        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 = "";
+
+
+
+            ArrayList<Object> arrayList = new ArrayList<>();
+
+            double percent;
+            int count = 1;
+            ScheduleEntity schedule = new ScheduleEntity();
+            while ((errorLine = errorBuf.readLine()) != null) {
+                errorStr.append(errorLine).append("\n");
+                System.out.println("errorStr: "+ errorLine);
+                if (errorLine.contains("(glue) progress:")) {
+                    // 截取百分比
+                    str = errorLine.substring(errorLine.indexOf("%.") - 7, errorLine.indexOf("%."));
+                    percent = Double.parseDouble(str);
+                    arrayList.add(percent);
+                    if (1 == count) {
+                        schedule.setFileId(fileId);
+                        schedule.setPercent(str);
+                        schedule.setCreateTime(new Date());
+                        schedule.setUpdateTime(new Date());
+                        schedule.setType("vts");
+                        count = count + 5;
+                        schedule = scheduleRepository.save(schedule);
+                        log.info("count 1: {}", count);
+                    }
+                    if (percent > count && percent == 100) {
+                        schedule.setPercent(str);
+                        schedule.setUpdateTime(new Date());
+                        schedule = scheduleRepository.save(schedule);
+                        count = count + 5;
+                        log.info("count 5: {}", count);
+                    }
+                }
+                if (errorLine.contains("All done. {vts.cpp:add():")){
+                    percent = 100;
+                    str = "100.00";
+                    schedule.setPercent(str);
+                    schedule.setUpdateTime(new Date());
+                    schedule = scheduleRepository.save(schedule);
+                    arrayList.add(percent);
+                }
+
+            }
+            log.info("error result: {}", errorStr.toString());
+            log.info("exeCmdVts 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();
+            log.info("result: {}", result);
+
+            // 结束命令行
+            isCmd = ps.waitFor();
+            if (isCmd == 0) {
+                log.info("wsitFore cmd success : {}", isCmd);
+            } else {
+                log.info("wsitFore cmd run error : {}", isCmd);
+            }
+
+            // 关闭流
+            br.close();
+            errorBuf.close();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return isCmd;
+    }
+
+    public static void main(String[] args) {
+        String e = "(glue) progress:  99.83 %. {progress.cpp:report():48}";
+        e = e.substring(e.lastIndexOf("%.")-7, e.lastIndexOf("%."));
+        System.out.println(e);
+
+    }
+
+}

+ 131 - 0
src/main/java/com/fd/server/impl/FileServerImpl.java

@@ -0,0 +1,131 @@
+package com.fd.server.impl;
+
+import com.fd.constant.ErrorCode;
+import com.fd.entity.FileEntity;
+import com.fd.repository.FileRepository;
+import com.fd.result.ResponseResult;
+import com.fd.server.FileServer;
+import com.fd.util.FileUtils;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.transaction.Transactional;
+import java.io.*;
+import java.util.Base64;
+import java.util.Date;
+import java.util.Optional;
+
+/**
+ * Created by Owen on 2019/10/25 0025 16:06
+ */
+@Log4j2
+@Service
+@Transactional
+public class FileServerImpl implements FileServer {
+
+    @Autowired
+    private FileRepository fileRepository;
+
+    public ResponseResult uploadBigFile(MultipartFile file, String savePath) {
+        if (file.isEmpty() || file.getSize() <= 0) {
+            log.info("文件为空");
+            return new ResponseResult (50001, ErrorCode.E50001);
+        }
+
+        // 文件名全名
+        String fullFileName = file.getOriginalFilename();
+
+        // 创建目录路径
+        FileUtils.createDir(savePath);
+
+        // 拼接唯一文件名
+        String fileName = FileUtils.dateStr() + fullFileName;
+
+        // 文件保存路径
+        String filePath = savePath + fileName;
+
+        // 写文件到本地
+        try {
+            FileUtils.bigFileWrite(file.getInputStream(), filePath);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        log.info("filePath: {}", filePath);
+
+        // 保存信息到db
+        FileEntity entity = new FileEntity();
+        entity.setFileName(fileName);
+        entity.setFileUrl(filePath);
+        entity.setRecStatus("A");
+        entity.setCreateTime(new Date());
+        entity.setUpdateTime(new Date());
+        fileRepository.save(entity);
+
+        return new ResponseResult (200,"success");
+    }
+
+
+    /**
+     * 特别需求,只能用文件名,不能用时间戳
+     */
+    public ResponseResult upload2(MultipartFile file, String savePath) {
+        if (file.isEmpty() || file.getSize() <= 0) {
+            log.info("文件为空");
+            return new ResponseResult (50001, ErrorCode.E50001);
+        }
+
+        // 文件名全名
+        String fullFileName = file.getOriginalFilename();
+
+        // 创建目录路径
+        FileUtils.createDir(savePath);
+
+        // 拼接唯一文件名
+//        String fileName = FileUtils.dateStr() + fullFileName;
+
+        // 文件保存路径
+        String filePath = savePath + fullFileName;
+
+        // 写文件到本地
+        try {
+//            FileUtils.bigFileWrite(file.getInputStream(), filePath);
+            byte[] bytes = file.getBytes();
+            String content = Base64.getEncoder().encodeToString(bytes);
+//            FileUtils.fileWriter(content, filePath);
+            FileUtils.base64ToFileWriter(content, filePath);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        log.info("filePath: {}", filePath);
+
+        // 保存信息到db
+        FileEntity entity = new FileEntity();
+        entity.setFileName(fullFileName);
+        entity.setFileUrl(filePath);
+        entity.setRecStatus("A");
+        entity.setCreateTime(new Date());
+        entity.setUpdateTime(new Date());
+        fileRepository.save(entity);
+
+        return new ResponseResult (200,"success");
+    }
+
+    @Override
+    public boolean deleteById(Long id)  {
+
+        // 删除服务器文件
+//        Optional<FileEntity> e = fileRepository.findById(id);
+//        if (!e.isPresent()) {
+//            throw new Exception(ErrorCode.E50002);
+//        }
+//        FileEntity fileEntity = e.get();
+//        fileEntity.getFileUrl();
+//        FileUtils.
+
+        // 删除数据库记录
+
+        return false;
+    }
+}

+ 161 - 0
src/main/java/com/fd/server/impl/JsonServerImpl.java

@@ -0,0 +1,161 @@
+package com.fd.server.impl;
+
+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 com.fd.server.JsonServer;
+import com.fd.util.FileUtils;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+/**
+ * Created by Owen on 2019/10/30 0030 17:16
+ */
+@Service
+@Log4j2
+public class JsonServerImpl implements JsonServer {
+
+
+//    private static String RESOURCESJSON_PATH = "json/resources.json";
+//
+//    private static String FDAGE_PATH = "json/4dage";
+
+//    private static String RESOURCESJSON_PATH = "/etc/vts/mapproxy/tianditu.d/resources.json";
+//
+//    private static String FDAGE_PATH = "/var/vts/store/map-config/4dage";
+
+    @Value("${updateFile.resourcesJsonPath}")
+    private String RESOURCESJSON_PATH;
+
+    @Value("${updateFile.fdagePath}")
+    private String FDAGE_PATH;
+
+
+
+    @Override
+    public void updateResourcesJson(ResourcesJsonDto param) {
+        // 读取文件,获取结果集
+//        String s = readJson(RESOURCESJSON_PATH);
+        String s = readJsonLinux(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() +"'}";
+
+        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));
+
+        log.info("result: {}", originalArray.toJSONString());
+
+        try {
+//            FileUtils.fileWriter(JSON.toJSONString(originalArray),"/var/vts/store/map-config/resources_test.json");
+            FileUtils.fileWriter(JSON.toJSONString(originalArray), RESOURCESJSON_PATH);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    @Override
+    public void updateFdage(FdageDto param) {
+        // 读取文件,获取结果集
+//        String s = readJson(FDAGE_PATH);
+        String s = readJsonLinux(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));
+
+        log.info("result: {}", original.toJSONString());
+
+        System.out.println("========== :  " +original.toJSONString());
+
+        try {
+//            FileUtils.fileWriter(JSON.toJSONString(original),"/var/vts/store/map-config/4dage_test");
+            FileUtils.fileWriter(JSON.toJSONString(original), FDAGE_PATH);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+
+    /**
+     * 读取json 文件, windows版
+     */
+    public static String readJson(String path){
+        String resource = FileUtils.getResource();
+        String param = FileUtils.readFile( resource+path);
+        return param;
+
+    }
+
+
+    /**
+     * 读取json 文件, Linux版
+     */
+    public static String readJsonLinux(String path){
+        String param = FileUtils.readFile(path);
+        return param;
+
+    }
+
+
+
+
+
+
+
+
+}

+ 61 - 0
src/main/java/com/fd/server/impl/PercentThread.java

@@ -0,0 +1,61 @@
+package com.fd.server.impl;
+
+import com.fd.entity.ScheduleEntity;
+import com.fd.repository.FileRepository;
+import com.fd.repository.ScheduleRepository;
+
+import java.util.Date;
+
+/**
+ * Created by Owen on 2019/11/5 0005 9:32
+ *
+ * 记录进度多线程
+ */
+public class PercentThread implements Runnable {
+
+    private Long id;
+
+    private boolean isRunning;
+
+    private String percent;
+
+    private FileRepository fileRepository;
+
+    private ScheduleRepository scheduleRepository;
+
+    public PercentThread(Long id, boolean isRunning, String percent, FileRepository fileRepository, ScheduleRepository scheduleRepository){
+        this.id = id;
+        this.isRunning = isRunning;
+        this.percent = percent;
+        this.fileRepository = fileRepository;
+        this.scheduleRepository = scheduleRepository;
+    }
+
+    @Override
+    public void run() {
+        int count = 1;
+        ScheduleEntity schedule = new ScheduleEntity();
+        while (isRunning) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+
+            if (count == 1) {
+                schedule.setFileId(id);
+                schedule.setPercent(percent);
+                schedule.setCreateTime(new Date());
+                schedule.setUpdateTime(new Date());
+                schedule.setRecStatus("A");
+            } else {
+                schedule.setPercent(percent);
+                schedule.setUpdateTime(new Date());
+            }
+            schedule = scheduleRepository.save(schedule);
+            count++;
+
+        }
+
+    }
+}

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

@@ -0,0 +1,192 @@
+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;
+//
+//    }
+}

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

@@ -0,0 +1,130 @@
+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) {
+
+
+
+
+    }
+
+}

+ 213 - 0
src/main/java/com/fd/util/FileUtils.java

@@ -0,0 +1,213 @@
+package com.fd.util;
+
+import lombok.extern.log4j.Log4j2;
+import org.springframework.util.ResourceUtils;
+
+import java.io.*;
+import java.net.URLDecoder;
+import java.text.SimpleDateFormat;
+import java.util.Base64;
+import java.util.Date;
+
+/**
+ * Created by Owen on 2019/10/25 0025 14:20
+ */
+@Log4j2
+public class FileUtils {
+
+    /**
+     * 获取类路径
+     */
+    public static String getResource(){
+        String path = "";
+        try {
+            path = ResourceUtils.getURL("classpath:").getPath();
+            path = URLDecoder.decode(path,"utf-8");
+            log.info("classpath path :"+path);
+        } catch (Exception e) {
+            log.error(" classpath Error" + e.getMessage(), e);
+        }
+        return path;
+    }
+
+
+    /**
+     * 创建文件夹
+     * destDirName:文件夹名称
+     */
+    public static void createDir(String destDirName) {
+        File dir = new File(destDirName);
+        // 创建目录
+        if (!dir.exists()) {
+            dir.mkdir();
+        }
+    }
+
+    /**
+     * 大文件读写
+     *
+     * 1.先将文件中的内容读入到缓冲输入流中
+     * 2.将输入流中的数据通过缓冲输出流写入到目标文件中
+     * 3.关闭输入流和输出流
+     *
+     * in: 输入流
+     * path: 保持位置
+     */
+
+    public static void bigFileWrite(InputStream in, String path) throws IOException {
+        long start = System.currentTimeMillis();
+        // 输入缓冲流
+        BufferedInputStream inputBuff = new BufferedInputStream(in);
+
+        // 输出缓冲流
+        BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(path));
+        int len = 0;
+        byte[] buffer = new byte[1024];
+        while ((len = inputBuff.read(buffer)) != -1) {
+            stream.write(buffer, 0, len);
+        }
+        stream.flush();
+        stream.close();
+        inputBuff.close();
+
+        long end = System.currentTimeMillis();
+
+        System.out.println("total: "+ (end-start)/1000);
+    }
+
+
+    /**
+     *
+     * @param content base64内容
+     * @param path 输出文件路径,需要后缀名
+     * @return
+     */
+    public static  boolean base64ToFileWriter(String content, String path) {
+        if (content == null) {
+            return false;
+        }
+        try {
+            byte[] b = Base64.getDecoder().decode(content);
+            // processing data
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {
+                    b[i] += 256;
+                }
+            }
+            OutputStream out = new FileOutputStream(path);
+            out.write(b);
+            out.flush();
+            out.close();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+
+    /**
+     * 读取文件方法
+     * @param Path 文件路径
+     * @return 返回内容
+     */
+    public static String readFile(String Path){
+        BufferedReader reader = null;
+        String laststr = "";
+        try{
+            FileInputStream fileInputStream = new FileInputStream(Path);
+            InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
+            reader = new BufferedReader(inputStreamReader);
+            String tempString = null;
+            while((tempString = reader.readLine()) != null){
+                laststr += tempString;
+            }
+            reader.close();
+        }catch(IOException e){
+            e.printStackTrace();
+        }finally{
+            if(reader != null){
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return laststr;
+    }
+
+
+    /**
+     * 生成文件
+     * @param content 内容
+     * @param path 生成路径
+     * @throws IOException
+     */
+    public static void fileWriter(String content, String path) throws IOException {
+        FileWriter writer = new FileWriter(path);
+        writer.write(content);
+        writer.flush();
+        writer.close();
+    }
+
+    // 获取时间戳
+    public static String dateStr() {
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
+        String format = df.format(new Date());
+        long timeMillis = System.currentTimeMillis();
+        return format + "_" + timeMillis + "_";
+    }
+
+    /**
+     * 删除指定文件夹下所有文件
+     * @param path 文件夹完整绝对路径
+     * @return
+     */
+    public static boolean delAllFile(String path) {
+        boolean flag = false;
+        File file = new File(path);
+        if (!file.exists()) {
+            return flag;
+        }
+        if (!file.isDirectory()) {
+            return flag;
+        }
+        String[] tempList = file.list();
+        File temp = null;
+        for (int i = 0; i < tempList.length; i++) {
+            if (path.endsWith(File.separator)) {
+                temp = new File(path + tempList[i]);
+            } else {
+                temp = new File(path + File.separator + tempList[i]);
+            }
+            if (temp.isFile()) {
+                temp.delete();
+            }
+            if (temp.isDirectory()) {
+//                delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
+//                delFolder(path + "/" + tempList[i]);//再删除空文件夹
+                delAllFile(path + tempList[i]);//先删除文件夹里面的文件
+                delFolder(path + tempList[i]);//再删除空文件夹
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+
+    /**
+     * 删除文件夹
+     * @param folderPath 文件夹完整绝对路径
+     */
+    public static void delFolder(String folderPath) {
+        try {
+            delAllFile(folderPath); //删除完里面所有内容
+            String filePath = folderPath;
+            filePath = filePath.toString();
+            java.io.File myFilePath = new java.io.File(filePath);
+            myFilePath.delete(); //删除空文件夹
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 14 - 0
src/main/resources/application-dev.properties

@@ -0,0 +1,14 @@
+#saveFilePath=F:\\test\\vts\\
+
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.url=jdbc:mysql://localhost:3306/data_manager?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.username=root
+spring.datasource.password=123456
+
+logging.file=log/vts.log
+
+uploadFile.fdmodelPath=F:\\test\\
+uploadFile.vectorPath=F:\\test\\
+
+updateFile.fdagePath=/var/vts/store/map-config/4dage
+updateFile.resourcesJsonPath=/etc/vts/mapproxy/tianditu.d/resources.json

+ 14 - 0
src/main/resources/application-pro.properties

@@ -0,0 +1,14 @@
+#saveFilePath=F:\\test\\vts\\
+
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.url=jdbc:mysql://192.168.0.248:3306/data_manager?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.username=root
+spring.datasource.password=4dage
+
+logging.file=log/vts.log
+
+uploadFile.fdmodelPath=/var/vts/input/
+uploadFile.vectorPath=/var/vts/mapproxy/datasets/
+
+updateFile.fdagePath=/var/vts/store/map-config/4dage
+updateFile.resourcesJsonPath=/etc/vts/mapproxy/tianditu.d/resources.json