Kaynağa Gözat

1231,打包节点、组合过滤条件、图例匹配条件

zhaoyk 3 yıl önce
ebeveyn
işleme
2eae87dfec
17 değiştirilmiş dosya ile 390 ekleme ve 133 silme
  1. 155 2
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/DiagramBuilder.java
  2. 18 79
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/DiagramDataLoader.java
  3. 6 9
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/EquipmentNode.java
  4. 15 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/legend/Legend.java
  5. 22 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/AndFilter.java
  6. 23 3
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/DataFilter.java
  7. 1 1
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/DynGroup.java
  8. 34 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/LogicFilter.java
  9. 17 5
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/MatchFilter.java
  10. 22 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/OrFilter.java
  11. 10 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/template/DiagramTemplate.java
  12. 15 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/template/MainPipe.java
  13. 10 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/virtual/PackNode.java
  14. 6 0
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/util/GsonUtil.java
  15. 1 1
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/frame/EditRequest.java
  16. 6 2
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/manage/LegendManager.java
  17. 29 31
      adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/manage/TemplateManager.java

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

@@ -1,11 +1,20 @@
 package com.persagy.adm.diagram.core;
 
+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.model.Diagram;
+import com.persagy.adm.diagram.core.model.EquipmentNode;
+import com.persagy.adm.diagram.core.model.Label;
 import com.persagy.adm.diagram.core.model.base.Container;
+import com.persagy.adm.diagram.core.model.base.IComponent;
+import com.persagy.adm.diagram.core.model.legend.Legend;
 import com.persagy.adm.diagram.core.model.virtual.PackNode;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 处理系统图的计算逻辑
