From f3fa4412a507ed24b32f580fa802cc5b9e6c295c Mon Sep 17 00:00:00 2001 From: zhangdahai112 Date: Wed, 19 Jan 2022 22:22:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=89=88=E6=9C=AC=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/ext/ExtTestPlanLoadCaseMapper.xml | 20 - .../service/TestPlanLoadCaseService.java | 11 +- .../comonents/api/TestCaseApiRelevance.vue | 26 +- .../functional/FunctionalRelevance.vue | 14 +- .../comonents/load/TestCaseLoadRelevance.vue | 12 +- .../view/components/TestReviewRelevance.vue | 518 +++++++++--------- 6 files changed, 320 insertions(+), 281 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml index fdf674d572..0202b831ab 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml @@ -31,26 +31,6 @@ and load_test.ref_id = #{request.refId} - - AND ( - load_test.version_id = (SELECT project_version.id - FROM load_test tmp - JOIN project_version - ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE - WHERE ref_id = load_test.ref_id - LIMIT 1) - OR - load_test.version_id = (SELECT project_version.id - FROM load_test tmp - JOIN project_version ON tmp.project_id = project_version.project_id AND - tmp.version_id = project_version.id - WHERE ref_id = load_test.ref_id - GROUP BY ref_id - HAVING MAX(latest) = 0 - ORDER BY MAX(project_version.create_time) DESC - LIMIT 1) - ) - diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java index 2cfa23a95b..6115c3b37a 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java @@ -9,6 +9,7 @@ import io.metersphere.base.mapper.LoadTestMapper; import io.metersphere.base.mapper.LoadTestReportMapper; import io.metersphere.base.mapper.TestPlanLoadCaseMapper; import io.metersphere.base.mapper.TestPlanMapper; +import io.metersphere.base.mapper.ext.ExtLoadTestMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper; import io.metersphere.commons.constants.PerformanceTestStatus; @@ -21,6 +22,7 @@ import io.metersphere.controller.request.OrderRequest; import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.dto.LoadTestDTO; import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.performance.request.QueryTestPlanRequest; import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.track.dto.*; @@ -69,6 +71,8 @@ public class TestPlanLoadCaseService { @Resource @Lazy private TestPlanService testPlanService; + @Resource + private ExtLoadTestMapper extLoadTestMapper; public Pager> relevanceList(LoadCaseRequest request, int goPage, int pageSize) { List orders = ServiceUtils.getDefaultSortOrder(request.getOrders()); @@ -82,7 +86,12 @@ public class TestPlanLoadCaseService { return PageUtils.setPageInfo(PageHelper.startPage(goPage, pageSize, true), new ArrayList <>()); } Page page = PageHelper.startPage(goPage, pageSize, true); - return PageUtils.setPageInfo(page, performanceTestService.getLoadTestListByIds(ids)); + QueryTestPlanRequest newRequest = new QueryTestPlanRequest(); + Map filters = new HashMap(); + filters.put("id", ids); + newRequest.setFilters(filters); + List loadTestDTOS = extLoadTestMapper.list(newRequest); + return PageUtils.setPageInfo(page, loadTestDTOS); } public List list(LoadCaseRequest request) { diff --git a/frontend/src/business/components/track/plan/view/comonents/api/TestCaseApiRelevance.vue b/frontend/src/business/components/track/plan/view/comonents/api/TestCaseApiRelevance.vue index f627a6e93c..fc7a49d598 100644 --- a/frontend/src/business/components/track/plan/view/comonents/api/TestCaseApiRelevance.vue +++ b/frontend/src/business/components/track/plan/view/comonents/api/TestCaseApiRelevance.vue @@ -27,7 +27,11 @@ :plan-id="planId" :versionFilters="versionFilters" @isApiListEnableChange="isApiListEnableChange" - ref="apiList"/> + ref="apiList"> + + + ref="apiCaseList"> + + @@ -51,6 +61,8 @@ import RelevanceApiList from "../../../../../api/automation/scenario/api/RelevanceApiList"; import RelevanceCaseList from "../../../../../api/automation/scenario/api/RelevanceCaseList"; import {getCurrentProjectID, hasLicense} from "@/common/js/utils"; + const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); + const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; export default { name: "TestCaseApiRelevance", @@ -59,6 +71,7 @@ RelevanceApiList, MsApiModule, TestCaseRelevanceBase, + 'VersionSelect': VersionSelect.default, }, data() { return { @@ -198,6 +211,15 @@ }); } }, + changeVersion(currentVersion, type) { + if (type == 'api') { + this.$refs.apiList.condition.versionId = currentVersion || null; + this.$refs.apiList.initTable(); + } else { + this.$refs.apiCaseList.condition.versionId = currentVersion || null; + this.$refs.apiCaseList.initTable(); + } + } } } diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue index fe11d5c089..5f52ad1738 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalRelevance.vue @@ -17,8 +17,11 @@ ref="nodeTree"/> - - + + + 0 ? requireComponent("./version/VersionSelect.vue") : {}; export default { name: "FunctionalRelevance", @@ -127,6 +132,7 @@ export default { MsTableSearchBar, MsTableAdvSearchBar, MsTableHeader, + 'VersionSelect': VersionSelect.default, }, mounted(){ this.getVersionOptions(); @@ -255,6 +261,10 @@ export default { }); } }, + changeVersion(currentVersion) { + this.page.condition.versionId = currentVersion || null; + this.getTestCases(); + } } } diff --git a/frontend/src/business/components/track/plan/view/comonents/load/TestCaseLoadRelevance.vue b/frontend/src/business/components/track/plan/view/comonents/load/TestCaseLoadRelevance.vue index f5adbf675a..4950dfc96e 100644 --- a/frontend/src/business/components/track/plan/view/comonents/load/TestCaseLoadRelevance.vue +++ b/frontend/src/business/components/track/plan/view/comonents/load/TestCaseLoadRelevance.vue @@ -19,6 +19,7 @@ + 0 ? requireComponent("./version/VersionSelect.vue") : {}; export default { name: "TestCaseLoadRelevance", @@ -113,7 +116,8 @@ export default { MsTableAdvSearchBar, MsTableHeader, MsPerformanceTestStatus, - MsTablePagination + MsTablePagination, + 'VersionSelect': VersionSelect.default, }, data() { return { @@ -140,7 +144,7 @@ export default { {text: 'Completed', value: 'Completed'}, {text: 'Error', value: 'Error'} ], - versionFilters: [] + versionFilters: [], }; }, props: { @@ -303,6 +307,10 @@ export default { }); } }, + changeVersion(currentVersion){ + this.condition.versionId = currentVersion || null; + this.search(); + } } } diff --git a/frontend/src/business/components/track/review/view/components/TestReviewRelevance.vue b/frontend/src/business/components/track/review/view/components/TestReviewRelevance.vue index 6bcbda78ab..e3f4eec2f2 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewRelevance.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewRelevance.vue @@ -24,7 +24,11 @@ - + + + 0 ? requireComponent("./version/VersionSelect.vue") : {}; export default { @@ -135,269 +141,273 @@ export default { MsTableSearchBar, MsTableAdvSearchBar, MsTableHeader, - SwitchProject, - ReviewStatus - + SwitchProject, + ReviewStatus, + 'VersionSelect': VersionSelect.default, + }, + directives: { + 'el-table-infinite-scroll': elTableInfiniteScroll + }, + data() { + return { + openType: 'relevance', + checked: true, + result: {}, + currentProject: {}, + dialogFormVisible: false, + isCheckAll: false, + testReviews: [], + versionFilters: [], + selectIds: new Set(), + treeNodes: [], + selectNodeIds: [], + selectNodeNames: [], + projectId: '', + projectName: '', + projects: [], + pageSize: 50, + currentPage: 1, + total: 0, + lineStatus: true, + condition: { + components: TEST_CASE_CONFIGS + }, + priorityFilters: [ + {text: 'P0', value: 'P0'}, + {text: 'P1', value: 'P1'}, + {text: 'P2', value: 'P2'}, + {text: 'P3', value: 'P3'} + ], + typeFilters: [ + {text: this.$t('commons.functional'), value: 'functional'}, + {text: this.$t('commons.performance'), value: 'performance'}, + {text: this.$t('commons.api'), value: 'api'} + ], + statusFilters: [ + {text: this.$t('test_track.review.prepare'), value: 'Prepare'}, + {text: this.$t('test_track.review.pass'), value: 'Pass'}, + {text: this.$t('test_track.review.un_pass'), value: 'UnPass'}, + ], + }; + }, + props: { + reviewId: { + type: String + } + }, + watch: { + reviewId() { + this.condition.reviewId = this.reviewId; }, - directives: { - 'el-table-infinite-scroll': elTableInfiniteScroll - }, - data() { - return { - openType: 'relevance', - checked: true, - result: {}, - currentProject: {}, - dialogFormVisible: false, - isCheckAll: false, - testReviews: [], - versionFilters: [], - selectIds: new Set(), - treeNodes: [], - selectNodeIds: [], - selectNodeNames: [], - projectId: '', - projectName: '', - projects: [], - pageSize: 50, - currentPage: 1, - total: 0, - lineStatus: true, - condition: { - components: TEST_CASE_CONFIGS - }, - priorityFilters: [ - {text: 'P0', value: 'P0'}, - {text: 'P1', value: 'P1'}, - {text: 'P2', value: 'P2'}, - {text: 'P3', value: 'P3'} - ], - typeFilters: [ - {text: this.$t('commons.functional'), value: 'functional'}, - {text: this.$t('commons.performance'), value: 'performance'}, - {text: this.$t('commons.api'), value: 'api'} - ], - statusFilters: [ - {text: this.$t('test_track.review.prepare'), value: 'Prepare'}, - {text: this.$t('test_track.review.pass'), value: 'Pass'}, - {text: this.$t('test_track.review.un_pass'), value: 'UnPass'}, - ], - }; - }, - props: { - reviewId: { - type: String - } - }, - watch: { - reviewId() { - this.condition.reviewId = this.reviewId; - }, - selectNodeIds() { - if (this.dialogFormVisible) { - this.search(); - } - }, - projectId() { - this.condition.projectId = this.projectId; - this.getProjectNode(); - } - }, - mounted() { - if (hasLicense()) { - this.getVersionOptions(); - } - }, - updated() { - this.toggleSelection(this.testReviews); - }, - methods: { - hasLicense(){ - return hasLicense(); - }, - openTestReviewRelevanceDialog() { - this.getProject(); - this.dialogFormVisible = true; - }, - saveReviewRelevance() { - let param = {}; - param.reviewId = this.reviewId; - param.testCaseIds = [...this.selectIds]; - param.request = this.condition; -/* - param.checked = this.checked; -*/ - // 选择全选则全部加入到评审,无论是否加载完全部 - if (this.testReviews.length === param.testCaseIds.length) { - param.testCaseIds = ['all']; - } - this.result = this.$post('/test/case/review/relevance', param, () => { - this.selectIds.clear(); - this.$success(this.$t('commons.save_success')); - this.dialogFormVisible = false; - this.$emit('refresh'); - }); - }, - buildPagePath(path) { - return path + "/" + this.currentPage + "/" + this.pageSize; - }, - getReviews(flag) { - if (this.reviewId) { - this.condition.reviewId = this.reviewId; - } - if (this.selectNodeIds && this.selectNodeIds.length > 0) { - this.condition.nodeIds = this.selectNodeIds; - } else { - this.condition.nodeIds = []; - } - if (this.projectId) { - this.condition.projectId = this.projectId; - this.result = this.$post(this.buildPagePath('/test/case/reviews/case'), this.condition, response => { - let data = response.data; - this.total = data.itemCount; - let tableData = data.listObject; - tableData.forEach(item => { - item.checked = false; - }); - flag ? this.testReviews = tableData : this.testReviews = this.testReviews.concat(tableData); - // 去重处理 - let hash = {} - this.testReviews = this.testReviews.reduce((item, next) => { - if (!hash[next.id]) { - hash[next.id] = true - item.push(next) - } - return item - }, []) - this.lineStatus = tableData.length === 50 && this.testReviews.length < this.total; - - }); - } - - }, - handleSelectAll(selection) { - if (selection.length > 0) { - this.testReviews.forEach(item => { - this.selectIds.add(item.id); - }); - } else { - this.testReviews.forEach(item => { - if (this.selectIds.has(item.id)) { - this.selectIds.delete(item.id); - } - }); - } - }, - handleSelectionChange(selection, row) { - if (this.selectIds.has(row.id)) { - this.selectIds.delete(row.id); - } else { - this.selectIds.add(row.id); - } - }, - nodeChange(node, nodeIds, nodeNames) { - this.selectNodeIds = nodeIds; - this.selectNodeNames = nodeNames; - }, - refresh() { - this.close(); - }, - getAllNodeTreeByPlanId() { - if (this.reviewId) { - let param = { - reviewId: this.reviewId, - projectId: this.projectId - }; - this.result = this.$post("/case/node/list/all/review", param, response => { - this.treeNodes = response.data; - }); - } - }, - close() { - this.lineStatus = false; - this.selectIds.clear(); - this.selectNodeIds = []; - this.selectNodeNames = []; - }, - filter(filters) { - _filter(filters, this.condition); + selectNodeIds() { + if (this.dialogFormVisible) { this.search(); - }, - toggleSelection(rows) { - rows.forEach(row => { - this.selectIds.forEach(id => { - if (row.id === id) { - // true 是为选中 - this.$refs.table.toggleRowSelection(row, true) + } + }, + projectId() { + this.condition.projectId = this.projectId; + this.getProjectNode(); + } + }, + mounted() { + if (hasLicense()) { + this.getVersionOptions(); + } + }, + updated() { + this.toggleSelection(this.testReviews); + }, + methods: { + hasLicense() { + return hasLicense(); + }, + openTestReviewRelevanceDialog() { + this.getProject(); + this.dialogFormVisible = true; + }, + saveReviewRelevance() { + let param = {}; + param.reviewId = this.reviewId; + param.testCaseIds = [...this.selectIds]; + param.request = this.condition; + /* + param.checked = this.checked; + */ + // 选择全选则全部加入到评审,无论是否加载完全部 + if (this.testReviews.length === param.testCaseIds.length) { + param.testCaseIds = ['all']; + } + this.result = this.$post('/test/case/review/relevance', param, () => { + this.selectIds.clear(); + this.$success(this.$t('commons.save_success')); + this.dialogFormVisible = false; + this.$emit('refresh'); + }); + }, + buildPagePath(path) { + return path + "/" + this.currentPage + "/" + this.pageSize; + }, + getReviews(flag) { + if (this.reviewId) { + this.condition.reviewId = this.reviewId; + } + if (this.selectNodeIds && this.selectNodeIds.length > 0) { + this.condition.nodeIds = this.selectNodeIds; + } else { + this.condition.nodeIds = []; + } + if (this.projectId) { + this.condition.projectId = this.projectId; + this.result = this.$post(this.buildPagePath('/test/case/reviews/case'), this.condition, response => { + let data = response.data; + this.total = data.itemCount; + let tableData = data.listObject; + tableData.forEach(item => { + item.checked = false; + }); + flag ? this.testReviews = tableData : this.testReviews = this.testReviews.concat(tableData); + // 去重处理 + let hash = {} + this.testReviews = this.testReviews.reduce((item, next) => { + if (!hash[next.id]) { + hash[next.id] = true + item.push(next) } - }) + return item + }, []) + this.lineStatus = tableData.length === 50 && this.testReviews.length < this.total; + + }); + } + + }, + handleSelectAll(selection) { + if (selection.length > 0) { + this.testReviews.forEach(item => { + this.selectIds.add(item.id); + }); + } else { + this.testReviews.forEach(item => { + if (this.selectIds.has(item.id)) { + this.selectIds.delete(item.id); + } + }); + } + }, + handleSelectionChange(selection, row) { + if (this.selectIds.has(row.id)) { + this.selectIds.delete(row.id); + } else { + this.selectIds.add(row.id); + } + }, + nodeChange(node, nodeIds, nodeNames) { + this.selectNodeIds = nodeIds; + this.selectNodeNames = nodeNames; + }, + refresh() { + this.close(); + }, + getAllNodeTreeByPlanId() { + if (this.reviewId) { + let param = { + reviewId: this.reviewId, + projectId: this.projectId + }; + this.result = this.$post("/case/node/list/all/review", param, response => { + this.treeNodes = response.data; + }); + } + }, + close() { + this.lineStatus = false; + this.selectIds.clear(); + this.selectNodeIds = []; + this.selectNodeNames = []; + }, + filter(filters) { + _filter(filters, this.condition); + this.search(); + }, + toggleSelection(rows) { + rows.forEach(row => { + this.selectIds.forEach(id => { + if (row.id === id) { + // true 是为选中 + this.$refs.table.toggleRowSelection(row, true) + } }) - }, - getProject() { - if (this.reviewId) { - this.$post("/project/list/related", {userId: getCurrentUserId(), workspaceId: getCurrentWorkspaceId()}, res => { - let data = res.data; - if (data) { - this.projects = data; - const index = data.findIndex(d => d.id === getCurrentProjectID()); - if (index !== -1) { - this.projectId = data[index].id; - this.projectName = data[index].name; - this.currentProject = data[index]; - } else { - this.projectId = data[0].id; - this.projectName = data[0].name; - this.currentProject = data[0]; - } + }) + }, + getProject() { + if (this.reviewId) { + this.$post("/project/list/related", {userId: getCurrentUserId(), workspaceId: getCurrentWorkspaceId()}, res => { + let data = res.data; + if (data) { + this.projects = data; + const index = data.findIndex(d => d.id === getCurrentProjectID()); + if (index !== -1) { + this.projectId = data[index].id; + this.projectName = data[index].name; + this.currentProject = data[index]; + } else { + this.projectId = data[0].id; + this.projectName = data[0].name; + this.currentProject = data[0]; } - }) - } - }, - switchProject() { - this.$refs.switchProject.open({id: this.reviewId, url: '/test/case/review/project/', type: 'review'}); - }, - scrollLoading() { - if (this.dialogFormVisible && this.lineStatus) { - this.currentPage += 1; - this.getReviews(); - } - }, - search() { - this.currentPage = 1; - this.testReviews = []; - this.getReviews(true); - }, - changeProject(project) { - this.projectId = project.id; - }, + } + }) + } + }, + switchProject() { + this.$refs.switchProject.open({id: this.reviewId, url: '/test/case/review/project/', type: 'review'}); + }, + scrollLoading() { + if (this.dialogFormVisible && this.lineStatus) { + this.currentPage += 1; + this.getReviews(); + } + }, + search() { + this.currentPage = 1; + this.testReviews = []; + this.getReviews(true); + }, + changeProject(project) { + this.projectId = project.id; + }, - getProjectNode(projectId) { - const index = this.projects.findIndex(project => project.id === projectId); - if (index !== -1) { - this.projectName = this.projects[index].name; - this.currentProject = this.projects[index]; - } - if (projectId) { - this.projectId = projectId; - } - this.result = this.$post("/case/node/list/all/review", - {reviewId: this.reviewId, projectId: this.projectId}, response => { - this.treeNodes = response.data; - }); + getProjectNode(projectId) { + const index = this.projects.findIndex(project => project.id === projectId); + if (index !== -1) { + this.projectName = this.projects[index].name; + this.currentProject = this.projects[index]; + } + if (projectId) { + this.projectId = projectId; + } + this.result = this.$post("/case/node/list/all/review", + {reviewId: this.reviewId, projectId: this.projectId}, response => { + this.treeNodes = response.data; + }); - this.selectNodeIds = []; - }, - getVersionOptions() { - if (hasLicense()) { - this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => { - this.versionFilters = response.data.map(u => { - return {text: u.name, value: u.id}; - }); + this.selectNodeIds = []; + }, + getVersionOptions() { + if (hasLicense()) { + this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => { + this.versionFilters = response.data.map(u => { + return {text: u.name, value: u.id}; }); - } - }, + }); + } + }, + changeVersion(version) { + this.condition.versionId = version || null; + this.search(); } } +}