|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.persagy.adm.diagram.core.ContentParser;
|
|
import com.persagy.adm.diagram.core.ContentParser;
|
|
import com.persagy.adm.diagram.core.model.*;
|
|
import com.persagy.adm.diagram.core.model.*;
|
|
@@ -97,12 +98,13 @@ public class DiagramBuilder {
|
|
int pos = container.getParent().getChildren().indexOf(container);
|
|
int pos = container.getParent().getChildren().indexOf(container);
|
|
|
|
|
|
boolean isCompSrc = dynGroup.isCompSrc();
|
|
boolean isCompSrc = dynGroup.isCompSrc();
|
|
|
|
+ boolean isBuildingSrc = DynGroup.SRC_BUILDING.equals(dynGroup.getDynSource());
|
|
|
|
+ boolean isFloorSrc = DynGroup.SRC_FLOOR.equals(dynGroup.getDynSource());
|
|
if(isCompSrc) {
|
|
if(isCompSrc) {
|
|
IEquipHolder srcComp = context.getComp(dynGroup.getDynSource(), dynGroup.getDynSourceType());
|
|
IEquipHolder srcComp = context.getComp(dynGroup.getDynSource(), dynGroup.getDynSourceType());
|
|
dynData = findMatchedData(srcComp);
|
|
dynData = findMatchedData(srcComp);
|
|
} else {
|
|
} else {
|
|
- //TODO 楼层,建筑等分组方式
|
|
|
|
- dynData = new ArrayList<>();
|
|
|
|
|
|
+ dynData = getGroupList(dynGroup);
|
|
}
|
|
}
|
|
|
|
|
|
if (CollUtil.isEmpty(dynData)) {
|
|
if (CollUtil.isEmpty(dynData)) {
|
|
@@ -124,6 +126,10 @@ public class DiagramBuilder {
|
|
|
|
|
|
if(isCompSrc) {
|
|
if(isCompSrc) {
|
|
group.setDynSrcComp(context.getComp(dynGroup.getDynSource(), dynGroup.getDynSourceType()), dynData.get(i));
|
|
group.setDynSrcComp(context.getComp(dynGroup.getDynSource(), dynGroup.getDynSourceType()), dynData.get(i));
|
|
|
|
+ } else if(isFloorSrc) {
|
|
|
|
+ group.setFloor(dynData.get(i));
|
|
|
|
+ } else if(isBuildingSrc) {
|
|
|
|
+ group.setBuilding(dynData.get(i));
|
|
}
|
|
}
|
|
|
|
|
|
loadEquipsData(subEquipBoxes, subDynCons, relMainPipes);
|
|
loadEquipsData(subEquipBoxes, subDynCons, relMainPipes);
|
|
@@ -151,6 +157,10 @@ public class DiagramBuilder {
|
|
|
|
|
|
if(isCompSrc) {
|
|
if(isCompSrc) {
|
|
group.setDynSrcComp(context.getComp(dynGroup.getDynSource(), dynGroup.getDynSourceType()), dynData.get(i));
|
|
group.setDynSrcComp(context.getComp(dynGroup.getDynSource(), dynGroup.getDynSourceType()), dynData.get(i));
|
|
|
|
+ } else if(isFloorSrc) {
|
|
|
|
+ group.setFloor(dynData.get(i));
|
|
|
|
+ } else if(isBuildingSrc) {
|
|
|
|
+ group.setBuilding(dynData.get(i));
|
|
}
|
|
}
|
|
|
|
|
|
loadEquipsData(newSubEquipBoxes, newSubDynCons, newMps);
|
|
loadEquipsData(newSubEquipBoxes, newSubDynCons, newMps);
|
|
@@ -165,6 +175,45 @@ public class DiagramBuilder {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private List<ObjectNode> getGroupList(DynGroup dynGroup){
|
|
|
|
+ if(DynGroup.SRC_TYPE_GROUP.equals(dynGroup.getDynSourceType())) {
|
|
|
|
+ //按设备统计
|
|
|
|
+ return getGroupList(dynGroup.getDynSource());
|
|
|
|
+ } else if(DynGroup.SRC_TYPE_DATA.equals(dynGroup.getDynSourceType())) {
|
|
|
|
+ //TODO 数据查询
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<ObjectNode> getGroupList(String group){
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
+ HashMap<String, ObjectNode> map = new HashMap<>();
|
|
|
|
+ //TODO 楼层和建筑对象
|
|
|
|
+ for(ObjectNode obj : context.getOptionalObjs()) {
|
|
|
|
+ if(DynGroup.SRC_FLOOR.equals(group)) {
|
|
|
|
+ String key = getFloorId(obj);
|
|
|
|
+ if(StrUtil.isNotBlank(key) && !map.containsKey(key)){
|
|
|
|
+ map.put(key, mapper.createObjectNode().put("id", key));
|
|
|
|
+ }
|
|
|
|
+ } else if(DynGroup.SRC_BUILDING.equals(group)) {
|
|
|
|
+ String key = getBuildingId(obj);
|
|
|
|
+ if(StrUtil.isNotBlank(key) && !map.containsKey(key)){
|
|
|
|
+ map.put(key, mapper.createObjectNode().put("id", key));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<ObjectNode> list = new ArrayList<>(map.values());
|
|
|
|
+ sortBdFlList(list);
|
|
|
|
+
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void sortBdFlList(List<ObjectNode> list){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private void setGroupContainer(Container con, CalcGroup currentGroup) {
|
|
private void setGroupContainer(Container con, CalcGroup currentGroup) {
|
|
for (Container item : con.listContainers()) {
|
|
for (Container item : con.listContainers()) {
|
|
currentGroup.addComp(getSrcId(item.getId()), item);
|
|
currentGroup.addComp(getSrcId(item.getId()), item);
|
|
@@ -300,7 +349,7 @@ public class DiagramBuilder {
|
|
if (mainPipe.isBindEquipment()) {
|
|
if (mainPipe.isBindEquipment()) {
|
|
List<ObjectNode> matchedData = mainPipe.getMatchedData();
|
|
List<ObjectNode> matchedData = mainPipe.getMatchedData();
|
|
if(CollUtil.isNotEmpty(matchedData)) {
|
|
if(CollUtil.isNotEmpty(matchedData)) {
|
|
- orderDataList(matchedData);
|
|
|
|
|
|
+ sortDataList(matchedData);
|
|
|
|
|
|
ObjectNode obj = (ObjectNode)mainPipe.getMatchedData().get(0);
|
|
ObjectNode obj = (ObjectNode)mainPipe.getMatchedData().get(0);
|
|
mainPipe.setDataObject(obj);
|
|
mainPipe.setDataObject(obj);
|
|
@@ -314,7 +363,7 @@ public class DiagramBuilder {
|
|
if(con.isEquipmentBox()) {
|
|
if(con.isEquipmentBox()) {
|
|
List<ObjectNode> matchedData = con.getMatchedData();
|
|
List<ObjectNode> matchedData = con.getMatchedData();
|
|
if(CollUtil.isNotEmpty(matchedData)) {
|
|
if(CollUtil.isNotEmpty(matchedData)) {
|
|
- orderDataList(matchedData);
|
|
|
|
|
|
+ sortDataList(matchedData);
|
|
|
|
|
|
for(ObjectNode obj : matchedData) {
|
|
for(ObjectNode obj : matchedData) {
|
|
if(con.getEquipPack() != null) {
|
|
if(con.getEquipPack() != null) {
|
|
@@ -328,7 +377,7 @@ public class DiagramBuilder {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void orderDataList(List<ObjectNode> dataList){
|
|
|
|
|
|
+ private void sortDataList(List<ObjectNode> dataList){
|
|
//TODO 对设备数据进行排序操作
|
|
//TODO 对设备数据进行排序操作
|
|
}
|
|
}
|
|
|
|
|
|
@@ -420,15 +469,35 @@ public class DiagramBuilder {
|
|
private boolean match(ObjectNode obj, IEquipHolder equipHolder) {
|
|
private boolean match(ObjectNode obj, IEquipHolder equipHolder) {
|
|
String classCode = DiagramBuilder.getClassCode(obj);
|
|
String classCode = DiagramBuilder.getClassCode(obj);
|
|
if(equipHolder.getEquipmentTypes() != null && equipHolder.getEquipmentTypes().contains(classCode)) {
|
|
if(equipHolder.getEquipmentTypes() != null && equipHolder.getEquipmentTypes().contains(classCode)) {
|
|
- DataFilter filter = equipHolder.getDataFilter();
|
|
|
|
- if(filter != null) {
|
|
|
|
- return filter.filter(obj, context);
|
|
|
|
|
|
+ if(checkBdFl(obj)){
|
|
|
|
+ DataFilter filter = equipHolder.getDataFilter();
|
|
|
|
+ if(filter != null) {
|
|
|
|
+ return filter.filter(obj, context);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private boolean checkBdFl(ObjectNode obj){
|
|
|
|
+ ObjectNode bd = context.getBuilding();
|
|
|
|
+ ObjectNode fl = context.getFloor();
|
|
|
|
+ if(bd != null){
|
|
|
|
+ String bdId = getBuildingId(obj);
|
|
|
|
+ if(!bd.get("id").asText().equals(bdId)){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(fl != null){
|
|
|
|
+ String flId = getFloorId(obj);
|
|
|
|
+ if(!fl.get("id").asText().equals(flId)){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 对节点进行处理,并返回图例锚点会使用到的关系类型
|
|
* 对节点进行处理,并返回图例锚点会使用到的关系类型
|
|
*/
|
|
*/
|
|
@@ -631,10 +700,23 @@ public class DiagramBuilder {
|
|
}
|
|
}
|
|
|
|
|
|
public static String getClassCode(ObjectNode obj){
|
|
public static String getClassCode(ObjectNode obj){
|
|
- if(obj != null && obj.get("classCode") != null) {
|
|
|
|
- return obj.get("classCode").asText();
|
|
|
|
|
|
+ return getInfo(obj, "classCode");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String getInfo(ObjectNode obj, String infoCode){
|
|
|
|
+ if(obj != null && obj.get(infoCode) != null) {
|
|
|
|
+ return obj.get(infoCode).asText();
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static String getBuildingId(ObjectNode obj){
|
|
|
|
+ return getInfo(obj, "buildingId");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String getFloorId(ObjectNode obj){
|
|
|
|
+ return getInfo(obj, "floorId");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|