fix(工作台): 修复缺陷本地和三方平台统计未合并问题

This commit is contained in:
guoyuqi 2024-11-21 11:26:10 +08:00 committed by 刘瑞斌
parent 8d8c568503
commit 36e381c4c5
6 changed files with 61 additions and 33 deletions

View File

@ -443,7 +443,7 @@ report.status.fake_error=误报
api_definition.status.ongoing=进行中 api_definition.status.ongoing=进行中
api_definition.status.completed=已完成 api_definition.status.completed=已完成
api_definition.status.abandoned=已废弃 api_definition.status.abandoned=已废弃
api_definition.status.continuous=调中 api_definition.status.continuous=调中
api_test_case.clear.api_change=忽略本次变更差异 api_test_case.clear.api_change=忽略本次变更差异
api_test_case.ignore.api_change=忽略全部变更差异 api_test_case.ignore.api_change=忽略全部变更差异

View File

@ -417,7 +417,7 @@ report.status.fake_error=误报
api_definition.status.ongoing=进行中 api_definition.status.ongoing=进行中
api_definition.status.completed=已完成 api_definition.status.completed=已完成
api_definition.status.abandoned=已废弃 api_definition.status.abandoned=已废弃
api_definition.status.continuous=调中 api_definition.status.continuous=调中
api_test_case.clear.api_change=忽略本次变更差异 api_test_case.clear.api_change=忽略本次变更差异
api_test_case.ignore.api_change=忽略全部变更差异 api_test_case.ignore.api_change=忽略全部变更差异

View File

@ -136,5 +136,5 @@ public interface ExtBugMapper {
*/ */
List<ProjectUserStatusCountDTO> projectUserBugStatusCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") List<String> userIds, @Param("platforms") Set<String> platforms); List<ProjectUserStatusCountDTO> projectUserBugStatusCount(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("userIds") List<String> userIds, @Param("platforms") Set<String> platforms);
List<Bug>getSimpleList(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime,@Param("handleUser") String handleUser,@Param("createUser") String createUser, @Param("platforms") Set<String> platforms, @Param("currentUser") String currentUser); List<Bug>getSimpleList(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime,@Param("handleUsers") Set<String> handleUsers,@Param("createUser") String createUser, @Param("platforms") Set<String> platforms);
} }

View File

@ -457,16 +457,11 @@
<if test="startTime != null and endTime != null"> <if test="startTime != null and endTime != null">
AND bug.create_time BETWEEN #{startTime} AND #{endTime} AND bug.create_time BETWEEN #{startTime} AND #{endTime}
</if> </if>
<if test="handleUser != null or currentUser != null"> <if test="handleUsers != null and handleUsers.size() > 0">
AND ( AND bug.handle_user IN
FALSE <foreach collection="handleUsers" item="handleUser" separator="," open="(" close=")">
<if test="handleUser != null and handleUser != ''"> #{handleUser}
OR bug.handle_user = #{handleUser} </foreach>
</if>
<if test="currentUser != null and currentUser != ''">
OR bug.handle_user = #{currentUser}
</if>
)
</if> </if>
<if test="createUser != null and createUser != ''"> <if test="createUser != null and createUser != ''">
AND bug.create_user = #{createUser} AND bug.create_user = #{createUser}

View File

