fix(场景自动化) 修复生成依赖关系问题

This commit is contained in:
fit2-zhao 2021-10-29 18:53:17 +08:00 committed by fit2-zhao
parent bea8964e47
commit c8193ff213
2 changed files with 14 additions and 4 deletions

View File

@ -281,6 +281,12 @@ public class ElementUtil {
}
}
/**
* 只找出场景直接依赖
*
* @param hashTree
* @param referenceRelationships
*/
public static void relationships(JSONArray hashTree, List<String> referenceRelationships) {
for (int i = 0; i < hashTree.size(); i++) {
JSONObject element = hashTree.getJSONObject(i);
@ -288,10 +294,11 @@ public class ElementUtil {
if (!referenceRelationships.contains(element.get("id").toString())) {
referenceRelationships.add(element.get("id").toString());
}
}
if (element.containsKey("hashTree")) {
JSONArray elementJSONArray = element.getJSONArray("hashTree");
relationships(elementJSONArray, referenceRelationships);
} else {
if (element.containsKey("hashTree")) {
JSONArray elementJSONArray = element.getJSONArray("hashTree");
relationships(elementJSONArray, referenceRelationships);
}
}
}
}

View File

@ -232,6 +232,9 @@ public class RelationshipEdgeService {
if (addEdgesIds.contains(item.getSourceId() + item.getTargetId())) {
if(batchMapper.selectByPrimaryKey(item) == null ) {
batchMapper.insert(item);
}else{
item.setGraphId(graphId); // 把原来图的id设置成合并后新的图的id
batchMapper.updateByPrimaryKey(item);
}
} else {
item.setGraphId(graphId); // 把原来图的id设置成合并后新的图的id