wuweihao 5 vuotta sitten
vanhempi
commit
87ea5f59e2
42 muutettua tiedostoa jossa 3137 lisäystä ja 2 poistoa
  1. 101 0
      pom.xml
  2. 14 0
      src/main/java/com/fd/DataManagerApplication.java
  3. 17 0
      src/main/java/com/fd/Dto/BaseMapFdageDto.java
  4. 22 0
      src/main/java/com/fd/Dto/FdageDto.java
  5. 16 0
      src/main/java/com/fd/Dto/ModelFdageDto.java
  6. 17 0
      src/main/java/com/fd/Dto/PageDto.java
  7. 21 0
      src/main/java/com/fd/Dto/ResourcesJsonDto.java
  8. 29 0
      src/main/java/com/fd/Dto/VectorResourcesJsonDto.java
  9. 41 0
      src/main/java/com/fd/config/MyInterceptor.java
  10. 44 0
      src/main/java/com/fd/config/Swagger2.java
  11. 46 0
      src/main/java/com/fd/config/WebMvcConfg.java
  12. 29 0
      src/main/java/com/fd/constant/CommandMsg.java
  13. 30 0
      src/main/java/com/fd/constant/MsgCode.java
  14. 22 0
      src/main/java/com/fd/constant/TypeCode.java
  15. 43 0
      src/main/java/com/fd/controller/VtsBaseMapController.java
  16. 319 0
      src/main/java/com/fd/controller/VtsModelController.java
  17. 200 0
      src/main/java/com/fd/controller/VtsVectorController.java
  18. 40 0
      src/main/java/com/fd/entity/BaseEntity.java
  19. 47 0
      src/main/java/com/fd/entity/FileEntity.java
  20. 39 0
      src/main/java/com/fd/entity/GenerateFileEntity.java
  21. 27 0
      src/main/java/com/fd/entity/ScheduleEntity.java
  22. 22 0
      src/main/java/com/fd/repository/FileRepository.java
  23. 14 0
      src/main/java/com/fd/repository/GenerateFileRepository.java
  24. 21 0
      src/main/java/com/fd/repository/ScheduleRepository.java
  25. 16 0
      src/main/java/com/fd/server/CmdServer.java
  26. 21 0
      src/main/java/com/fd/server/FileServer.java
  27. 23 0
      src/main/java/com/fd/server/JsonServer.java
  28. 355 0
      src/main/java/com/fd/server/impl/CmdServerImpl.java
  29. 152 0
      src/main/java/com/fd/server/impl/FileServerImpl.java
  30. 322 0
      src/main/java/com/fd/server/impl/JsonServerImpl.java
  31. 55 0
      src/main/java/com/fd/test/Md5.java
  32. 93 0
      src/main/java/com/fd/test/cmd.java
  33. 213 0
      src/main/java/com/fd/util/FileUtils.java
  34. 140 0
      src/main/java/com/fd/util/ResponseResult.java
  35. 14 0
      src/main/resources/application-dev.properties
  36. 14 0
      src/main/resources/application-pro.properties
  37. 10 0
      src/main/resources/application.properties
  38. 40 0
      src/main/resources/json/4dage
  39. 7 0
      src/main/resources/json/data.json
  40. 441 0
      src/main/resources/json/resources.json
  41. 0 1
      新建文本文档 (2).txt
  42. 0 1
      新建文本文档.txt

+ 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>gis_vts</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>gis_vts</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);
+    }
+
+}

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

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

+ 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;
+
+
+}

+ 16 - 0
src/main/java/com/fd/Dto/ModelFdageDto.java

@@ -0,0 +1,16 @@
+package com.fd.Dto;
+
+import lombok.Data;
+
+/**
+ * Created by Owen on 2019/10/30 0030 10:36
+ *
+ */
+@Data
+public class ModelFdageDto {
+
+    private String tilesets;
+
+    private String viewSurfaces;
+
+}

+ 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;
+
+}

+ 29 - 0
src/main/java/com/fd/Dto/VectorResourcesJsonDto.java

@@ -0,0 +1,29 @@
+package com.fd.Dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Created by Owen on 2019/10/30 0030 10:36
+ *
+ * vector data ResourcesJson 请求参数
+ */
+@Data
+public class VectorResourcesJsonDto {
+
+    private String id;
+
+    private String definitionDataset;
+
+    private String definitionStyleUrl;
+
+    private Integer registryCreditsFageId;
+
+    private String registryCreditsFageNotice;
+
+    private List<List<Integer>> referenceFramesMelown2015TileRange;
+
+    private List<Integer> referenceFramesMelown2015LodRange;
+
+}

+ 41 - 0
src/main/java/com/fd/config/MyInterceptor.java

