wuweihao пре 5 година
родитељ
комит
e81ce24163

+ 4 - 1
src/main/java/com/fd/constant/CommandMsg.java

@@ -12,13 +12,16 @@ public class CommandMsg {
             "chmod 755 -R /var/vts/store/resources/tilesets/@fileName/";
 
     // 切换用户
-    public static String MODEL_USER = "sudo -iu vts";
+    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";
 

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

@@ -0,0 +1,15 @@
+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_VECTOR = "vector";
+
+    public static final String FILE_TYPE_VECTOR_GEOJSON = "geojson";
+}

+ 422 - 400
src/main/java/com/fd/controller/VtsController.java

@@ -1,404 +1,426 @@
-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);
+//package com.fd.controller;
+//
+//import com.fd.Dto.FdageDto;
+//import com.fd.Dto.ResourcesJsonDto;
+//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.web.bind.annotation.*;
+//
+///**
+// * 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;
+//
+////    @Autowired
+////    private SlpkToVtsFielRepository slpkToVtsFielRepository;
+////
+////
+////    // 多线程共享变量
+////    // false 表示完成
+////    private static AtomicBoolean existsSlpk2vts = new AtomicBoolean(false);
+////
+////    private static AtomicBoolean existsVts = new AtomicBoolean(false);
+//
+//
+//    /**
+//     * 文件列表
+//     * Sort.by("createTime"),createTime属性名
+//     */
+////    @ApiOperation("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);
+////
+////            // 保存新产生的文件到数据库
+////            String fileName = fileEntity.getFileName();
+////            fileName = fileName.substring(0, fileName.lastIndexOf("."));
+////            String fileUrl = cmd.substring(cmd.indexOf("--output") + 9, cmd.indexOf("--tilesetId") - 1);
+////            FileEntity resultFile = new FileEntity();
+////            SlpkToVtsFielEntity entity = slpkToVtsFielRepository.findByFileId(fileId);
+////            if (entity == null) {
+////                entity = new SlpkToVtsFielEntity();
+////            }
+////            entity.setFileId(fileId);
+////            entity.setFileName(fileName);
+////            entity.setFileUrl(fileUrl);
+////            entity.setCreateTime(new Date());
+////            entity.setUpdateTime(new Date());
+////            entity.setType("vts");
+////            slpkToVtsFielRepository.save(entity);
+////            // 表示执行完成,释放锁
+////            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.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");
-
-        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;
-    }
-
-
-}
+////        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;
+////    }
+//
+//
+//    public static void main(String[] args) {
+//        String a = "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/";
+//
+//        String b = "1222.aa";
+//        System.out.println(b.substring(0, b.lastIndexOf(".")));
+//
+//        System.out.println(a.substring(a.indexOf("--output") + 9, a.indexOf("--tilesetId") - 1));
+//    }
+//
+//}

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

