|
@@ -2,6 +2,7 @@ package com.persagy.adm.diagram.manage;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.adm.diagram.core.ContentParser;
|
|
|
import com.persagy.adm.diagram.core.DataStrategy;
|
|
@@ -401,4 +402,64 @@ public class TemplateManager {
|
|
|
return saveTemplate(template);
|
|
|
}
|
|
|
|
|
|
+ public String getCopyContent(String compId, String templateId){
|
|
|
+ DiagramTemplate template = dataStrategy.getTemplate(templateId);
|
|
|
+ template.init();
|
|
|
+
|
|
|
+ Object obj;
|
|
|
+ if(StrUtil.isNotBlank(compId)) {
|
|
|
+ obj = template.getContainerById(compId);
|
|
|
+ if(obj == null){
|
|
|
+ obj = template.getMainPipeById(compId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ obj = template;
|
|
|
+ }
|
|
|
+ return obj != null ? contentParser.toJson(obj) : "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public DiagramTemplate setPasteContent(String content, String compId, String templateId){
|
|
|
+ DiagramTemplate template = dataStrategy.getTemplate(templateId);
|
|
|
+ template.init();
|
|
|
+
|
|
|
+ if(StrUtil.isNotBlank(content)) {
|
|
|
+ Map<String, Object> map = contentParser.parseContent(content, Map.class);
|
|
|
+ Object o = null;
|
|
|
+ if(Container.TYPE.equals(map.get("compType"))){
|
|
|
+ o = contentParser.parseContent(content, Container.class);
|
|
|
+ } else if(MainPipe.TYPE.equals(map.get("compType"))) {
|
|
|
+ o = contentParser.parseContent(content, MainPipe.class);
|
|
|
+ } else if(map.containsKey("frame")) {
|
|
|
+ o = contentParser.parseContent(content, DiagramTemplate.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(o != null) {
|
|
|
+ if(o instanceof DiagramTemplate){
|
|
|
+ DiagramTemplate other = (DiagramTemplate)o;
|
|
|
+ if(StrUtil.isBlank(compId)) {
|
|
|
+ template.setFrame(other.getFrame());
|
|
|
+ template.setMainPipes(other.getMainPipes());
|
|
|
+ template.setScatteredContainers(other.getScatteredContainers());
|
|
|
+ }
|
|
|
+ } else if(o instanceof Container) {
|
|
|
+ Container target = null;
|
|
|
+ if(StrUtil.isNotBlank(compId)) {
|
|
|
+ Container con = template.getContainerById(compId);
|
|
|
+ if(con != null){
|
|
|
+ target = con;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ target = template.getFrame();
|
|
|
+ }
|
|
|
+ if(target != null){
|
|
|
+ target.addComp((Container)o);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //暂不支持干管粘贴
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return saveTemplate(template);
|
|
|
+ }
|
|
|
+
|
|
|
}
|