From 22904097f6301a498b2c4854cba4d8ab9e774b80 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 25 Oct 2021 10:26:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8A=A5=E8=A1=A8=E7=BB=9F=E8=AE=A1):=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8A=A5=E8=A1=A8=E7=BB=9F=E8=AE=A1=E7=9A=84?= =?UTF-8?q?=E6=9F=B1=E7=8A=B6=E5=9B=BE=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整报表统计的柱状图宽度 --- .../reportstatistics/dto/charts/Series.java | 1 + .../service/TestCaseCountService.java | 43 +++++++++++++++++++ .../chart/TestCaseCountChart.vue | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/reportstatistics/dto/charts/Series.java b/backend/src/main/java/io/metersphere/reportstatistics/dto/charts/Series.java index 823e066a05..42da77d0a1 100644 --- a/backend/src/main/java/io/metersphere/reportstatistics/dto/charts/Series.java +++ b/backend/src/main/java/io/metersphere/reportstatistics/dto/charts/Series.java @@ -17,4 +17,5 @@ public class Series { private String stack; private JSONObject encode; private List center; + private String barWidth = null; } diff --git a/backend/src/main/java/io/metersphere/reportstatistics/service/TestCaseCountService.java b/backend/src/main/java/io/metersphere/reportstatistics/service/TestCaseCountService.java index 1f438af677..8368303c99 100644 --- a/backend/src/main/java/io/metersphere/reportstatistics/service/TestCaseCountService.java +++ b/backend/src/main/java/io/metersphere/reportstatistics/service/TestCaseCountService.java @@ -265,6 +265,31 @@ public class TestCaseCountService { loadCaseCount = extTestCaseCountMapper.getLoadCaseCount(request); } + //默认值判断。 如:用例类型为 接口、功能、性能, 但是只查出了接口用例,那么功能、性能 + if(request.getFilterSearchList() != null){ + List xaxisColumnsList = new ArrayList<>(); + if(request.getFilterSearchList().containsKey(request.getXaxis())){ + xaxisColumnsList = request.getFilterSearchList().get(request.getXaxis()); + + if(CollectionUtils.isNotEmpty(xaxisColumnsList)){ + for (String xcolum : xaxisColumnsList) { + functionCaseCountResult = this.checkCountChartResultHasColumn(xcolum,functionCaseCountResult); + apiCaseCountResult = this.checkCountChartResultHasColumn(xcolum,apiCaseCountResult); + scenarioCaseCount = this.checkCountChartResultHasColumn(xcolum,scenarioCaseCount); + loadCaseCount = this.checkCountChartResultHasColumn(xcolum,loadCaseCount); + } + } + }else if(StringUtils.equalsIgnoreCase(request.getXaxis(),"caseType")){ + functionCaseCountResult = this.checkCountChartResultHasColumn("功能用例",functionCaseCountResult); + apiCaseCountResult = this.checkCountChartResultHasColumn("接口用例",apiCaseCountResult); + scenarioCaseCount = this.checkCountChartResultHasColumn("场景用例",scenarioCaseCount); + loadCaseCount = this.checkCountChartResultHasColumn("性能用例",loadCaseCount); + } + } + + + + Map summaryMap = this.summaryCountResult(parseUser, parseStatus,request.getProjectId(),request.getOrder(), functionCaseCountResult, apiCaseCountResult, scenarioCaseCount, loadCaseCount); @@ -280,6 +305,23 @@ public class TestCaseCountService { return testCaseCountResult; } + private List checkCountChartResultHasColumn(String xcolumn,List resultList) { + boolean hasResult = false; + for (TestCaseCountChartResult result: resultList) { + if(StringUtils.equals(result.getGroupName(),xcolumn)){ + hasResult = true; + break; + } + } + if(!hasResult){ + TestCaseCountChartResult result = new TestCaseCountChartResult(); + result.setCountNum(0); + result.setGroupName(xcolumn); + resultList.add(result); + } + return resultList; + } + private void formatPieChart(PieChartDTO pieChartDTO, String groupName, Map summaryMap, boolean selectTestCase, boolean selectApi, boolean selectScenarioCase, boolean selectLoad) { JSONArray titleArray = new JSONArray(); @@ -573,6 +615,7 @@ public class TestCaseCountService { tetcaseSeries.setType("bar"); tetcaseSeries.setStack("total"); tetcaseSeries.setData(testCaseCountList); + tetcaseSeries.setBarWidth("50"); seriesList.add(tetcaseSeries); Series apiSeries = new Series(); diff --git a/frontend/src/business/components/reportstatistics/testCaseCount/chart/TestCaseCountChart.vue b/frontend/src/business/components/reportstatistics/testCaseCount/chart/TestCaseCountChart.vue index 5ada182cfa..6e353b5488 100644 --- a/frontend/src/business/components/reportstatistics/testCaseCount/chart/TestCaseCountChart.vue +++ b/frontend/src/business/components/reportstatistics/testCaseCount/chart/TestCaseCountChart.vue @@ -174,7 +174,7 @@ } this.dataOption.series.forEach(item => { item.type = this.chartType; - }) + }); this.reload(); }, reload() {