|
@@ -24,7 +24,6 @@ import com.fd.util.R;
|
|
|
import com.fd.util.RegexUtils;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
@@ -33,6 +32,7 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.transaction.Transactional;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
@@ -46,6 +46,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@Log4j2
|
|
|
@Service
|
|
|
+@Transactional
|
|
|
public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
@Value("${input.file.path.vector}")
|
|
@@ -77,9 +78,6 @@ public class VectorServerImpl implements VectorServer {
|
|
|
@Autowired
|
|
|
private StyleRepository styleRepository;
|
|
|
|
|
|
-// @Autowired
|
|
|
-// private LayerRepository layerRepository;
|
|
|
-
|
|
|
@Override
|
|
|
public R moveFileToServer(Long fileId, ConfigJsonDto param) {
|
|
|
Optional<OutputFileEntity> o = outputFileRepository.findById(fileId);
|
|
@@ -104,6 +102,7 @@ public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
|
|
|
entity.setStatus(8);
|
|
|
+ entity.setServicePath(slice);
|
|
|
entity.setUpdateTime(new Date());
|
|
|
outputFileRepository.save(entity);
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
@@ -146,6 +145,7 @@ public class VectorServerImpl implements VectorServer {
|
|
|
deleteFolder(path, entity);
|
|
|
}
|
|
|
|
|
|
+ // 文件类型
|
|
|
if (entity.getGeojsonPath() != null) {
|
|
|
String path = entity.getGeojsonPath();
|
|
|
deleteFolder(path, entity);
|
|
@@ -155,10 +155,22 @@ public class VectorServerImpl implements VectorServer {
|
|
|
FileUtils.delFolder(entity.getSlicePath());
|
|
|
}
|
|
|
|
|
|
+ // 目录类型
|
|
|
+ if (entity.getServicePath() != null) {
|
|
|
+ FileUtils.delFolder(entity.getServicePath());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 删除配置文件config.json制定行
|
|
|
+ StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(fileId);
|
|
|
+ deleteRowConfigJson(styleEntity);
|
|
|
+
|
|
|
|
|
|
// 删除数据库记录
|
|
|
outputFileRepository.deleteById(fileId);
|
|
|
fileRepository.deleteById(entity.getUploadId());
|
|
|
+ styleRepository.deleteByOutputFileId(fileId);
|
|
|
+
|
|
|
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
|
}
|
|
@@ -338,11 +350,14 @@ public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
@Override
|
|
|
public R saveStyle(StyleDto entity) {
|
|
|
-// StyleEntity styleEntity = new StyleEntity();
|
|
|
StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getOutputFileId());
|
|
|
-
|
|
|
-
|
|
|
-// BeanUtils.copyProperties(entity, styleEntity);
|
|
|
+ Optional<OutputFileEntity> o = outputFileRepository.findById(entity.getOutputFileId());
|
|
|
+ if (o.isPresent()) {
|
|
|
+ OutputFileEntity outputFileEntity = o.get();
|
|
|
+ outputFileEntity.setStatus(11);
|
|
|
+ outputFileEntity.setUpdateTime(new Date());
|
|
|
+ outputFileRepository.save(outputFileEntity);
|
|
|
+ }
|
|
|
styleEntity.setUpdateTime(new Date());
|
|
|
styleEntity.setContent(entity.getContent());
|
|
|
StyleEntity save = styleRepository.save(styleEntity);
|
|
@@ -502,6 +517,9 @@ 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);
|
|
@@ -512,8 +530,9 @@ public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
JSONObject subJson = new JSONObject();
|
|
|
long cu = System.currentTimeMillis();
|
|
|
+ String name = "vector_" + cu;
|
|
|
// 需要唯一
|
|
|
- subJson.put("name", "vector_" + cu);
|
|
|
+ subJson.put("name", name);
|
|
|
|
|
|
subJson.put("text", param.getText());
|
|
|
// vector 就用这个类型geodata
|
|
@@ -521,10 +540,9 @@ public class VectorServerImpl implements VectorServer {
|
|
|
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());
|
|
@@ -533,10 +551,13 @@ public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
// 将图层信息保存到db
|
|
|
|
|
|
- StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getId());
|
|
|
+ log.info("check test 1");
|
|
|
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();
|
|
@@ -544,6 +565,38 @@ public class VectorServerImpl implements VectorServer {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除制定行的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();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
|
String inPath = "F:\\test\\clip\\aaa\\wwww";
|