|
@@ -6,6 +6,7 @@ import com.fd.constant.TypeCode;
|
|
|
import com.fd.dto.MyQueue;
|
|
|
import com.fd.dto.PageDto;
|
|
|
import com.fd.entity.FileEntity;
|
|
|
+import com.fd.entity.OutputFileEntity;
|
|
|
import com.fd.server.CmdServer;
|
|
|
import com.fd.server.FileServer;
|
|
|
import com.fd.server.RasterServer;
|
|
@@ -83,14 +84,16 @@ public class RasterController {
|
|
|
return new R(50008,MsgCode.E50008);
|
|
|
}
|
|
|
|
|
|
- return fileServer.uploadRasterBigFile(file, TypeCode.FILE_TYPE_RASTER);
|
|
|
+// return fileServer.uploadRasterBigFile(file, TypeCode.FILE_TYPE_RASTER);
|
|
|
+ return rasterServer.uploadBigFile(file);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取栅格数据列表")
|
|
|
@PostMapping(value = "list")
|
|
|
private R list(@RequestBody PageDto param){
|
|
|
log.info("run list");
|
|
|
- return fileServer.findByType(TypeCode.FILE_TYPE_RASTER, param);
|
|
|
+ return rasterServer.findByType(TypeCode.FILE_TYPE_RASTER, param);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -108,10 +111,14 @@ public class RasterController {
|
|
|
@GetMapping("command/judge/coord/{fileId}/")
|
|
|
private R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run cmdJudgeCoord: {}", fileId);
|
|
|
- FileEntity entity = fileServer.findById(fileId);
|
|
|
+// FileEntity entity = fileServer.findById(fileId);
|
|
|
+
|
|
|
+
|
|
|
+ OutputFileEntity entity = rasterServer.findById(fileId);
|
|
|
+
|
|
|
|
|
|
String cmd = Command.RASTER_JUDGE_COORD;
|
|
|
- cmd = cmd.replace("@inputFile", entity.getFileUrl());
|
|
|
+ cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
Integer isJudge = cmdServer.exeCmdRasterJudgeCoord(cmd);
|
|
@@ -119,7 +126,7 @@ public class RasterController {
|
|
|
if (1000 == isJudge){
|
|
|
log.info("need to transform");
|
|
|
// 严格坐标转换
|
|
|
- entity = cmdTansformGdalwarpStrict(fileId);
|
|
|
+ entity = cmdTansformGdalwarpStrict(entity);
|
|
|
} else if (0 == isJudge){
|
|
|
log.info("not to transform");
|
|
|
} else {
|
|
@@ -136,7 +143,7 @@ public class RasterController {
|
|
|
@GetMapping("command/osgeo/{fileId}/")
|
|
|
private R cmdOsgeo(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run cmdOsgeo: {}", fileId);
|
|
|
- FileEntity entity = fileServer.findById(fileId);
|
|
|
+ OutputFileEntity entity = rasterServer.findById(fileId);
|
|
|
|
|
|
String fileName = StringUtils.substringBeforeLast(entity.getFileName(), ".");
|
|
|
// fileName_tiles
|
|
@@ -147,27 +154,35 @@ public class RasterController {
|
|
|
|
|
|
|
|
|
String cmd = Command.RASTER_SLICE_OSGEO;
|
|
|
- cmd = cmd.replace("@inputFile", entity.getFileUrl());
|
|
|
+ cmd = cmd.replace("@inputFile", entity.getCoordStrictPath());
|
|
|
cmd = cmd.replace("@outputFile", outFilePath);
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
|
|
|
- FileEntity fileEntity = new FileEntity();
|
|
|
- fileEntity.setFileName(fileName);
|
|
|
- fileEntity.setFileUrl(INPUT_FILE_PATH + fileName);
|
|
|
- fileEntity.setCreateTime(new Date());
|
|
|
- fileEntity.setUpdateTime(new Date());
|
|
|
- fileEntity.setType(TypeCode.FILE_TYPE_RASTER);
|
|
|
- // 设个默认经度给前端显示
|
|
|
- fileEntity.setProgress(1);
|
|
|
- fileEntity.setStatus(6);
|
|
|
+// FileEntity fileEntity = new FileEntity();
|
|
|
+// fileEntity.setFileName(fileName);
|
|
|
+// fileEntity.setFileUrl(INPUT_FILE_PATH + fileName);
|
|
|
+// fileEntity.setCreateTime(new Date());
|
|
|
+// fileEntity.setUpdateTime(new Date());
|
|
|
+// fileEntity.setType(TypeCode.FILE_TYPE_RASTER);
|
|
|
+// // 设个默认进度给前端显示
|
|
|
+// fileEntity.setProgress(1);
|
|
|
+// fileEntity.setStatus(6);
|
|
|
+//
|
|
|
+// fileEntity = fileServer.save(fileEntity);
|
|
|
+
|
|
|
+ // 设个默认进度给前端显示
|
|
|
+ entity.setProgress(1);
|
|
|
+ entity.setStatus(6);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ entity.setSlicePath(outFilePath);
|
|
|
|
|
|
- fileEntity = fileServer.save(fileEntity);
|
|
|
+ entity = rasterServer.save(entity);
|
|
|
|
|
|
// 多线程运行切片
|
|
|
- new Thread(new RasterSliceThread(cmd, fileEntity)).start();
|
|
|
+ new Thread(new RasterSliceThread(cmd, entity)).start();
|
|
|
|
|
|
- return new R(200, fileEntity) ;
|
|
|
+ return new R(200, entity) ;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -175,9 +190,9 @@ public class RasterController {
|
|
|
|
|
|
private String cmd;
|
|
|
|
|
|
- private FileEntity entity;
|
|
|
+ private OutputFileEntity entity;
|
|
|
|
|
|
- private RasterSliceThread(String cmd, FileEntity entity){
|
|
|
+ private RasterSliceThread(String cmd, OutputFileEntity entity){
|
|
|
this.cmd = cmd;
|
|
|
this.entity = entity;
|
|
|
}
|
|
@@ -188,14 +203,15 @@ public class RasterController {
|
|
|
Integer integer = cmdServer.exeCmdRasterSlice(cmd, entity);
|
|
|
if (integer != 0) {
|
|
|
log.info("error command exeCmdRasterSlice");
|
|
|
- // 如果命令运行失败,删除刚才创建的实体类
|
|
|
- fileServer.deleteById(entity.getId());
|
|
|
+ // 如果命令运行失败,状态改为0
|
|
|
+ entity.setStatus(0);
|
|
|
+ rasterServer.save(entity);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 修改状态, 告诉前端切片完成
|
|
|
entity.setStatus(5);
|
|
|
- fileServer.save(entity);
|
|
|
+ rasterServer.save(entity);
|
|
|
log.warn("end RasterSliceThread");
|
|
|
}
|
|
|
}
|
|
@@ -204,7 +220,7 @@ public class RasterController {
|
|
|
@GetMapping("progress/{fileId}/")
|
|
|
private R getProgress(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run getProgress: {}", fileId);
|
|
|
- FileEntity entity = fileServer.findById(fileId);
|
|
|
+ OutputFileEntity entity = rasterServer.findById(fileId);
|
|
|
return new R(200, entity);
|
|
|
}
|
|
|
|
|
@@ -218,16 +234,26 @@ public class RasterController {
|
|
|
|
|
|
|
|
|
// 严格坐标转换
|
|
|
- private FileEntity cmdTansformGdalwarpStrict(Long fileId){
|
|
|
- log.info("run cmdTansformGdalwarpStrict: {}", fileId);
|
|
|
- FileEntity entity = fileServer.findById(fileId);
|
|
|
+ private OutputFileEntity cmdTansformGdalwarpStrict(OutputFileEntity entity){
|
|
|
+ log.info("run cmdTansformGdalwarpStrict");
|
|
|
|
|
|
String fileName = StringUtils.substringBeforeLast(entity.getFileName(), ".");
|
|
|
|
|
|
+ String outFileStep1 = OUTPUT_FILE_PATH + "transform";
|
|
|
+ FileUtils.createDir(outFileStep1);
|
|
|
+ outFileStep1 = outFileStep1 + File.separator + entity.getFileName();
|
|
|
+
|
|
|
String step_1 = Command.RASTER_TRANSFORM_GDALWARP_STRICT_1;
|
|
|
String step_2 = Command.RASTER_TRANSFORM_GDALWARP_STRICT_2;
|
|
|
- step_1 = step_1.replace("@fileName",fileName);
|
|
|
- step_2 = step_2.replace("@fileName",fileName);
|
|
|
+ step_1 = step_1.replace("@inputFile", entity.getUploadPath());
|
|
|
+ step_1 = step_1.replace("@outputFile", outFileStep1);
|
|
|
+
|
|
|
+ String outFileStep2 = OUTPUT_FILE_PATH + "transform_strict";
|
|
|
+ FileUtils.createDir(outFileStep2);
|
|
|
+ outFileStep2 = outFileStep2 + File.separator + entity.getFileName();
|
|
|
+
|
|
|
+ step_2 = step_2.replace("@inputFile", outFileStep1);
|
|
|
+ step_2 = step_2.replace("@outputFile", outFileStep2);
|
|
|
log.info("cmd1: {}", step_1);
|
|
|
log.info("cmd2: {}", step_2);
|
|
|
|
|
@@ -238,17 +264,24 @@ public class RasterController {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- FileEntity fileEntity = new FileEntity();
|
|
|
- fileEntity.setFileName(entity.getFileName());
|
|
|
- fileEntity.setFileUrl(INPUT_FILE_PATH + "transform_strict" + File.separator + entity.getFileName());
|
|
|
- fileEntity.setCreateTime(new Date());
|
|
|
- fileEntity.setUpdateTime(new Date());
|
|
|
- fileEntity.setType(TypeCode.FILE_TYPE_RASTER);
|
|
|
- fileEntity.setStatus(4);
|
|
|
+ entity.setStatus(4);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ entity.setCoordGeneralPath(outFileStep1);
|
|
|
+ entity.setCoordStrictPath(outFileStep2);
|
|
|
+
|
|
|
+ entity = rasterServer.save(entity);
|
|
|
|
|
|
- fileEntity = fileServer.save(fileEntity);
|
|
|
+// FileEntity fileEntity = new FileEntity();
|
|
|
+// fileEntity.setFileName(entity.getFileName());
|
|
|
+// fileEntity.setFileUrl(INPUT_FILE_PATH + "transform_strict" + File.separator + entity.getFileName());
|
|
|
+// fileEntity.setCreateTime(new Date());
|
|
|
+// fileEntity.setUpdateTime(new Date());
|
|
|
+// fileEntity.setType(TypeCode.FILE_TYPE_RASTER);
|
|
|
+// fileEntity.setStatus(4);
|
|
|
+//
|
|
|
+// fileEntity = fileServer.save(fileEntity);
|
|
|
|
|
|
- return fileEntity;
|
|
|
+ return entity;
|
|
|
}
|
|
|
|
|
|
}
|