fix(测试计划): 测试计划报告的通过率执行率精度改为小数点后2位

【【富国基金】测试计划报告通过率的计算,希望保留两位小数,不用四舍五入。】
https://www.tapd.cn/55049933/prong/stories/view/1155049933001012667
This commit is contained in:
song-tianyang 2023-08-09 14:29:24 +08:00 committed by 建国
parent 3822c100ac
commit fef7e26254
3 changed files with 163 additions and 145 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-loading="result.loading" v-if="threadGroups.length > 0" class="pressure-config-container"> <div v-loading="result.loading" v-if="loadIsOver" class="pressure-config-container">
<el-row> <el-row>
<el-col> <el-col>
<el-form :inline="true" :disabled="isReadOnly"> <el-form :inline="true" :disabled="isReadOnly">
@ -320,6 +320,7 @@ export default {
step: 0, step: 0,
rpsLimit: 0, rpsLimit: 0,
rpsLimitEnable: false, rpsLimitEnable: false,
loadIsOver: true,
options: {}, options: {},
resourcePool: null, resourcePool: null,
setPoolNull: false, setPoolNull: false,
@ -415,6 +416,7 @@ export default {
getLoadConfig(this.testId, this.reportId, this.isShare) getLoadConfig(this.testId, this.reportId, this.isShare)
.then(response => { .then(response => {
let data = JSON.parse(response.data); let data = JSON.parse(response.data);
this.loadIsOver = false;
for (let i = 0; i < this.threadGroups.length; i++) { for (let i = 0; i < this.threadGroups.length; i++) {
data[i].forEach(item => { data[i].forEach(item => {
switch (item.key) { switch (item.key) {
@ -509,6 +511,7 @@ export default {
tg.durationMinutes = Math.floor((tg.duration / 60 % 60)); tg.durationMinutes = Math.floor((tg.duration / 60 % 60));
tg.durationSeconds = Math.floor((tg.duration % 60)); tg.durationSeconds = Math.floor((tg.duration % 60));
} }
this.loadIsOver = true;
this.resourcePoolChange(); this.resourcePoolChange();
this.calculateTotalChart(); this.calculateTotalChart();
}); });

View File

@ -80,6 +80,7 @@ import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function; import java.util.function.Function;
@ -1750,15 +1751,29 @@ public class TestPlanService {
} }
issuesService.calculateReportByIssueList(testPlanCaseReportResultDTO.getIssueList(), report); issuesService.calculateReportByIssueList(testPlanCaseReportResultDTO.getIssueList(), report);
DecimalFormat rateFormat = new DecimalFormat("#0.00");
rateFormat.setMinimumFractionDigits(2);
rateFormat.setMaximumFractionDigits(2);
if (report.getExecuteCount() != 0 && report.getCaseCount() != null) { if (report.getExecuteCount() != 0 && report.getCaseCount() != null) {
report.setExecuteRate(report.getExecuteCount() * 0.1 * 10 / report.getCaseCount()); double executeRate = Double.parseDouble(rateFormat.format((double) report.getExecuteCount() / (double) report.getCaseCount()));
if (executeRate == 1 && report.getExecuteCount() < report.getCaseCount()) {
report.setExecuteRate(0.99);
} else { } else {
report.setExecuteRate(0.0); report.setExecuteRate(executeRate);
}
} else {
report.setExecuteRate(0.00);
} }
if (report.getPassCount() != 0 && report.getCaseCount() != null) { if (report.getPassCount() != 0 && report.getCaseCount() != null) {
report.setPassRate(report.getPassCount() * 0.1 * 10 / report.getCaseCount()); double passRate = Double.parseDouble(rateFormat.format((double) report.getPassCount() / (double) report.getCaseCount()));
if (passRate == 1 && report.getPassCount() < report.getCaseCount()) {
report.setPassRate(0.99);
} else { } else {
report.setPassRate(0.0); report.setPassRate(passRate);
}
} else {
report.setPassRate(0.00);
} }
report.setName(testPlan.getName()); report.setName(testPlan.getName());

View File

@ -19,7 +19,7 @@
{{ resourcePool }} {{ resourcePool }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> </el-col> <el-col :span="8"></el-col>
</el-row> </el-row>
<el-row <el-row
class="select-time" class="select-time"
@ -70,7 +70,7 @@
:label="$t('test_track.report.executive_finish_rate') + ':'" :label="$t('test_track.report.executive_finish_rate') + ':'"
> >
{{ {{
(report.executeRate ? (report.executeRate * 100).toFixed(1) : 0) + (report.executeRate ? (report.executeRate * 100).toFixed(2) : 0) +
"%" "%"
}} }}
<ms-instructions-icon <ms-instructions-icon
@ -81,7 +81,7 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('test_track.report.passing_rate') + ':'"> <el-form-item :label="$t('test_track.report.passing_rate') + ':'">
{{ {{
(report.passRate ? (report.passRate * 100).toFixed(1) : 0) + "%" (report.passRate ? (report.passRate * 100).toFixed(2) : 0) + "%"
}} }}
<ms-instructions-icon <ms-instructions-icon
:content="$t('test_track.report.passing_rate_tip')" :content="$t('test_track.report.passing_rate_tip')"
@ -98,7 +98,7 @@ import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
import TestPlanReportContainer from "@/business/plan/view/comonents/report/detail/TestPlanReportContainer"; import TestPlanReportContainer from "@/business/plan/view/comonents/report/detail/TestPlanReportContainer";
import MsInstructionsIcon from "metersphere-frontend/src/components/MsInstructionsIcon"; import MsInstructionsIcon from "metersphere-frontend/src/components/MsInstructionsIcon";
import MsTag from "metersphere-frontend/src/components/MsTag"; import MsTag from "metersphere-frontend/src/components/MsTag";
import { datetimeFormat } from "fit2cloud-ui/src/filters/time"; import {datetimeFormat} from "fit2cloud-ui/src/filters/time";
export default { export default {
name: "TestPlanOverviewReport", name: "TestPlanOverviewReport",