@@ -13,8 +22,152 @@ import java.util.Map;
  */
 public class DiagramBuilder {
 
-	private Map<Container, List<PackNode>> packNodes = new HashMap<>();
+	private Diagram diagram;
 
+	private DataStrategy dataStrategy;
 
+	private HashMap<String, List<Legend>> legendsCache = new HashMap<>();
+
+	public DiagramBuilder(Diagram diagram, DataStrategy dataStrategy) {
+		this.diagram = diagram;
+		this.dataStrategy = dataStrategy;
+	}
+
+	public void addEquipNode(Container con, ObjectNode obj){
+		EquipmentNode node = new EquipmentNode();
+		node.setId(IdUtil.simpleUUID());
+		node.setObjId(obj.get("id").asText());
+		node.setObjClassCode(DiagramBuilder.getClassCode(obj));
+		node.setDataObject(obj);
+
+		initNode(node, DiagramBuilder.getName(obj), con);
+
+		Legend legend = findLegend(node.getObjClassCode(), obj);
+		if(legend != null) {
+			node.setLegendId(legend.getId());
+			node.setLegend(legend);
+		}
+	}
+
+	private void initNode(EquipmentNode node, String name, Container con){
+		con.addComp(node);
+		node.setContainerId(con.getId());
+		node.setLayoutIndex(con.getChildren().size() - 1);
+
+		Label label = new Label();
+		label.setContent(name);
+		node.setLabel(label);
+
+		diagram.getNodes().add(node);
+	}
+
+	public void addPackData(Container con, ObjectNode obj){
+		PackNode pn = null;
+		String classCode = getClassCode(obj);
+		Legend legend = null;
+		if(!con.getEquipPack().isPackByType()) { //single
+			String packName = con.getEquipPack().getPackName();
+			if(StrUtil.isBlank(packName))
+				packName = getTypeName(classCode);
+			if(con.getChildren().size() == 0)
+				pn = newPackNode(PackNode.SINGLE_PACK, con, packName);
+			else
+				pn = (PackNode) con.getChildren().get(0);
+			if(con.getEquipPack().getLegendId() != null)
+				legend = dataStrategy.getLegend(con.getEquipPack().getLegendId(), classCode.substring(0, 4));
+		} else { //group
+			for(IComponent comp : con.getChildren()) {
+				PackNode item = (PackNode) comp;
+				if(item.getObjClassCode().equals(classCode)){
+					pn = item;
+					break;
+				}
+			}
+			if(pn == null)
+				pn = newPackNode(classCode, con, getTypeName(classCode));
+		}
+
+		if(legend == null)
+			legend = findLegend(classCode, null);
+		if(legend != null) {
+			pn.setLegendId(legend.getId());
+			pn.setLegend(legend);
+		}
+
+		pn.add(classCode);
+	}
+
+	private PackNode newPackNode(String objClsCode, Container con, String packName){
+		PackNode pn = new PackNode();
+		pn.setId(IdUtil.simpleUUID());
+		pn.setObjClassCode(objClsCode);
+
+		initNode(pn, packName, con);
+
+		return pn;
+	}
+
+	private String getTypeName(String classCode){
+		//TODO
+		return classCode;
+	}
+
+	private Legend findLegend(String classCode, ObjectNode obj){
+		List<Legend> legends = legendsCache.get(classCode);
+		if (legends == null) {
+			legends = dataStrategy.getLegendsForEquipment(classCode);
+			if (legends == null)
+				legends = new ArrayList<>();
+			legendsCache.put(classCode, legends);
+		}
+		if(legends.size() > 0) {
+			Legend l0 = null, l1 = null;
+			for(Legend legend : legends) {
+				//系统图类型匹配
+				boolean typeMatch = CollUtil.isNotEmpty(legend.getDiagramTypes()) && legend.getDiagramTypes().contains(diagram.getType());
+				//过滤条件匹配
+				boolean filterMatch;
+				if(obj != null && legend.getDataFilter() != null)
+					filterMatch = legend.getDataFilter().filter(obj);
+				else
+					filterMatch = true;
+
+				if(typeMatch && filterMatch)
+					return legend;
+
+				if(typeMatch && l0 == null)
+					l0 = legend;
+				if(filterMatch && l1 == null)
+					l1 = legend;
+			}
+			if(l0 != null)
+				return l0;
+			if(l1 != null)
+				return l1;
+
+			return legends.get(0); //没有优先匹配的话取第一个
+		}
+
+		//返回一个缺省图例
+		Legend l = new Legend();
+		l.setWidth(100);
+		l.setHeight(100);
+		return l;
+	}
+
+	public static String getName(ObjectNode obj){
+		String name = null;
+		if(obj.get("localName") != null)
+			name = obj.get("localName").asText();
+		if(StrUtil.isBlank(name))
+			name = obj.get("name").asText();
+		return name;
+	}
+
+	public static String getClassCode(ObjectNode obj){
+		if(obj.get("classCode") != null)
+			return obj.get("classCode").asText();
+		return null;
+	}
 
 }

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

@@ -1,17 +1,12 @@
 package com.persagy.adm.diagram.core;
 
 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.model.EquipmentNode;
-import com.persagy.adm.diagram.core.model.base.Container;
 import com.persagy.adm.diagram.core.model.Diagram;
 import com.persagy.adm.diagram.core.model.DiagramNode;
-import com.persagy.adm.diagram.core.model.Label;
-import com.persagy.adm.diagram.core.model.legend.Legend;
+import com.persagy.adm.diagram.core.model.EquipmentNode;
+import com.persagy.adm.diagram.core.model.base.Container;
 import com.persagy.adm.diagram.core.model.logic.DataFilter;
