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() {