From f840218c8ffea83afaf28aa290a47bf96bed1397 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 16 Mar 2023 10:40:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E5=88=97=E8=A1=A8=E8=B7=A8?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=94=A8=E4=BE=8B=EF=BC=8C=E8=B4=A3=E4=BB=BB?= =?UTF-8?q?=E4=BA=BA=E6=98=BE=E7=A4=BA=E5=8F=AF=E8=83=BD=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024451 --user=陈建星 【测试跟踪】用例评审-关联跨项目用例-责任人未显示 https://www.tapd.cn/55049933/s/1351037 --- .../service/TestReviewTestCaseService.java | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) 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);