@@ -0,0 +1,41 @@
+package com.fd.config;
+
+import lombok.extern.log4j.Log4j2;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Created by Owen on 2019/10/25 0025 16:49
+ *
+ *  拦截验证
+ */
+@Log4j2
+public class MyInterceptor implements HandlerInterceptor {
+
+    //重写preHandle方法
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        log.info("run preHandle");
+
+        log.info("request url: {}", request.getRequestURL());
+
+
+        String originHeader = request.getHeader("origin");
+//        response.setHeader("Access-Control-Allow-Origin", originHeader);
+        String requestHeaders = request.getHeader("Access-Control-Request-Headers");
+        if (requestHeaders==null) {
+            requestHeaders = "";
+        }
+        response.setHeader("Access-Control-Allow-Credentials", "true");
+        response.setHeader("Access-Control-Allow-Methods", "HEAD,PUT,DELETE,POST,GET");
+        response.setHeader("Access-Control-Allow-Headers", "Accept, Origin, XRequestedWith, Content-Type, LastModified," + requestHeaders);
+        response.setHeader("Access-Control-Allow-Origin", "*");
+
+
+        return true;
+    }
+
+
+}

+ 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();
+    }
+}

+ 46 - 0
src/main/java/com/fd/config/WebMvcConfg.java

@@ -0,0 +1,46 @@
+package com.fd.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * Created by Owen on 2019/10/25 0025 16:29
+ */
+@Configuration
+public class WebMvcConfg implements WebMvcConfigurer {
+
+
+    @Bean
+    public MyInterceptor myInterceptor(){
+        return new MyInterceptor();
+    }
+
+    /**
+   * 重写addInterceptors方法
+   * addPathPatterns:需要拦截的访问路径
+   * excludePathPatterns:不需要拦截的路径,
+   * String数组类型可以写多个用","分割
+   */
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(myInterceptor())
+//                .addPathPatterns("/**")
+                .addPathPatterns("/api/vts/**")
+                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html");
+    }
+
+    /**
+     * 配置全局跨域
+     */
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**")
+                .allowedOrigins("*")
+                .allowCredentials(true)
+                .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS")
+                .maxAge(3600);
+    }
+}

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

@@ -0,0 +1,29 @@
+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_VTS = "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";
+
+    // vts /var/vts/store/stage.melown2015 --remove Production_13
+    public static String MODEL_VTS_REMOVE = "vts /var/vts/store/stage.melown2015 --remove @fileName";
+
+    // 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";
+}

+ 30 - 0
src/main/java/com/fd/constant/MsgCode.java

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

+ 22 - 0
src/main/java/com/fd/constant/TypeCode.java

@@ -0,0 +1,22 @@
+package com.fd.constant;
+
+/**
+ * Created by Owen on 2019/11/7 0007 11:10
+ *
+ * 文件类型
+ */
+public class TypeCode {
+
+    public static final String FILE_TYPE_MODEL = "model";
+
+    public static final String FILE_TYPE_MODEL_TILE = "tile"; // 瓦片
+
+    public static final String SCHEDULE_TYPE_MODEL_VTS = "vts"; // 进度表类型
+
+    public static final String SCHEDULE_TYPE_MODEL_SLPK = "slpk"; // 进度表类型
+
+    public static final String FILE_TYPE_VECTOR = "vector";
+
+    public static final String FILE_TYPE_VECTOR_GEOJSON = "geojson";
+
+}

+ 43 - 0
src/main/java/com/fd/controller/VtsBaseMapController.java

@@ -0,0 +1,43 @@
+package com.fd.controller;
+
+import com.fd.Dto.BaseMapFdageDto;
+import com.fd.Dto.FdageDto;
+import com.fd.Dto.ResourcesJsonDto;
+import com.fd.server.JsonServer;
+import com.fd.util.ResponseResult;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * Created by Owen on 2019/11/12 0007 10:19
+ */
+@Log4j2
+@RestController
+@RequestMapping("api/vts/basemap")
+public class VtsBaseMapController {
+
+    @Autowired
+    private JsonServer jsonServer;
+
+
+    @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 BaseMapFdageDto param){
+        log.info("run updateFdage");
+
+        return jsonServer.updateBaseMapFdage(param);
+    }
+
+}

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

