diff --git a/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/TestAnalysisService.java b/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/TestAnalysisService.java index ad2090260a..1618952cdd 100644 --- a/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/TestAnalysisService.java +++ b/report-stat/backend/src/main/java/io/metersphere/reportstatistics/service/TestAnalysisService.java @@ -2,14 +2,12 @@ package io.metersphere.reportstatistics.service; import io.metersphere.commons.utils.DateUtils; import io.metersphere.commons.utils.SessionUtils; -import io.metersphere.dto.ProjectDTO; import io.metersphere.reportstatistics.dto.*; import io.metersphere.reportstatistics.dto.charts.Legend; import io.metersphere.reportstatistics.dto.charts.Series; import io.metersphere.reportstatistics.dto.charts.XAxis; import io.metersphere.reportstatistics.dto.charts.YAxis; import io.metersphere.reportstatistics.service.remote.track.TestCaseRemoteService; -import io.metersphere.request.ProjectRequest; import io.metersphere.service.BaseProjectService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -39,17 +37,10 @@ public class TestAnalysisService { request.setStartTime(DateUtils.getDataStr(request.getTimes().get(0))); request.setEndTime(DateUtils.getDataStr(request.getTimes().get(1))); if (CollectionUtils.isEmpty(request.getProjects())) { - // 获取当前组织空间下所有项目 - String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); - - ProjectRequest projectRequest = new ProjectRequest(); - projectRequest.setWorkspaceId(currentWorkspaceId); - List projectDTOS = projectService.getProjectList(projectRequest); - if (CollectionUtils.isNotEmpty(projectDTOS)) { - request.setProjects(projectDTOS.stream().map(ProjectDTO::getId).collect(Collectors.toList())); - } else { - request.setProjects(new LinkedList() {{ - this.add(UUID.randomUUID().toString()); + String projectId = SessionUtils.getCurrentProjectId(); + if (StringUtils.isNotBlank(projectId)) { + request.setProjects(new ArrayList<>() {{ + this.add(projectId); }}); } } @@ -117,7 +108,10 @@ public class TestAnalysisService { List upCollect = dtos.stream().map(item -> Integer.valueOf(item.getUpdateCount())).collect(Collectors.toList()); // reduce求和 Optional updateCount = upCollect.stream().reduce(Integer::sum); - dtos.add(new TestAnalysisTableDTO("Count", createCount.get().toString(), updateCount.get().toString(), new LinkedList<>())); + dtos.add(new TestAnalysisTableDTO("Count", + createCount.isEmpty() ? "0" : createCount.get().toString(), + updateCount.isEmpty() ? "0" : updateCount.get().toString(), + new LinkedList<>())); TestAnalysisResult testAnalysisResult = new TestAnalysisResult(); testAnalysisResult.setChartDTO(dto); diff --git a/report-stat/frontend/src/api/project.js b/report-stat/frontend/src/api/project.js index 3f34b71f98..19f0a78382 100644 --- a/report-stat/frontend/src/api/project.js +++ b/report-stat/frontend/src/api/project.js @@ -1,9 +1,5 @@ import {get} from "metersphere-frontend/src/plugins/request" -export function listAllProject(workspaceId) { - return get(`/project/listAll/${workspaceId}`) -} - export function getProject(id) { return get(`/project/get/${id}`) } diff --git a/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue b/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue index 40df2d8cc0..24df618694 100644 --- a/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue +++ b/report-stat/frontend/src/business/enterprisereport/components/chart/ReportChart.vue @@ -30,8 +30,8 @@ + :style="{width: '100%', height: (h-70) + 'px'}" class="chart-config" :autoresize="true" + id="picChart"/> diff --git a/report-stat/frontend/src/business/projectstatistics/casecount/TestCaseCountContainer.vue b/report-stat/frontend/src/business/projectstatistics/casecount/TestCaseCountContainer.vue index ea490eddd4..664fd53490 100644 --- a/report-stat/frontend/src/business/projectstatistics/casecount/TestCaseCountContainer.vue +++ b/report-stat/frontend/src/business/projectstatistics/casecount/TestCaseCountContainer.vue @@ -1,13 +1,12 @@