|
@@ -1,7 +1,11 @@
|
|
|
package com.fd.server.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fd.constant.MsgCode;
|
|
|
import com.fd.constant.TypeCode;
|
|
|
+import com.fd.dto.ConfigJsonDto;
|
|
|
import com.fd.dto.PageDto;
|
|
|
import com.fd.entity.FileEntity;
|
|
|
import com.fd.entity.OutputFileEntity;
|
|
@@ -43,6 +47,14 @@ public class VectorServerImpl implements VectorServer {
|
|
|
@Value("${copy.file.path.vector}")
|
|
|
private String MOVE_FILE_TO_SERVER;
|
|
|
|
|
|
+ // config.json 地址
|
|
|
+ @Value("${config.path}")
|
|
|
+ private String CONFIG_JSON_PATH;
|
|
|
+
|
|
|
+ // config.json teileset 的相对路径
|
|
|
+ @Value("${config.tileset}")
|
|
|
+ private String CONFIG_TILESET;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FileRepository fileRepository;
|
|
|
|
|
@@ -51,7 +63,7 @@ public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public R moveFileToServer(Long fileId) {
|
|
|
+ public R moveFileToServer(Long fileId, ConfigJsonDto param) {
|
|
|
Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
|
|
|
if (!o.isPresent()) {
|
|
|
log.info("id:{} 不存在", fileId);
|
|
@@ -59,7 +71,19 @@ public class VectorServerImpl implements VectorServer {
|
|
|
}
|
|
|
OutputFileEntity entity = o.get();
|
|
|
FileUtils.createDir(MOVE_FILE_TO_SERVER);
|
|
|
- FileUtils.base64ToFileWriter(entity.getSlicePath(), MOVE_FILE_TO_SERVER);
|
|
|
+// FileUtils.base64ToFileWriter(entity.getSlicePath(), MOVE_FILE_TO_SERVER);
|
|
|
+
|
|
|
+ try {
|
|
|
+ org.apache.commons.io.FileUtils.copyFileToDirectory(new File(entity.getSlicePath()), new File(MOVE_FILE_TO_SERVER));
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new R(200, MsgCode.E51004, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改前端的config.json 文件
|
|
|
+ writeJsonFile(param);
|
|
|
+
|
|
|
+
|
|
|
entity.setStatus(8);
|
|
|
outputFileRepository.save(entity);
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
@@ -216,8 +240,47 @@ public class VectorServerImpl implements VectorServer {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- String a = "11111.shp";
|
|
|
- System.out.println(StringUtils.substringAfterLast(a, "."));
|
|
|
+ /**
|
|
|
+ * 修改config.json
|
|
|
+ */
|
|
|
+ private void writeJsonFile(ConfigJsonDto param) {
|
|
|
+ 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();
|
|
|
+ subJson.put("name", "vector_" + cu); // 需要唯一
|
|
|
+ subJson.put("text", param.getText());
|
|
|
+ subJson.put("type", "geodata"); // vector 就用这个类型geodata
|
|
|
+ subJson.put("checked", false);
|
|
|
+ subJson.put("show", true);
|
|
|
+ subJson.put("url", param.getUrl());
|
|
|
+
|
|
|
+ layers.add(subJson);
|
|
|
+
|
|
|
+ original.put("layers", layers);
|
|
|
+
|
|
|
+ log.info("original update: {}", original.toJSONString());
|
|
|
+ try {
|
|
|
+ FileUtils.fileWriter(JSON.toJSONString(original), CONFIG_JSON_PATH);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
+
|
|
|
+ String inPath = "F:\\test\\clip";
|
|
|
+ String outPath = "F:\\test\\copy";
|
|
|
+
|
|
|
+// FileUtils.base64ToFileWriter(inPath, outPath);
|
|
|
+ org.apache.commons.io.FileUtils.copyFileToDirectory(new File(inPath), new File(outPath));
|
|
|
+// org.apache.commons.io.FileUtils.
|
|
|
}
|
|
|
}
|