From f62c6bdb4e7739c4510f72332bd46247ff51430a Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 21 Jul 2020 23:54:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E5=9B=BE=E8=A1=A8=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/ReportResultChartComponent.java | 21 ++++++++++++++++++- .../TestResultChartComponent.vue | 10 ++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/domain/ReportResultChartComponent.java b/backend/src/main/java/io/metersphere/track/domain/ReportResultChartComponent.java index 52deed64ee..1a0817ce65 100644 --- a/backend/src/main/java/io/metersphere/track/domain/ReportResultChartComponent.java +++ b/backend/src/main/java/io/metersphere/track/domain/ReportResultChartComponent.java @@ -1,5 +1,6 @@ package io.metersphere.track.domain; +import io.metersphere.commons.constants.TestPlanTestCaseStatus; import io.metersphere.track.dto.TestCaseReportMetricDTO; import io.metersphere.track.dto.TestCaseReportStatusResultDTO; import io.metersphere.track.dto.TestPlanCaseDTO; @@ -7,6 +8,7 @@ import io.metersphere.track.dto.TestPlanDTO; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; public class ReportResultChartComponent extends ReportComponent { @@ -25,7 +27,24 @@ public class ReportResultChartComponent extends ReportComponent { @Override public void afterBuild(TestCaseReportMetricDTO testCaseReportMetric) { - testCaseReportMetric.setExecuteResult(new ArrayList<>(reportStatusResultMap.values())); + testCaseReportMetric.setExecuteResult(getReportStatusResult()); + } + + private List getReportStatusResult() { + List reportStatusResult = new ArrayList<>(); + addToReportStatusResultList(reportStatusResult, TestPlanTestCaseStatus.Pass.name()); + addToReportStatusResultList(reportStatusResult, TestPlanTestCaseStatus.Failure.name()); + addToReportStatusResultList(reportStatusResult, TestPlanTestCaseStatus.Blocking.name()); + addToReportStatusResultList(reportStatusResult, TestPlanTestCaseStatus.Skip.name()); + addToReportStatusResultList(reportStatusResult, TestPlanTestCaseStatus.Underway.name()); + addToReportStatusResultList(reportStatusResult, TestPlanTestCaseStatus.Prepare.name()); + return reportStatusResult; + } + + private void addToReportStatusResultList(List reportStatusResultList, String status) { + if (reportStatusResultMap.get(status) != null) { + reportStatusResultList.add(reportStatusResultMap.get(status)); + } } private void getStatusResultMap(Map reportStatusResultMap, TestPlanCaseDTO testCase) { diff --git a/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TestResultChartComponent.vue b/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TestResultChartComponent.vue index f5ae7febc6..24bd94fc31 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TestResultChartComponent.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TestResultChartComponent.vue @@ -24,11 +24,11 @@ return { dataMap: new Map([ ["Pass", {name: this.$t('test_track.plan_view.pass'), itemStyle: {color: '#67C23A'}}], + ["Failure", {name: this.$t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], ["Blocking", {name: this.$t('test_track.plan_view.blocking'), itemStyle: {color: '#E6A23C'}}], ["Skip", {name: this.$t('test_track.plan_view.skip'), itemStyle: {color: '#909399'}}], - ["Prepare", {name: this.$t('test_track.plan.plan_status_prepare'), itemStyle: {color: '#DEDE10'}}], - ["Failure", {name: this.$t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], - ["Underway", {name: this.$t('test_track.plan.plan_status_running'), itemStyle: {color: 'lightskyblue'}}] + ["Underway", {name: this.$t('test_track.plan.plan_status_running'), itemStyle: {color: 'lightskyblue'}}], + ["Prepare", {name: this.$t('test_track.plan.plan_status_prepare'), itemStyle: {color: '#DEDE10'}}] ]), charData: [], isShow: true @@ -40,11 +40,11 @@ default() { return [ {status: 'Pass', count: '235'}, + {status: 'Failure', count: '310'}, {status: 'Blocking', count: '274'}, {status: 'Skip', count: '335'}, - {status: 'Prepare', count: '265'}, - {status: 'Failure', count: '310'}, {status: 'Underway', count: '245'}, + {status: 'Prepare', count: '265'}, ] } }