-import com.persagy.adm.diagram.core.model.logic.MatchFilter;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -38,11 +33,12 @@ public class DiagramDataLoader {
 
 	private List<ObjectNode> optionalRels;
 
-	private HashMap<String, List<Legend>> legendsCache = new HashMap<>();
+	private DiagramBuilder builder;
 
 	public DiagramDataLoader(Diagram diagram, DataStrategy dataStrategy) {
 		this.diagram = diagram;
 		this.dataStrategy = dataStrategy;
+		this.builder = new DiagramBuilder(diagram, dataStrategy);
 	}
 
 	public void load(){
@@ -85,6 +81,7 @@ public class DiagramDataLoader {
 		} else
 			containers = new ArrayList<>();
 
+		//TODO 数据查询,需要区分打包设备
 		if(equipTypes.size() > 0)
 			optionalObjs = dataStrategy.loadObjectsByType(equipTypes, diagram.getProjectId(), diagram.getSystemId(), diagram.getGroupCode());
 		else
@@ -108,12 +105,13 @@ public class DiagramDataLoader {
 		addEquipNodes();
 		buildContainers();
 
-		if(optionalObjs.size() > 0) {
-			List<String> objIds = new ArrayList<>(optionalObjs.size());
-			optionalObjs.forEach(obj -> objIds.add(obj.get("id").asText()));
-			optionalRels = dataStrategy.loadRelationsByType(null, objIds, diagram.getProjectId(), diagram.getGroupCode());
-		} else
-			optionalRels = new ArrayList<>();
+		//TODO 关系查询,需要区分打包设备
+//		if(optionalObjs.size() > 0) {
+//			List<String> objIds = new ArrayList<>(optionalObjs.size());
+//			optionalObjs.forEach(obj -> objIds.add(obj.get("id").asText()));
+//			optionalRels = dataStrategy.loadRelationsByType(null, objIds, diagram.getProjectId(), diagram.getGroupCode());
+//		} else
+//			optionalRels = new ArrayList<>();
 
 		addLines();
 	}
@@ -131,32 +129,10 @@ public class DiagramDataLoader {
 		for(Container con : containers) {
 			for(ObjectNode obj : optionalObjs){
 				if (match(obj, con)) {
-					EquipmentNode node = new EquipmentNode();
-					node.setId(IdUtil.simpleUUID());
-					node.setObjId(obj.get("id").asText());
-					node.setObjClassCode(obj.get("classCode").asText());
-					node.setDataObject(obj);
-
-					Label label = new Label();
-					String content = null;
-					if(obj.get("localName") != null)
-						content = obj.get("localName").asText();
-					if(StrUtil.isBlank(content))
-						content = obj.get("name").asText();
-					label.setContent(content);
-					node.setLabel(label);
-
-					diagram.getNodes().add(node);
-
-					con.addComp(node);
-					node.setContainerId(con.getId());
-					node.setLayoutIndex(con.getChildren().size() - 1);
-
-					Legend legend = findLegend(node, obj);
-					if(legend != null) {
-						node.setLegendId(legend.getId());
-						node.setLegend(legend);
-					}
+					if(con.getEquipPack() != null)
+						builder.addPackData(con, obj);
+					else
+						builder.addEquipNode(con, obj);
 				}
 			}
 		}
@@ -209,53 +185,16 @@ public class DiagramDataLoader {
 //	}
 
 	private boolean match(ObjectNode obj, Container con) {
-		String classCode = obj.get("classCode").asText();
+		String classCode = DiagramBuilder.getClassCode(obj);
 		if(con.getEquipmentTypes() != null && con.getEquipmentTypes().contains(classCode)) {
 			DataFilter filter = con.getDataFilter();
 			if(filter != null)
-				return filter.filter(getDataForFilter(filter, obj));
+				return filter.filter(obj);
 			return true;
 		}
 		return false;
 	}
 
-	private Object getDataForFilter(DataFilter filter, ObjectNode obj){
-		if(filter instanceof MatchFilter) {
-			MatchFilter mf = (MatchFilter) filter;
-			if(mf.getObject().equals(MatchFilter.OBJ_NAME)) {
-				String name = null;
-				if(obj.get("localName") != null)
-					name = obj.get("localName").asText();
-				if(StrUtil.isBlank(name))
-					name = obj.get("name").asText();
-				return name;
-			} else if(mf.getObject().startsWith(MatchFilter.OBJ_INFOS)) {
-				String infoCode = mf.getObject().substring(MatchFilter.OBJ_INFOS.length());
-				return obj.get(infoCode);
-			}
-		}
-		return null;
-	}
-
-	private Legend findLegend(EquipmentNode node, ObjectNode obj){
-		String classCode = node.getObjClassCode();
-		List<Legend> legends = legendsCache.get(classCode);
-		if (legends == null) {
-			legends = dataStrategy.getLegendsForEquipment(classCode);
-			if (legends == null)
-				legends = new ArrayList<>();
-			legendsCache.put(classCode, legends);
-		}
-		if(legends.size() > 0) {
-			for(Legend legend : legends) {
-				if(CollUtil.isNotEmpty(legend.getDiagramTypes()) && legend.getDiagramTypes().contains(diagram.getType()))
-					return legend; //优先返回适配系统图类型的图例
-			}
-			return legends.get(0); //缺省取第一个
-		}
-		return null;
-	}
-
 	private void buildContainers() {
 		for(Container con : containers) {
 			if(con.isEquipmentBox()) {

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

@@ -49,16 +49,13 @@ public class EquipmentNode extends DiagramNode {
 
 	@Override
 	public void layout() {
-		if(legend != null) {
-			setSize(new XY(legend.getWidth(), legend.getHeight()));
-			if(legend.getAnchors() != null) {
-				anchorLocations = new HashMap<>();
-				for(Anchor anchor : legend.getAnchors()) {
-					anchorLocations.put(anchor.getCode(), anchor.calcLocation(size));
-				}
+		setSize(new XY(legend.getWidth(), legend.getHeight()));
+		if(legend.getAnchors() != null) {
+			anchorLocations = new HashMap<>();
+			for(Anchor anchor : legend.getAnchors()) {
+				anchorLocations.put(anchor.getCode(), anchor.calcLocation(size));
 			}
-		} else
-			setSize(new XY(100, 100)); //TODO default size
+		}
 
 		if(label != null) {
 			label.setLocation(new XY(10, 10)); //TODO

+ 15 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/legend/Legend.java

@@ -2,6 +2,7 @@ package com.persagy.adm.diagram.core.model.legend;
 
 import com.google.gson.annotations.Expose;
 import com.persagy.adm.diagram.core.model.base.XY;
+import com.persagy.adm.diagram.core.model.logic.DataFilter;
 
 import java.util.List;
 
@@ -48,6 +49,12 @@ public class Legend {
 	private List<String> diagramTypes;
 
 	/**
+	 * 匹配数据的过滤条件
+	 */
+	@Expose
+	private DataFilter dataFilter;
+
+	/**
 	 * 轮廓图形
 	 */
 	@Expose
@@ -139,6 +146,14 @@ public class Legend {
 		this.diagramTypes = diagramTypes;
 	}
 
+	public DataFilter getDataFilter() {
+		return dataFilter;
+	}
+
+	public void setDataFilter(DataFilter dataFilter) {
+		this.dataFilter = dataFilter;
+	}
+
 	public List<List<XY>> getOutline() {
 		return outline;
 	}

+ 22 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/AndFilter.java

@@ -0,0 +1,22 @@
+package com.persagy.adm.diagram.core.model.logic;
+
+/**
+ * and条件
+ * @author zhaoyk
+ */
+public class AndFilter extends LogicFilter {
+
+	public AndFilter(){
+		this.type = TYPE_AND;
+	}
+
+	@Override
+	protected boolean judge(Object data) {
+		for(DataFilter item : items) {
+			if(!item.filter(data))
+				return false;
+		}
+		return true;
+	}
+
+}

+ 23 - 3
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/DataFilter.java

@@ -14,14 +14,18 @@ abstract public class DataFilter {
 
 	public static final int TYPE_OR = 3;
 
-	public static final int TYPE_NOT = 4;
-
 	/**
 	 * 过滤器类型
 	 */
 	@Expose
 	protected int type;
 
+	/**
+	 * 否定
+	 */
+	@Expose
+	protected boolean not;
+
 	public int getType() {
 		return type;
 	}
@@ -30,9 +34,25 @@ abstract public class DataFilter {
 		this.type = type;
 	}
 
+	public boolean isNot() {
+		return not;
+	}
+
+	public void setNot(boolean not) {
+		this.not = not;
+	}
+
 	/**
 	 * 过滤操作,返回true时通过
 	 */
-	abstract public boolean filter(Object data);
+	public boolean filter(Object data) {
+		boolean rtn = judge(data);
+		return not ? !rtn : rtn;
+	}
+
+	/**
+	 * 子类实现具体的判断逻辑
+	 */
+	abstract protected boolean judge(Object data);
 
 }

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

@@ -9,7 +9,7 @@ import com.google.gson.annotations.Expose;
 public class DynGroup {
 
 	/**
-	 * 动态源,可选值:floor | building | mainPipe:id | container:id
+	 * 动态源,可选值:floor | building | mainPipe:id | containerElement:id
 	 */
 	@Expose
 	private String dynSource;

+ 34 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/LogicFilter.java

@@ -0,0 +1,34 @@
+package com.persagy.adm.diagram.core.model.logic;
+
+import com.google.gson.annotations.Expose;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 逻辑组合过滤条件
+ * @author zhaoyk
+ */
+abstract public class LogicFilter extends DataFilter {
+
+	/**
+	 * 条目列表
+	 */
+	@Expose
+	protected List<DataFilter> items;
+
+	public List<DataFilter> getItems() {
+		return items;
+	}
+
+	public void setItems(List<DataFilter> items) {
+		this.items = items;
+	}
+
+	public void addItem(DataFilter item) {
+		if(items == null)
+			items = new ArrayList<>();
+		items.add(item);
+	}
+
+}

+ 17 - 5
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/MatchFilter.java

@@ -1,7 +1,9 @@
 package com.persagy.adm.diagram.core.model.logic;
 
 import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.gson.annotations.Expose;
+import com.persagy.adm.diagram.core.DiagramBuilder;
 
 import java.util.Objects;
 
@@ -35,20 +37,30 @@ public class MatchFilter extends DataFilter {
 	}
 
 	@Override
-	public boolean filter(Object data) {
-		if(EQUALS.equals(operation)) {
+	protected boolean judge(Object data) {
+		Object param = null;
+		if (data instanceof ObjectNode) {
+			if(object.equals(MatchFilter.OBJ_NAME)) {
+				param = DiagramBuilder.getName((ObjectNode)data);
+			} else if(object.startsWith(MatchFilter.OBJ_INFOS)) {
+				String infoCode = object.substring(MatchFilter.OBJ_INFOS.length());
+				param = ((ObjectNode)data).get(infoCode);
+			}
+		}
+
+		if (EQUALS.equals(operation)) {
 			if(VALUE_EMPTY.equals(value)){
-				return data == null || StrUtil.isBlank(data.toString());
+				return param == null || StrUtil.isBlank(param.toString());
 			} else {
 				Object val = value;
-				if(data instanceof Number) {
+				if(param instanceof Number) {
 					try {
 						val = Double.parseDouble(value);
 					}catch (Exception e) {
 
 					}
 				}
-				return Objects.equals(data, val);
+				return Objects.equals(param, val);
 			}
 		} else if(CONTAINS.equals(operation)) {
 			//简单处理,暂时只考虑字符串,多个匹配项之间使用';'隔开

+ 22 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/logic/OrFilter.java

@@ -0,0 +1,22 @@
+package com.persagy.adm.diagram.core.model.logic;
+
+/**
+ * or条件
+ * @author zhaoyk
+ */
+public class OrFilter extends LogicFilter {
+
+	public OrFilter(){
+		this.type = TYPE_OR;
+	}
+
+	@Override
+	protected boolean judge(Object data) {
+		for(DataFilter item : items) {
+			if(!item.filter(data))
+				return true;
+		}
+		return false;
+	}
+	
+}

+ 10 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/template/DiagramTemplate.java

@@ -186,6 +186,16 @@ public class DiagramTemplate {
 		return null;
 	}
 
+	public MainPipe getMainPipeById(String mainPipeId) {
+		if(mainPipes != null) {
+			for (MainPipe mainPipe : mainPipes) {
+				if (mainPipe.getId().equals(mainPipeId))
+					return mainPipe;
+			}
+		}
+		return null;
+	}
+
 	public void layout(XY location) {
 		frame.setLocation(location);
 		frame.layout();

+ 15 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/template/MainPipe.java

@@ -4,6 +4,7 @@ import com.google.gson.annotations.Expose;
 import com.persagy.adm.diagram.core.model.base.Container;
 import com.persagy.adm.diagram.core.model.AbstractLine;
 import com.persagy.adm.diagram.core.model.base.XY;
+import com.persagy.adm.diagram.core.model.logic.DataFilter;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -32,6 +33,12 @@ public class MainPipe extends AbstractLine {
 	@Expose
 	private boolean bindEquipment; //干管是否绑定具体设备
 
+	/**
+	 * 设备数据过滤器
+	 */
+	@Expose
+	private DataFilter dataFilter;
+
 	@Expose
 	private List<List<MainPipePoint>> path = new ArrayList<>();
 
@@ -104,6 +111,14 @@ public class MainPipe extends AbstractLine {
 		this.bindEquipment = bindEquipment;
 	}
 
+	public DataFilter getDataFilter() {
+		return dataFilter;
+	}
+
+	public void setDataFilter(DataFilter dataFilter) {
+		this.dataFilter = dataFilter;
+	}
+
 	public List<List<MainPipePoint>> getPath() {
 		return path;
 	}

+ 10 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/virtual/PackNode.java

@@ -14,6 +14,8 @@ public class PackNode extends EquipmentNode {
 
 	public static final String TYPE = "packNode";
 
+	public static final String SINGLE_PACK = "singlePack";
+
 	/**
 	 * 设备统计信息{设备类型, 设备数量}
 	 */
@@ -40,4 +42,12 @@ public class PackNode extends EquipmentNode {
 		statInfo.put(equipClassCode, i == null ? 1 : i + 1);
 	}
 
+	public int totalCount(){
+		int i = 0;
+		for(Integer num : statInfo.values()) {
+			i += num;
+		}
+		return i;
+	}
+
 }

+ 6 - 0
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/util/GsonUtil.java

@@ -5,8 +5,10 @@ import com.persagy.adm.diagram.core.model.EquipmentNode;
 import com.persagy.adm.diagram.core.model.Label;
 import com.persagy.adm.diagram.core.model.base.Container;
 import com.persagy.adm.diagram.core.model.base.IComponent;
+import com.persagy.adm.diagram.core.model.logic.AndFilter;
 import com.persagy.adm.diagram.core.model.logic.DataFilter;
 import com.persagy.adm.diagram.core.model.logic.MatchFilter;
+import com.persagy.adm.diagram.core.model.logic.OrFilter;
 import com.persagy.adm.diagram.core.model.virtual.PackNode;
 import org.springframework.stereotype.Component;
 
@@ -75,6 +77,10 @@ public class GsonUtil {
 			int fType = jsonElement.getAsJsonObject().get("type").getAsInt();
 			if(fType == DataFilter.TYPE_MATCH)
 				target = MatchFilter.class;
+			else if(fType == AndFilter.TYPE_AND)
+				target = AndFilter.class;
+			else if(fType == OrFilter.TYPE_OR)
+				target = OrFilter.class;
 			else {
 				//TODO 其他类型
 			}

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

@@ -29,7 +29,7 @@ public class EditRequest {
 
 	private String sys;
 
-	private Legend legend;
+	private Map<String, Object> legend;
 
 	private String diagramId;
 

+ 6 - 2
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/manage/LegendManager.java

@@ -3,6 +3,7 @@ package com.persagy.adm.diagram.manage;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.persagy.adm.diagram.core.ContentParser;
 import com.persagy.adm.diagram.core.DataStrategy;
 import com.persagy.adm.diagram.core.model.legend.Legend;
 import com.persagy.adm.diagram.core.util.GsonUtil;
@@ -27,6 +28,9 @@ public class LegendManager {
 	private final DataStrategy dataStrategy;
 
 	@Autowired
+	private ContentParser parser;
+
+	@Autowired
 	public LegendManager(@Qualifier(DataStrategy.implQualifier) DataStrategy dataStrategy) {
 		this.dataStrategy = dataStrategy;
 	}
@@ -55,8 +59,8 @@ public class LegendManager {
 	/**
 	 * 保存图例
 	 */
-	public Legend saveLegend(Legend legend, String sys) {
-		return dataStrategy.saveLegend(legend, sys);
+	public Legend saveLegend(Map<String, Object> legendMap, String sys) {
+		return dataStrategy.saveLegend(parser.parseContent(parser.toJson(legendMap), Legend.class), sys);
 	}
 
 	/**

+ 29 - 31
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/manage/TemplateManager.java

@@ -3,11 +3,9 @@ package com.persagy.adm.diagram.manage;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.IdUtil;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.adm.diagram.core.ContentParser;
 import com.persagy.adm.diagram.core.model.base.*;
-import com.persagy.adm.diagram.core.model.logic.DataFilter;
-import com.persagy.adm.diagram.core.model.logic.DynGroup;
-import com.persagy.adm.diagram.core.model.logic.EquipPack;
-import com.persagy.adm.diagram.core.model.logic.MatchFilter;
+import com.persagy.adm.diagram.core.model.logic.*;
 import com.persagy.adm.diagram.entity.DiagramType;
 import com.persagy.adm.diagram.frame.EditRequest;
 import com.persagy.adm.diagram.core.DataStrategy;
@@ -41,6 +39,9 @@ public class TemplateManager {
 	}
 
 	@Autowired
+	private ContentParser contentParser;
+
+	@Autowired
 	private BdtpDataService bdtpDataService;
 
 	/**
@@ -315,23 +316,19 @@ public class TemplateManager {
 	/**
 	 * 修改干管
 	 */
-	public DiagramTemplate modifyMainPipe(EditRequest.TemplatePropsData propsData, String containerId, String templateId){
+	public DiagramTemplate modifyMainPipe(EditRequest.TemplatePropsData propsData, String mainPipeId, String templateId){
 		DiagramTemplate template = dataStrategy.getTemplate(templateId);
 
-		if(template.getMainPipes() != null) {
-			for(MainPipe mainPipe : template.getMainPipes()) {
-				if(mainPipe.getId().equals(containerId)) {
-					mainPipe.setId(propsData.getId());
-					mainPipe.setName(propsData.getName());
-					mainPipe.setRemark(propsData.getRemark());
-					mainPipe.setPipeType(propsData.getPipeType());
-					mainPipe.setBindEquipment(propsData.isBindEquipment());
-					mainPipe.setEquipmentTypes(propsData.getEquipTypes());
-					mainPipe.setPassbyRels(propsData.getPassbyRels());
-					mainPipe.setConnectEquips(propsData.getConnectEquips());
-					break;
-				}
-			}
+		MainPipe mainPipe = template.getMainPipeById(mainPipeId);
+		if(mainPipe != null) {
+			mainPipe.setId(propsData.getId());
+			mainPipe.setName(propsData.getName());
+			mainPipe.setRemark(propsData.getRemark());
+			mainPipe.setPipeType(propsData.getPipeType());
+			mainPipe.setBindEquipment(propsData.isBindEquipment());
+			mainPipe.setEquipmentTypes(propsData.getEquipTypes());
+			mainPipe.setPassbyRels(propsData.getPassbyRels());
+			mainPipe.setConnectEquips(propsData.getConnectEquips());
 		}
 
 		return saveTemplate(template);
@@ -341,22 +338,23 @@ public class TemplateManager {
 	 * 修改设备数据过滤条件
 	 * filter可能是多种类型,通过Map转换
 	 */
-	public DiagramTemplate modifyFilter(Map<String, Object> filter, String containerId, String templateId){
+	public DiagramTemplate modifyFilter(Map<String, Object> filter, String compId, String templateId){
 		DiagramTemplate template = dataStrategy.getTemplate(templateId);
 		template.init();
 
-		Container con = template.getContainerById(containerId);
-		if(filter == null)
-			con.setDataFilter(null);
+		DataFilter dataFilter;
+		if(filter != null)
+			dataFilter = contentParser.parseContent(contentParser.toJson(filter), DataFilter.class);
+		else
+			dataFilter = null;
+
+		Container con = template.getContainerById(compId);
+		if(con != null)
+			con.setDataFilter(dataFilter);
 		else {
-			int type = (Integer)filter.get("type");
-			if(type == DataFilter.TYPE_MATCH) {
-				MatchFilter mf = new MatchFilter();
-				mf.setObject((String) filter.get("object"));
-				mf.setOperation((String) filter.get("operation"));
-				mf.setValue((String) filter.get("value"));
-				con.setDataFilter(mf);
-			}
+			MainPipe mainPipe = template.getMainPipeById(compId);
+			if(mainPipe != null)
+				mainPipe.setDataFilter(dataFilter);
 		}
 
 		return saveTemplate(template);