|
@@ -75,6 +75,46 @@ 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) {
|
|
|
Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
|
|
@@ -83,27 +123,27 @@ public class VectorServerImpl implements VectorServer {
|
|
|
return new R(50002, MsgCode.E50002);
|
|
|
}
|
|
|
OutputFileEntity entity = o.get();
|
|
|
- FileUtils.createDir(MOVE_FILE_TO_SERVER);
|
|
|
+// FileUtils.createDir(MOVE_FILE_TO_SERVER);
|
|
|
|
|
|
try {
|
|
|
- org.apache.commons.io.FileUtils.copyDirectoryToDirectory(new File(entity.getSlicePath()), new File(MOVE_FILE_TO_SERVER));
|
|
|
+// 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);
|
|
|
+// 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.setServicePath(entity.getSlicePath());
|
|
|
entity.setUpdateTime(new Date());
|
|
|
outputFileRepository.save(entity);
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
// 服务发布失败
|
|
|
entity.setStatus(10);
|
|
@@ -150,26 +190,13 @@ public class VectorServerImpl implements VectorServer {
|
|
|
}
|
|
|
|
|
|
if (entity.getSlicePath() != null) {
|
|
|
- log.info("test file getSlicePath");
|
|
|
- File file = new File(entity.getSlicePath());
|
|
|
- if (file.exists()) {
|
|
|
- log.info("test file ");
|
|
|
FileUtils.delFolder(entity.getSlicePath());
|
|
|
- }
|
|
|
- log.info("test file getSlicePath ok");
|
|
|
}
|
|
|
|
|
|
// 目录类型
|
|
|
- if (entity.getServicePath() != null) {
|
|
|
- log.info("test file getServicePath");
|
|
|
-
|
|
|
- File file = new File(entity.getServicePath());
|
|
|
- if (file.exists()) {
|
|
|
- log.info("test file ");
|
|
|
- FileUtils.delFolder(entity.getServicePath());
|
|
|
- }
|
|
|
- log.info("test file getServicePath ok");
|
|
|
- }
|
|
|
+// if (entity.getServicePath() != null) {
|
|
|
+// FileUtils.delFolder(entity.getServicePath());
|
|
|
+// }
|
|
|
|
|
|
|
|
|
// 删除配置文件config.json制定行
|
|
@@ -200,70 +227,70 @@ 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 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) {
|
|
@@ -311,11 +338,13 @@ public class VectorServerImpl implements VectorServer {
|
|
|
String [] suffixCheck = {"dbf","shp","shx","prj"};
|
|
|
if (Arrays.asList(suffixCheck).contains(s)) {
|
|
|
suffixCheckInt += 1;
|
|
|
+
|
|
|
+ // 判断前缀名字是否一致
|
|
|
+ String prefix = StringUtils.substringBeforeLast(filename, ".");
|
|
|
+ setPrefix.add(prefix);
|
|
|
}
|
|
|
|
|
|
- // 判断前缀名字是否一致
|
|
|
- String prefix = StringUtils.substringBeforeLast(filename, ".");
|
|
|
- setPrefix.add(prefix);
|
|
|
+
|
|
|
|
|
|
if ("shp".equals(s)) {
|
|
|
shpFlag = true;
|
|
@@ -335,7 +364,7 @@ public class VectorServerImpl implements VectorServer {
|
|
|
if (setPrefix.size() > 1) {
|
|
|
|
|
|
log.info("文件名前缀不一致");
|
|
|
- return new R(51008, MsgCode.E51008);
|
|
|
+ return new R(51009, MsgCode.E51009);
|
|
|
}
|
|
|
|
|
|
// 上传文件格式有误
|
|
@@ -364,14 +393,21 @@ public class VectorServerImpl implements VectorServer {
|
|
|
outputFile.setCoord(entity.getCoord());
|
|
|
outputFile.setCreateTime(new Date());
|
|
|
outputFile.setUpdateTime(new Date());
|
|
|
+ outputFile.setResStatus(0);
|
|
|
outputFile = outputFileRepository.save(outputFile);
|
|
|
}
|
|
|
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.findByType(type, PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
|
|
|
+ Page<OutputFileEntity> page = outputFileRepository.findByTypeAndResStatus(type, 0, PageRequest.of(pageDto.getPageNum(), pageDto.getPageSize(), Sort.by("createTime").descending()));
|
|
|
return new R(200, page);
|
|
|
}
|
|
|
|
|
@@ -660,6 +696,54 @@ public class VectorServerImpl implements VectorServer {
|
|
|
* 发布服务
|
|
|
* 修改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());
|
|
@@ -683,8 +767,10 @@ public class VectorServerImpl implements VectorServer {
|
|
|
subJson.put("type", "geodata");
|
|
|
subJson.put("checked", false);
|
|
|
subJson.put("show", true);
|
|
|
- subJson.put("url", "../data/" + lastName);
|
|
|
-// subJson.put("style", JSON.parse(styleEntity.getContent()));
|
|
|
+// subJson.put("url", "../data/" + lastName);
|
|
|
+ String slicePath = entity.getSlicePath();
|
|
|
+ slicePath = slicePath.replace("/root/gis/cesium", "");
|
|
|
+ subJson.put("url", slicePath);
|
|
|
layers.add(subJson);
|
|
|
|
|
|
original.put("layers", layers);
|
|
@@ -698,9 +784,7 @@ public class VectorServerImpl implements VectorServer {
|
|
|
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();
|