diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 14f4173cd5..dc8299a19c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -281,6 +281,12 @@ public class ElementUtil { } } + /** + * 只找出场景直接依赖 + * + * @param hashTree + * @param referenceRelationships + */ public static void relationships(JSONArray hashTree, List 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); + } } } } diff --git a/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java b/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java index 398a9bf04c..96cde437af 100644 --- a/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java +++ b/backend/src/main/java/io/metersphere/service/RelationshipEdgeService.java @@ -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