|
@@ -0,0 +1,589 @@
|
|
|
+package com.fd.server.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fd.constant.Command;
|
|
|
+import com.fd.constant.MsgCode;
|
|
|
+import com.fd.constant.TypeCode;
|
|
|
+import com.fd.dto.ConfigJsonDto;
|
|
|
+import com.fd.entity.FileEntity;
|
|
|
+import com.fd.entity.OutputFileEntity;
|
|
|
+import com.fd.entity.StyleEntity;
|
|
|
+import com.fd.entity.User;
|
|
|
+import com.fd.repository.FileRepository;
|
|
|
+import com.fd.repository.OutputFileRepository;
|
|
|
+import com.fd.repository.StyleRepository;
|
|
|
+import com.fd.repository.UserRepository;
|
|
|
+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 lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.concurrent.BlockingQueue;
|
|
|
+import java.util.concurrent.LinkedBlockingQueue;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by Owen on 2019/11/21 0021 15:29
|
|
|
+ */
|
|
|
+@Log4j2
|
|
|
+@Service
|
|
|
+public class DemServerImpl extends BaseServerImpl implements DemServer {
|
|
|
+
|
|
|
+ private String INPUT_PATH;
|
|
|
+
|
|
|
+ private String OUTPUT_PATH;
|
|
|
+
|
|
|
+ @Value("${copy.file.path.model}")
|
|
|
+ private String MOVE_FILE_TO_SERVER;
|
|
|
+
|
|
|
+ // 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;
|
|
|
+
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ private void init(){
|
|
|
+ this.INPUT_PATH = BASE_PATH + "/input/dem/";
|
|
|
+ this.OUTPUT_PATH = BASE_PATH + "/output/dem/";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FileRepository fileRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OutputFileRepository outputFileRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StyleRepository styleRepository;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserRepository userRepository;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 队列
|
|
|
+ */
|
|
|
+ private static BlockingQueue<Integer> queue = new LinkedBlockingQueue<Integer>(2);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保证线程安全的
|
|
|
+ */
|
|
|
+ private static AtomicInteger count = new AtomicInteger();
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OutputFileEntity 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 + "/";
|
|
|
+ FileUtils.createDir(filePath);
|
|
|
+ log.info("filePath: {}", filePath);
|
|
|
+
|
|
|
+ // 存储多个文件名
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ for (MultipartFile f : files) {
|
|
|
+ String filename = f.getOriginalFilename();
|
|
|
+ sb.append(filename).append(",");
|
|
|
+
|
|
|
+ try {
|
|
|
+ FileUtils.bigFileWrite(f.getInputStream(), filePath + filename);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.warn("FileWrite success");
|
|
|
+
|
|
|
+
|
|
|
+ // 数据打包
|
|
|
+// String outPath = OUTPUT_PATH + "bulid/" + time + "/";
|
|
|
+ String outPath = OUTPUT_PATH + "bulid/";
|
|
|
+ FileUtils.createDir(outPath);
|
|
|
+ outPath = outPath + time + ".vrt";
|
|
|
+ String cmd = Command.DEM_BUILD;
|
|
|
+ cmd = cmd.replace("@inputFile", filePath + "*.tif");
|
|
|
+ cmd = cmd.replace("@outputFile", outPath);
|
|
|
+ log.warn("cmd: {}", cmd);
|
|
|
+ Integer integer = CmdUtil.exeCmdSingle(cmd);
|
|
|
+ log.warn("cmd success");
|
|
|
+
|
|
|
+ // 保存信息
|
|
|
+ OutputFileEntity outputFile = new OutputFileEntity();
|
|
|
+ if (integer == 0) {
|
|
|
+ FileEntity entity = new FileEntity();
|
|
|
+ entity.setDirectory(time);
|
|
|
+ entity.setFileName(sb.toString());
|
|
|
+ // 只存目录,没有存完整路径
|
|
|
+ entity.setFileUrl(filePath);
|
|
|
+ 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.setType(TypeCode.FILE_TYPE_DEM);
|
|
|
+// outputFile.setCoord(entity.getCoord());
|
|
|
+ outputFile.setCreateTime(new Date());
|
|
|
+ outputFile.setUpdateTime(new Date());
|
|
|
+ outputFile.setResStatus(0);
|
|
|
+ outputFile.setBuildPath(outPath);
|
|
|
+
|
|
|
+ outputFile = outputFileRepository.save(outputFile);
|
|
|
+ log.warn("end uploads");
|
|
|
+ return outputFile;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void test() {
|
|
|
+ log.warn("input: {}", INPUT_PATH);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R cmdSlice(Long fileId) {
|
|
|
+ log.warn("run cmdSlice: {}", fileId);
|
|
|
+
|
|
|
+ OutputFileEntity entity = null;
|
|
|
+ Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
|
|
|
+ if (o.isPresent()) {
|
|
|
+ entity = o.get();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String outputPath = OUTPUT_PATH + "slice/" + entity.getDirectory();
|
|
|
+ FileUtils.createDir(outputPath);
|
|
|
+ log.warn("outputPath: {}", outputPath);
|
|
|
+
|
|
|
+ // 切片命令
|
|
|
+ String cmd = Command.DEM_SLICE;
|
|
|
+ cmd = cmd.replace("@inputFile", entity.getBuildPath());
|
|
|
+ cmd = cmd.replace("@outputFile", outputPath);
|
|
|
+// log.info("cmd: {}", cmd);
|
|
|
+
|
|
|
+ // 把数据放入队列中
|
|
|
+ boolean offer = false;
|
|
|
+ try {
|
|
|
+ offer = queue.offer(count.incrementAndGet(), 1, TimeUnit.SECONDS);
|
|
|
+ log.info("dem slice enqueue success");
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ log.error("error enqueue: {}", e);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (offer) {
|
|
|
+ // 6:切片中
|
|
|
+ entity.setStatus(6);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ // 是目录
|
|
|
+ entity.setServicePath(outputPath);
|
|
|
+
|
|
|
+ entity = outputFileRepository.save(entity);
|
|
|
+ asyncTask.demSlice(queue, outputFileRepository, entity, cmd);
|
|
|
+ } else {
|
|
|
+ // 0:切片失败
|
|
|
+ entity.setStatus(0);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ outputFileRepository.save(entity);
|
|
|
+
|
|
|
+ return new R(5200, MsgCode.E52000);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ log.warn("end cmdSlice");
|
|
|
+
|
|
|
+ return new R(200, entity);
|
|
|
+ }
|
|
|
+
|
|
|
+// @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);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|