@@ -0,0 +1,319 @@
+package com.fd.controller;
+
+import com.fd.Dto.ModelFdageDto;
+import com.fd.Dto.PageDto;
+import com.fd.constant.CommandMsg;
+import com.fd.constant.MsgCode;
+import com.fd.constant.TypeCode;
+import com.fd.entity.FileEntity;
+import com.fd.entity.ScheduleEntity;
+import com.fd.repository.FileRepository;
+//import com.fd.repository.GenerateFileRepository;
+import com.fd.repository.ScheduleRepository;
+import com.fd.util.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.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created by Owen on 2019/11/7 0007 10:19
+ * 3D Model
+ *
+ * 时间很长的命令才需要多前程运行,其他命令不使用
+ */
+@Log4j2
+@RestController
+@RequestMapping("api/vts/model")
+public class VtsModelController {
+
+    @Value("${uploadFile.fdmodelPath}")
+    private String fdmodelPath;
+
+    @Autowired
+    private FileServer fileServer;
+
+    @Autowired
+    private FileRepository fileRepository;
+
+    @Autowired
+    private JsonServer jsonServer;
+
+    @Autowired
+    private CmdServer cmdServer;
+
+    @Autowired
+    private ScheduleRepository scheduleRepository;
+
+//    @Autowired
+//    private GenerateFileRepository generateFileRepository;
+
+
+    // 多线程共享变量
+    // false 表示完成
+    private static AtomicBoolean existsSlpk2vts = new AtomicBoolean(false);
+
+    private static AtomicBoolean existsVts = new AtomicBoolean(false);
+
+    @ApiOperation("upload model file list")
+    @PostMapping(value = "list")
+    private ResponseResult list(@RequestBody PageDto param){
+        log.info("run list");
+        Page<FileEntity> page = fileRepository.findByType(
+                TypeCode.FILE_TYPE_MODEL,
+                TypeCode.FILE_TYPE_MODEL_TILE,
+                PageRequest.of(param.getPageNum(), param.getPageSize(), Sort.by("createTime").descending()));
+        return new ResponseResult(200, page);
+    }
+
+
+    /**
+     * 文件上传 到3d model
+     * 上传大文件 xxx.slpk
+     * @return
+     */
+    @ApiOperation("upload 3D model file")
+    @PostMapping(value = "upload", consumes = { "multipart/form-data" })
+    private ResponseResult upload(@RequestParam("file") MultipartFile file){
+        log.info("run upload");
+        return fileServer.uploadBigFile(file, fdmodelPath);
+    }
+
+
+    /**
+     * 可能运行1s -- 12h
+     * 需要记录进度
+     * 需要多前程运行
+     *
+     */
+    @ApiOperation("commandSlpk2vts")
+    @GetMapping("/command/slpk2vts/{fileId}/")
+    private ResponseResult commandSlpk2vts(@PathVariable("fileId") Long fileId) {
+        log.info("run commandSlpk2vts : {}", fileId);
+
+        Optional<FileEntity> entity = fileRepository.findById(fileId);
+        if (!entity.isPresent()) {
+            return new ResponseResult(50002, MsgCode.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: {}", MsgCode.E50005);
+            }
+            log.info("cmd  run : success");
+            fileEntity.setStatus(1); // 1:表示文件执行完成
+            fileEntity.setUpdateTime(new Date());
+            fileRepository.save(fileEntity);
+
+            // 保存新产生的文件到数据库
+            String fileName = fileEntity.getFileName();
+            fileName = fileName.substring(0, fileName.lastIndexOf("."));
+            String fileUrl = cmd.substring(cmd.indexOf("--output") + 9, cmd.indexOf("--tilesetId") - 1);
+
+            FileEntity entity = new FileEntity();
+            entity.setFileName(fileName);
+            entity.setFileUrl(fileUrl);
+            entity.setCreateTime(new Date());
+            entity.setUpdateTime(new Date());
+            entity.setType(TypeCode.FILE_TYPE_MODEL_TILE);
+            fileRepository.save(entity);
+            // 表示执行完成,释放锁
+            existsSlpk2vts.set(false);
+
+        }
+    }
+
+
+    /**
+     * 可能运行1s -- 12h
+     * 需要记录进度
+     * 需要多前程运行
+     */
+    @ApiOperation("commandVts")
+    @GetMapping("/command/vts/{fileId}/")
+    private ResponseResult commandVts(@PathVariable("fileId") Long fileId) {
+        log.info("run commandVts");
+
+        Optional<FileEntity> entity = fileRepository.findById(fileId);
+        if (!entity.isPresent()) {
+            return new ResponseResult(50002, MsgCode.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: {}", MsgCode.E50005);
+            }
+            log.info("cmd  run : success");
+            fileEntity.setStatus(2); // 2:表示VTS命令执行完成
+            fileEntity.setUpdateTime(new Date());
+            fileRepository.save(fileEntity);
+            // 表示执行完成,释放锁
+            existsVts.set(false);
+
+        }
+    }
+
+//    @ApiOperation("command model vts remove")
+//    @GetMapping("/command/vts/remove/{fileId}")
+//    private ResponseResult commandVtsRemove(@PathVariable("fileId") Long fileId) {
+//        log.info("run commandVtsRemove");
+//        GenerateFileEntity entity = generateFileRepository.findByFileId(fileId);
+//        if (entity == null) {
+//            return new ResponseResult(50002, MsgCode.E50002);
+//        }
+//
+//        String fileName = entity.getFileName();
+//        String cmd = CommandMsg.MODEL_USER_VTS;
+//        cmd = cmd.replaceAll("@fileName", fileName);
+//
+//        Integer s = cmdServer.exeCmd(cmd);
+//        if (s ==1) {
+//            log.info("cmd  run: {}", MsgCode.E50005);
+//            return new ResponseResult(50005, MsgCode.E50005);
+//        }
+//        log.info("cmd  run : success");
+//
+//        return new ResponseResult(200, "success");
+//    }
+
+
+    @ApiOperation("command change user vts")
+    @GetMapping("/command/change/user/vts")
+    private ResponseResult commandChangeUserVts() {
+        log.info("run commandChangeUserVts");
+
+        Integer s = cmdServer.exeCmd(CommandMsg.MODEL_USER_VTS);
+        if (s ==1) {
+            log.info("cmd  run: {}", MsgCode.E50005);
+            return new ResponseResult(50005, MsgCode.E50005);
+        }
+        log.info("cmd  run : success");
+
+        return new ResponseResult(200, "success");
+    }
+
+    /**
+     * 删除文件
+     */
+    @GetMapping("delete/{fileId}/")
+    private ResponseResult deleteFile(@PathVariable("fileId") Long fileId) {
+        log.info("run deleteFile: {}", fileId);
+        return fileServer.deleteFileById(fileId);
+    }
+
+
+//    @GetMapping("test")
+//    private ResponseResult test() {
+//        log.info("run test: {}");
+//
+//
+//        return new ResponseResult(200, "123");
+//    }
+
+
+    /**
+     * 查询命令处理进度
+     * @param fileId 上传文件的id
+     * @param type 执行命令的类型
+     * @return
+     */
+    @ApiOperation("query progress bar; type: vts / slpk")
+    @GetMapping("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);
+    }
+
+
+    @ApiOperation("update 4dage")
+    @PostMapping("update/fdage")
+    private ResponseResult updateFdage(@RequestBody ModelFdageDto param){
+        log.info("run updateFdage");
+
+        return jsonServer.updateModelFdage(param);
+    }
+
+
+
+
+
+}

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

