|
@@ -12,18 +12,20 @@ import com.fd.entity.FileEntity;
|
|
import com.fd.entity.OutputFileEntity;
|
|
import com.fd.entity.OutputFileEntity;
|
|
import com.fd.server.CmdServer;
|
|
import com.fd.server.CmdServer;
|
|
import com.fd.server.RasterServer;
|
|
import com.fd.server.RasterServer;
|
|
|
|
+import com.fd.server.impl.CmdServerImpl;
|
|
|
|
+import com.fd.server.impl.RasterServerImpl;
|
|
import com.fd.util.FileUtils;
|
|
import com.fd.util.FileUtils;
|
|
import com.fd.util.R;
|
|
import com.fd.util.R;
|
|
import com.fd.util.RegexUtils;
|
|
import com.fd.util.RegexUtils;
|
|
|
|
+import com.fd.util.SpringContext;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -48,38 +50,21 @@ public class RasterController {
|
|
@Value("${output.file.path.raster}")
|
|
@Value("${output.file.path.raster}")
|
|
private String OUTPUT_FILE_PATH;
|
|
private String OUTPUT_FILE_PATH;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private CmdServer cmdServer;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private RasterServer rasterServer;
|
|
|
|
|
|
+ private static BlockingQueue<MyQueue> sliceQueue = new LinkedBlockingQueue<MyQueue>(2);
|
|
|
|
|
|
- BlockingQueue<MyQueue> sliceQueue = new LinkedBlockingQueue<MyQueue>(2);
|
|
|
|
|
|
+ private static BlockingQueue<MyQueue> coordQueue = new LinkedBlockingQueue<MyQueue>(2);
|
|
|
|
|
|
- BlockingQueue<MyQueue> coordQueue = new LinkedBlockingQueue<MyQueue>(2);
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 初始化队列
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @PostConstruct
|
|
|
|
- private void init() {
|
|
|
|
-
|
|
|
|
- // 判断坐标消费队列
|
|
|
|
- new Thread(new JudgeCoordConsumerThread(coordQueue)).start();
|
|
|
|
-
|
|
|
|
- // 切片消费队列
|
|
|
|
- new Thread(new SliceConsumerThread(sliceQueue)).start();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
@ApiOperation("上传数据,校验文件名")
|
|
@ApiOperation("上传数据,校验文件名")
|
|
@GetMapping("check/{fileName}/")
|
|
@GetMapping("check/{fileName}/")
|
|
private R checkFileName(@PathVariable("fileName") String fileName) {
|
|
private R checkFileName(@PathVariable("fileName") String fileName) {
|
|
log.info("run checkFileName: {}",fileName);
|
|
log.info("run checkFileName: {}",fileName);
|
|
|
|
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
|
|
+
|
|
|
|
|
|
// 文件是否包含中文字符
|
|
// 文件是否包含中文字符
|
|
if (RegexUtils.regexChinese(fileName)) {
|
|
if (RegexUtils.regexChinese(fileName)) {
|
|
@@ -108,6 +93,9 @@ public class RasterController {
|
|
log.info("coord: {}", Arrays.toString(coord));
|
|
log.info("coord: {}", Arrays.toString(coord));
|
|
String strCoord = Arrays.toString(coord);
|
|
String strCoord = Arrays.toString(coord);
|
|
|
|
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
|
|
+ CmdServer cmdServer = SpringContext.getBean(CmdServerImpl.class);
|
|
|
|
+
|
|
// 文件名全名
|
|
// 文件名全名
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|
|
|
|
|
|
@@ -132,7 +120,7 @@ public class RasterController {
|
|
OutputFileEntity entity = (OutputFileEntity) r.getData();
|
|
OutputFileEntity entity = (OutputFileEntity) r.getData();
|
|
|
|
|
|
// 判断坐标
|
|
// 判断坐标
|
|
- entity = JudgeCoord(entity);
|
|
|
|
|
|
+ entity = JudgeCoord(entity, rasterServer, cmdServer);
|
|
|
|
|
|
return new R(200, entity);
|
|
return new R(200, entity);
|
|
|
|
|
|
@@ -142,7 +130,7 @@ public class RasterController {
|
|
* 上传后判断坐标,显示原始坐标
|
|
* 上传后判断坐标,显示原始坐标
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private OutputFileEntity JudgeCoord(OutputFileEntity entity){
|
|
|
|
|
|
+ private OutputFileEntity JudgeCoord(OutputFileEntity entity, RasterServer rasterServer, CmdServer cmdServer){
|
|
|
|
|
|
String cmd = Command.RASTER_JUDGE_COORD;
|
|
String cmd = Command.RASTER_JUDGE_COORD;
|
|
cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
@@ -174,28 +162,17 @@ public class RasterController {
|
|
@ApiOperation("获取栅格数据列表")
|
|
@ApiOperation("获取栅格数据列表")
|
|
@PostMapping(value = "list")
|
|
@PostMapping(value = "list")
|
|
private R list(@RequestBody PageDto param){
|
|
private R list(@RequestBody PageDto param){
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
return rasterServer.findByType(TypeCode.FILE_TYPE_RASTER, param);
|
|
return rasterServer.findByType(TypeCode.FILE_TYPE_RASTER, param);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// /**
|
|
|
|
-// * 删除文件
|
|
|
|
-// */
|
|
|
|
-// @ApiOperation("删除文件")
|
|
|
|
-// @GetMapping("delete/{fileId}/")
|
|
|
|
-// private R deleteFile(@PathVariable("fileId") Long fileId) {
|
|
|
|
-// log.info("run deleteFile: {}", fileId);
|
|
|
|
-// return rasterServer.deleteById(fileId);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
@ApiOperation("删除文件")
|
|
@ApiOperation("删除文件")
|
|
@GetMapping("delete/{fileId}/")
|
|
@GetMapping("delete/{fileId}/")
|
|
private R deleteFile(@PathVariable("fileId") Long fileId) {
|
|
private R deleteFile(@PathVariable("fileId") Long fileId) {
|
|
log.info("run deleteFile: {}", fileId);
|
|
log.info("run deleteFile: {}", fileId);
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
|
|
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
entity.setResStatus(1);
|
|
entity.setResStatus(1);
|
|
@@ -205,32 +182,34 @@ public class RasterController {
|
|
fileEntity.setResStatus(1);
|
|
fileEntity.setResStatus(1);
|
|
rasterServer.saveInputFile(fileEntity);
|
|
rasterServer.saveInputFile(fileEntity);
|
|
|
|
|
|
- new Thread(new RasterDeleteThread(fileId)).start();
|
|
|
|
- log.info("delete vector id");
|
|
|
|
|
|
+ runDeleteThread(fileId, rasterServer);
|
|
|
|
+
|
|
|
|
+ log.info("delete raster id: {}", fileId);
|
|
return new R(200, MsgCode.SUCCESS);
|
|
return new R(200, MsgCode.SUCCESS);
|
|
}
|
|
}
|
|
|
|
|
|
- public class RasterDeleteThread implements Runnable{
|
|
|
|
-
|
|
|
|
- private Long fileId;
|
|
|
|
-
|
|
|
|
- public RasterDeleteThread(Long fileId){
|
|
|
|
- this.fileId = fileId;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- log.info("run RasterDeleteThread");
|
|
|
|
- rasterServer.deleteById(fileId);
|
|
|
|
- log.info("end RasterDeleteThread: {}", fileId);
|
|
|
|
|
|
+ @Async("taskExecutor")
|
|
|
|
+ public void runDeleteThread(Long fileId, RasterServer rasterServer) {
|
|
|
|
+ log.info("run RasterDeleteThread");
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(2000);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+ rasterServer.deleteById(fileId);
|
|
|
|
+ log.info("end RasterDeleteThread: {}", fileId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@ApiOperation("栅格数据判断坐标")
|
|
@ApiOperation("栅格数据判断坐标")
|
|
@GetMapping("command/judge/coord/{fileId}/")
|
|
@GetMapping("command/judge/coord/{fileId}/")
|
|
private R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
private R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
log.info("run cmdJudgeCoord: {}", fileId);
|
|
log.info("run cmdJudgeCoord: {}", fileId);
|
|
|
|
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
|
|
+ CmdServer cmdServer = SpringContext.getBean(CmdServerImpl.class);
|
|
|
|
+
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
|
|
|
|
|
|
|
|
@@ -239,11 +218,6 @@ public class RasterController {
|
|
log.info("cmd: {}", cmd);
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
|
|
|
|
-// entity.setStatus(9);
|
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
|
-// entity = rasterServer.save(entity);
|
|
|
|
-// log.info("coord entity: {}",entity);
|
|
|
|
-// log.info("coord producer update time: {}", entity.getUpdateTime());
|
|
|
|
|
|
|
|
// 把数据放入队列中
|
|
// 把数据放入队列中
|
|
MyQueue data = new MyQueue();
|
|
MyQueue data = new MyQueue();
|
|
@@ -265,77 +239,64 @@ public class RasterController {
|
|
entity = rasterServer.save(entity);
|
|
entity = rasterServer.save(entity);
|
|
log.info("coord entity: {}",entity);
|
|
log.info("coord entity: {}",entity);
|
|
log.info("coord producer update time: {}", entity.getUpdateTime());
|
|
log.info("coord producer update time: {}", entity.getUpdateTime());
|
|
|
|
+
|
|
|
|
+ judgeCoordConsumerThread(coordQueue, rasterServer, cmdServer);
|
|
|
|
+
|
|
return new R(200, entity);
|
|
return new R(200, entity);
|
|
}
|
|
}
|
|
return new R(52000, MsgCode.E52000);
|
|
return new R(52000, MsgCode.E52000);
|
|
-// return new R(200, entity);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Async("taskExecutor")
|
|
|
|
+ public void judgeCoordConsumerThread(BlockingQueue<MyQueue> queue, RasterServer rasterServer, CmdServer cmdServer){
|
|
|
|
+ MyQueue data = null;
|
|
|
|
+ try {
|
|
|
|
+ data = queue.poll(3, TimeUnit.SECONDS);
|
|
|
|
+
|
|
|
|
+ if (data != null) {
|
|
|
|
+ log.warn("run JudgeCoordConsumerThread");
|
|
|
|
+
|
|
|
|
+ // 先让它等一秒
|
|
|
|
+ log.info("start time: {}", new Date());
|
|
|
|
+ Thread.sleep(2000);
|
|
|
|
+ log.info("end time: {}", new Date());
|
|
|
|
+
|
|
|
|
+ OutputFileEntity entity = data.getOutputFile();
|
|
|
|
+
|
|
|
|
+ log.info("CoordType: {}", entity.getCoordType());
|
|
|
|
+
|
|
|
|
+ if (TypeCode.COORD_XIAN_1980.equals(entity.getCoordType())){
|
|
|
|
+ log.info("need to transform");
|
|
|
|
+ // 严格坐标转换
|
|
|
|
+ entity = cmdTansformGdalwarpStrict(entity, rasterServer, cmdServer);
|
|
|
|
+ } else if (TypeCode.COORD_WGS84.equals(entity.getCoordType())){
|
|
|
|
+ log.info("not to transform");
|
|
|
|
+ // 4:未切片
|
|
|
|
+ entity.setStatus(4);
|
|
|
|
+ // 不需要转,就把上传文件路径复制到严格坐标路径上
|
|
|
|
+ entity.setCoordStrictPath(entity.getUploadPath());
|
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
+ entity = rasterServer.save(entity);
|
|
|
|
+ log.info("coord Consumer update time: {}", entity.getUpdateTime());
|
|
|
|
+ log.info("JudgeCoordConsumerThread update entity: {}", entity);
|
|
|
|
+ } else {
|
|
|
|
+ log.info("error exeCmd");
|
|
|
|
+ entity.setStatus(0);
|
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
+ rasterServer.save(entity);
|
|
|
|
+ }
|
|
|
|
+ log.warn("end JudgeCoordConsumerThread id: {}", entity.getId());
|
|
|
|
|
|
- /**
|
|
|
|
- * 坐标转换消费队列
|
|
|
|
- */
|
|
|
|
- public class JudgeCoordConsumerThread implements Runnable{
|
|
|
|
-
|
|
|
|
- private BlockingQueue<MyQueue> queue;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- private boolean isRun = true;
|
|
|
|
- public JudgeCoordConsumerThread(BlockingQueue<MyQueue> queue){
|
|
|
|
- this.queue = queue;
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- while (true) {
|
|
|
|
- try {
|
|
|
|
-
|
|
|
|
- MyQueue data = queue.poll(3, TimeUnit.SECONDS);
|
|
|
|
- if (data != null) {
|
|
|
|
- log.warn("run JudgeCoordConsumerThread");
|
|
|
|
-
|
|
|
|
- // 先让它等一秒
|
|
|
|
- log.info("start time: {}", new Date());
|
|
|
|
- Thread.sleep(2000);
|
|
|
|
- log.info("end time: {}", new Date());
|
|
|
|
-
|
|
|
|
- OutputFileEntity entity = data.getOutputFile();
|
|
|
|
-
|
|
|
|
- log.info("CoordType: {}", entity.getCoordType());
|
|
|
|
-
|
|
|
|
- if (TypeCode.COORD_XIAN_1980.equals(entity.getCoordType())){
|
|
|
|
- log.info("need to transform");
|
|
|
|
- // 严格坐标转换
|
|
|
|
- entity = cmdTansformGdalwarpStrict(entity);
|
|
|
|
- } else if (TypeCode.COORD_WGS84.equals(entity.getCoordType())){
|
|
|
|
- log.info("not to transform");
|
|
|
|
- // 4:未切片
|
|
|
|
- entity.setStatus(4);
|
|
|
|
- // 不需要转,就把上传文件路径复制到严格坐标路径上
|
|
|
|
- entity.setCoordStrictPath(entity.getUploadPath());
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- entity = rasterServer.save(entity);
|
|
|
|
- log.info("coord Consumer update time: {}", entity.getUpdateTime());
|
|
|
|
- log.info("JudgeCoordConsumerThread update entity: {}", entity);
|
|
|
|
- } else {
|
|
|
|
- log.info("error exeCmd");
|
|
|
|
- entity.setStatus(0);
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- rasterServer.save(entity);
|
|
|
|
- }
|
|
|
|
- log.warn("end JudgeCoordConsumerThread id: {}", entity.getId());
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- Thread.currentThread().interrupt();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- log.error("error consume queue raster JudgeCoordConsumerThread: {}", e);
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@ApiOperation("栅格数据切片命令")
|
|
@ApiOperation("栅格数据切片命令")
|
|
@GetMapping("command/osgeo/{fileId}/{layerMin}/{layerMax}/")
|
|
@GetMapping("command/osgeo/{fileId}/{layerMin}/{layerMax}/")
|
|
private R cmdSlice(@PathVariable("fileId") Long fileId, @PathVariable("layerMin") String layerMin, @PathVariable("layerMax") String layerMax) {
|
|
private R cmdSlice(@PathVariable("fileId") Long fileId, @PathVariable("layerMin") String layerMin, @PathVariable("layerMax") String layerMax) {
|
|
@@ -347,7 +308,8 @@ public class RasterController {
|
|
if (!RegexUtils.regexInt(layerMax)){
|
|
if (!RegexUtils.regexInt(layerMax)){
|
|
return new R(50010, MsgCode.E50010) ;
|
|
return new R(50010, MsgCode.E50010) ;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
|
|
+ CmdServer cmdServer = SpringContext.getBean(CmdServerImpl.class);
|
|
|
|
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
|
|
|
|
@@ -365,16 +327,6 @@ public class RasterController {
|
|
log.info("cmd: {}", cmd);
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
|
|
|
|
-// // 设个默认进度给前端显示
|
|
|
|
-// entity.setProgress(1);
|
|
|
|
-// entity.setStatus(6);
|
|
|
|
-// entity.setLayerMin(Integer.valueOf(layerMin));
|
|
|
|
-// entity.setLayerMax(Integer.valueOf(layerMax));
|
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
|
-// entity.setSlicePath(outFilePath);
|
|
|
|
-//
|
|
|
|
-// entity = rasterServer.save(entity);
|
|
|
|
-
|
|
|
|
|
|
|
|
// 把数据放入队列中
|
|
// 把数据放入队列中
|
|
MyQueue data = new MyQueue();
|
|
MyQueue data = new MyQueue();
|
|
@@ -390,72 +342,61 @@ public class RasterController {
|
|
}
|
|
}
|
|
|
|
|
|
if (offer) {
|
|
if (offer) {
|
|
- // 设个默认进度给前端显示
|
|
|
|
- entity.setProgress(1);
|
|
|
|
- entity.setStatus(6);
|
|
|
|
- entity.setLayerMin(Integer.valueOf(layerMin));
|
|
|
|
- entity.setLayerMax(Integer.valueOf(layerMax));
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- entity.setSlicePath(outFilePath);
|
|
|
|
|
|
+ // 设个默认进度给前端显示
|
|
|
|
+ entity.setProgress(1);
|
|
|
|
+ entity.setStatus(6);
|
|
|
|
+ entity.setLayerMin(Integer.valueOf(layerMin));
|
|
|
|
+ entity.setLayerMax(Integer.valueOf(layerMax));
|
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
+ entity.setSlicePath(outFilePath);
|
|
|
|
|
|
- entity = rasterServer.save(entity);
|
|
|
|
|
|
+ entity = rasterServer.save(entity);
|
|
|
|
+
|
|
|
|
+ sliceThread(sliceQueue, rasterServer, cmdServer);
|
|
|
|
|
|
return new R(200, entity) ;
|
|
return new R(200, entity) ;
|
|
}
|
|
}
|
|
return new R(52000, MsgCode.E52000);
|
|
return new R(52000, MsgCode.E52000);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 切片消费队列
|
|
|
|
- */
|
|
|
|
- public class SliceConsumerThread implements Runnable{
|
|
|
|
-
|
|
|
|
- private BlockingQueue<MyQueue> queue;
|
|
|
|
- private boolean isRun = true;
|
|
|
|
- public SliceConsumerThread(BlockingQueue<MyQueue> queue){
|
|
|
|
- this.queue = queue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- while (isRun) {
|
|
|
|
- try {
|
|
|
|
- MyQueue data = queue.poll(2, TimeUnit.SECONDS);
|
|
|
|
- if (data != null) {
|
|
|
|
- log.warn("run SliceConsumerThread");
|
|
|
|
- OutputFileEntity entity = data.getOutputFile();
|
|
|
|
- log.info("raster cmd: {}", data.getStr());
|
|
|
|
- Integer integer = cmdServer.exeCmdRasterSlice(data.getStr(), entity);
|
|
|
|
- if (integer != 0) {
|
|
|
|
- log.info("error command exeCmdRasterSlice");
|
|
|
|
- // 如果命令运行失败,状态改为0
|
|
|
|
- entity.setStatus(0);
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- rasterServer.save(entity);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- // 切片完成,修改完成状态
|
|
|
|
- entity.setStatus(5);
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- rasterServer.save(entity);
|
|
|
|
- log.warn("end SliceConsumerThread");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- Thread.currentThread().interrupt();
|
|
|
|
-
|
|
|
|
- log.error("error consume queue raster SliceConsumerThread: {}", e);
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ @Async("taskExecutor")
|
|
|
|
+ public void sliceThread(BlockingQueue<MyQueue> queue, RasterServer rasterServer, CmdServer cmdServer) {
|
|
|
|
+ try {
|
|
|
|
+ MyQueue data = queue.poll(2, TimeUnit.SECONDS);
|
|
|
|
+ if (data != null) {
|
|
|
|
+ log.warn("run SliceConsumerThread");
|
|
|
|
+ OutputFileEntity entity = data.getOutputFile();
|
|
|
|
+ log.info("raster cmd: {}", data.getStr());
|
|
|
|
+ Integer integer = cmdServer.exeCmdRasterSlice(data.getStr(), entity);
|
|
|
|
+ if (integer != 0) {
|
|
|
|
+ log.info("error command exeCmdRasterSlice");
|
|
|
|
+ // 如果命令运行失败,状态改为0
|
|
|
|
+ entity.setStatus(0);
|
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
+ rasterServer.save(entity);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
+ // 切片完成,修改完成状态
|
|
|
|
+ entity.setStatus(5);
|
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
+ rasterServer.save(entity);
|
|
|
|
+ log.warn("end SliceConsumerThread");
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@ApiOperation("栅格数据进度查询")
|
|
@ApiOperation("栅格数据进度查询")
|
|
@GetMapping("progress/{fileId}/")
|
|
@GetMapping("progress/{fileId}/")
|
|
private R getProgress(@PathVariable("fileId") Long fileId) {
|
|
private R getProgress(@PathVariable("fileId") Long fileId) {
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
OutputFileEntity entity = rasterServer.findById(fileId);
|
|
return new R(200, entity);
|
|
return new R(200, entity);
|
|
}
|
|
}
|
|
@@ -465,6 +406,7 @@ public class RasterController {
|
|
@PostMapping("move/{fileId}/")
|
|
@PostMapping("move/{fileId}/")
|
|
private R moveFile(@PathVariable("fileId") Long fileId, @RequestBody ConfigJsonDto param) {
|
|
private R moveFile(@PathVariable("fileId") Long fileId, @RequestBody ConfigJsonDto param) {
|
|
log.info("run moveFile: {}", fileId);
|
|
log.info("run moveFile: {}", fileId);
|
|
|
|
+ RasterServer rasterServer = SpringContext.getBean(RasterServerImpl.class);
|
|
return rasterServer.moveFileToServer(fileId, param);
|
|
return rasterServer.moveFileToServer(fileId, param);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -473,9 +415,10 @@ public class RasterController {
|
|
/**
|
|
/**
|
|
* 严格坐标转换
|
|
* 严格坐标转换
|
|
*/
|
|
*/
|
|
- private OutputFileEntity cmdTansformGdalwarpStrict(OutputFileEntity entity){
|
|
|
|
|
|
+ private OutputFileEntity cmdTansformGdalwarpStrict(OutputFileEntity entity, RasterServer rasterServer, CmdServer cmdServer){
|
|
log.info("run cmdTansformGdalwarpStrict");
|
|
log.info("run cmdTansformGdalwarpStrict");
|
|
|
|
|
|
|
|
+
|
|
String fileName = StringUtils.substringBeforeLast(entity.getFileName(), ".");
|
|
String fileName = StringUtils.substringBeforeLast(entity.getFileName(), ".");
|
|
|
|
|
|
String outFileStep1 = OUTPUT_FILE_PATH + "transform";
|
|
String outFileStep1 = OUTPUT_FILE_PATH + "transform";
|
|
@@ -551,20 +494,4 @@ public class RasterController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
|
- String [] a = {"1.1","1.2","1.3"};
|
|
|
|
- System.out.println("a: " + Arrays.toString(a));
|
|
|
|
-
|
|
|
|
- String b = Arrays.toString(a);
|
|
|
|
-
|
|
|
|
- JSONArray array = JSON.parseArray(b);
|
|
|
|
- System.out.println(array.getString(2));
|
|
|
|
- System.out.println(array.getString(1));
|
|
|
|
- System.out.println(array.get(1));
|
|
|
|
- System.out.println(array.get(0));
|
|
|
|
- System.out.println(array.get(3));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|