|
@@ -15,6 +15,7 @@ import com.fd.entity.StyleEntity;
|
|
|
import com.fd.server.CmdServer;
|
|
|
import com.fd.server.VectorServer;
|
|
|
import com.fd.server.impl.VectorServerImpl;
|
|
|
+import com.fd.thread.AsyncTask;
|
|
|
import com.fd.util.FileUtils;
|
|
|
import com.fd.util.R;
|
|
|
import com.fd.util.RegexUtils;
|
|
@@ -48,20 +49,26 @@ import java.util.concurrent.TimeUnit;
|
|
|
@RestController
|
|
|
public class VectorController {
|
|
|
|
|
|
-// @Value("${input.file.path.vector}")
|
|
|
- private static String INPUT_FILE_PATH = "/root/gis/cesium/input/vector/";
|
|
|
+//// @Value("${input.file.path.vector}")
|
|
|
+// private static String INPUT_FILE_PATH = "/root/gis/cesium/input/vector/";
|
|
|
+//
|
|
|
+//// @Value("${output.file.path.vector}")
|
|
|
+// private static String OUTPUT_FILE_PATH = "/root/gis/cesium/output/vector/";
|
|
|
|
|
|
-// @Value("${output.file.path.vector}")
|
|
|
- private static String OUTPUT_FILE_PATH = "/root/gis/cesium/output/vector/";
|
|
|
+ @Value("${input.file.path.vector}")
|
|
|
+ private String INPUT_FILE_PATH;
|
|
|
|
|
|
+ @Value("${output.file.path.vector}")
|
|
|
+ private String OUTPUT_FILE_PATH;
|
|
|
|
|
|
|
|
|
|
|
|
-// @Autowired
|
|
|
-// private VectorServer vectorServer;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// private CmdServer cmdServer;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private VectorServer vectorServer;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AsyncTask asyncTask;
|
|
|
|
|
|
/**
|
|
|
* 需要坐标转换
|
|
@@ -121,7 +128,7 @@ public class VectorController {
|
|
|
if (RegexUtils.regexChinese(directoryName)) {
|
|
|
return new R(51005, MsgCode.E51005);
|
|
|
}
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
List<FileEntity> directory = vectorServer.findByDirectory(directoryName);
|
|
|
if (directory.size() > 0) {
|
|
|
return new R(51006, MsgCode.E51006);
|
|
@@ -204,7 +211,7 @@ public class VectorController {
|
|
|
@ApiOperation("获取矢量数据列表")
|
|
|
@PostMapping(value = "list")
|
|
|
private R list(@RequestBody PageDto param) {
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
return vectorServer.findByType(TypeCode.FILE_TYPE_VECTOR, param);
|
|
|
}
|
|
|
|
|
@@ -218,7 +225,7 @@ public class VectorController {
|
|
|
@GetMapping("delete/{fileId}/")
|
|
|
private R deleteFile(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run deleteFile: {}", fileId);
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
OutputFileEntity entity = vectorServer.findById(fileId);
|
|
|
entity.setResStatus(1);
|
|
|
vectorServer.save(entity);
|
|
@@ -228,39 +235,26 @@ public class VectorController {
|
|
|
fileEntity = vectorServer.saveInputFile(fileEntity);
|
|
|
|
|
|
// new Thread(new DeleteThread(fileId)).start();
|
|
|
- deleteThread(fileId, vectorServer);
|
|
|
- log.info("delete vector id");
|
|
|
+// deleteThread(fileId, vectorServer);
|
|
|
+ asyncTask.vectorDelete(fileId, vectorServer);
|
|
|
+ log.info("end delete vector id");
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
- @Async("taskExecutor")
|
|
|
- public void deleteThread(Long fileId, VectorServer vectorServer){
|
|
|
- log.info("run deleteThread");
|
|
|
- vectorServer.deleteById(fileId);
|
|
|
- log.info("end deleteThread id : {}", fileId);
|
|
|
- }
|
|
|
-
|
|
|
-// public class DeleteThread implements Runnable{
|
|
|
-//
|
|
|
-// private Long fileId;
|
|
|
-//
|
|
|
-// public DeleteThread(Long fileId){
|
|
|
-// this.fileId = fileId;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// log.info("run DeleteThread");
|
|
|
-// vectorServer.deleteById(fileId);
|
|
|
-// log.info("end DeleteThread: {}", fileId);
|
|
|
-// }
|
|
|
+// @Async("taskExecutor")
|
|
|
+// public void deleteThread(Long fileId, VectorServer vectorServer){
|
|
|
+// log.info("run deleteThread");
|
|
|
+// vectorServer.deleteById(fileId);
|
|
|
+// log.info("end deleteThread id : {}", fileId);
|
|
|
// }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation("矢量数据判断坐标")
|
|
|
@GetMapping("command/judge/coord/{fileId}/")
|
|
|
private R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run cmdJudgeCoord: {}", fileId);
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
|
|
|
OutputFileEntity entity = vectorServer.findById(fileId);
|
|
|
|
|
@@ -294,7 +288,8 @@ public class VectorController {
|
|
|
entity.setStatus(9);
|
|
|
entity = vectorServer.save(entity);
|
|
|
|
|
|
- convertCoordThread(vectorCoordQueue, vectorServer);
|
|
|
+// convertCoordThread(vectorCoordQueue, vectorServer);
|
|
|
+ asyncTask.vectorConvertCoordThread(vectorCoordQueue, vectorServer, OUTPUT_FILE_PATH);
|
|
|
|
|
|
return new R(200, entity);
|
|
|
}
|
|
@@ -304,219 +299,88 @@ public class VectorController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 坐标判断消费队列
|
|
|
- * 矢量数据转坐标只转一次就成功了。
|
|
|
- * 所以转换的成功的路径都放到strictCoordTransform 路径
|
|
|
- * 文件都放transform 目录
|
|
|
- */
|
|
|
- @Async("taskExecutor")
|
|
|
- public void convertCoordThread (BlockingQueue<MyQueue> queue, VectorServer vectorServer){
|
|
|
- try {
|
|
|
- MyQueue data = queue.poll(2, TimeUnit.SECONDS);
|
|
|
- if (data != null) {
|
|
|
- log.info("run convertCoordThread 出队");
|
|
|
- Thread.sleep(2000);
|
|
|
- OutputFileEntity entity = data.getOutputFile();
|
|
|
- // 坐标处理
|
|
|
- String coord = entity.getCoord();
|
|
|
- log.info("convert coord: {}", coord);
|
|
|
- JSONArray arrayCoord = JSON.parseArray(coord);
|
|
|
-
|
|
|
-
|
|
|
- // 转换坐标 普通坐标转换
|
|
|
- if (TypeCode.COORD_SYSTEM_2000.equals(entity.getCoordType())) {
|
|
|
- // 普通坐标转换
|
|
|
- log.info("need to general transform");
|
|
|
- if (arrayCoord.size() == 0) {
|
|
|
- // 没有坐标参数,执行普通坐标转换(ogrinfo)
|
|
|
- log.info("run generalCoordTransform");
|
|
|
- entity = generalCoordTransform(entity, Command.VECTOR_TRANSFORM_GENERAL, vectorServer);
|
|
|
-
|
|
|
- } else {
|
|
|
- // 有坐标参数,执行严格坐标转换(CGCS2000转wgs80)
|
|
|
- log.info("run strictCoordTransform");
|
|
|
- entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS80, vectorServer);
|
|
|
- }
|
|
|
-
|
|
|
- } else if (TypeCode.COORD_XIAN_1980.equals(entity.getCoordType())) {
|
|
|
-
|
|
|
- // 严格坐标转换 (西安80转wgs84),需要参数
|
|
|
- log.info("need to strict transform, CoordType: {}", entity.getCoordType());
|
|
|
- if (arrayCoord.size() == 0) {
|
|
|
- log.info("error: {}", MsgCode.E50009);
|
|
|
- entity.setStatus(7);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- vectorServer.save(entity);
|
|
|
- } else {
|
|
|
- log.info("run strictCoordTransform");
|
|
|
- entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS84, vectorServer);
|
|
|
- }
|
|
|
-
|
|
|
- } else if (TypeCode.COORD_WGS84.equals(entity.getCoordType())) {
|
|
|
- // 不转换坐标 把文件信息移动到CoordStrictPath 这路径下
|
|
|
- log.info("not to transform");
|
|
|
-
|
|
|
- entity.setCoordStrictPath(entity.getUploadPath());
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- entity.setStatus(3);
|
|
|
- entity.setCoordType(TypeCode.COORD_WGS84);
|
|
|
- vectorServer.save(entity);
|
|
|
- } else {
|
|
|
- log.info("error exeCmd");
|
|
|
- entity.setStatus(7);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- vectorServer.save(entity);
|
|
|
- }
|
|
|
- log.info("end convertCoordThread id: {}", entity.getId());
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- Thread.currentThread().interrupt();
|
|
|
- log.error("error vector consume queue VectorJudgeCoordConsumerThread: {}", e);
|
|
|
- throw new RuntimeException(e);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 坐标判断消费队列
|
|
|
- * <p>
|
|
|
- * 矢量数据转坐标只转一次就成功了。
|
|
|
- * 所以转换的成功的路径都放到strictCoordTransform 路径
|
|
|
- * 文件都放transform 目录
|
|
|
- */
|
|
|
-// public class VectorJudgeCoordConsumerThread implements Runnable {
|
|
|
+// /**
|
|
|
+// * 坐标判断消费队列
|
|
|
+// * 矢量数据转坐标只转一次就成功了。
|
|
|
+// * 所以转换的成功的路径都放到strictCoordTransform 路径
|
|
|
+// * 文件都放transform 目录
|
|
|
+// */
|
|
|
+// @Async("taskExecutor")
|
|
|
+// public void convertCoordThread (BlockingQueue<MyQueue> queue, VectorServer vectorServer){
|
|
|
+// try {
|
|
|
+// MyQueue data = queue.poll(2, TimeUnit.SECONDS);
|
|
|
+// if (data != null) {
|
|
|
+// log.info("run convertCoordThread 出队");
|
|
|
+// Thread.sleep(2000);
|
|
|
+// OutputFileEntity entity = data.getOutputFile();
|
|
|
+// // 坐标处理
|
|
|
+// String coord = entity.getCoord();
|
|
|
+// log.info("convert coord: {}", coord);
|
|
|
+// JSONArray arrayCoord = JSON.parseArray(coord);
|
|
|
//
|
|
|
-// private BlockingQueue<MyQueue> queue;
|
|
|
//
|
|
|
-// private boolean isRun = true;
|
|
|
+// // 转换坐标 普通坐标转换
|
|
|
+// if (TypeCode.COORD_SYSTEM_2000.equals(entity.getCoordType())) {
|
|
|
+// // 普通坐标转换
|
|
|
+// log.info("need to general transform");
|
|
|
+// if (arrayCoord.size() == 0) {
|
|
|
+// // 没有坐标参数,执行普通坐标转换(ogrinfo)
|
|
|
+// log.info("run generalCoordTransform");
|
|
|
+// entity = generalCoordTransform(entity, Command.VECTOR_TRANSFORM_GENERAL, vectorServer);
|
|
|
//
|
|
|
-// public VectorJudgeCoordConsumerThread(BlockingQueue<MyQueue> queue) {
|
|
|
-// this.queue = queue;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// while (true) {
|
|
|
-// try {
|
|
|
-// MyQueue data = queue.poll(2, TimeUnit.SECONDS);
|
|
|
-// if (data != null) {
|
|
|
-// log.info("run VectorJudgeCoordConsumerThread 出队");
|
|
|
-// Thread.sleep(2000);
|
|
|
-// OutputFileEntity entity = data.getOutputFile();
|
|
|
-// // 坐标处理
|
|
|
-// String coord = entity.getCoord();
|
|
|
-// log.info("convert coord: {}", coord);
|
|
|
-// JSONArray arrayCoord = JSON.parseArray(coord);
|
|
|
-//
|
|
|
-//
|
|
|
-// // 转换坐标 普通坐标转换
|
|
|
-// if (TypeCode.COORD_SYSTEM_2000.equals(entity.getCoordType())) {
|
|
|
-// // 普通坐标转换
|
|
|
-// log.info("need to general transform");
|
|
|
-// if (arrayCoord.size() == 0) {
|
|
|
-// // 没有坐标参数,执行普通坐标转换(ogrinfo)
|
|
|
-// log.info("run generalCoordTransform");
|
|
|
-// entity = generalCoordTransform(entity, Command.VECTOR_TRANSFORM_GENERAL);
|
|
|
-//
|
|
|
-// } else {
|
|
|
-// // 有坐标参数,执行严格坐标转换(CGCS2000转wgs80)
|
|
|
-// log.info("run strictCoordTransform");
|
|
|
-// entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS80);
|
|
|
-// }
|
|
|
-//
|
|
|
-// } else if (TypeCode.COORD_XIAN_1980.equals(entity.getCoordType())) {
|
|
|
-//
|
|
|
-// // 严格坐标转换 (西安80转wgs84),需要参数
|
|
|
-// log.info("need to strict transform, CoordType: {}", entity.getCoordType());
|
|
|
-// if (arrayCoord.size() == 0) {
|
|
|
-// log.info("error: {}", MsgCode.E50009);
|
|
|
-// entity.setStatus(7);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// vectorServer.save(entity);
|
|
|
-// } else {
|
|
|
-// log.info("run strictCoordTransform");
|
|
|
-// entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS84);
|
|
|
-// }
|
|
|
+// } else {
|
|
|
+// // 有坐标参数,执行严格坐标转换(CGCS2000转wgs80)
|
|
|
+// log.info("run strictCoordTransform");
|
|
|
+// entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS80, vectorServer);
|
|
|
+// }
|
|
|
//
|
|
|
-// } else if (TypeCode.COORD_WGS84.equals(entity.getCoordType())) {
|
|
|
-// // 不转换坐标 把文件信息移动到CoordStrictPath 这路径下
|
|
|
-// log.info("not to transform");
|
|
|
+// } else if (TypeCode.COORD_XIAN_1980.equals(entity.getCoordType())) {
|
|
|
//
|
|
|
-// entity.setCoordStrictPath(entity.getUploadPath());
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// entity.setStatus(3);
|
|
|
-// entity.setCoordType(TypeCode.COORD_WGS84);
|
|
|
-// vectorServer.save(entity);
|
|
|
-// } else {
|
|
|
-// log.info("error exeCmd");
|
|
|
-// entity.setStatus(7);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// vectorServer.save(entity);
|
|
|
-// }
|
|
|
-// log.info("end VectorJudgeCoordConsumerThread ");
|
|
|
+// // 严格坐标转换 (西安80转wgs84),需要参数
|
|
|
+// log.info("need to strict transform, CoordType: {}", entity.getCoordType());
|
|
|
+// if (arrayCoord.size() == 0) {
|
|
|
+// log.info("error: {}", MsgCode.E50009);
|
|
|
+// entity.setStatus(7);
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+// vectorServer.save(entity);
|
|
|
+// } else {
|
|
|
+// log.info("run strictCoordTransform");
|
|
|
+// entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS84, vectorServer);
|
|
|
// }
|
|
|
-// } catch (Exception e) {
|
|
|
-// Thread.currentThread().interrupt();
|
|
|
-// log.error("error vector consume queue VectorJudgeCoordConsumerThread: {}", e);
|
|
|
-// throw new RuntimeException(e);
|
|
|
//
|
|
|
+// } else if (TypeCode.COORD_WGS84.equals(entity.getCoordType())) {
|
|
|
+// // 不转换坐标 把文件信息移动到CoordStrictPath 这路径下
|
|
|
+// log.info("not to transform");
|
|
|
//
|
|
|
+// entity.setCoordStrictPath(entity.getUploadPath());
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+// entity.setStatus(3);
|
|
|
+// entity.setCoordType(TypeCode.COORD_WGS84);
|
|
|
+// vectorServer.save(entity);
|
|
|
+// } else {
|
|
|
+// log.info("error exeCmd");
|
|
|
+// entity.setStatus(7);
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+// vectorServer.save(entity);
|
|
|
// }
|
|
|
+// log.info("end convertCoordThread id: {}", entity.getId());
|
|
|
// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// public class VectorSliceThread implements Runnable {
|
|
|
-//
|
|
|
-// private BlockingQueue<MyQueue> queue;
|
|
|
-//
|
|
|
-// public VectorSliceThread(BlockingQueue<MyQueue> queue) {
|
|
|
-// this.queue = queue;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
+// } catch (Exception e) {
|
|
|
+// Thread.currentThread().interrupt();
|
|
|
+// log.error("error vector consume queue VectorJudgeCoordConsumerThread: {}", e);
|
|
|
+// throw new RuntimeException(e);
|
|
|
//
|
|
|
-// while (true) {
|
|
|
-// try {
|
|
|
-// MyQueue data = queue.poll(4, TimeUnit.SECONDS);
|
|
|
-// if (data != null) {
|
|
|
-// log.warn("run SliceVectorThread");
|
|
|
//
|
|
|
-// OutputFileEntity entity = data.getOutputFile();
|
|
|
-// log.info("slice cmd: {}", data.getStr());
|
|
|
-// Integer integer = vectorServer.cmdSlice(data.getStr(), entity);
|
|
|
-// if (integer != 0) {
|
|
|
-// log.info("error command exeCmdVectorSlice");
|
|
|
-// // 如果命令运行失败,状态改为0
|
|
|
-// entity.setStatus(0);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// vectorServer.save(entity);
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// // 切片完成,修改完成状态
|
|
|
-// entity.setStatus(5);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// vectorServer.save(entity);
|
|
|
-// log.warn("end SliceVectorThread");
|
|
|
-// }
|
|
|
-// } catch (Exception e) {
|
|
|
-// Thread.currentThread().interrupt();
|
|
|
-// log.error("error consume queue vector SliceConsumerThread: {}", e);
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation("矢量数据转geojson")
|
|
|
@GetMapping("command/geojson/{fileId}/")
|
|
|
private R cmdGeojson(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run cmdGeojson: {}", fileId);
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
OutputFileEntity entity = vectorServer.findById(fileId);
|
|
|
|
|
|
String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
@@ -556,7 +420,7 @@ public class VectorController {
|
|
|
private R cmdSlice(@PathVariable("fileId") Long fileId, @PathVariable("layerMin") String layerMin, @PathVariable("layerMax") String layerMax) {
|
|
|
log.info("run cmdSlice: {}", fileId);
|
|
|
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
|
|
|
if (!RegexUtils.regexInt(layerMin)) {
|
|
|
return new R(50010, MsgCode.E50010);
|
|
@@ -578,15 +442,6 @@ public class VectorController {
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
|
|
|
-// entity.setSlicePath(outPath);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// // 6:切片中
|
|
|
-// entity.setStatus(6);
|
|
|
-// entity.setLayerMin(Integer.valueOf(layerMin));
|
|
|
-// entity.setLayerMax(Integer.valueOf(layerMax));
|
|
|
-// entity = vectorServer.save(entity);
|
|
|
-
|
|
|
-
|
|
|
// 把数据放入队列中
|
|
|
MyQueue data = new MyQueue();
|
|
|
data.setOutputFile(entity);
|
|
@@ -609,7 +464,8 @@ public class VectorController {
|
|
|
entity.setLayerMax(Integer.valueOf(layerMax));
|
|
|
entity = vectorServer.save(entity);
|
|
|
|
|
|
- sliceThread(vectorSliceQueue, vectorServer);
|
|
|
+// sliceThread(vectorSliceQueue, vectorServer);
|
|
|
+ asyncTask.vectorSliceThread(vectorSliceQueue, vectorServer);
|
|
|
|
|
|
return new R(200, entity);
|
|
|
}
|
|
@@ -617,41 +473,41 @@ public class VectorController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void sliceThread(BlockingQueue<MyQueue> queue, VectorServer vectorServer){
|
|
|
- try {
|
|
|
- MyQueue data = queue.poll(4, TimeUnit.SECONDS);
|
|
|
- if (data != null) {
|
|
|
- log.warn("run SliceVectorThread");
|
|
|
-
|
|
|
- OutputFileEntity entity = data.getOutputFile();
|
|
|
- log.info("slice cmd: {}", data.getStr());
|
|
|
- Integer integer = vectorServer.cmdSlice(data.getStr(), entity);
|
|
|
- if (integer != 0) {
|
|
|
- log.info("error command exeCmdVectorSlice");
|
|
|
- // 如果命令运行失败,状态改为0
|
|
|
- entity.setStatus(0);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- vectorServer.save(entity);
|
|
|
- return;
|
|
|
- }
|
|
|
- // 切片完成,修改完成状态
|
|
|
- entity.setStatus(5);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- vectorServer.save(entity);
|
|
|
- log.warn("end SliceVectorThread");
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- Thread.currentThread().interrupt();
|
|
|
- log.error("error consume queue vector SliceConsumerThread: {}", e);
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+// private void sliceThread(BlockingQueue<MyQueue> queue, VectorServer vectorServer){
|
|
|
+// try {
|
|
|
+// MyQueue data = queue.poll(4, TimeUnit.SECONDS);
|
|
|
+// if (data != null) {
|
|
|
+// log.warn("run SliceVectorThread");
|
|
|
+//
|
|
|
+// OutputFileEntity entity = data.getOutputFile();
|
|
|
+// log.info("slice cmd: {}", data.getStr());
|
|
|
+// Integer integer = vectorServer.cmdSlice(data.getStr(), entity);
|
|
|
+// if (integer != 0) {
|
|
|
+// log.info("error command exeCmdVectorSlice");
|
|
|
+// // 如果命令运行失败,状态改为0
|
|
|
+// entity.setStatus(0);
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+// vectorServer.save(entity);
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 切片完成,修改完成状态
|
|
|
+// entity.setStatus(5);
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+// vectorServer.save(entity);
|
|
|
+// log.warn("end SliceVectorThread");
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// Thread.currentThread().interrupt();
|
|
|
+// log.error("error consume queue vector SliceConsumerThread: {}", e);
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
@ApiOperation("矢量数据进度查询")
|
|
|
@GetMapping("progress/{fileId}/")
|
|
|
private R getProgress(@PathVariable("fileId") Long fileId) {
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
OutputFileEntity entity = vectorServer.findById(fileId);
|
|
|
return new R(200, entity);
|
|
|
}
|
|
@@ -660,48 +516,17 @@ public class VectorController {
|
|
|
@PostMapping("move/{fileId}/")
|
|
|
private R moveFile(@PathVariable("fileId") Long fileId, @RequestBody ConfigJsonDto param) {
|
|
|
log.info("run moveFile: {}", fileId);
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
return vectorServer.moveFileToServer(fileId, param);
|
|
|
}
|
|
|
|
|
|
-// @ApiOperation("移动数据到服务器上")
|
|
|
-// @PostMapping("move/{fileId}/")
|
|
|
-// private R moveFile(@PathVariable("fileId") Long fileId, @RequestBody ConfigJsonDto param) {
|
|
|
-// log.info("run moveFile: {}", fileId);
|
|
|
-//
|
|
|
-// OutputFileEntity entity = vectorServer.findById(fileId);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// // 发布中
|
|
|
-// entity.setStatus(13);
|
|
|
-// entity = vectorServer.save(entity);
|
|
|
-//
|
|
|
-// new Thread(new MoveVectorThread(fileId, param)).start();
|
|
|
-//
|
|
|
-// return new R(200, entity);
|
|
|
-// }
|
|
|
-
|
|
|
-// public class MoveVectorThread implements Runnable{
|
|
|
-//
|
|
|
-// private Long fileId;
|
|
|
-// private ConfigJsonDto param;
|
|
|
-// public MoveVectorThread(Long fileId, ConfigJsonDto param){
|
|
|
-// this.fileId = fileId;
|
|
|
-// this.param = param;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// log.info("run MoveVectorThread");
|
|
|
-// vectorServer.moveFileToServer(fileId, param);
|
|
|
-// }
|
|
|
-// }
|
|
|
|
|
|
|
|
|
@ApiOperation("保存样式")
|
|
|
@PostMapping("style/save/")
|
|
|
private R saveStyle(@RequestBody StyleDto param) {
|
|
|
log.info("run saveStyle");
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
return vectorServer.editStyle(param);
|
|
|
}
|
|
|
|
|
@@ -709,73 +534,73 @@ public class VectorController {
|
|
|
@GetMapping("style/get/{fileId}/")
|
|
|
private R getStyle(@PathVariable("fileId") Long fileId) {
|
|
|
log.info("run getStyle: {}", fileId);
|
|
|
- VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
+// VectorServer vectorServer = SpringContext.getBean(VectorServerImpl.class);
|
|
|
return vectorServer.getStyle(fileId);
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 普通坐标转换
|
|
|
- */
|
|
|
- private OutputFileEntity generalCoordTransform(OutputFileEntity entity, String cmd, VectorServer vectorServer) {
|
|
|
-
|
|
|
- String directory = createDirectory(entity);
|
|
|
- directory = directory + File.separator + entity.getFileName();
|
|
|
-
|
|
|
- cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
|
- cmd = cmd.replace("@outputFile", directory);
|
|
|
- log.info("cmd: {}", cmd);
|
|
|
- return runCmd(cmd, entity, null, directory, vectorServer);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 严格坐标转换
|
|
|
- private OutputFileEntity strictCoordTransform(OutputFileEntity entity, String cmd, VectorServer vectorServer) {
|
|
|
-
|
|
|
- String directory = createDirectory(entity);
|
|
|
- directory = directory + File.separator + entity.getFileName();
|
|
|
- String coord = entity.getCoord();
|
|
|
- coord = coord.replace("[", "");
|
|
|
- coord = coord.replace("]", "");
|
|
|
- // 去空格
|
|
|
- coord = StringUtils.deleteWhitespace(coord);
|
|
|
-
|
|
|
- cmd = cmd.replace("@coord", coord);
|
|
|
- cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
|
- cmd = cmd.replace("@outputFile", directory);
|
|
|
- log.info("cmd: {}", cmd);
|
|
|
-
|
|
|
- return runCmd(cmd, entity, null, directory, vectorServer);
|
|
|
- }
|
|
|
-
|
|
|
- // 创建目录
|
|
|
- private String createDirectory(OutputFileEntity entity) {
|
|
|
- String directory = OUTPUT_FILE_PATH + "transform" + File.separator + entity.getDirectory();
|
|
|
- FileUtils.createDir(directory);
|
|
|
- return directory;
|
|
|
- }
|
|
|
-
|
|
|
- // 执行命令,创建对象, 坐标转换使用
|
|
|
- private OutputFileEntity runCmd(String cmd, OutputFileEntity entity, String generalPath, String strictPath, VectorServer vectorServer) {
|
|
|
- Integer integer = vectorServer.exeCmd(cmd);
|
|
|
- // 转换坐标失败, 修改状态
|
|
|
- if (integer != 0) {
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- entity.setStatus(7);
|
|
|
- entity = vectorServer.save(entity);
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- entity.setFileName(entity.getFileName());
|
|
|
- entity.setCoordGeneralPath(generalPath);
|
|
|
- entity.setCoordStrictPath(strictPath);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
- entity.setStatus(3);
|
|
|
-
|
|
|
- entity = vectorServer.save(entity);
|
|
|
-
|
|
|
- return entity;
|
|
|
-
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 普通坐标转换
|
|
|
+// */
|
|
|
+// private OutputFileEntity generalCoordTransform(OutputFileEntity entity, String cmd, VectorServer vectorServer) {
|
|
|
+//
|
|
|
+// String directory = createDirectory(entity);
|
|
|
+// directory = directory + File.separator + entity.getFileName();
|
|
|
+//
|
|
|
+// cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
|
+// cmd = cmd.replace("@outputFile", directory);
|
|
|
+// log.info("cmd: {}", cmd);
|
|
|
+// return runCmd(cmd, entity, null, directory, vectorServer);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// // 严格坐标转换
|
|
|
+// private OutputFileEntity strictCoordTransform(OutputFileEntity entity, String cmd, VectorServer vectorServer) {
|
|
|
+//
|
|
|
+// String directory = createDirectory(entity);
|
|
|
+// directory = directory + File.separator + entity.getFileName();
|
|
|
+// String coord = entity.getCoord();
|
|
|
+// coord = coord.replace("[", "");
|
|
|
+// coord = coord.replace("]", "");
|
|
|
+// // 去空格
|
|
|
+// coord = StringUtils.deleteWhitespace(coord);
|
|
|
+//
|
|
|
+// cmd = cmd.replace("@coord", coord);
|
|
|
+// cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
|
+// cmd = cmd.replace("@outputFile", directory);
|
|
|
+// log.info("cmd: {}", cmd);
|
|
|
+//
|
|
|
+// return runCmd(cmd, entity, null, directory, vectorServer);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 创建目录
|
|
|
+// private String createDirectory(OutputFileEntity entity) {
|
|
|
+// String directory = OUTPUT_FILE_PATH + "transform" + File.separator + entity.getDirectory();
|
|
|
+// FileUtils.createDir(directory);
|
|
|
+// return directory;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 执行命令,创建对象, 坐标转换使用
|
|
|
+// private OutputFileEntity runCmd(String cmd, OutputFileEntity entity, String generalPath, String strictPath, VectorServer vectorServer) {
|
|
|
+// Integer integer = vectorServer.exeCmd(cmd);
|
|
|
+// // 转换坐标失败, 修改状态
|
|
|
+// if (integer != 0) {
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+// entity.setStatus(7);
|
|
|
+// entity = vectorServer.save(entity);
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+//
|
|
|
+// entity.setFileName(entity.getFileName());
|
|
|
+// entity.setCoordGeneralPath(generalPath);
|
|
|
+// entity.setCoordStrictPath(strictPath);
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+// entity.setStatus(3);
|
|
|
+//
|
|
|
+// entity = vectorServer.save(entity);
|
|
|
+//
|
|
|
+// return entity;
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
}
|