@@ -0,0 +1,200 @@
+package com.fd.controller;
+
+import com.fd.Dto.PageDto;
+import com.fd.Dto.VectorResourcesJsonDto;
+import com.fd.constant.CommandMsg;
+import com.fd.constant.MsgCode;
+import com.fd.constant.TypeCode;
+import com.fd.entity.FileEntity;
+import com.fd.repository.FileRepository;
+//import com.fd.repository.GenerateFileRepository;
+import com.fd.repository.ScheduleRepository;
+import com.fd.util.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.Optional;
+
+/**
+ * Created by Owen on 2019/11/7 0007 10:19
+ */
+@Log4j2
+@RestController
+@RequestMapping("api/vts/vector")
+public class VtsVectorController {
+
+    @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;
+
+//    @Autowired
+//    private GenerateFileRepository generateFileRepository;
+
+
+    @ApiOperation("upload Vector file list")
+    @PostMapping(value = "list")
+    private ResponseResult list(@RequestBody PageDto param){
+        log.info("run list");
+        Page<FileEntity> page = fileRepository.findByType(
+                TypeCode.FILE_TYPE_VECTOR, TypeCode.FILE_TYPE_VECTOR_GEOJSON,
+                PageRequest.of(param.getPageNum(), param.getPageSize(), Sort.by("createTime").descending()));
+        return new ResponseResult(200,page);
+    }
+
+    /**
+     * 文件上传
+     * 需要创建目录
+     * 不支持大文件上传
+     *
+     * @return
+     */
+    @ApiOperation("upload Vector file")
+    @PostMapping(value = "upload/{directoryName}/", consumes = { "multipart/form-data" })
+    private ResponseResult uploadVector(@RequestParam("file") MultipartFile file, @PathVariable("directoryName") String directoryName){
+        log.info("run uploadVector");
+        return fileServer.upload2(file, vectorPath+directoryName+"/");
+    }
+
+
+    @ApiOperation("commandOgr2ogr")
+    @GetMapping("/command/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, MsgCode.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: {}", MsgCode.E50005);
+            return new ResponseResult(50005, MsgCode.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.setCreateTime(new Date());
+        geojson.setUpdateTime(new Date());
+        geojson.setType(TypeCode.FILE_TYPE_VECTOR_GEOJSON);
+        fileRepository.save(geojson);
+
+        return new ResponseResult(200, geojson);
+    }
+
+    @ApiOperation("commandTippecanoe ")
+    @GetMapping("/command/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, MsgCode.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: {}", MsgCode.E50005);
+            return new ResponseResult(50005, MsgCode.E50005);
+        }
+        log.info("cmd  run : success");
+
+        return new ResponseResult(200, "success");
+    }
+
+    /**
+     * 删除文件
+     */
+    @GetMapping("delete/{fileId}/")
+    private ResponseResult deleteFile(@PathVariable("fileId") Long fileId) {
+        log.info("run deleteFile: {}", fileId);
+        return fileServer.deleteFileById(fileId);
+    }
+
+
+//    @ApiOperation("update 4dage")
+//    @GetMapping("update/fdage/{param}/")
+//    private ResponseResult updateFdage(@PathVariable("param") String param){
+//        log.info("run updateFdage");
+//        jsonServer.updateVectroFdage(param);
+//        return new ResponseResult(200,"success");
+//    }
+
+
+    /**
+     * restful 风格会,参数多,会传不进来
+     */
+    @ApiOperation("update 4dage")
+    @GetMapping("update/fdage")
+    private ResponseResult updateFdage(String param){
+        log.info("run updateFdage");
+        jsonServer.updateVectroFdage(param);
+        return new ResponseResult(200,"success");
+    }
+
+
+    /**
+     * 会增加一块数据
+     * @param param
+     * @return
+     */
+    @ApiOperation("update vector resources.json")
+    @PostMapping("update/resources")
+    private ResponseResult updateVectorResources(@RequestBody VectorResourcesJsonDto param){
+        log.info("run updateVectorResources");
+        System.out.println(param.toString());
+        jsonServer.updateVectorResourcesJson(param);
+        return new ResponseResult(200,"success");
+    }
+
+}

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

