fix(测试跟踪): 修复测试计划报告环境显示不全的问题
--bug=1015084 --user=宋天阳 【测试跟踪】测试计划-报告列表,报告里的运行环境少了一个 https://www.tapd.cn/55049933/s/1205607
This commit is contained in:
parent
c012ff0738
commit
a4e4bb60b9
|
@ -3,7 +3,9 @@ package io.metersphere.track.dto.testplan;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
|
@ -14,7 +16,7 @@ public class TestPlanReportRunInfoDTO {
|
|||
|
||||
private String runMode;
|
||||
// <测试计划场景关联表ID, <项目ID,环境ID>>
|
||||
private Map<String, Map<String,String>> scenarioRunInfo;
|
||||
private Map<String, Map<String, List<String>>> scenarioRunInfo;
|
||||
// <测试计划用例关联表ID, <项目ID,环境ID>>
|
||||
private Map<String, Map<String, String>> apiCaseRunInfo;
|
||||
|
||||
|
@ -24,10 +26,24 @@ public class TestPlanReportRunInfoDTO {
|
|||
}
|
||||
|
||||
public void putScenarioRunInfo(String scenarioResourceId, String projectId, String environmentId) {
|
||||
scenarioRunInfo.put(scenarioResourceId,new HashMap<>(){{
|
||||
this.put(projectId,environmentId);
|
||||
if (scenarioRunInfo.containsKey(scenarioResourceId)) {
|
||||
if (scenarioRunInfo.get(scenarioResourceId).containsKey(projectId)) {
|
||||
if (!scenarioRunInfo.get(scenarioResourceId).get(projectId).contains(environmentId)) {
|
||||
scenarioRunInfo.get(scenarioResourceId).get(projectId).add(environmentId);
|
||||
}
|
||||
} else {
|
||||
scenarioRunInfo.get(scenarioResourceId).put(projectId, new ArrayList<>() {{
|
||||
this.add(environmentId);
|
||||
}});
|
||||
}
|
||||
} else {
|
||||
scenarioRunInfo.put(scenarioResourceId, new HashMap<>() {{
|
||||
this.put(projectId, new ArrayList<>() {{
|
||||
this.add(environmentId);
|
||||
}});
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
public void putApiCaseRunInfo(String apiCaseResourceId, String projectId, String environmentId) {
|
||||
apiCaseRunInfo.put(apiCaseResourceId, new HashMap<>() {{
|
||||
|
|
|
@ -305,11 +305,11 @@ public class TestPlanReportService {
|
|||
try {
|
||||
Map<String, String> envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
||||
if (MapUtils.isNotEmpty(envMap)) {
|
||||
String envId = null;
|
||||
for (String envIdStr : envMap.values()) {
|
||||
envId = envIdStr;
|
||||
for (Map.Entry<String, String> entry : envMap.entrySet()) {
|
||||
String projectId = entry.getKey();
|
||||
String envIdStr = entry.getValue();
|
||||
runInfoDTO.putScenarioRunInfo(model.getId(), projectId, envIdStr);
|
||||
}
|
||||
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), envId);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
|
@ -991,10 +991,10 @@ public class TestPlanReportService {
|
|||
testPlanReportDTO.setRunMode(StringUtils.equalsIgnoreCase(runInfoDTO.getRunMode(), "serial") ? Translator.get("serial") : Translator.get("parallel"));
|
||||
Map<String, Set<String>> projectEnvMap = new LinkedHashMap<>();
|
||||
if (MapUtils.isNotEmpty(runInfoDTO.getApiCaseRunInfo())) {
|
||||
this.setProjectEnvMap(projectEnvMap, runInfoDTO.getApiCaseRunInfo());
|
||||
this.setApiCaseProjectEnvMap(projectEnvMap, runInfoDTO.getApiCaseRunInfo());
|
||||
}
|
||||
if (MapUtils.isNotEmpty(runInfoDTO.getScenarioRunInfo())) {
|
||||
this.setProjectEnvMap(projectEnvMap, runInfoDTO.getScenarioRunInfo());
|
||||
this.setScenarioProjectEnvMap(projectEnvMap, runInfoDTO.getScenarioRunInfo());
|
||||
}
|
||||
Map<String, List<String>> showProjectEnvMap = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, Set<String>> entry : projectEnvMap.entrySet()) {
|
||||
|
@ -1012,7 +1012,33 @@ public class TestPlanReportService {
|
|||
}
|
||||
}
|
||||
|
||||
private void setProjectEnvMap(Map<String, Set<String>> projectEnvMap, Map<String, Map<String, String>> caseEnvironmentMap) {
|
||||
private void setScenarioProjectEnvMap(Map<String, Set<String>> projectEnvMap, Map<String, Map<String, List<String>>> caseEnvironmentMap) {
|
||||
if (projectEnvMap == null || caseEnvironmentMap == null) {
|
||||
return;
|
||||
}
|
||||
for (Map<String, List<String>> map : caseEnvironmentMap.values()) {
|
||||
if (MapUtils.isEmpty(map)) {
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
||||
String projectId = entry.getKey();
|
||||
List<String> envIdList = entry.getValue();
|
||||
if (CollectionUtils.isNotEmpty(envIdList)) {
|
||||
envIdList.forEach(envId -> {
|
||||
if (projectEnvMap.containsKey(projectId)) {
|
||||
projectEnvMap.get(projectId).add(envId);
|
||||
} else {
|
||||
projectEnvMap.put(projectId, new LinkedHashSet<>() {{
|
||||
this.add(envId);
|
||||
}});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setApiCaseProjectEnvMap(Map<String, Set<String>> projectEnvMap, Map<String, Map<String, String>> caseEnvironmentMap) {
|
||||
if (projectEnvMap == null || caseEnvironmentMap == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
<div style="float: right">
|
||||
<div v-if="report.envGroupName" style="margin-left: 42px">
|
||||
<ms-tag type="danger" :content="$t('commons.group')"></ms-tag>
|
||||
<ms-tag type="danger" :content="$t('workspace.env_group.name')"></ms-tag>
|
||||
{{ report.envGroupName }}
|
||||
</div>
|
||||
<div v-else-if="report.projectEnvMap" style="margin-left: 42px">
|
||||
|
|
Loading…
Reference in New Issue