@@ -0,0 +1,274 @@
+package com.fd.controller;
+
+import com.fd.Dto.PageDto;
+import com.fd.constant.CommandMsg;
+import com.fd.constant.ErrorCode;
+import com.fd.constant.TypeCode;
+import com.fd.entity.FileEntity;
+import com.fd.entity.GenerateFileEntity;
+import com.fd.repository.FileRepository;
+import com.fd.repository.GenerateFileRepository;
+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.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Created by Owen on 2019/11/7 0007 10:19
+ * 3D Model
+ */
+@CrossOrigin(maxAge = 3600)
+@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){
+        Page<FileEntity> page = fileRepository.findByType(TypeCode.FILE_TYPE_MODEL, 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, 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);
+
+            // 保存新产生的文件到数据库
+            String fileName = fileEntity.getFileName();
+            fileName = fileName.substring(0, fileName.lastIndexOf("."));
+            String fileUrl = cmd.substring(cmd.indexOf("--output") + 9, cmd.indexOf("--tilesetId") - 1);
+            GenerateFileEntity entity = generateFileRepository.findByFileId(fileId);
+            if (entity == null) {
+                entity = new GenerateFileEntity();
+            }
+            entity.setFileId(fileId);
+            entity.setFileName(fileName);
+            entity.setFileUrl(fileUrl);
+            entity.setCreateTime(new Date());
+            entity.setUpdateTime(new Date());
+            entity.setType("vts");
+            generateFileRepository.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, 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("command model vts remove")
+    @GetMapping("/command/vts/remove/{fileId}")
+    private ResponseResult commandVtsRemove(@PathVariable("fileId") Long fileId) {
+        log.info("run commandChangeUserVts");
+        GenerateFileEntity entity = generateFileRepository.findByFileId(fileId);
+        if (entity == null) {
+            return new ResponseResult(50002, ErrorCode.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: {}", ErrorCode.E50005);
+            return new ResponseResult(50005, ErrorCode.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: {}", ErrorCode.E50005);
+            return new ResponseResult(50005, ErrorCode.E50005);
+        }
+        log.info("cmd  run : success");
+
+        return new ResponseResult(200, "success");
+    }
+
+
+
+
+
+}

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

@@ -0,0 +1,158 @@
+package com.fd.controller;
+
+import com.fd.Dto.PageDto;
+import com.fd.constant.CommandMsg;
+import com.fd.constant.ErrorCode;
+import com.fd.constant.TypeCode;
+import com.fd.entity.FileEntity;
+import com.fd.entity.GenerateFileEntity;
+import com.fd.repository.FileRepository;
+import com.fd.repository.GenerateFileRepository;
+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.Optional;
+
+/**
+ * Created by Owen on 2019/11/7 0007 10:19
+ */
+@CrossOrigin(maxAge = 3600)
+@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){
+        Page<FileEntity> page = fileRepository.findByType(TypeCode.FILE_TYPE_VECTOR, 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){
+        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, 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();
+
+        // 把生成的文件信息写入数据库
+        GenerateFileEntity geojson = generateFileRepository.findByFileId(fileId);
+        if (geojson == null) {
+            geojson = new GenerateFileEntity();
+        }
+        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);
+
+        geojson = generateFileRepository.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, 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");
+    }
+}

+ 3 - 3
src/main/java/com/fd/entity/BaseEntity.java

@@ -28,9 +28,9 @@ public class BaseEntity implements Serializable {
     @Column
     private Date updateTime;
 
-    @JsonIgnore
-    @Column
-    private String recStatus; // 记录 A:可用 I:禁用(假性删除)
+//    @JsonIgnore
+//    @Column
+//    private String recStatus; // 记录 A:可用 I:禁用(假性删除)
 
 
 

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

@@ -1,5 +1,6 @@
 package com.fd.entity;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Data;
 
 import javax.persistence.*;
@@ -25,12 +26,18 @@ public class FileEntity extends BaseEntity implements Serializable {
     @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命令

+ 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:未完成
+}

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

@@ -1,6 +1,8 @@
 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;
 
@@ -11,4 +13,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  */
 public interface FileRepository extends JpaRepository<FileEntity, Long>, JpaSpecificationExecutor<FileEntity> {
 
+    // 条件分页查询
+    Page<FileEntity> findByType(String type, 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);
+}

+ 5 - 2
src/main/java/com/fd/server/impl/FileServerImpl.java

@@ -1,6 +1,7 @@
 package com.fd.server.impl;
 
 import com.fd.constant.ErrorCode;
+import com.fd.constant.TypeCode;
 import com.fd.entity.FileEntity;
 import com.fd.repository.FileRepository;
 import com.fd.result.ResponseResult;
@@ -58,9 +59,10 @@ public class FileServerImpl implements FileServer {
         FileEntity entity = new FileEntity();
         entity.setFileName(fileName);
         entity.setFileUrl(filePath);
-        entity.setRecStatus("A");
+//        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");
@@ -104,9 +106,10 @@ public class FileServerImpl implements FileServer {
         FileEntity entity = new FileEntity();
         entity.setFileName(fullFileName);
         entity.setFileUrl(filePath);
-        entity.setRecStatus("A");
+//        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");

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

@@ -47,7 +47,7 @@ public class PercentThread implements Runnable {
                 schedule.setPercent(percent);
                 schedule.setCreateTime(new Date());
                 schedule.setUpdateTime(new Date());
-                schedule.setRecStatus("A");
+//                schedule.setRecStatus("A");
             } else {
                 schedule.setPercent(percent);
                 schedule.setUpdateTime(new Date());