Bladeren bron

细节修改;增加获取系统图使用到的图例id列表的方法;

zhaoyk 3 jaren geleden
bovenliggende
commit
8964aedb4c

+ 4 - 2
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/DiagramBuilder.java

@@ -110,7 +110,7 @@ public class DiagramBuilder {
 		}
 
 		EquipmentNode node = new EquipmentNode();
-		node.setId(IdUtil.simpleUUID());
+		node.setId(IdUtil.fastSimpleUUID());
 		node.setDataObjectId(obj.get("id").asText());
 		node.setObjClassCode(DiagramBuilder.getClassCode(obj));
 		node.setDataObject(obj);
@@ -128,6 +128,7 @@ public class DiagramBuilder {
 		node.setLayoutIndex(con.getChildren().size() - 1);
 
 		Label label = new Label();
+		label.setId(IdUtil.fastSimpleUUID());
 		label.setContent(name);
 		node.setLabel(label);
 
@@ -180,7 +181,7 @@ public class DiagramBuilder {
 
 	private PackNode newPackNode(String objClsCode, Container con, String packName){
 		PackNode pn = new PackNode();
-		pn.setId(IdUtil.simpleUUID());
+		pn.setId(IdUtil.fastSimpleUUID());
 		pn.setObjClassCode(objClsCode);
 
 		initNode(pn, packName, con);
@@ -392,6 +393,7 @@ public class DiagramBuilder {
 	}
 
 	private void addLine(Line line) {
+		line.setId(IdUtil.fastSimpleUUID());
 		markAnchorLine(line.getFrom(), line);
 		markAnchorLine(line.getTo(), line);
 		diagram.getLines().add(line);

+ 26 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/Diagram.java

@@ -129,12 +129,25 @@ public class Diagram {
 			size = template.getFrame().getSize();
 		}
 
+		layoutLines(context);
+	}
+
+	public void layoutLines(CalcContext context) {
 		LineLayoutManager lineLayoutManager = new LineLayoutManager(context);
 		for(Line line : lines) {
 			line.layout(lineLayoutManager);
 		}
 	}
 
+	public void layoutLine(String lineId, CalcContext context){
+		for(Line line : lines) {
+			if(lineId.equals(line.getId())) {
+				line.layout(new LineLayoutManager(context));
+				break;
+			}
+		}
+	}
+
 	public void clearLayout(){
 		if(template != null) {
 			template.clearLayout();
@@ -306,4 +319,17 @@ public class Diagram {
 		this.template = template;
 	}
 
+	public String[] getLegendIds() {
+		HashSet<String> ids = new HashSet<>();
+		nodes.forEach(node -> {
+			if(node instanceof EquipmentNode) {
+				String legendId = ((EquipmentNode) node).getLegendId();
+				if(StrUtil.isNotBlank(legendId)){
+					ids.add(legendId);
+				}
+			}
+		});
+		return ids.toArray(new String[ids.size()]);
+	}
+
 }

+ 15 - 1
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/DynGroup.java

@@ -9,12 +9,18 @@ import com.google.gson.annotations.Expose;
 public class DynGroup {
 
 	/**
-	 * 动态源,可选值:floor | building | mainPipe:id | containerElement:id
+	 * 动态源(floor | building | mainPipe.id | container.id)
 	 */
 	@Expose
 	private String dynSource;
 
 	/**
+	 * 动态源类型,可选值: data | group | mainPipe | container
+	 */
+	@Expose
+	private String dynSourceType;
+
+	/**
 	 * 分组标签的位置, top | bottom | left | right
 	 */
 	@Expose
@@ -28,6 +34,14 @@ public class DynGroup {
 		this.dynSource = dynSource;
 	}
 
+	public String getDynSourceType() {
+		return dynSourceType;
+	}
+
+	public void setDynSourceType(String dynSourceType) {
+		this.dynSourceType = dynSourceType;
+	}
+
 	public String getLabelPosition() {
 		return labelPosition;
 	}

+ 9 - 5
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/manage/TemplateManager.java

@@ -444,15 +444,19 @@ public class TemplateManager {
                 } else if(o instanceof Container) {
                     Container target = null;
                     if(StrUtil.isNotBlank(compId)) {
-                        Container con = template.getContainerById(compId);
-                        if(con != null){
-                            target = con;
+                        Container c = template.getContainerById(compId);
+                        if(c != null){
+                            target = c;
                         }
                     } else {
                       target = template.getFrame();
                     }
-                    if(target != null){
-                        target.addComp((Container)o);
+                    if(target != null && !target.isEquipmentBox()){
+                        Container con = (Container)o;
+                        if(template.getContainerById(con.getId()) != null){
+                            con.setId(IdUtil.simpleUUID());
+                        }
+                        target.addComp(con);
                     }
                 } else {
                     //暂不支持干管粘贴