|
@@ -21,9 +21,7 @@ import com.fd.server.DemServer;
|
|
|
import com.fd.server.ModelServer;
|
|
|
import com.fd.shiro.JWTUtil;
|
|
|
import com.fd.thread.AsyncTask;
|
|
|
-import com.fd.util.CmdUtil;
|
|
|
-import com.fd.util.FileUtils;
|
|
|
-import com.fd.util.R;
|
|
|
+import com.fd.util.*;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -56,19 +54,13 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
|
|
|
private String OUTPUT_PATH;
|
|
|
|
|
|
- @Value("${copy.file.path.model}")
|
|
|
- private String MOVE_FILE_TO_SERVER;
|
|
|
+ @Value("${base.path}")
|
|
|
+ private String BASE_PATH;
|
|
|
|
|
|
// config.json 地址
|
|
|
@Value("${config.path}")
|
|
|
private String CONFIG_JSON_PATH;
|
|
|
|
|
|
- @Value("${base.path}")
|
|
|
- private String BASE_PATH;
|
|
|
-
|
|
|
- // config.json teileset 的相对路径
|
|
|
- @Value("${config.tileset}")
|
|
|
- private String CONFIG_TILESET;
|
|
|
|
|
|
@Autowired
|
|
|
private AsyncTask asyncTask;
|
|
@@ -87,11 +79,10 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
private OutputFileRepository outputFileRepository;
|
|
|
|
|
|
@Autowired
|
|
|
- private StyleRepository styleRepository;
|
|
|
-
|
|
|
+ private UserRepository userRepository;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserRepository userRepository;
|
|
|
+ private StyleRepository styleRepository;
|
|
|
|
|
|
/**
|
|
|
* 队列
|
|
@@ -105,12 +96,10 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public OutputFileEntity uploads(MultipartFile[] files, HttpServletRequest req) {
|
|
|
+ public R uploads(MultipartFile[] files, HttpServletRequest req) {
|
|
|
log.warn("run uploads");
|
|
|
if (files != null && files.length > 0) {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// 创建目录
|
|
|
String time = DateUtil.format(new DateTime(), "yyyyMMdd_HHmmss");
|
|
|
String filePath = INPUT_PATH + time;
|
|
@@ -122,6 +111,12 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
|
|
|
for (MultipartFile f : files) {
|
|
|
String filename = f.getOriginalFilename();
|
|
|
+
|
|
|
+ // 文件是否包含中文字符
|
|
|
+ if (RegexUtils.regexChinese(filename)) {
|
|
|
+ return new R(51005, MsgCode.E51005);
|
|
|
+ }
|
|
|
+
|
|
|
sb.append(filename).append(",");
|
|
|
|
|
|
try {
|
|
@@ -134,7 +129,6 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
|
|
|
|
|
|
// 数据打包
|
|
|
-// String outPath = OUTPUT_PATH + "bulid/" + time + "/";
|
|
|
String outPath = OUTPUT_PATH + "bulid/";
|
|
|
FileUtils.createDir(outPath);
|
|
|
outPath = outPath + time + ".vrt";
|
|
@@ -156,18 +150,16 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
entity.setCreateTime(new Date());
|
|
|
entity.setUpdateTime(new Date());
|
|
|
entity.setType(TypeCode.FILE_TYPE_DEM);
|
|
|
-// entity.setCoord(coord);
|
|
|
entity.setResStatus(0);
|
|
|
entity = fileRepository.save(entity);
|
|
|
|
|
|
outputFile.setUploadId(entity.getId());
|
|
|
outputFile.setUploadPath(entity.getFileUrl());
|
|
|
outputFile.setDirectory(entity.getDirectory());
|
|
|
-// outputFile.setFileName(shpName);
|
|
|
- // 等下在修改
|
|
|
- outputFile.setStatus(2);
|
|
|
+ outputFile.setFileName(entity.getFileName());
|
|
|
+ // 4:未切片
|
|
|
+ outputFile.setStatus(4);
|
|
|
outputFile.setType(TypeCode.FILE_TYPE_DEM);
|
|
|
-// outputFile.setCoord(entity.getCoord());
|
|
|
outputFile.setCreateTime(new Date());
|
|
|
outputFile.setUpdateTime(new Date());
|
|
|
outputFile.setResStatus(0);
|
|
@@ -175,7 +167,7 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
|
|
|
outputFile = outputFileRepository.save(outputFile);
|
|
|
log.warn("end uploads");
|
|
|
- return outputFile;
|
|
|
+ return new R(200, outputFile);
|
|
|
|
|
|
|
|
|
}
|
|
@@ -210,7 +202,6 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
String cmd = Command.DEM_SLICE;
|
|
|
cmd = cmd.replace("@inputFile", entity.getBuildPath());
|
|
|
cmd = cmd.replace("@outputFile", outputPath);
|
|
|
-// log.info("cmd: {}", cmd);
|
|
|
|
|
|
// 把数据放入队列中
|
|
|
boolean offer = false;
|
|
@@ -229,7 +220,7 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
entity.setStatus(6);
|
|
|
entity.setUpdateTime(new Date());
|
|
|
// 是目录
|
|
|
- entity.setServicePath(outputPath);
|
|
|
+ entity.setSlicePath(outputPath);
|
|
|
|
|
|
entity = outputFileRepository.save(entity);
|
|
|
asyncTask.demSlice(queue, outputFileRepository, entity, cmd);
|
|
@@ -249,6 +240,28 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public R moveFileToServer(Long fileId, ConfigJsonDto param) {
|
|
|
+ log.warn("run moveFileToServer");
|
|
|
+ OutputFileEntity entity = getOutputFileEntity(fileId);
|
|
|
+ if (entity == null) {
|
|
|
+ return new R(50002, MsgCode.E50002);
|
|
|
+ }
|
|
|
+
|
|
|
+ writeJsonFile(param, entity);
|
|
|
+
|
|
|
+ entity.setStatus(8);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ // 添加图层角色
|
|
|
+ entity.setLayerRole(param.getRole());
|
|
|
+ outputFileRepository.save(entity);
|
|
|
+
|
|
|
+ log.warn("end moveFileToServer");
|
|
|
+ return new R(200, MsgCode.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 重写 deleteById
|
|
|
* @param id
|
|
@@ -262,6 +275,14 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
OutputFileEntity entity = null;
|
|
|
FileEntity fileEntity = null;
|
|
|
|
|
|
+ // 删除配置文件config.json制定行
|
|
|
+ StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(id);
|
|
|
+ if (styleEntity != null) {
|
|
|
+ ConfigJsonUtils.deleteRowConfigJson(styleEntity, CONFIG_JSON_PATH);
|
|
|
+ styleRepository.deleteByOutputFileId(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
boolean flag = false;
|
|
|
if (o.isPresent()) {
|
|
|
entity = o.get();
|
|
@@ -289,361 +310,77 @@ public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
-// FileUtils.createDir("F:\\test\\test123");
|
|
|
-// FileUtils.createDir("F:\\test\\test1234\\1.txt");
|
|
|
-// FileUtils.delFolder("F:\\test\\test1234\\1.txt");
|
|
|
- FileUtils.delFolder("F:\\test\\test1234");
|
|
|
+ private OutputFileEntity getOutputFileEntity(Long id) {
|
|
|
+ Optional<OutputFileEntity> o = outputFileRepository.findById(id);
|
|
|
+ if (o.isPresent()) {
|
|
|
+ return o.get();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改config.json
|
|
|
+ * @param param
|
|
|
+ * @param entity
|
|
|
+ */
|
|
|
+ private void writeJsonFile(ConfigJsonDto param, OutputFileEntity entity) {
|
|
|
+ String s = FileUtils.readFile(CONFIG_JSON_PATH);
|
|
|
+
|
|
|
+ StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getId());
|
|
|
+ if (styleEntity == null) {
|
|
|
+ styleEntity = new StyleEntity();
|
|
|
+ styleEntity.setOutputFileId(entity.getId());
|
|
|
+ styleEntity.setCreateTime(new Date());
|
|
|
+ styleEntity.setResStatus(0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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 = "dem_" + cu;
|
|
|
+ subJson.put("name", name);
|
|
|
+ subJson.put("text", param.getText());
|
|
|
+ // raster 就用这个类型
|
|
|
+ subJson.put("type", "dem");
|
|
|
+ subJson.put("checked", false);
|
|
|
+ subJson.put("show", true);
|
|
|
|
|
|
- // log.info("run deleteFile: {}", fileId);
|
|
|
-// OutputFileEntity entity = modelServer.findById(fileId);
|
|
|
-// entity.setResStatus(1);
|
|
|
-// modelServer.save(entity);
|
|
|
-//
|
|
|
-// FileEntity fileEntity = modelServer.findByInputFileId(entity.getUploadId());
|
|
|
-// fileEntity.setResStatus(1);
|
|
|
-// modelServer.saveInputFile(fileEntity);
|
|
|
-//
|
|
|
-// asyncTask.modelDelete(fileId, modelServer);
|
|
|
-
|
|
|
-// @Override
|
|
|
-// public R deleteById(Long fileId) {
|
|
|
-// // 删除服务器文件
|
|
|
-// Optional<OutputFileEntity> e = outputFileRepository.findById(fileId);
|
|
|
-// if (!e.isPresent()) {
|
|
|
-// return new R(50002, MsgCode.E50002);
|
|
|
-// }
|
|
|
-// OutputFileEntity fileEntity = e.get();
|
|
|
-//
|
|
|
-// // 删除配置文件config.json制定行
|
|
|
-// StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(fileId);
|
|
|
-// if (styleEntity != null) {
|
|
|
-// deleteRowConfigJson(styleEntity);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 删除数据库记录
|
|
|
-// outputFileRepository.deleteById(fileId);
|
|
|
-// fileRepository.deleteById(fileEntity.getUploadId());
|
|
|
-// styleRepository.deleteByOutputFileId(fileId);
|
|
|
-//
|
|
|
-// // 文件
|
|
|
-// if (fileEntity.getUploadPath() != null) {
|
|
|
-// FileUtils.delFolder(fileEntity.getUploadPath());
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (fileEntity.getCoordGeneralPath() != null) {
|
|
|
-// FileUtils.delFolder(fileEntity.getCoordGeneralPath());
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (fileEntity.getUnZipPath() != null) {
|
|
|
-// FileUtils.delFolder(fileEntity.getUnZipPath());
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (fileEntity.getGeojsonPath() != null) {
|
|
|
-// FileUtils.delFolder(fileEntity.getGeojsonPath());
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (fileEntity.getCoordStrictPath() != null) {
|
|
|
-// FileUtils.delFolder(fileEntity.getCoordStrictPath());
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (fileEntity.getSlicePath() != null) {
|
|
|
-// FileUtils.delFolder(fileEntity.getSlicePath());
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// return new R(200, MsgCode.SUCCESS);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 删除指定行的config.json 数据
|
|
|
-// */
|
|
|
-// private void deleteRowConfigJson(StyleEntity entity) {
|
|
|
-// String s = FileUtils.readFile(CONFIG_JSON_PATH);
|
|
|
-// JSONObject original = JSON.parseObject(s);
|
|
|
-// log.info("original: {}", s);
|
|
|
-//
|
|
|
-// JSONArray layers = JSON.parseArray(original.getString("layers"));
|
|
|
-//
|
|
|
-// for (int i = 0; i < layers.size(); i++) {
|
|
|
-// JSONObject o = (JSONObject) layers.get(i);
|
|
|
-// if (o.getString("name").equals(entity.getName())) {
|
|
|
-// // 删除对象
|
|
|
-// layers.remove(i);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 更新json
|
|
|
-// original.put("layers", layers);
|
|
|
-// log.info("original update: {}", original.toJSONString());
|
|
|
-//
|
|
|
-// // 更新config.json
|
|
|
-// try {
|
|
|
-// FileUtils.fileWriter(JSON.toJSONString(original), CONFIG_JSON_PATH);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public List<FileEntity> findByFileName(String fileName) {
|
|
|
-//
|
|
|
-//// return fileRepository.findByFileNameAndType(fileName, TypeCode.FILE_TYPE_MODEL);
|
|
|
-// return fileRepository.findByFileNameAndTypeAndResStatus(fileName, TypeCode.FILE_TYPE_MODEL, 0);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Integer cmdSlice(String commandStr) {
|
|
|
-//
|
|
|
-// // 命令运行结果 1:失败, 0:成功
|
|
|
-// Integer isCmd = null;
|
|
|
-// try {
|
|
|
-// String[] cmd = new String[]{"/bin/sh", "-c", commandStr};
|
|
|
-// Process ps = Runtime.getRuntime().exec(cmd);
|
|
|
-//
|
|
|
-// BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
|
|
|
-// BufferedReader errorBuf = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
|
|
|
-//
|
|
|
-// StringBuffer sb = new StringBuffer();
|
|
|
-// StringBuffer errorStr = new StringBuffer();
|
|
|
-//
|
|
|
-// // error : 坑, 控制台信息是从errorBuf这里出来的
|
|
|
-// String errorLine;
|
|
|
-// while ((errorLine = errorBuf.readLine()) != null) {
|
|
|
-// errorStr.append(errorLine).append("\n");
|
|
|
-// log.info("line data: {}", errorLine);
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotEmpty(errorStr)){
|
|
|
-// log.info("error result: {}", errorStr.toString());
|
|
|
-// }
|
|
|
-//
|
|
|
-// // success ,没有获取到信息
|
|
|
-// String line;
|
|
|
-// while ((line = br.readLine()) != null) {
|
|
|
-// //执行结果加上回车
|
|
|
-// sb.append(line).append("\n");
|
|
|
-// log.info("data: {}", line);
|
|
|
-// }
|
|
|
-// log.info("result: {}", sb.toString());
|
|
|
-//
|
|
|
-// // 结束命令行
|
|
|
-// isCmd = ps.waitFor();
|
|
|
-//
|
|
|
-// // 关闭流
|
|
|
-// br.close();
|
|
|
-// errorBuf.close();
|
|
|
-//
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (isCmd == 0) {
|
|
|
-// log.info("end exeCmd : {}", isCmd);
|
|
|
-// } else {
|
|
|
-// log.info("wsitFore cmd run error : {}", isCmd);
|
|
|
-// }
|
|
|
-// return isCmd;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// @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);
|
|
|
-//
|
|
|
-// // 成功,状态
|
|
|
-// entity.setStatus(8);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-//
|
|
|
-// // 添加图层角色
|
|
|
-// entity.setLayerRole(param.getRole());
|
|
|
-// outputFileRepository.save(entity);
|
|
|
-//
|
|
|
-// return new R(200, MsgCode.SUCCESS);
|
|
|
-// } catch (Exception e) {
|
|
|
-//
|
|
|
-// // 发布失败
|
|
|
-// entity.setStatus(10);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// outputFileRepository.save(entity);
|
|
|
-// e.printStackTrace();
|
|
|
-// return new R(51004, MsgCode.E51004, e);
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public R uploadBigFile(MultipartFile file, String token) {
|
|
|
-// 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();
|
|
|
-//
|
|
|
-// // 创建目录路径
|
|
|
-// FileUtils.createDir(INPUT_FILE_PATH);
|
|
|
-//
|
|
|
-// // 拼接唯一文件名
|
|
|
-// long timeMillis = System.currentTimeMillis();
|
|
|
-//// String fileName = timeMillis + "_" + fullFileName;
|
|
|
-// String fileName = fullFileName;
|
|
|
-//
|
|
|
-// // 文件保存路径
|
|
|
-// String filePath = INPUT_FILE_PATH + fileName;
|
|
|
-//
|
|
|
-// // 写文件到本地
|
|
|
-// try {
|
|
|
-// FileUtils.bigFileWrite(file.getInputStream(), filePath);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// log.info("filePath: {}", filePath);
|
|
|
-//
|
|
|
-//
|
|
|
-// String username = JWTUtil.getUsername(token);
|
|
|
-//
|
|
|
-// // 根据用户名查找用户
|
|
|
-// User user = userRepository.findByUsername(username);
|
|
|
-//
|
|
|
-// // 保存信息到db
|
|
|
-// FileEntity entity = new FileEntity();
|
|
|
-// entity.setFileName(fileName);
|
|
|
-// entity.setFileUrl(filePath);
|
|
|
-// entity.setCreateTime(new Date());
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// entity.setType(TypeCode.FILE_TYPE_MODEL);
|
|
|
-//// entity.setStatus(1);
|
|
|
-// entity.setResStatus(0);
|
|
|
-// entity = fileRepository.save(entity);
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// OutputFileEntity outputFile = new OutputFileEntity();
|
|
|
-// outputFile.setUploadId(entity.getId());
|
|
|
-// outputFile.setUploadPath(entity.getFileUrl());
|
|
|
-// outputFile.setFileName(entity.getFileName());
|
|
|
-// outputFile.setStatus(1);
|
|
|
-// outputFile.setResStatus(0);
|
|
|
-// outputFile.setType(TypeCode.FILE_TYPE_MODEL);
|
|
|
-// outputFile.setCreateTime(new Date());
|
|
|
-// outputFile.setUpdateTime(new Date());
|
|
|
-//
|
|
|
-// // 添加分组
|
|
|
-// outputFile.setUserId(user.getId());
|
|
|
-// outputFile.setUserGroup(user.getUserGroup());
|
|
|
-//
|
|
|
-// 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 OutputFileEntity findByUploadId(Long uploadId) {
|
|
|
-// return outputFileRepository.findByUploadId(uploadId);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public OutputFileEntity save(OutputFileEntity fileSchedule) {
|
|
|
-// return outputFileRepository.save(fileSchedule);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// private void writeJsonFile(ConfigJsonDto param, OutputFileEntity entity) {
|
|
|
-// String s = FileUtils.readFile(CONFIG_JSON_PATH);
|
|
|
-//
|
|
|
-// StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getId());
|
|
|
-// if (styleEntity == null) {
|
|
|
-// styleEntity = new StyleEntity();
|
|
|
-// styleEntity.setOutputFileId(entity.getId());
|
|
|
-// styleEntity.setCreateTime(new Date());
|
|
|
-// styleEntity.setResStatus(0);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// 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 = "model_" + cu;
|
|
|
-// subJson.put("name", name);
|
|
|
-// subJson.put("text", param.getText());
|
|
|
-// // raster 就用这个类型
|
|
|
-// subJson.put("type", "tileset");
|
|
|
-// subJson.put("checked", false);
|
|
|
-// subJson.put("show", true);
|
|
|
-//
|
|
|
-// String slicePath = entity.getSlicePath();
|
|
|
-//// slicePath = slicePath.replace("/root/gis/data", "");
|
|
|
-// slicePath = slicePath.replace(BASE_PATH, "");
|
|
|
-//
|
|
|
-// subJson.put("url", slicePath);
|
|
|
-//
|
|
|
-// 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);
|
|
|
-// styleRepository.save(styleEntity);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// public static void main(String[] args) throws IOException {
|
|
|
-// String path1 = "F:\\test\\a1";
|
|
|
-// String path2 = "F:\\test\\vts.log";
|
|
|
-//// org.apache.commons.io.FileUtils.deleteDirectory(new File(path2));
|
|
|
-// FileUtils.delFolder(path1);
|
|
|
-// }
|
|
|
+ String slicePath = entity.getSlicePath();
|
|
|
+ slicePath = slicePath.replace(BASE_PATH, "");
|
|
|
|
|
|
+ subJson.put("url", slicePath);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ styleRepository.save(styleEntity);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ FileUtils.delFolder("F:\\test\\test1234");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|