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