@@ -0,0 +1,40 @@
+package com.fd.entity;
+
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @Column
+    private Date createTime;
+
+//    @Temporal(TemporalType.TIMESTAMP)
+//    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @Column
+    private Date updateTime;
+
+//    @JsonIgnore
+//    @Column
+//    private String recStatus; // 记录 A:可用 I:禁用(假性删除)
+
+
+
+}

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

@@ -0,0 +1,47 @@
+package com.fd.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+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; // 文件路径
+
+//    @JsonIgnore
+//    @Column
+//    private String description; // 描述
+
+//    @JsonIgnore
+//    @Column
+//    private String version; // 版本
+
+
+    @Column
+    private String type; // 文件类型
+
+    /**
+     * 状态
+     * model的.slpk文件 0:未完成 1:完成Slpk2vts命令 2:完成vts命令
+     */
+    @Column
+    private Integer status; // 状态,是否可用 1:完成, 0:未完成
+}

+ 39 - 0
src/main/java/com/fd/entity/GenerateFileEntity.java

@@ -0,0 +1,39 @@
+//package com.fd.entity;
+//
+//import lombok.Data;
+//
+//import javax.persistence.Column;
+//import javax.persistence.Entity;
+//import javax.persistence.Table;
+//import java.io.Serializable;
+//
+///**
+// * Created by Owen on 2019/11/7 0007 9:28
+// * slpk 转 vts 文件表
+// */
+//
+//@Data
+//@Entity
+//@Table(name = "t_generate_file")
+//public class GenerateFileEntity extends BaseEntity implements Serializable {
+//    private static final long serialVersionUID = -6628206768042601783L;
+//
+//    @Column
+//    private Long fileId; // 文件id 唯一
+//
+//    @Column
+//    private String fileName; // 文件名称
+//
+//    @Column
+//    private String fileUrl; // 文件路径
+//
+//    @Column
+//    private String type; // 文件类型
+//
+//    /**
+//     * 状态
+//     * 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
+}

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

@@ -0,0 +1,22 @@
+package com.fd.repository;
+
+import com.fd.entity.FileEntity;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+/**
+ * Created by Owen on 2019/10/28 0028 11:36
+ *
+ * JpaSpecificationExecutor 条件分页查询
+ */
+public interface FileRepository extends JpaRepository<FileEntity, Long>, JpaSpecificationExecutor<FileEntity> {
+
+    // 条件分页查询
+    Page<FileEntity> findByType(String type, Pageable pageable);
+
+    @Query(value = "select r from FileEntity r where r.type=?1 or r.type =?2")
+    Page<FileEntity> findByType(String type, String type1, Pageable pageable);
+}

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

@@ -0,0 +1,14 @@
+//package com.fd.repository;
+//
+//import com.fd.entity.GenerateFileEntity;
+//import org.springframework.data.jpa.repository.JpaRepository;
+//
+//
+///**
+// * Created by Owen on 2019/10/28 0028 11:36
+// *
+// */
+//public interface GenerateFileRepository extends JpaRepository<GenerateFileEntity, Long> {
+//
+//    GenerateFileEntity findByFileId(Long id);
+//}

+ 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);
+}

+ 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);
+}

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

@@ -0,0 +1,21 @@
+package com.fd.server;
+
+import com.fd.util.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);
+
+    ResponseResult deleteFileById(Long id);
+
+//    ResponseResult deleteDirectoryById(Long fileId);
+}

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

@@ -0,0 +1,23 @@
+package com.fd.server;
+
+import com.fd.Dto.*;
+import com.fd.util.ResponseResult;
+
+/**
+ * Created by Owen on 2019/10/30 0030 17:16
+ */
+public interface JsonServer {
+
+
+    void updateVectorResourcesJson(VectorResourcesJsonDto param);
+
+    void updateResourcesJson(ResourcesJsonDto param);
+
+    void updateFdage(FdageDto param);
+
+    ResponseResult updateVectroFdage(String param);
+
+    ResponseResult updateModelFdage(ModelFdageDto param);
+
+    ResponseResult updateBaseMapFdage(BaseMapFdageDto param);
+}

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

