From 7f9a7af0f5ae67ad0223f0d34c86d9f7002828eb Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 16 Feb 2022 19:53:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E7=BC=BA=E9=99=B7=E4=B8=8E?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=BC=BA=E9=99=B7=E5=88=86?= =?UTF-8?q?=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtIssuesMapper.java | 2 + .../base/mapper/ext/ExtIssuesMapper.xml | 41 ++++++++++++++----- .../base/mapper/ext/ExtProjectMapper.xml | 4 +- .../base/mapper/ext/ExtTestCaseMapper.xml | 4 +- .../controller/ShareController.java | 2 +- .../track/controller/IssuesController.java | 2 +- .../track/request/testcase/IssuesRequest.java | 2 + .../track/service/IssuesService.java | 37 ++++++++++++----- .../track/service/TestPlanService.java | 2 +- .../track/case/components/IssueRelateList.vue | 3 +- .../case/components/TestCaseIssueRelate.vue | 4 ++ .../track/issue/TestCaseIssueList.vue | 9 ++++ .../track/issue/TestCaseRelateList.vue | 7 ++++ 13 files changed, 91 insertions(+), 28 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java index 1be154ab26..3af38e4368 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java @@ -27,4 +27,6 @@ public interface ExtIssuesMapper { ListgetCountByStatus(@Param("request") IssuesRequest issuesRequest); List selectIdNotInUuIds(@Param("projectId") String projectId, @Param("platform") String platform, @Param("platformIds") List platformIds); + + List getPlanIssues(@Param("request") IssuesRequest issueRequest); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml index 9575540d2f..03873e3cff 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml @@ -8,7 +8,6 @@ inner join test_case_issues on test_case_issues.issues_id = issues.id - and (issues.platform_status != 'delete' or issues.platform_status is NULL) @@ -37,20 +36,38 @@ order by num asc + + issues.id, issues.platform_id, issues.num, ifnull(issues.title, '') as title, issues.project_id, issues.create_time, issues.update_time, + ifnull(issues.description, '') as description, issues.status, issues.platform, issues.custom_fields, issues.reporter, + issues.creator,issues.resource_id,issues.platform_status, + issues.lastmodify + + + + + @@ -66,10 +83,8 @@ issues.lastmodify from issues left join - test_case_issues on issues.id = test_case_issues.issues_id + test_case_issues on issues.id = test_case_issues.issues_id and issues.project_id = #{request.projectId} - and (test_case_issues.resource_id is null or test_case_issues.resource_id != #{request.caseResourceId}) - and (issues.platform_status != 'delete' or issues.platform_status is NULL) group by issues.id @@ -130,6 +145,12 @@ and issues.id = #{request.id} + + and issues.id not in + + #{value} + + @@ -157,7 +178,7 @@ - + and (issues.platform_status != 'delete' or issues.platform_status is NULL) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index 94bda3db29..8f581ac945 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -249,8 +249,8 @@ select count(distinct (tci.issues_id)) from test_plan_test_case tptc - join test_case_issues tci on tptc.case_id = tci.resource_id + join test_case_issues tci on tptc.id = tci.resource_id right join test_case - on test_case.id = tci.resource_id + on test_case.id = tci.ref_id join issues on tci.issues_id = issues.id where tptc.plan_id = #{planId} diff --git a/backend/src/main/java/io/metersphere/controller/ShareController.java b/backend/src/main/java/io/metersphere/controller/ShareController.java index f25438c2f9..e67bcc48ed 100644 --- a/backend/src/main/java/io/metersphere/controller/ShareController.java +++ b/backend/src/main/java/io/metersphere/controller/ShareController.java @@ -74,7 +74,7 @@ public class ShareController { @GetMapping("/issues/plan/get/{shareId}/{planId}") public List getIssuesByPlanoId(@PathVariable String shareId, @PathVariable String planId) { shareInfoService.validate(shareId, planId); - return issuesService.getIssuesByPlanoId(planId); + return issuesService.getIssuesByPlanId(planId); } @GetMapping("/test/plan/report/{shareId}/{planId}") diff --git a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java index 2f5bccabf6..71882dc889 100644 --- a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java @@ -82,7 +82,7 @@ public class IssuesController { @GetMapping("/plan/get/{planId}") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ) public List getIssuesByPlanId(@PathVariable String planId) { - return issuesService.getIssuesByPlanoId(planId); + return issuesService.getIssuesByPlanId(planId); } @GetMapping("/auth/{workspaceId}/{platform}") diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java index a64f8c1d95..5eb302f14c 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java @@ -43,9 +43,11 @@ public class IssuesRequest extends BaseQueryRequest { private String platform; private String customFields; private List testCaseIds; + private List notInIds; private String requestType; private String status; private String defaultCustomFields; private Boolean isPlanEdit = false; + private String planId; } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index f1065217f0..8262f7e47b 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -272,7 +272,7 @@ public class IssuesService { example.createCriteria().andIssuesIdEqualTo(id); List testCaseIssues = testCaseIssuesMapper.selectByExample(example); testCaseIssues.forEach(i -> { - if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL)) { + if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name())) { testCaseIssueService.updateIssuesCount(i.getResourceId()); } }); @@ -335,14 +335,21 @@ public class IssuesService { if (planMap.get(item.getResourceId()) != null) { item.setResourceName(planMap.get(item.getResourceId())); } + TestCaseIssuesExample example = new TestCaseIssuesExample(); example.createCriteria().andIssuesIdEqualTo(item.getId()); List testCaseIssues = testCaseIssuesMapper.selectByExample(example); - List caseIds = testCaseIssues.stream() - .map(TestCaseIssues::getResourceId) - .collect(Collectors.toList()); - item.setCaseIds(caseIds); - item.setCaseCount(testCaseIssues.size()); + Set caseIdSet = new HashSet<>(); + testCaseIssues.forEach(i -> { + if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name())) { + caseIdSet.add(i.getRefId()); + } else { + caseIdSet.add(i.getResourceId()); + } + }); + item.setCaseIds(new ArrayList<>(caseIdSet)); + item.setCaseCount(caseIdSet.size()); + try { if (StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Tapd.name())) { TapdPlatform platform = (TapdPlatform) IssueFactory.createPlatform(item.getPlatform(), request); @@ -540,7 +547,7 @@ public class IssuesService { } public List relateList(IssuesRequest request) { - return extIssuesMapper.getRelateIssues(request); + return extIssuesMapper.getIssues(request); } public void userAuth(AuthUserIssueRequest authUserIssueRequest) { @@ -577,10 +584,20 @@ public class IssuesService { functionResult.setIssueData(statusResult); } - public List getIssuesByPlanoId(String planId) { + public List getIssuesByPlanId(String planId) { IssuesRequest issueRequest = new IssuesRequest(); - issueRequest.setResourceId(planId); - return extIssuesMapper.getIssues(issueRequest); + issueRequest.setPlanId(planId); + List planIssues = extIssuesMapper.getPlanIssues(issueRequest); + Set ids = new HashSet<>(planIssues.size()); + Iterator iterator = planIssues.iterator(); + while (iterator.hasNext()) { + IssuesDao next = iterator.next(); + if (ids.contains(next.getId())) { + iterator.remove(); + } + ids.add(next.getId()); + } + return planIssues; } public void changeStatus(IssuesRequest request) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 6a7f421f4d..abcd5616fa 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1397,7 +1397,7 @@ public class TestPlanService { report.setFunctionFailureCases(failureCases); } if (checkReportConfig(config, "functional", "issue")) { - List issueList = issuesService.getIssuesByPlanoId(planId); + List issueList = issuesService.getIssuesByPlanId(planId); report.setIssueList(issueList); } } diff --git a/frontend/src/business/components/track/case/components/IssueRelateList.vue b/frontend/src/business/components/track/case/components/IssueRelateList.vue index a82657245b..fa68e9bf7e 100644 --- a/frontend/src/business/components/track/case/components/IssueRelateList.vue +++ b/frontend/src/business/components/track/case/components/IssueRelateList.vue @@ -93,6 +93,7 @@ export default { props: { caseId: String, planCaseId: String, + notInIds: Array, }, created() { isThirdPartEnable((data) => { @@ -106,7 +107,7 @@ export default { }, getIssues() { this.page.condition.projectId = this.projectId; - this.page.condition.caseResourceId = this.getCaseResourceId(); + this.page.condition.notInIds = this.notInIds; this.page.result = getRelateIssues(this.page); }, getCaseResourceId() { diff --git a/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue b/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue index abf60e0d5b..d28716b5ed 100644 --- a/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue +++ b/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue @@ -95,6 +95,7 @@ @@ -145,6 +146,9 @@ export default { issueStatusMap() { return ISSUE_STATUS_MAP; }, + notInIds() { + return this.page.data ? this.page.data.map(i => i.id) : []; + } }, created() { getIssuePartTemplateWithProject((template, project) => { diff --git a/frontend/src/business/components/track/issue/TestCaseIssueList.vue b/frontend/src/business/components/track/issue/TestCaseIssueList.vue index c22b19ed3d..2f757ee049 100644 --- a/frontend/src/business/components/track/issue/TestCaseIssueList.vue +++ b/frontend/src/business/components/track/issue/TestCaseIssueList.vue @@ -50,6 +50,7 @@ @@ -72,6 +73,7 @@ export default { tableData: [], deleteIds: new Set(), addIds: new Set(), + testCaseContainIds: new Set(), operators: [ { tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger", @@ -85,6 +87,7 @@ export default { }, methods: { handleDelete(item, index) { + this.testCaseContainIds.delete(item.id); this.tableData.splice(index, 1); this.deleteIds.add(item.id); }, @@ -96,6 +99,9 @@ export default { if (this.issuesId) { this.result = this.$post('test/case/issues/list', condition, response => { this.tableData = response.data; + this.tableData.forEach(item => { + this.testCaseContainIds.add(item.id); + }); this.$refs.table.reloadTable(); }); } @@ -106,6 +112,9 @@ export default { handleRelate(selectRows) { let selectData = Array.from(selectRows); selectRows.forEach(i => { + if (i.id) { + this.testCaseContainIds.add(i.id); + } this.deleteIds.delete(i.id); this.addIds.add(i.id); }); diff --git a/frontend/src/business/components/track/issue/TestCaseRelateList.vue b/frontend/src/business/components/track/issue/TestCaseRelateList.vue index 7f859fa036..5161028aa9 100644 --- a/frontend/src/business/components/track/issue/TestCaseRelateList.vue +++ b/frontend/src/business/components/track/issue/TestCaseRelateList.vue @@ -107,6 +107,12 @@ export default { selectNodeIds: [], }; }, + props: { + testCaseContainIds: { + type: Set, + default: new Set() + } + }, watch: { selectNodeIds() { this.initTableData(); @@ -132,6 +138,7 @@ export default { if (this.projectId) { this.getProjectNode(); this.condition.projectId = this.projectId; + this.condition.testCaseContainIds = Array.from(this.testCaseContainIds) this.result = this.$post('/test/case/relate/issue/' + +this.currentPage + '/' + this.pageSize, this.condition, response => { let data = response.data; this.total = data.itemCount;