|
@@ -14,6 +14,7 @@ import com.fd.server.CmdServer;
|
|
|
import com.fd.server.VectorServer;
|
|
|
import com.fd.util.FileUtils;
|
|
|
import com.fd.util.R;
|
|
|
+import com.fd.util.RegexUtils;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -104,16 +105,63 @@ public class VectorController {
|
|
|
log.info("run uploadMult");
|
|
|
log.info("coord: {}", coord);
|
|
|
|
|
|
+ R r = vectorServer.uploadDirectoryFileMul(file, directoryName, coord);
|
|
|
|
|
|
+ OutputFileEntity entity = (OutputFileEntity) r.getData();
|
|
|
|
|
|
- return vectorServer.uploadDirectoryFileMul(file, directoryName, coord);
|
|
|
+ // 判断坐标
|
|
|
+ entity = JudgeCoord(entity);
|
|
|
+
|
|
|
+ return new R(200, entity);
|
|
|
+
|
|
|
+// return vectorServer.uploadDirectoryFileMul(file, directoryName, coord);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传后判断坐标,显示原始坐标
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private OutputFileEntity JudgeCoord(OutputFileEntity entity){
|
|
|
+
|
|
|
+ // 判断是否需要坐标转换
|
|
|
+ String cmd = Command.VECTOR_JUDGE_COORD;
|
|
|
+ cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
|
+ log.info("cmd: {}", cmd);
|
|
|
+
|
|
|
+ Integer isJudge = cmdServer.exeCmdJudgeCoord(cmd);
|
|
|
+
|
|
|
+
|
|
|
+ // 转换坐标 普通坐标转换
|
|
|
+ if (isJudge == 1000){
|
|
|
+ // 普通坐标转换
|
|
|
+ log.info("need to general transform");
|
|
|
+ entity.setCoordType(TypeCode.COORD_SYSTEM_2000);
|
|
|
+ } else if (isJudge == 1001) {
|
|
|
+
|
|
|
+ // 严格坐标转换 (西安80转wgs84),需要参数
|
|
|
+ log.info("need to strict transform, code: {}", isJudge);
|
|
|
+ entity.setCoordType(TypeCode.COORD_XIAN_1980);
|
|
|
+
|
|
|
+ } else if (0 == isJudge){
|
|
|
+ // 不转换坐标 把文件信息移动到CoordStrictPath 这路径下
|
|
|
+ log.info("not to transform");
|
|
|
+ entity.setCoordType(TypeCode.COORD_WGS84);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.info("error exeCmd");
|
|
|
+ entity.setStatus(7);
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ vectorServer.save(entity);
|
|
|
+ return entity;
|
|
|
}
|
|
|
|
|
|
|
|
|
@ApiOperation("获取矢量数据列表")
|
|
|
@PostMapping(value = "list")
|
|
|
private R list(@RequestBody PageDto param){
|
|
|
-// log.info("run list");
|
|
|
return vectorServer.findByType(TypeCode.FILE_TYPE_VECTOR, param);
|
|
|
}
|
|
|
|
|
@@ -133,7 +181,6 @@ public class VectorController {
|
|
|
@GetMapping("command/judge/coord/{fileId}/")
|
|
|
private R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run cmdJudgeCoord: {}", fileId);
|
|
|
-// FileEntity entity = fileServer.findById(fileId);
|
|
|
|
|
|
OutputFileEntity entity = vectorServer.findById(fileId);
|
|
|
entity.setUpdateTime(new Date());
|
|
@@ -228,24 +275,10 @@ public class VectorController {
|
|
|
// 不转换坐标 把文件信息移动到CoordStrictPath 这路径下
|
|
|
log.info("not to transform");
|
|
|
|
|
|
- // 若果改成用一张表,这里需要修改
|
|
|
-// FileEntity fileEntity = vectorServer.findByFileName(entity.getFileName());
|
|
|
-//
|
|
|
-// String shpPath = OUTPUT_FILE_PATH + "transform" + File.separator + fileEntity.getDirectory();
|
|
|
-// FileUtils.createDir(shpPath);
|
|
|
-// shpPath = shpPath + "transform" + File.separator + entity.getFileName();
|
|
|
-// entity.setCoordStrictPath(shpPath);
|
|
|
-//
|
|
|
-// try {
|
|
|
-// String uploadPath = entity.getUploadPath();
|
|
|
-// uploadPath= StringUtils.substringBeforeLast(uploadPath, "/");
|
|
|
-// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(new File(uploadPath), new File(OUTPUT_FILE_PATH + "transform"));
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
entity.setCoordStrictPath(entity.getUploadPath());
|
|
|
entity.setUpdateTime(new Date());
|
|
|
entity.setStatus(3);
|
|
|
+ entity.setCoordType(TypeCode.COORD_WGS84);
|
|
|
vectorServer.save(entity);
|
|
|
} else {
|
|
|
log.info("error exeCmd");
|
|
@@ -254,13 +287,7 @@ public class VectorController {
|
|
|
vectorServer.save(entity);
|
|
|
}
|
|
|
}
|
|
|
-// Thread.sleep(4000);
|
|
|
} catch (Exception e) {
|
|
|
- //出现异常了,修改修改状态
|
|
|
-// entity.setStatus(7);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// vectorServer.save(entity);
|
|
|
-
|
|
|
log.error("error vector consume queue VectorJudgeCoordConsumerThread: {}", e);
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
@@ -308,10 +335,17 @@ public class VectorController {
|
|
|
|
|
|
|
|
|
@ApiOperation("矢量数据切片")
|
|
|
- @GetMapping("command/slice/{fileId}/")
|
|
|
- private R cmdSlice (@PathVariable("fileId") Long fileId) {
|
|
|
+ @GetMapping("command/slice/{fileId}/{layerMin}/{layerMax}/")
|
|
|
+ private R cmdSlice (@PathVariable("fileId") Long fileId, @PathVariable("layerMin") String layerMin, @PathVariable("layerMax") String layerMax) {
|
|
|
log.info("run cmdSlice: {}", fileId);
|
|
|
|
|
|
+ if (!RegexUtils.regexInt(layerMin)){
|
|
|
+ return new R(50010, MsgCode.E50010) ;
|
|
|
+ }
|
|
|
+ if (!RegexUtils.regexInt(layerMax)){
|
|
|
+ return new R(50010, MsgCode.E50010) ;
|
|
|
+ }
|
|
|
+
|
|
|
OutputFileEntity entity = vectorServer.findById(fileId);
|
|
|
|
|
|
String outPath = OUTPUT_FILE_PATH + "slice" + File.separator + entity.getDirectory();
|
|
@@ -320,6 +354,8 @@ public class VectorController {
|
|
|
String cmd = Command.VECTOR_SLICE_TIPPECANOE;
|
|
|
cmd = cmd.replace("@inputFile", entity.getGeojsonPath());
|
|
|
cmd = cmd.replace("@outputFile", outPath);
|
|
|
+ cmd = cmd.replace("@layerMin", layerMin);
|
|
|
+ cmd = cmd.replace("@layerMax", layerMax);
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
|
|
@@ -331,6 +367,8 @@ public class VectorController {
|
|
|
entity.setSlicePath(outPath);
|
|
|
entity.setUpdateTime(new Date());
|
|
|
entity.setStatus(5);
|
|
|
+ entity.setLayerMin(Integer.valueOf(layerMin));
|
|
|
+ entity.setLayerMax(Integer.valueOf(layerMax));
|
|
|
entity = vectorServer.save(entity);
|
|
|
|
|
|
return new R(200, entity);
|
|
@@ -371,7 +409,6 @@ public class VectorController {
|
|
|
cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
|
cmd = cmd.replace("@outputFile", directory);
|
|
|
log.info("cmd: {}", cmd);
|
|
|
-// return runCmd(cmd, entity, directory, null);
|
|
|
return runCmd(cmd, entity, null, directory);
|
|
|
}
|
|
|
|