|
@@ -1,6 +1,7 @@
|
|
|
package com.fd.controller;
|
|
|
|
|
|
import com.fd.Dto.PageDto;
|
|
|
+import com.fd.Dto.StyleDto;
|
|
|
import com.fd.Dto.VectorResourcesJsonDto;
|
|
|
import com.fd.constant.CommandMsg;
|
|
|
import com.fd.constant.MsgCode;
|
|
@@ -9,6 +10,7 @@ import com.fd.entity.FileEntity;
|
|
|
import com.fd.repository.FileRepository;
|
|
|
//import com.fd.repository.GenerateFileRepository;
|
|
|
import com.fd.repository.ScheduleRepository;
|
|
|
+import com.fd.util.FileUtils;
|
|
|
import com.fd.util.ResponseResult;
|
|
|
import com.fd.server.CmdServer;
|
|
|
import com.fd.server.FileServer;
|
|
@@ -23,7 +25,12 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
|
|
|
/**
|
|
@@ -55,8 +62,6 @@ public class VtsVectorController {
|
|
|
@Autowired
|
|
|
private ScheduleRepository scheduleRepository;
|
|
|
|
|
|
-// @Autowired
|
|
|
-// private GenerateFileRepository generateFileRepository;
|
|
|
|
|
|
|
|
|
@ApiOperation("upload Vector file list")
|
|
@@ -70,6 +75,39 @@ public class VtsVectorController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 生成style文件
|
|
|
+ * 跟xxx.shp 是同一个目录
|
|
|
+ */
|
|
|
+ @ApiOperation("update style ")
|
|
|
+ @PostMapping(value = "update/style")
|
|
|
+ private ResponseResult updateStyle(String param, String directoryName){
|
|
|
+ log.info("run updateStyle");
|
|
|
+ String filePath = vectorPath + directoryName + File.separator + "style.style";
|
|
|
+ try {
|
|
|
+ // 生成文件
|
|
|
+ FileUtils.fileWriter(param, filePath);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成的文件需要修改文件权限
|
|
|
+ String cmd = CommandMsg.VECTOR_DIRECTORY_PERMISSION;
|
|
|
+ cmd = cmd.replace("@fileName", directoryName);
|
|
|
+ cmd = cmd + "style.style";
|
|
|
+ log.info("cmd : {}", cmd);
|
|
|
+ cmdServer.exeCmd(cmd);
|
|
|
+
|
|
|
+ // 修改文件权限用户为vts
|
|
|
+ cmd = CommandMsg.VECTOR_DIRECTORY_VTS;
|
|
|
+ cmd = cmd.replace("@fileName", directoryName);
|
|
|
+ cmdServer.exeCmd(cmd);
|
|
|
+
|
|
|
+ return new ResponseResult(200, MsgCode.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 文件上传
|
|
|
* 需要创建目录
|
|
|
* 不支持大文件上传
|
|
@@ -80,7 +118,23 @@ public class VtsVectorController {
|
|
|
@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+"/");
|
|
|
+ return fileServer.uploadVector(file, vectorPath, directoryName);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("commandMapproxyUpdate")
|
|
|
+ @GetMapping("/command/mapproxyUpdate")
|
|
|
+ private ResponseResult commandMapproxyUpdate() {
|
|
|
+ log.info("run commandMapproxyUpdate");
|
|
|
+ String cmd = CommandMsg.BASE_MAPPROXY_UPDATE;
|
|
|
+
|
|
|
+ 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, "");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -121,6 +175,17 @@ public class VtsVectorController {
|
|
|
geojson.setType(TypeCode.FILE_TYPE_VECTOR_GEOJSON);
|
|
|
fileRepository.save(geojson);
|
|
|
|
|
|
+// FileEntity style = new FileEntity();
|
|
|
+// style.setFileName("style.style");
|
|
|
+// style.setFileUrl();
|
|
|
+// style.setType();
|
|
|
+// geojson.setCreateTime(new Date());
|
|
|
+// geojson.setUpdateTime(new Date());
|
|
|
+// fileRepository.save(style);
|
|
|
+//
|
|
|
+// Map<Object, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
return new ResponseResult(200, geojson);
|
|
|
}
|
|
|
|