@ -776,8 +776,14 @@ public class DashboardService {
Long toEndTime = request.getToEndTime(); Long toEndTime = request.getToEndTime();
List<SelectOption> headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId); List<SelectOption> headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId);
//获取每个人每个状态有多少数据(已按照用户id排序) //获取每个人每个状态有多少数据(已按照用户id排序)
List<SelectOption> headerStatusOption = bugStatusService.getHeaderStatusOption(projectId); String platformName = projectApplicationService.getPlatformName(projectId);
Set<String> platforms = getPlatforms(projectId); List<SelectOption> headerStatusOption = bugStatusService.getAllLocalStatusOptions(projectId);
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
List<SelectOption> thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId);
headerStatusOption.addAll(thirdStatusOptions);
}
headerStatusOption = headerStatusOption.stream().distinct().toList();
Set<String> platforms = getPlatforms(platformName);
List<String> handleUserIds = headerHandlerOption.stream().sorted(Comparator.comparing(SelectOption::getValue)).map(SelectOption::getValue).collect(Collectors.toList()); List<String> handleUserIds = headerHandlerOption.stream().sorted(Comparator.comparing(SelectOption::getValue)).map(SelectOption::getValue).collect(Collectors.toList());
List<ProjectUserStatusCountDTO> projectUserStatusCountDTOS = extBugMapper.projectUserBugStatusCount(projectId, toStartTime, toEndTime, handleUserIds, platforms); List<ProjectUserStatusCountDTO> projectUserStatusCountDTOS = extBugMapper.projectUserBugStatusCount(projectId, toStartTime, toEndTime, handleUserIds, platforms);
Map<String, SelectOption> statusMap = headerStatusOption.stream().collect(Collectors.toMap(SelectOption::getValue, t -> t)); Map<String, SelectOption> statusMap = headerStatusOption.stream().collect(Collectors.toMap(SelectOption::getValue, t -> t));
@ -882,24 +888,32 @@ public class DashboardService {
* @return 处理人id 名称的集合 * @return 处理人id 名称的集合
*/ */
private List<SelectOption> getHandlerOption(List<String> handleUsers, String projectId) { private List<SelectOption> getHandlerOption(List<String> handleUsers, String projectId) {
List<SelectOption> headerHandlerOption; String platformName = projectApplicationService.getPlatformName(projectId);
List<SelectOption> headerHandlerOption = bugCommonService.getLocalHandlerOption(projectId);
List<SelectOption> thirdHandlerOption;
if (CollectionUtils.isEmpty(handleUsers)) { if (CollectionUtils.isEmpty(handleUsers)) {
headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId); if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
thirdHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
if (CollectionUtils.isNotEmpty(thirdHandlerOption)) {
headerHandlerOption.addAll(thirdHandlerOption);
}
}
} else { } else {
List<SelectOption> headerHandlerOptionList = bugCommonService.getHeaderHandlerOption(projectId); if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
headerHandlerOption = headerHandlerOptionList.stream().filter(t -> handleUsers.contains(t.getValue())).toList(); List<SelectOption> headerHandlerOptionList = bugCommonService.getHeaderHandlerOption(projectId);
headerHandlerOption.addAll(headerHandlerOptionList);
}
headerHandlerOption = headerHandlerOption.stream().filter(t -> handleUsers.contains(t.getValue())).toList();
} }
return headerHandlerOption; return headerHandlerOption.stream().distinct().toList();
} }
/** /**
* 根据项目id获取当前对接平台与本地进行组装 * 根据项目id获取当前对接平台与本地进行组装
* *
* @param projectId 项目ID
* @return 本地与对接平台集合 * @return 本地与对接平台集合
*/ */
private Set<String> getPlatforms(String projectId) { private Set<String> getPlatforms(String platformName) {
String platformName = projectApplicationService.getPlatformName(projectId);
Set<String> platforms = new HashSet<>(); Set<String> platforms = new HashSet<>();
platforms.add(BugPlatform.LOCAL.getName()); platforms.add(BugPlatform.LOCAL.getName());
if (!StringUtils.equalsIgnoreCase(platformName, BugPlatform.LOCAL.getName())) { if (!StringUtils.equalsIgnoreCase(platformName, BugPlatform.LOCAL.getName())) {
@ -1152,7 +1166,7 @@ public class DashboardService {
if (CollectionUtils.isNotEmpty(simpleAllApiCaseList)) { if (CollectionUtils.isNotEmpty(simpleAllApiCaseList)) {
simpleAllApiCaseSize = simpleAllApiCaseList.size(); simpleAllApiCaseSize = simpleAllApiCaseList.size();
} }
List<ApiTestCase> unExecList = simpleAllApiCaseList.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getLastReportStatus(), ExecStatus.PENDING.toString())).toList(); List<ApiTestCase> unExecList = simpleAllApiCaseList.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getLastReportStatus(), StringUtils.EMPTY)).toList();
int unExecSize = CollectionUtils.isNotEmpty(unExecList) ? unExecList.size() : 0; int unExecSize = CollectionUtils.isNotEmpty(unExecList) ? unExecList.size() : 0;
List<ApiTestCase> successList = simpleAllApiCaseList.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getLastReportStatus(), ResultStatus.SUCCESS.name())).toList(); List<ApiTestCase> successList = simpleAllApiCaseList.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getLastReportStatus(), ResultStatus.SUCCESS.name())).toList();
@ -1282,19 +1296,30 @@ public class DashboardService {
statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode()); statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
return statisticsDTO; return statisticsDTO;
} }
Set<String>handleUsers = new HashSet<>();
String localHandleUser = hasHandleUser ? userId : null; String localHandleUser = hasHandleUser ? userId : null;
handleUsers.add(localHandleUser);
String handleUser = hasHandleUser ? handleUserId : null; String handleUser = hasHandleUser ? handleUserId : null;
handleUsers.add(handleUser);
String createUser = hasCreateUser ? userId : null; String createUser = hasCreateUser ? userId : null;
Set<String> platforms = getPlatforms(projectId); String platformName = projectApplicationService.getPlatformName(projectId);
List<Bug> allSimpleList = extBugMapper.getSimpleList(projectId, null, null, handleUser, createUser, platforms, localHandleUser); Set<String> platforms = getPlatforms(platformName);
List<String> localLastStepStatus = getBugEndStatus(projectId); List<Bug> allSimpleList = extBugMapper.getSimpleList(projectId, null, null, handleUsers, createUser, platforms);
List<String> localLastStepStatus = getBugEndStatus(projectId, platformName);
List<Bug> statusList = allSimpleList.stream().filter(t -> !localLastStepStatus.contains(t.getStatus())).toList(); List<Bug> statusList = allSimpleList.stream().filter(t -> !localLastStepStatus.contains(t.getStatus())).toList();
int statusSize = CollectionUtils.isEmpty(statusList) ? 0 : statusList.size(); int statusSize = CollectionUtils.isEmpty(statusList) ? 0 : statusList.size();
int totalSize = CollectionUtils.isEmpty(allSimpleList) ? 0 : allSimpleList.size(); int totalSize = CollectionUtils.isEmpty(allSimpleList) ? 0 : allSimpleList.size();
List<NameCountDTO> nameCountDTOS = buildBugRetentionRateList(totalSize, statusSize); List<NameCountDTO> nameCountDTOS = buildBugRetentionRateList(totalSize, statusSize);
Map<String, List<NameCountDTO>> statusStatisticsMap = new HashMap<>(); Map<String, List<NameCountDTO>> statusStatisticsMap = new HashMap<>();
statusStatisticsMap.put("retentionRate", nameCountDTOS); statusStatisticsMap.put("retentionRate", nameCountDTOS);
List<SelectOption> headerStatusOption = bugStatusService.getHeaderStatusOption(projectId); List<SelectOption> headerStatusOption = bugStatusService.getAllLocalStatusOptions(projectId);
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
List<SelectOption> thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId);
if (CollectionUtils.isNotEmpty(thirdStatusOptions)) {
headerStatusOption.addAll(thirdStatusOptions);
}
}
headerStatusOption = headerStatusOption.stream().distinct().toList();
Map<String, List<Bug>> bugMap = allSimpleList.stream().collect(Collectors.groupingBy(Bug::getStatus)); Map<String, List<Bug>> bugMap = allSimpleList.stream().collect(Collectors.groupingBy(Bug::getStatus));
List<StatusPercentDTO> bugPercentList = bulidBugPercentList(headerStatusOption, bugMap, totalSize); List<StatusPercentDTO> bugPercentList = bulidBugPercentList(headerStatusOption, bugMap, totalSize);
statisticsDTO.setStatusStatisticsMap(statusStatisticsMap); statisticsDTO.setStatusStatisticsMap(statusStatisticsMap);
@ -1303,9 +1328,8 @@ public class DashboardService {
} }
@NotNull @NotNull
private List<String> getBugEndStatus(String projectId) { private List<String> getBugEndStatus(String projectId, String platformName) {
List<String> localLastStepStatus = bugCommonService.getLocalLastStepStatus(projectId); List<String> localLastStepStatus = bugCommonService.getLocalLastStepStatus(projectId);
String platformName = projectApplicationService.getPlatformName(projectId);
if (StringUtils.equalsIgnoreCase(platformName, BugPlatform.LOCAL.getName())) { if (StringUtils.equalsIgnoreCase(platformName, BugPlatform.LOCAL.getName())) {
return localLastStepStatus; return localLastStepStatus;
} }
@ -1379,11 +1403,19 @@ public class DashboardService {
statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode()); statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
return statisticsDTO; return statisticsDTO;
} }
Set<String> platforms = getPlatforms(projectId); String platformName = projectApplicationService.getPlatformName(projectId);
Set<String> platforms = getPlatforms(platformName);
List<SelectOption> planBugList = extTestPlanMapper.getPlanBugList(projectId, TestPlanConstants.TEST_PLAN_TYPE_PLAN, new ArrayList<>(platforms), null); List<SelectOption> planBugList = extTestPlanMapper.getPlanBugList(projectId, TestPlanConstants.TEST_PLAN_TYPE_PLAN, new ArrayList<>(platforms), null);
List<String> localLastStepStatus = getBugEndStatus(projectId); List<String> localLastStepStatus = getBugEndStatus(projectId, platformName);
List<SelectOption> legacyBugList = planBugList.stream().filter(t -> !localLastStepStatus.contains(t.getText())).toList(); List<SelectOption> legacyBugList = planBugList.stream().filter(t -> !localLastStepStatus.contains(t.getText())).toList();
List<SelectOption> headerStatusOption = bugStatusService.getHeaderStatusOption(projectId); List<SelectOption> headerStatusOption = bugStatusService.getAllLocalStatusOptions(projectId);
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
List<SelectOption> thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId);
if (CollectionUtils.isNotEmpty(thirdStatusOptions)) {
headerStatusOption.addAll(thirdStatusOptions);
}
}
headerStatusOption = headerStatusOption.stream().distinct().toList();
int statusSize = CollectionUtils.isEmpty(legacyBugList) ? 0 : legacyBugList.size(); int statusSize = CollectionUtils.isEmpty(legacyBugList) ? 0 : legacyBugList.size();
int totalSize = CollectionUtils.isEmpty(planBugList) ? 0 : planBugList.size(); int totalSize = CollectionUtils.isEmpty(planBugList) ? 0 : planBugList.size();
List<NameCountDTO> nameCountDTOS = buildBugRetentionRateList(totalSize, statusSize); List<NameCountDTO> nameCountDTOS = buildBugRetentionRateList(totalSize, statusSize);

View File

@ -913,6 +913,7 @@
left join bug_relation_case on test_plan.id = bug_relation_case.test_plan_id left join bug_relation_case on test_plan.id = bug_relation_case.test_plan_id
left join bug on bug_relation_case.bug_id = bug.id left join bug on bug_relation_case.bug_id = bug.id
where test_plan.status = 'NOT_ARCHIVED' where test_plan.status = 'NOT_ARCHIVED'
and bug.deleted = false
<if test="type != null and type != ''"> <if test="type != null and type != ''">
and test_plan.type= #{type} and test_plan.type= #{type}
</if> </if>