|
@@ -63,6 +63,9 @@ public class VectorServerImpl implements VectorServer {
|
|
|
@Value("${config.tileset}")
|
|
|
private String CONFIG_TILESET;
|
|
|
|
|
|
+ @Value("${base.path}")
|
|
|
+ private String BASE_PATH;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FileRepository fileRepository;
|
|
|
|
|
@@ -75,45 +78,6 @@ public class VectorServerImpl implements VectorServer {
|
|
|
@Autowired
|
|
|
private StyleRepository styleRepository;
|
|
|
|
|
|
-// @Override
|
|
|
-// public R moveFileToServer(Long fileId, ConfigJsonDto param) {
|
|
|
-// Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
|
|
|
-// if (!o.isPresent()) {
|
|
|
-// log.info("id:{} 不存在", fileId);
|
|
|
-// return new R(50002, MsgCode.E50002);
|
|
|
-// }
|
|
|
-// OutputFileEntity entity = o.get();
|
|
|
-// FileUtils.createDir(MOVE_FILE_TO_SERVER);
|
|
|
-//
|
|
|
-// try {
|
|
|
-// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(new File(entity.getSlicePath()), new File(MOVE_FILE_TO_SERVER));
|
|
|
-// // 修改前端的config.json 文件
|
|
|
-// writeJsonFile(param, entity.getDirectory(), entity);
|
|
|
-//
|
|
|
-// //修改linux 文件权限
|
|
|
-// String cmd = Command.CMD_CHOMD_755;
|
|
|
-// String slice = MOVE_FILE_TO_SERVER + entity.getDirectory();
|
|
|
-// cmd = cmd.replace("@path", slice);
|
|
|
-// log.info("cmd: {}", cmd);
|
|
|
-// cmdServer.exeCmdInt(cmd);
|
|
|
-//
|
|
|
-//
|
|
|
-// entity.setStatus(8);
|
|
|
-// entity.setServicePath(slice);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// outputFileRepository.save(entity);
|
|
|
-// return new R(200, MsgCode.SUCCESS);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// // 服务发布失败
|
|
|
-// entity.setStatus(10);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// outputFileRepository.save(entity);
|
|
|
-// return new R(51004, MsgCode.E51004, e);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public R moveFileToServer(Long fileId, ConfigJsonDto param) {
|
|
@@ -230,71 +194,6 @@ public class VectorServerImpl implements VectorServer {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// @Override
|
|
|
-// public R uploadDirectoryFile(MultipartFile file, String directoryName, String coord) {
|
|
|
-//
|
|
|
-// log.warn("run uploadBigFile");
|
|
|
-// long start = System.currentTimeMillis();
|
|
|
-// if (file.isEmpty() || file.getSize() <= 0) {
|
|
|
-// log.info("文件为空");
|
|
|
-// return new R(50001, MsgCode.E50001);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 文件名全名
|
|
|
-// String fullFileName = file.getOriginalFilename();
|
|
|
-//
|
|
|
-// // 创建目录路径
|
|
|
-// String filePath = INPUT_FILE_PATH + directoryName + File.separator;
|
|
|
-// FileUtils.createDir(filePath);
|
|
|
-//
|
|
|
-//
|
|
|
-// // 文件保存路径
|
|
|
-// filePath = filePath + fullFileName;
|
|
|
-//
|
|
|
-// // 写文件到本地
|
|
|
-//
|
|
|
-// try {
|
|
|
-// FileUtils.bigFileWrite(file.getInputStream(), filePath);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// log.info("filePath: {}", filePath);
|
|
|
-//
|
|
|
-// // 保存信息到db
|
|
|
-// FileEntity entity = new FileEntity();
|
|
|
-// entity.setFileName(fullFileName);
|
|
|
-// entity.setDirectory(directoryName);
|
|
|
-// entity.setFileUrl(filePath);
|
|
|
-// entity.setCreateTime(new Date());
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// entity.setType(TypeCode.FILE_TYPE_VECTOR);
|
|
|
-// entity.setCoord(coord);
|
|
|
-// entity.setStatus(2);
|
|
|
-// fileRepository.save(entity);
|
|
|
-//
|
|
|
-// OutputFileEntity outputFile = null;
|
|
|
-// String s = StringUtils.substringAfterLast(fullFileName, ".");
|
|
|
-// if ("shp".equals(s)) {
|
|
|
-//
|
|
|
-// outputFile = new OutputFileEntity();
|
|
|
-// outputFile.setUploadId(entity.getId());
|
|
|
-// outputFile.setUploadPath(entity.getFileUrl());
|
|
|
-// outputFile.setFileName(entity.getFileName());
|
|
|
-// outputFile.setStatus(2);
|
|
|
-// outputFile.setType(TypeCode.FILE_TYPE_VECTOR);
|
|
|
-// outputFile.setCoord(entity.getCoord());
|
|
|
-// outputFile.setCreateTime(new Date());
|
|
|
-// outputFile.setUpdateTime(new Date());
|
|
|
-//
|
|
|
-// outputFile = outputFileRepository.save(outputFile);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// long end = System.currentTimeMillis();
|
|
|
-// log.info("end uploadBigFile, total time: {} s", (end - start) / 1000);
|
|
|
-// return new R(200, outputFile);
|
|
|
-// }
|
|
|
-
|
|
|
@Override
|
|
|
public R uploadDirectoryFileMul(MultipartFile[] files, String directoryName, String coord) {
|
|
|
|
|
@@ -405,12 +304,6 @@ public class VectorServerImpl implements VectorServer {
|
|
|
return new R(200, outputFile);
|
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
-// public R findByType(String type, PageDto pageDto) {
|
|
|
-// Page<OutputFileEntity> page = outputFileRepository.findByType(type, PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
|
|
|
-// return new R(200, page);
|
|
|
-// }
|
|
|
-
|
|
|
@Override
|
|
|
public R findByType(String type, PageDto pageDto) {
|
|
|
Page<OutputFileEntity> page = outputFileRepository.findByTypeAndResStatus(type, 0, PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
|
|
@@ -719,8 +612,6 @@ public class VectorServerImpl implements VectorServer {
|
|
|
return isCmd;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 获取经纬度平均值
|
|
|
*
|
|
@@ -772,59 +663,6 @@ public class VectorServerImpl implements VectorServer {
|
|
|
return outputFileRepository.save(fileSchedule);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 发布服务
|
|
|
- * 修改config.json
|
|
|
- */
|
|
|
-// private void writeJsonFile(ConfigJsonDto param, String lastName, OutputFileEntity entity) {
|
|
|
-//
|
|
|
-// StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getId());
|
|
|
-//
|
|
|
-// String s = FileUtils.readFile(CONFIG_JSON_PATH);
|
|
|
-//
|
|
|
-// JSONObject original = JSON.parseObject(s);
|
|
|
-//
|
|
|
-// log.info("original: {}", s);
|
|
|
-//
|
|
|
-// JSONArray layers = JSON.parseArray(original.getString("layers"));
|
|
|
-//
|
|
|
-// JSONObject subJson = new JSONObject();
|
|
|
-// long cu = System.currentTimeMillis();
|
|
|
-// String name = "vector_" + cu;
|
|
|
-// // 需要唯一
|
|
|
-// subJson.put("name", name);
|
|
|
-//
|
|
|
-// subJson.put("text", param.getText());
|
|
|
-// // vector 就用这个类型geodata
|
|
|
-// subJson.put("type", "geodata");
|
|
|
-// subJson.put("checked", false);
|
|
|
-// subJson.put("show", true);
|
|
|
-// subJson.put("url", "../data/" + lastName);
|
|
|
-//// subJson.put("style", JSON.parse(styleEntity.getContent()));
|
|
|
-// layers.add(subJson);
|
|
|
-//
|
|
|
-// original.put("layers", layers);
|
|
|
-//
|
|
|
-// log.info("original update: {}", original.toJSONString());
|
|
|
-// try {
|
|
|
-// FileUtils.fileWriter(JSON.toJSONString(original), CONFIG_JSON_PATH);
|
|
|
-//
|
|
|
-// // 将图层信息保存到db
|
|
|
-// // 前端需要layer信息
|
|
|
-// styleEntity.setLayer(subJson.toJSONString());
|
|
|
-// styleEntity.setUpdateTime(new Date());
|
|
|
-// styleEntity.setName(name);
|
|
|
-//// log.info("check test 2");
|
|
|
-// styleRepository.save(styleEntity);
|
|
|
-//// log.info("check test 3");
|
|
|
-//
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
private void writeJsonFile(ConfigJsonDto param, String lastName, OutputFileEntity entity) {
|
|
|
|
|
|
StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getId());
|
|
@@ -850,7 +688,8 @@ public class VectorServerImpl implements VectorServer {
|
|
|
subJson.put("show", true);
|
|
|
// subJson.put("url", "../data/" + lastName);
|
|
|
String slicePath = entity.getSlicePath();
|
|
|
- slicePath = slicePath.replace("/root/gis/cesium", "");
|
|
|
+// slicePath = slicePath.replace("/root/gis/data", "");
|
|
|
+ slicePath = slicePath.replace(BASE_PATH, "");
|
|
|
subJson.put("url", slicePath);
|
|
|
layers.add(subJson);
|
|
|
|