zhaoyk 3 éve
szülő
commit
bc061c3721

+ 6 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/DiagramController.java

@@ -77,6 +77,12 @@ public class DiagramController {
 
         List<Diagram> diagramList = dataStrategy.getDiagrams(null, projectId,
                 (String) diagram.get("systemId"), groupCode, null, false);
+        if (diagramList != null) { //TODO 批量处理会导致接口响应慢,优化为列表和内容拆分的方式
+            diagramList.forEach(d -> {
+                diagramManager.buildDiagram(d);
+                d.toAbsoluteLocation();
+            });
+        }
 
         return diagramManager.json4View(ResultHelper.multi(diagramList));
     }

+ 10 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/TemplateController.java

@@ -106,4 +106,14 @@ public class TemplateController {
         return ResultHelper.single(templateManager.modifyDynGroup(params.getDynGroup(), params.getCurrentCompId(), params.getTemplateId()));
     }
 
+    @PostMapping("copyContent")
+    public CommonResult<String> copyContent(@RequestBody EditRequest params){
+        return ResultHelper.single(templateManager.getCopyContent(params.getCurrentCompId(), params.getTemplateId()));
+    }
+
+    @PostMapping("pasteContent")
+    public CommonResult<DiagramTemplate> pasteContent(@RequestBody EditRequest params){
+        return ResultHelper.single(templateManager.setPasteContent(params.getContent(), params.getCurrentCompId(), params.getTemplateId()));
+    }
+
 }

+ 1 - 1
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/DiagramDataLoader.java

@@ -70,7 +70,7 @@ public class DiagramDataLoader {
 				}
 
 				//设置anchorLocations
-				en.getAnchorLocations();
+				en.setAnchorLocations();
 			}
 
 			if(obj != null) {

+ 9 - 8
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/EquipmentNode.java

@@ -56,7 +56,7 @@ public class EquipmentNode extends DiagramNode implements IDataBind {
 			label.setLocation(new XY(10, 10)); //TODO
 		}
 
-		//TODO anchors
+		setAnchorLocations();
 	}
 
 	@Override
@@ -115,15 +115,16 @@ public class EquipmentNode extends DiagramNode implements IDataBind {
 		return legend;
 	}
 
-	public Map<String, XY> getAnchorLocations() {
-		if (anchorLocations == null) {
-			if (legend.getAnchors() != null) {
-				anchorLocations = new HashMap<>();
-				for (Anchor anchor : legend.getAnchors()) {
-					anchorLocations.put(anchor.getCode(), anchor.calcLocation(size));
-				}
+	public void setAnchorLocations() {
+		if (legend.getAnchors() != null) {
+			anchorLocations = new HashMap<>();
+			for (Anchor anchor : legend.getAnchors()) {
+				anchorLocations.put(anchor.getCode(), anchor.calcLocation(size));
 			}
 		}
+	}
+
+	public Map<String, XY> getAnchorLocations() {
 		return anchorLocations;
 	}
 

+ 2 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/frame/EditRequest.java

@@ -40,6 +40,8 @@ public class EditRequest {
 
 	private DynGroup dynGroup;
 
+	private String content;
+
 	@Data
 	public static class TemplatePropsData {
 

+ 61 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/manage/TemplateManager.java

@@ -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);
+    }
+
 }

+ 3 - 33
adm-business/adm-diagram/src/main/resources/bootstrap.yml

@@ -4,6 +4,8 @@ spring:
   application:
     # 应用名称
     name: adm-diagram
+  main:
+    allow-bean-definition-overriding: true
   datasource:
     dynamic:
       datasource:
@@ -22,36 +24,4 @@ persagy:
     dic:
       service: http://develop.ysbdtp.com/dmp-dic
     file:
-      service: http://develop.ysbdtp.com/dmp-file
-
-#    driver-class-name: com.mysql.cj.jdbc.Driver
-#  datasource:
-#    druid:
-#      filters: stat,slf4j
-#      filter:
-#        wall:
-#          config:
-#            #允许一次执行多条语句
-#            multi-statement-allow: true
-#            #允许非基本语句的其他语句,开启后可以执行DDL语句
-#            none-base-statement-allow: true
-#          enabled: false
-#        slf4j:
-#          enabled: true
-
-config:
-  file:
-    absolute:
-      path: ${CONFIG_FILE_PATH:D:\SpringCloud}
-#feign:
-#  compression:
-#    request:
-#      # 开启请求压缩
-#      enabled: true
-#      # 配置压缩的 MIME TYPE
-#      mime-types: text/xml,application/xml,application/json
-#      # 配置压缩数据大小的下限
-#      min-request-size: 2048
-#    response:
-#      # 开启响应压缩
-#      enabled: true
+      service: http://develop.ysbdtp.com/dmp-file