|
@@ -348,12 +348,20 @@ public class VectorServerImpl implements VectorServer {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改样式
|
|
|
+ *
|
|
|
+ * @param entity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public R saveStyle(StyleDto entity) {
|
|
|
+ public R editStyle(StyleDto entity) {
|
|
|
StyleEntity styleEntity = styleRepository.findByOutputFileIdTop(entity.getOutputFileId());
|
|
|
Optional<OutputFileEntity> o = outputFileRepository.findById(entity.getOutputFileId());
|
|
|
+
|
|
|
+ OutputFileEntity outputFileEntity = null;
|
|
|
if (o.isPresent()) {
|
|
|
- OutputFileEntity outputFileEntity = o.get();
|
|
|
+ outputFileEntity = o.get();
|
|
|
outputFileEntity.setStatus(11);
|
|
|
outputFileEntity.setUpdateTime(new Date());
|
|
|
outputFileRepository.save(outputFileEntity);
|
|
@@ -361,6 +369,15 @@ public class VectorServerImpl implements VectorServer {
|
|
|
styleEntity.setUpdateTime(new Date());
|
|
|
styleEntity.setContent(entity.getContent());
|
|
|
StyleEntity save = styleRepository.save(styleEntity);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发布完成才允许这一步操作,因为第一次发布时,还没有样式在config里面
|
|
|
+ *
|
|
|
+ * 发布时数据,已经把样式提交过去config了
|
|
|
+ */
|
|
|
+
|
|
|
+ editStyleConfigJson(save);
|
|
|
+
|
|
|
return new R(200, save.getOutputFileId());
|
|
|
}
|
|
|
|
|
@@ -514,6 +531,7 @@ public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 发布服务
|
|
|
* 修改config.json
|
|
|
*/
|
|
|
private void writeJsonFile(ConfigJsonDto param, String lastName, OutputFileEntity entity) {
|
|
@@ -540,7 +558,7 @@ 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()));
|
|
|
+// subJson.put("style", JSON.parse(styleEntity.getContent()));
|
|
|
layers.add(subJson);
|
|
|
|
|
|
original.put("layers", layers);
|
|
@@ -550,14 +568,13 @@ public class VectorServerImpl implements VectorServer {
|
|
|
FileUtils.fileWriter(JSON.toJSONString(original), CONFIG_JSON_PATH);
|
|
|
|
|
|
// 将图层信息保存到db
|
|
|
-
|
|
|
- log.info("check test 1");
|
|
|
+ // 前端需要layer信息
|
|
|
styleEntity.setLayer(subJson.toJSONString());
|
|
|
styleEntity.setUpdateTime(new Date());
|
|
|
styleEntity.setName(name);
|
|
|
- log.info("check test 2");
|
|
|
+// log.info("check test 2");
|
|
|
styleRepository.save(styleEntity);
|
|
|
- log.info("check test 3");
|
|
|
+// log.info("check test 3");
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
@@ -566,7 +583,7 @@ public class VectorServerImpl implements VectorServer {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 删除制定行的config.json 数据
|
|
|
+ * 删除指定行的config.json 数据
|
|
|
*/
|
|
|
private void deleteRowConfigJson(StyleEntity entity){
|
|
|
String s = FileUtils.readFile(CONFIG_JSON_PATH);
|
|
@@ -597,6 +614,41 @@ public class VectorServerImpl implements VectorServer {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑样式,指定行的config.json 数据
|
|
|
+ * 添加样式
|
|
|
+ */
|
|
|
+ private void editStyleConfigJson(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())) {
|
|
|
+ log.warn("old sytle: {}", o.toJSONString());
|
|
|
+ //修改样式
|
|
|
+ o.put("style",JSON.parse(entity.getContent()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.warn("update sytle: {}", layers.toJSONString());
|
|
|
+
|
|
|
+ // 更新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";
|