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

This commit is contained in:
guoyuqi 2024-11-22 17:42:28 +08:00 committed by Craftsman
parent 075c93d0e4
commit fa3caa483f
1 changed files with 34 additions and 27 deletions

View File

@ -777,12 +777,7 @@ public class DashboardService {
List<SelectOption> headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId); List<SelectOption> headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId);
//获取每个人每个状态有多少数据(已按照用户id排序) //获取每个人每个状态有多少数据(已按照用户id排序)
String platformName = projectApplicationService.getPlatformName(projectId); String platformName = projectApplicationService.getPlatformName(projectId);
List<SelectOption> headerStatusOption = bugStatusService.getAllLocalStatusOptions(projectId); List<SelectOption> headerStatusOption = getStatusOption(projectId, platformName);
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); 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);
@ -795,6 +790,18 @@ public class DashboardService {
return getHandleUserCount(xaxis, statusMap, statusCountArrayMap); return getHandleUserCount(xaxis, statusMap, statusCountArrayMap);
} }
@NotNull
private List<SelectOption> getStatusOption(String projectId, String platformName) {
List<SelectOption> allLocalStatusOptions = bugStatusService.getAllLocalStatusOptions(projectId);
List<SelectOption> headerStatusOption = new ArrayList<>(allLocalStatusOptions);
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
List<SelectOption> thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId);
headerStatusOption.addAll(new ArrayList<>(thirdStatusOptions));
}
headerStatusOption = headerStatusOption.stream().distinct().toList();
return headerStatusOption;
}
@NotNull @NotNull
private static OverViewCountDTO getHandleUserCount(List<String> xaxis, Map<String, SelectOption> statusMap, Map<String, List<Integer>> statusCountArrayMap) { private static OverViewCountDTO getHandleUserCount(List<String> xaxis, Map<String, SelectOption> statusMap, Map<String, List<Integer>> statusCountArrayMap) {
OverViewCountDTO overViewCountDTO = new OverViewCountDTO(); OverViewCountDTO overViewCountDTO = new OverViewCountDTO();
@ -889,19 +896,19 @@ public class DashboardService {
*/ */
private List<SelectOption> getHandlerOption(List<String> handleUsers, String projectId) { private List<SelectOption> getHandlerOption(List<String> handleUsers, String projectId) {
String platformName = projectApplicationService.getPlatformName(projectId); String platformName = projectApplicationService.getPlatformName(projectId);
List<SelectOption> headerHandlerOption = bugCommonService.getLocalHandlerOption(projectId); List<SelectOption> localHandlerOption = bugCommonService.getLocalHandlerOption(projectId);
List<SelectOption> thirdHandlerOption; List<SelectOption> headerHandlerOption = new ArrayList<>(localHandlerOption);
if (CollectionUtils.isEmpty(handleUsers)) { if (CollectionUtils.isEmpty(handleUsers)) {
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
thirdHandlerOption = bugCommonService.getHeaderHandlerOption(projectId); List<SelectOption> thirdHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
if (CollectionUtils.isNotEmpty(thirdHandlerOption)) { if (CollectionUtils.isNotEmpty(thirdHandlerOption)) {
headerHandlerOption.addAll(thirdHandlerOption); headerHandlerOption.addAll(new ArrayList<>(thirdHandlerOption));
} }
} }
} else { } else {
if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) {
List<SelectOption> headerHandlerOptionList = bugCommonService.getHeaderHandlerOption(projectId); List<SelectOption> headerHandlerOptionList = bugCommonService.getHeaderHandlerOption(projectId);
headerHandlerOption.addAll(headerHandlerOptionList); headerHandlerOption.addAll(new ArrayList<>(headerHandlerOptionList));
} }
headerHandlerOption = headerHandlerOption.stream().filter(t -> handleUsers.contains(t.getValue())).toList(); headerHandlerOption = headerHandlerOption.stream().filter(t -> handleUsers.contains(t.getValue())).toList();
} }
@ -1312,14 +1319,7 @@ public class DashboardService {
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.getAllLocalStatusOptions(projectId); List<SelectOption> headerStatusOption = getHeaderStatusOption(projectId, platformName);
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);
@ -1408,14 +1408,7 @@ public class DashboardService {
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, platformName); 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.getAllLocalStatusOptions(projectId); List<SelectOption> headerStatusOption = getHeaderStatusOption(projectId, platformName);
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);
@ -1443,6 +1436,20 @@ public class DashboardService {
return statisticsDTO; return statisticsDTO;
} }
@NotNull
private List<SelectOption> getHeaderStatusOption(String projectId, String platformName) {
List<SelectOption> allLocalStatusOptions = bugStatusService.getAllLocalStatusOptions(projectId);
List<SelectOption> headerStatusOption = new ArrayList<>(allLocalStatusOptions);
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();
return headerStatusOption;
}
public List<UserExtendDTO> getMemberOption(String projectId, String keyword) { public List<UserExtendDTO> getMemberOption(String projectId, String keyword) {
Project project = projectMapper.selectByPrimaryKey(projectId); Project project = projectMapper.selectByPrimaryKey(projectId);
if (project == null) { if (project == null) {