diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java index 89fa184f02..684b710ff8 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java @@ -81,10 +81,20 @@ public class TestReviewTestCaseService { ServiceUtils.buildProjectInfo(list); ServiceUtils.buildCustomNumInfo(list); - QueryMemberRequest queryMemberRequest = new QueryMemberRequest(); - queryMemberRequest.setWorkspaceId(SessionUtils.getCurrentProjectId()); - Map userMap = baseUserService.getMemberList(queryMemberRequest) - .stream().collect(Collectors.toMap(User::getId, User::getName)); + // 责任人 + List userIds = list.stream() + .map(TestReviewCaseDTO::getMaintainer) + .collect(Collectors.toList()); + + List caseIds = list.stream() + .map(TestReviewCaseDTO::getCaseId) + .collect(Collectors.toList()); + + // 查询评审人 + userIds.addAll(getReviewUserIds(request.getReviewId(), caseIds)); + + Map userNameMap = ServiceUtils.getUserNameMap(userIds); + List versionIds = list.stream().map(TestReviewCaseDTO::getVersionId).collect(Collectors.toList()); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); if (projectVersionService != null) { @@ -96,11 +106,9 @@ public class TestReviewTestCaseService { } list.forEach(item -> { - String reviewId = item.getReviewId(); - String caseId = item.getCaseId(); - List userIds = getReviewUserIds(reviewId, caseId); - item.setReviewerName(getReviewName(userIds, userMap)); - item.setMaintainerName(userMap.get(item.getMaintainer())); + // 设置责任人和评审人名称 + item.setReviewerName(getReviewName(userIds, userNameMap)); + item.setMaintainerName(userNameMap.get(item.getMaintainer())); }); return list; } @@ -678,6 +686,16 @@ public class TestReviewTestCaseService { return testCaseReviewUsers.stream().map(TestCaseReviewTestCaseUsers::getUserId).collect(Collectors.toList()); } + private List getReviewUserIds(String reviewId, List caseIds) { + if (CollectionUtils.isEmpty(caseIds)) { + return new ArrayList<>(); + } + TestCaseReviewTestCaseUsersExample testCaseReviewTestCaseUsersExample = new TestCaseReviewTestCaseUsersExample(); + testCaseReviewTestCaseUsersExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdIn(caseIds); + List testCaseReviewUsers = testCaseReviewTestCaseUsersMapper.selectByExample(testCaseReviewTestCaseUsersExample); + return testCaseReviewUsers.stream().map(TestCaseReviewTestCaseUsers::getUserId).collect(Collectors.toList()); + } + public List getCaseStatusByReviewIds(List reviewIds) { if (CollectionUtils.isEmpty(reviewIds)) { return new ArrayList<>(0);