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.completed=已完成
api_definition.status.abandoned=已废弃
api_definition.status.continuous=调中
api_definition.status.continuous=调中
api_test_case.clear.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.completed=已完成
api_definition.status.abandoned=已废弃
api_definition.status.continuous=调中
api_definition.status.continuous=调中
api_test_case.clear.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<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">
AND bug.create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if test="handleUser != null or currentUser != null">
AND (
FALSE
<if test="handleUser != null and handleUser != ''">
OR bug.handle_user = #{handleUser}
</if>
<if test="currentUser != null and currentUser != ''">
OR bug.handle_user = #{currentUser}
</if>
)
<if test="handleUsers != null and handleUsers.size() > 0">
AND bug.handle_user IN
<foreach collection="handleUsers" item="handleUser" separator="," open="(" close=")">
#{handleUser}
</foreach>
</if>
<if test="createUser != null and createUser != ''">
AND bug.create_user = #{createUser}

View File

@ -776,8 +776,14 @@ public class DashboardService {
Long toEndTime = request.getToEndTime();
List<SelectOption> headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId);
//获取每个人每个状态有多少数据(已按照用户id排序)
List<SelectOption> headerStatusOption = bugStatusService.getHeaderStatusOption(projectId);
Set<String> platforms = getPlatforms(projectId);
String platformName = projectApplicationService.getPlatformName(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<ProjectUserStatusCountDTO> projectUserStatusCountDTOS = extBugMapper.projectUserBugStatusCount(projectId, toStartTime, toEndTime, handleUserIds, platforms);
Map<String, SelectOption> statusMap = headerStatusOption.stream().collect(Collectors.toMap(SelectOption::getValue, t -> t));
@ -882,24 +888,32 @@ public class DashboardService {
* @return 处理人id 名称的集合
*/
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)) {
headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
} else {
List<SelectOption> headerHandlerOptionList = bugCommonService.getHeaderHandlerOption(projectId);
headerHandlerOption = headerHandlerOptionList.stream().filter(t -> handleUsers.contains(t.getValue())).toList();
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
thirdHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
if (CollectionUtils.isNotEmpty(thirdHandlerOption)) {
headerHandlerOption.addAll(thirdHandlerOption);
}
return headerHandlerOption;
}
} else {
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
List<SelectOption> headerHandlerOptionList = bugCommonService.getHeaderHandlerOption(projectId);
headerHandlerOption.addAll(headerHandlerOptionList);
}
headerHandlerOption = headerHandlerOption.stream().filter(t -> handleUsers.contains(t.getValue())).toList();
}
return headerHandlerOption.stream().distinct().toList();
}
/**
* 根据项目id获取当前对接平台与本地进行组装
*
* @param projectId 项目ID
* @return 本地与对接平台集合
*/
private Set<String> getPlatforms(String projectId) {
String platformName = projectApplicationService.getPlatformName(projectId);
private Set<String> getPlatforms(String platformName) {
Set<String> platforms = new HashSet<>();
platforms.add(BugPlatform.LOCAL.getName());
if (!StringUtils.equalsIgnoreCase(platformName, BugPlatform.LOCAL.getName())) {
@ -1152,7 +1166,7 @@ public class DashboardService {
if (CollectionUtils.isNotEmpty(simpleAllApiCaseList)) {
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;
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());
return statisticsDTO;
}
Set<String>handleUsers = new HashSet<>();
String localHandleUser = hasHandleUser ? userId : null;
handleUsers.add(localHandleUser);
String handleUser = hasHandleUser ? handleUserId : null;
handleUsers.add(handleUser);
String createUser = hasCreateUser ? userId : null;
Set<String> platforms = getPlatforms(projectId);
List<Bug> allSimpleList = extBugMapper.getSimpleList(projectId, null, null, handleUser, createUser, platforms, localHandleUser);
List<String> localLastStepStatus = getBugEndStatus(projectId);
String platformName = projectApplicationService.getPlatformName(projectId);
Set<String> platforms = getPlatforms(platformName);
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();
int statusSize = CollectionUtils.isEmpty(statusList) ? 0 : statusList.size();
int totalSize = CollectionUtils.isEmpty(allSimpleList) ? 0 : allSimpleList.size();
List<NameCountDTO> nameCountDTOS = buildBugRetentionRateList(totalSize, statusSize);
Map<String, List<NameCountDTO>> statusStatisticsMap = new HashMap<>();
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));
List<StatusPercentDTO> bugPercentList = bulidBugPercentList(headerStatusOption, bugMap, totalSize);
statisticsDTO.setStatusStatisticsMap(statusStatisticsMap);
@ -1303,9 +1328,8 @@ public class DashboardService {
}
@NotNull
private List<String> getBugEndStatus(String projectId) {
private List<String> getBugEndStatus(String projectId, String platformName) {
List<String> localLastStepStatus = bugCommonService.getLocalLastStepStatus(projectId);
String platformName = projectApplicationService.getPlatformName(projectId);
if (StringUtils.equalsIgnoreCase(platformName, BugPlatform.LOCAL.getName())) {
return localLastStepStatus;
}
@ -1379,11 +1403,19 @@ public class DashboardService {
statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
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<String> localLastStepStatus = getBugEndStatus(projectId);
List<String> localLastStepStatus = getBugEndStatus(projectId, platformName);
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 totalSize = CollectionUtils.isEmpty(planBugList) ? 0 : planBugList.size();
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 on bug_relation_case.bug_id = bug.id
where test_plan.status = 'NOT_ARCHIVED'
and bug.deleted = false
<if test="type != null and type != ''">
and test_plan.type= #{type}
</if>