fix(测试跟踪): 测试计划报告缺陷统计缺少部分缺陷

--bug=1018364 --user=陈建星 【测试跟踪】测试计划-报告统计-功能用例统计分析-测试结果-统计缺陷数的饼状图没了 https://www.tapd.cn/55049933/s/1269152
This commit is contained in:
chenjianxing 2022-10-20 11:57:09 +08:00 committed by jianxing
parent baafb0459a
commit 06933114d5
3 changed files with 32 additions and 17 deletions

View File

@ -117,7 +117,12 @@
where project_id = #{projectId} and platform = #{platform} and (platform_status != 'delete' or platform_status is null);
</select>
<select id="selectForPlanReport" resultType="io.metersphere.plan.dto.PlanReportIssueDTO">
select id,status,platform_status,platform from issues where resource_id = #{planId} and ( platform_status != 'delete' or platform_status is null);
select i.id, i.status, i.platform_status, i.platform
from issues i
inner join test_case_issues tci
on i.id = tci.issues_id and tci.ref_type = 'PLAN_FUNCTIONAL' and ( i.platform_status != 'delete' or i.platform_status is null)
inner join test_plan_test_case tptc
on tci.resource_id = tptc.id and tptc.plan_id = #{planId}
</select>
<select id="selectIdNotInUuIds" resultType="java.lang.String">
select id from issues

View File

@ -12,6 +12,7 @@ import io.metersphere.commons.constants.IssuesStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.plan.service.TestPlanTestCaseService;
import io.metersphere.utils.DistinctKeyUtil;
import io.metersphere.xpack.track.dto.AttachmentSyncType;
import io.metersphere.constants.AttachmentType;
import io.metersphere.constants.SystemCustomField;
@ -270,7 +271,7 @@ public class IssuesService {
issueRequest.setRefType(refType);
List<IssuesDao> issues = extIssuesMapper.getIssuesByCaseId(issueRequest);
handleCustomFieldStatus(issues);
return disconnectIssue(issues);
return DistinctKeyUtil.distinctByKey(issues, IssuesDao::getId);
}
private void handleCustomFieldStatus(List<IssuesDao> issues) {
@ -816,6 +817,7 @@ public class IssuesService {
public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) {
List<PlanReportIssueDTO> planReportIssueDTOS = extIssuesMapper.selectForPlanReport(planId);
planReportIssueDTOS = DistinctKeyUtil.distinctByKey(planReportIssueDTOS, PlanReportIssueDTO::getId);
TestPlanFunctionResultReportDTO functionResult = report.getFunctionResult();
List<TestCaseReportStatusResultDTO> statusResult = new ArrayList<>();
Map<String, TestCaseReportStatusResultDTO> statusResultMap = new HashMap<>();
@ -849,8 +851,7 @@ public class IssuesService {
buildCustomField(planIssues);
replaceStatus(planIssues, planId);
return disconnectIssue(planIssues);
return DistinctKeyUtil.distinctByKey(planIssues, IssuesDao::getId);
}
private void replaceStatus(List<IssuesDao> planIssues, String planId) {
@ -882,19 +883,6 @@ public class IssuesService {
});
}
public List<IssuesDao> disconnectIssue(List<IssuesDao> issues) {
Set<String> ids = new HashSet<>(issues.size());
Iterator<IssuesDao> iterator = issues.iterator();
while (iterator.hasNext()) {
IssuesDao next = iterator.next();
if (ids.contains(next.getId())) {
iterator.remove();
}
ids.add(next.getId());
}
return issues;
}
public void changeStatus(IssuesRequest request) {
String issuesId = request.getId();
String status = request.getStatus();

View File

@ -0,0 +1,22 @@
package io.metersphere.utils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public class DistinctKeyUtil {
/**
* 按照某个字段去重
* @param keyExtractor
* @param <T>
* @return
*/
public static <T> List<T> distinctByKey(List<T> list, Function<? super T, ?> keyExtractor) {
Map<Object, Boolean> map = new HashMap<>();
return list.stream().filter(t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null)
.collect(Collectors.toList());
}
}