@@ -0,0 +1,355 @@
+package com.fd.server.impl;
+
+import com.fd.constant.TypeCode;
+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(TypeCode.SCHEDULE_TYPE_MODEL_SLPK);
+                        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(TypeCode.SCHEDULE_TYPE_MODEL_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);
+
+    }
+
+}

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

@@ -0,0 +1,152 @@
+package com.fd.server.impl;
+
+import com.fd.constant.MsgCode;
+import com.fd.constant.TypeCode;
+import com.fd.entity.FileEntity;
+import com.fd.repository.FileRepository;
+import com.fd.util.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, MsgCode.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());
+        entity.setType(TypeCode.FILE_TYPE_MODEL);
+        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, MsgCode.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());
+        entity.setType(TypeCode.FILE_TYPE_VECTOR);
+        fileRepository.save(entity);
+
+        return new ResponseResult (200,"success");
+    }
+
+    @Override
+    public ResponseResult deleteFileById(Long id)  {
+
+        // 删除服务器文件
+        Optional<FileEntity> e = fileRepository.findById(id);
+        if (!e.isPresent()) {
+            return new ResponseResult(50002, MsgCode.E50002);
+        }
+        FileEntity fileEntity = e.get();
+        String fileName = fileEntity.getFileName();
+        // 文件
+        if (fileName.contains(".")) {
+            File file = new File(fileEntity.getFileUrl());
+            file.delete();
+        } else { // 目录
+            FileUtils.delAllFile(fileEntity.getFileUrl());
+        }
+
+
+        // 删除数据库记录
+        fileRepository.deleteById(id);
+
+        return new ResponseResult(200, "success");
+    }
+
+
+    public static void main(String[] args) {
+        String a = "aaa.bb";
+        String b = "aaa";
+        System.out.println(a.contains("."));
+        System.out.println(b.contains("."));
+
+    }
+
+}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 322 - 0
src/main/java/com/fd/server/impl/JsonServerImpl.java


+ 55 - 0
src/main/java/com/fd/test/Md5.java

