|
@@ -88,10 +88,11 @@ public class DiagramBuilder {
|
|
|
while (iter.hasNext()) {
|
|
|
ObjectNode obj = iter.next();
|
|
|
if (match(obj, con)) {
|
|
|
- if(con.getEquipPack() != null)
|
|
|
+ if(con.getEquipPack() != null) {
|
|
|
addPackData(con, obj);
|
|
|
- else
|
|
|
+ } else {
|
|
|
addEquipNode(con, obj);
|
|
|
+ }
|
|
|
|
|
|
iter.remove();
|
|
|
}
|
|
@@ -124,8 +125,9 @@ public class DiagramBuilder {
|
|
|
}
|
|
|
|
|
|
private void addEquipNode(Container con, ObjectNode obj){
|
|
|
- if(con.getChildren().size() > equipLimit)
|
|
|
+ if(con.getChildren().size() > equipLimit) {
|
|
|
return;
|
|
|
+ }
|
|
|
|
|
|
EquipmentNode node = new EquipmentNode();
|
|
|
node.setId(IdUtil.simpleUUID());
|
|
@@ -158,16 +160,20 @@ public class DiagramBuilder {
|
|
|
PackNode pn = null;
|
|
|
String classCode = getClassCode(obj);
|
|
|
Legend legend = null;
|
|
|
- if(!con.getEquipPack().isPackByType()) { //single
|
|
|
+ //single
|
|
|
+ if(!con.getEquipPack().isPackByType()) {
|
|
|
String packName = con.getEquipPack().getPackName();
|
|
|
- if(StrUtil.isBlank(packName))
|
|
|
+ if(StrUtil.isBlank(packName)) {
|
|
|
packName = getTypeName(classCode);
|
|
|
- if(con.getChildren().size() == 0)
|
|
|
+ }
|
|
|
+ if(con.getChildren().size() == 0) {
|
|
|
pn = newPackNode(PackNode.SINGLE_PACK, con, packName);
|
|
|
- else
|
|
|
+ } else {
|
|
|
pn = (PackNode) con.getChildren().get(0);
|
|
|
- if(con.getEquipPack().getLegendId() != null)
|
|
|
+ }
|
|
|
+ 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;
|
|
@@ -176,15 +182,18 @@ public class DiagramBuilder {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(pn == null)
|
|
|
+ if(pn == null) {
|
|
|
pn = newPackNode(classCode, con, getTypeName(classCode));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (pn.getLegend() == null) {
|
|
|
- if(con.getEquipPack().getLegendId() != null)
|
|
|
+ if(con.getEquipPack().getLegendId() != null) {
|
|
|
legend = dataStrategy.getLegend(con.getEquipPack().getLegendId(), classCode.substring(0, 4));
|
|
|
- if(legend == null)
|
|
|
+ }
|
|
|
+ if(legend == null) {
|
|
|
legend = findLegend(classCode, null);
|
|
|
+ }
|
|
|
|
|
|
pn.setLegendId(legend.getId());
|
|
|
pn.setLegend(legend);
|
|
@@ -207,8 +216,9 @@ public class DiagramBuilder {
|
|
|
String classCode = DiagramBuilder.getClassCode(obj);
|
|
|
if(equipHolder.getEquipmentTypes() != null && equipHolder.getEquipmentTypes().contains(classCode)) {
|
|
|
DataFilter filter = equipHolder.getDataFilter();
|
|
|
- if(filter != null)
|
|
|
+ if(filter != null) {
|
|
|
return filter.filter(obj);
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -217,8 +227,9 @@ public class DiagramBuilder {
|
|
|
private void buildContainers(List<Container> containers) {
|
|
|
for(Container con : containers) {
|
|
|
if(con.isEquipmentBox()) {
|
|
|
- if(Boolean.TRUE.equals(con.getProp(Container.PROP_AUTO_HIDDEN)) && CollUtil.isEmpty(con.getChildren()))
|
|
|
+ if(Boolean.TRUE.equals(con.getProp(Container.PROP_AUTO_HIDDEN)) && CollUtil.isEmpty(con.getChildren())) {
|
|
|
con.setHidden(true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -242,8 +253,9 @@ public class DiagramBuilder {
|
|
|
List<Anchor> anchors = equipmentNode.getLegend().getAnchors();
|
|
|
if(anchors != null) {
|
|
|
for(Anchor anchor : anchors) {
|
|
|
- if(anchor.getAcceptRelations() != null)
|
|
|
+ if(anchor.getAcceptRelations() != null) {
|
|
|
anchor.getAcceptRelations().forEach(rel -> refRelTypes.add(rel));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -257,8 +269,9 @@ public class DiagramBuilder {
|
|
|
List<Legend> legends = legendsCache.get(classCode);
|
|
|
if (legends == null) {
|
|
|
legends = dataStrategy.getLegendsForEquipment(classCode);
|
|
|
- if (legends == null)
|
|
|
+ if (legends == null) {
|
|
|
legends = new ArrayList<>();
|
|
|
+ }
|
|
|
legendsCache.put(classCode, legends);
|
|
|
}
|
|
|
if(legends.size() > 0) {
|
|
@@ -268,25 +281,31 @@ public class DiagramBuilder {
|
|
|
boolean typeMatch = CollUtil.isNotEmpty(legend.getDiagramTypes()) && legend.getDiagramTypes().contains(diagram.getType());
|
|
|
//过滤条件匹配
|
|
|
boolean filterMatch;
|
|
|
- if(obj != null && legend.getDataFilter() != null)
|
|
|
+ if(obj != null && legend.getDataFilter() != null) {
|
|
|
filterMatch = legend.getDataFilter().filter(obj);
|
|
|
- else
|
|
|
+ } else {
|
|
|
filterMatch = true;
|
|
|
+ }
|
|
|
|
|
|
- if(typeMatch && filterMatch)
|
|
|
+ if(typeMatch && filterMatch) {
|
|
|
return legend;
|
|
|
+ }
|
|
|
|
|
|
- if(typeMatch && l0 == null)
|
|
|
+ if(typeMatch && l0 == null) {
|
|
|
l0 = legend;
|
|
|
- if(filterMatch && l1 == null)
|
|
|
+ }
|
|
|
+ if(filterMatch && l1 == null) {
|
|
|
l1 = legend;
|
|
|
+ }
|
|
|
}
|
|
|
- if(l0 != null)
|
|
|
+ if(l0 != null) {
|
|
|
return l0;
|
|
|
- if(l1 != null)
|
|
|
+ }
|
|
|
+ if(l1 != null) {
|
|
|
return l1;
|
|
|
-
|
|
|
- return legends.get(0); //没有优先匹配的话取第一个
|
|
|
+ }
|
|
|
+ //没有优先匹配的话取第一个
|
|
|
+ return legends.get(0);
|
|
|
}
|
|
|
|
|
|
//返回一个缺省图例
|
|
@@ -320,10 +339,11 @@ public class DiagramBuilder {
|
|
|
|
|
|
private ConnectPoint getConnectPoint(Object obj, String relType, Object theOtherEnd){
|
|
|
ObjectNode theOtherData = null;
|
|
|
- if(theOtherEnd instanceof EquipmentNode)
|
|
|
+ if(theOtherEnd instanceof EquipmentNode) {
|
|
|
theOtherData = (ObjectNode) ((EquipmentNode) theOtherEnd).getDataObject();
|
|
|
- else if(theOtherEnd instanceof MainPipe)
|
|
|
+ } else if(theOtherEnd instanceof MainPipe) {
|
|
|
theOtherData = (ObjectNode) ((MainPipe) theOtherEnd).getDataObject();
|
|
|
+ }
|
|
|
String theOtherType = getClassCode(theOtherData);
|
|
|
|
|
|
if(obj instanceof EquipmentNode) {
|
|
@@ -336,35 +356,41 @@ public class DiagramBuilder {
|
|
|
Boolean relMatch = null; //关系匹配
|
|
|
Boolean equipMatch = null; //另一端设备匹配
|
|
|
|
|
|
- if(CollUtil.isNotEmpty(a.getAcceptRelations()))
|
|
|
+ if(CollUtil.isNotEmpty(a.getAcceptRelations())) {
|
|
|
relMatch = a.getAcceptRelations().contains(relType);
|
|
|
+ }
|
|
|
|
|
|
if(!Boolean.FALSE.equals(relMatch)) {
|
|
|
- if(CollUtil.isNotEmpty(a.getToEquipmentTypes()))
|
|
|
+ if(CollUtil.isNotEmpty(a.getToEquipmentTypes())) {
|
|
|
equipMatch = a.getToEquipmentTypes().contains(theOtherType);
|
|
|
- if(!Boolean.FALSE.equals(equipMatch) && a.getToDataFilter() != null)
|
|
|
+ }
|
|
|
+ if(!Boolean.FALSE.equals(equipMatch) && a.getToDataFilter() != null) {
|
|
|
equipMatch = a.getToDataFilter().filter(theOtherData);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if(!Boolean.FALSE.equals(relMatch) && !Boolean.FALSE.equals(equipMatch)) {
|
|
|
if(relMatch == null || equipMatch == null) {
|
|
|
//部分匹配
|
|
|
- if(anchor1 == null)
|
|
|
+ if(anchor1 == null) {
|
|
|
anchor1 = a;
|
|
|
- else if(CollUtil.isNotEmpty(anchor1.getLines()) && CollUtil.isEmpty(a.getLines()))
|
|
|
+ } else if(CollUtil.isNotEmpty(anchor1.getLines()) && CollUtil.isEmpty(a.getLines())) {
|
|
|
anchor1 = a;
|
|
|
+ }
|
|
|
} else {
|
|
|
//完全匹配
|
|
|
if(CollUtil.isEmpty(a.getLines())) { //优先每个锚点只有一条连线
|
|
|
anchor = a;
|
|
|
break;
|
|
|
- } else if(anchor == null)
|
|
|
+ } else if(anchor == null) {
|
|
|
anchor = a;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(anchor == null && anchor1 != null)
|
|
|
+ if(anchor == null && anchor1 != null) {
|
|
|
anchor = anchor1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if(anchor != null) {
|
|
@@ -424,16 +450,19 @@ public class DiagramBuilder {
|
|
|
|
|
|
public static String getName(ObjectNode obj){
|
|
|
String name = null;
|
|
|
- if(obj.get("localName") != null)
|
|
|
+ if(obj.get("localName") != null) {
|
|
|
name = obj.get("localName").asText();
|
|
|
- if(StrUtil.isBlank(name))
|
|
|
+ }
|
|
|
+ if(StrUtil.isBlank(name)) {
|
|
|
name = obj.get("name").asText();
|
|
|
+ }
|
|
|
return name;
|
|
|
}
|
|
|
|
|
|
public static String getClassCode(ObjectNode obj){
|
|
|
- if(obj != null && obj.get("classCode") != null)
|
|
|
+ if(obj != null && obj.get("classCode") != null) {
|
|
|
return obj.get("classCode").asText();
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|