@@ -0,0 +1,55 @@
+package com.fd.test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Created by Owen on 2019/11/5 0005 18:06
+ */
+public class Md5 {
+
+
+
+    public static void main(String[] args) {
+        File file = new File("D:\\工作\\gis\\vts\\file\\BusLine\\BusLine.shp");
+        File file1 = new File("D:\\工作\\gis\\vts\\file\\BusLine\\error\\BusLine.shp");
+        System.out.println(getFileMD5(file)); //380b741ded0bc3b201b7f594ab36e3c9
+        System.out.println(getFileMD5(file1)); //380b741ded0bc3b201b7f594ab36e3c9
+
+    }
+
+
+
+
+
+    //get bin file's md5 string
+    public static String getFileMD5(File file) {
+        if (!file.isFile()) {
+            return null;
+        }
+        MessageDigest digest = null;
+        FileInputStream in = null;
+        byte buffer[] = new byte[1024];
+        int len;
+        try {
+            digest = MessageDigest.getInstance("MD5");
+            in = new FileInputStream(file);
+            while ((len = in.read(buffer, 0, 1024)) != -1) {
+                digest.update(buffer, 0, len);
+            }
+            in.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+        BigInteger bigInt = new BigInteger(1, digest.digest());
+        return bigInt.toString(16);
+    }
+}

+ 93 - 0
src/main/java/com/fd/test/cmd.java

@@ -0,0 +1,93 @@
+package com.fd.test;
+
+import java.io.*;
+
+/**
+ * Created by Owen on 2019/10/31 0031 14:49
+ */
+public class cmd {
+
+    public static void main(String[] args) {
+
+//        String result = exeCmd();
+        exeCmdMulti_1();
+    }
+
+
+    public static String exeCmd() {
+        String command = "ifconfig";
+        String result = "";
+        try {
+            String[] cmd = new String[]{"/bin/sh", "-c", command};
+            Process ps = Runtime.getRuntime().exec(cmd);
+
+            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
+            StringBuffer sb = new StringBuffer();
+            String line;
+            while ((line = br.readLine()) != null) {
+                sb.append(line).append("\n");
+            }
+            result = sb.toString();
+            System.out.println("result: " + result);
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+
+    public static String exeCmdMulti() {
+        String result = "";
+        String command = "ifconfig;ls";
+        try {
+
+            String[] cmd = new String[]{"/bin/sh", "-c", command};
+            Process ps = Runtime.getRuntime().exec(cmd);
+
+            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
+            StringBuffer sb = new StringBuffer();
+            String line;
+            while ((line = br.readLine()) != null) {
+                sb.append(line).append("\n");
+            }
+            result = sb.toString();
+            System.out.println("result: " + result);
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+
+    public static String exeCmdMulti_1() {
+        String result = "";
+        String command = "slpk2vts --input /var/vts/input/Production_13.slpk --output /root/java/test/test_13 --tilesetId test_13 --referenceFrame melown2015";
+        try {
+
+            String[] cmd = new String[]{"/bin/sh", "-c", command};
+            Process ps = Runtime.getRuntime().exec(cmd);
+
+            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
+            StringBuffer sb = new StringBuffer();
+            String line;
+            while ((line = br.readLine()) != null) {
+                sb.append(line).append("\n");
+            }
+            result = sb.toString();
+            System.out.println("result: " + result);
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+
+
+
+}

+ 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.mkdirs();
+        }
+    }
+
+    /**
+     * 大文件读写
+     *
+     * 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();
+        }
+    }
+}

+ 140 - 0
src/main/java/com/fd/util/ResponseResult.java

@@ -0,0 +1,140 @@
+package com.fd.util;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+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(Integer status, Object data) {
+
+		super();
+
+		this.status = status;
+		this.message = null;
+
+		this.data = data;
+		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;
+	}
+}

+ 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/gis_vts?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/gis_vts?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

+ 10 - 0
src/main/resources/application.properties

@@ -0,0 +1,10 @@
+server.port=8082
+
+spring.profiles.active=pro
+spring.servlet.multipart.enabled=true
+spring.servlet.multipart.max-file-size=51200MB
+spring.servlet.multipart.max-request-size=51200MB
+
+spring.jpa.hibernate.ddl-auto=update
+spring.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
+

+ 40 - 0
src/main/resources/json/4dage

@@ -0,0 +1,40 @@
+{
+        "storage": "/var/vts/store/stage.melown2015",
+        "tilesets": [
+                "4dagecity",
+                "tiandi"
+        ],
+        "credits": { },
+        "boundLayers": {
+                "tiandi-map": "/mapproxy/melown2015/tms/tianditu/tianditms/boundlayer.json"
+        },
+        "freeLayers": {
+                "tiandi-surface": "/mapproxy/melown2015/surface/tianditu/tiandisurface/freelayer.json",
+                "road-vector": "/mapproxy/melown2015/geodata/tianditu/road-vec/freelayer.json",
+                "touristattractions-vec": "/mapproxy/melown2015/geodata/tianditu/touristattractions-vec/freelayer.json",
+                "busline-vector": "/mapproxy/melown2015/geodata/tianditu/busline-vec/freelayer.json",
+                "buspoints-vector": "/mapproxy/melown2015/geodata/tianditu/buspoints-vec/freelayer.json",
+                "channelbasicsinfo-vector": "/mapproxy/melown2015/geodata/tianditu/channelbasicsinfo-vec/freelayer.json",
+                "greenarea-vector": "/mapproxy/melown2015/geodata/tianditu/greenarea-vec/freelayer.json",
+                "maintouristattractions-vector": "/mapproxy/melown2015/geodata/tianditu/maintouristattractions-vec/freelayer.json",
+                "poi-vector": "/mapproxy/melown2015/geodata/tianditu/poi-vec/freelayer.json",
+                "railway-vector": "/mapproxy/melown2015/geodata/tianditu/railway-vec/freelayer.json",
+                "starhotel-vector": "/mapproxy/melown2015/geodata/tianditu/starhotel-vec/freelayer.json",
+                "trafficlights-vector": "/mapproxy/melown2015/geodata/tianditu/trafficlights-vec/freelayer.json",
+                "trafficdetection-vector": "/mapproxy/melown2015/geodata/tianditu/trafficdetection-vec/freelayer.json",
+                "surveillance-vector": "/mapproxy/melown2015/geodata/tianditu/surveillance-vec/freelayer.json"
+
+        },
+        "view": {
+                "description": "",
+                "surfaces": {
+                        "4dagecity": []
+                },
+                "freeLayers": {
+                        "tiandi-surface": { "boundLayers": ["tiandi-map"] }
+                }
+        },
+        "namedViews": {},
+        "position": ["obj",113.078029,22.599334,"fix",-4.99,130.98,-20.39,0.00,876.50,45.00],
+        "version": 1
+}

+ 7 - 0
src/main/resources/json/data.json

@@ -0,0 +1,7 @@
+[
+  {"id":0,"region":"东北楼1","storey":3,"status":1,"count":0},
+  {"id":1,"region":"东北楼2","storey":3,"status":1,"count":1},
+  {"id":2,"region":"东北楼3","storey":3,"status":1,"count":2},
+  {"id":3,"region":"东北楼4","storey":3,"status":1,"count":3},
+  {"id":4,"region":"东北楼5","storey":3,"status":1,"count":4}
+]

+ 441 - 0
src/main/resources/json/resources.json

@@ -0,0 +1,441 @@
+[
+{
+  "comment": "Tianditu Boundlayer",
+  "group": "tianditu",
+  "id": "tianditms",
+  "type": "tms",
+  "driver": "tms-raster-remote",
+  "credits": ["tianditu"],
+  "definition": {
+      "remoteUrl": "http://t1.tianditu.com/DataServer?T=img_w&X={locx}&Y={locy}&L={loclod}&tk=4bbbafdfeca49cb6fb5efb1a40164445"
+  },
+  "registry": {
+      "credits" : {"tianditu":{ "id": 8888, "notice": "{copy}{Y} TianDiTu" }}
+  },
+  "referenceFrames":
+      {
+          "melown2015": {
+              "tileRange": [[ 0, 0 ], [ 1, 1 ]],
+              "lodRange": [0, 17]
+          }
+      }
+},
+{
+        "comment": "spheroid",
+        "group": "tianditu",
+        "id": "tiandisurface",
+        "type": "surface",
+        "driver": "surface-spheroid",
+        "referenceFrames": {
+            "melown2015" : {
+                "lodRange": [0, 19],
+                "tileRange": [ [ 0, 0], [1, 1]]
+            }
+        },
+        "credits": [],
+        "definition": {
+            "introspection": {
+                "tms": [{ "group": "tianditu", "id": "tianditms" }]
+            }
+        }
+},
+{
+  "comment": "DEM",
+  "group": "tianditu",
+  "id": "dem",
+  "type": "surface",
+  "driver": "surface-dem",
+  "credits": [],
+  "definition": {
+      "dataset": "dem",
+      "geoidGrid": "egm96_15.gtx"
+  },
+  "referenceFrames": {
+      "melown2015": {
+          "tileRange": [
+              [ 51, 27 ],
+              [ 52, 28 ]
+          ],
+          "lodRange": [ 7, 17 ]
+      }
+  }
+},
+{
+   "comment": "Road MBtiles",
+   "group": "tianditu",
+   "id": "road-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "road/road.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:road/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "{copy}{Y} 4DAGE" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "ATouristAttractions MBtiles",
+   "group": "tianditu",
+   "id": "touristattractions-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "aTouristAttractionsInfo/ATouristAttractionsInfo.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:aTouristAttractionsInfo/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "Busline MBtiles",
+   "group": "tianditu",
+   "id": "busline-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "BusLine/busline.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:BusLine/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "Buspoints MBtiles",
+   "group": "tianditu",
+   "id": "buspoints-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "BusPoints/buspoints.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:BusPoints/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "ChannelBasicsInfo MBtiles",
+   "group": "tianditu",
+   "id": "channelbasicsinfo-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "channelBasicsInfo/channelbasicsinfo.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:channelBasicsInfo/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "GreenArea MBtiles",
+   "group": "tianditu",
+   "id": "greenarea-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "greenArea/greenarea.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:greenArea/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "MainTouristAttractions MBtiles",
+   "group": "tianditu",
+   "id": "maintouristattractions-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "mainTouristAttractions/maintouristattractions.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:mainTouristAttractions/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "POI MBtiles",
+   "group": "tianditu",
+   "id": "poi-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "poi/poi.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:poi/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "Railway MBtiles",
+   "group": "tianditu",
+   "id": "railway-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "railway/railway.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:railway/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "Star Hotel MBtiles",
+   "group": "tianditu",
+   "id": "starhotel-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "starHotel/starhotel.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:starHotel/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "Traffic Lights 交通信号灯",
+   "group": "tianditu",
+   "id": "trafficlights-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "交通信号灯/交通信号灯.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:交通信号灯/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "Traffic Detection 流量检测",
+   "group": "tianditu",
+   "id": "trafficdetection-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "流量检测/流量检测.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:流量检测/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+},
+{
+   "comment": "Video Surveillance",
+   "group": "tianditu",
+   "id": "surveillance-vec",
+   "type": "geodata",
+   "driver": "geodata-vector-tiled",
+   "credits": ["4dage"],
+   "definition": {
+       "dataset": "视频监控/视频监控.mbtiles/{loclod}-{locx}-{locy}"
+       , "demDataset": "dem"
+       , "geoidGrid": "egm96_15.gtx"
+       , "format": "geodataJson"
+       , "displaySize": 1024
+       , "styleUrl": "file:视频监控/style.style"
+   },
+   "registry": {
+       "credits" : {"4dage":{ "id": 104, "notice": "" }}
+   },
+   "referenceFrames":
+       {
+           "melown2015": {
+               "tileRange": [
+                   [26675, 14270],
+                   [26678, 14273]
+               ],
+               "lodRange": [16, 17]
+           }
+       }
+}
+]
+

+ 0 - 1
新建文本文档 (2).txt

@@ -1 +0,0 @@
-dddd 

+ 0 - 1
新建文本文档.txt

@@ -1 +0,0 @@
-オ羞羞ホオホ