报告持续时间

This commit is contained in:
shiziyuan9527 2020-04-09 16:25:25 +08:00
parent 31b6a9e1ad
commit 96c9a84a2b
7 changed files with 99 additions and 7 deletions

View File

@ -10,6 +10,7 @@ import io.metersphere.controller.request.ReportRequest;
import io.metersphere.dto.ReportDTO;
import io.metersphere.report.base.ChartsData;
import io.metersphere.report.base.Errors;
import io.metersphere.report.base.ReportTimeInfo;
import io.metersphere.report.base.TestOverview;
import io.metersphere.report.dto.ErrorsTop5DTO;
import io.metersphere.report.dto.RequestStatisticsDTO;
@ -77,6 +78,11 @@ public class PerformanceReportController {
return reportService.getTestOverview(reportId);
}
@GetMapping("/content/report_time/{reportId}")
public ReportTimeInfo getReportTimeInfo(@PathVariable String reportId) {
return reportService.getReportTimeInfo(reportId);
}
@GetMapping("/content/load_chart/{reportId}")
public List<ChartsData> getLoadChartData(@PathVariable String reportId) {
return reportService.getLoadChartData(reportId);

View File

@ -406,6 +406,28 @@ public class JtlResolver {
return chartsDataList;
}
public static ReportTimeInfo getReportTimeInfo(String jtlString) {
ReportTimeInfo reportTimeInfo = new ReportTimeInfo();
List<Metric> totalLineList = JtlResolver.resolver(jtlString);
totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
String startTimeStamp = totalLineList.get(0).getTimestamp();
String endTimeStamp = totalLineList.get(totalLineList.size()-1).getTimestamp();
String startTime = stampToDate(startTimeStamp);
String endTime = stampToDate(endTimeStamp);
reportTimeInfo.setStartTime(startTime);
reportTimeInfo.setEndTime(endTime);
Date startDate = new Date(Long.parseLong(startTimeStamp));
Date endDate = new Date(Long.parseLong(endTimeStamp));
long timestamp = endDate.getTime() - startDate.getTime();
reportTimeInfo.setDuration(String.valueOf(timestamp*1.0 / 1000 / 60));
return reportTimeInfo;
}
private static String stampToDate(String timeStamp) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long lt = Long.parseLong(timeStamp);

View File

@ -0,0 +1,32 @@
package io.metersphere.report.base;
public class ReportTimeInfo {
private String duration;
private String startTime;
private String endTime;
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}

View File

@ -3,9 +3,9 @@ package io.metersphere.report.base;
public class TestOverview {
private String maxUsers;
private String avgThroughput; // Hits/s
private String avgThroughput;
private String errors;
private String avgResponseTime; // s
private String avgResponseTime;
private String responseTime90;
private String avgBandwidth;

View File

@ -12,6 +12,7 @@ import io.metersphere.dto.ReportDTO;
import io.metersphere.report.JtlResolver;
import io.metersphere.report.base.ChartsData;
import io.metersphere.report.base.Errors;
import io.metersphere.report.base.ReportTimeInfo;
import io.metersphere.report.base.TestOverview;
import io.metersphere.report.dto.ErrorsTop5DTO;
import io.metersphere.report.dto.RequestStatisticsDTO;
@ -84,6 +85,14 @@ public class ReportService {
return testOverview;
}
public ReportTimeInfo getReportTimeInfo(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);
String content = loadTestReport.getContent();
ReportTimeInfo reportTimeInfo = JtlResolver.getReportTimeInfo(content);
return reportTimeInfo;
}
public List<ChartsData> getLoadChartData(String id) {
checkReportStatus(id);
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id);

View File

@ -20,13 +20,13 @@
</el-col>
<el-col :span="8">
<span class="ms-report-time-desc">
持续时间 30 分钟
持续时间 {{duration}} 分钟
</span>
<span class="ms-report-time-desc">
开始时间 2020-3-10 12:00:00
开始时间 {{startTime}}
</span>
<span class="ms-report-time-desc">
结束时间 2020-3-10 12:30:00
结束时间 {{endTime}}
</span>
</el-col>
</el-row>
@ -75,7 +75,10 @@
status: '',
reportName: '',
testName: '',
projectName: ''
projectName: '',
startTime: '0',
endTime: '0',
duration: '0'
}
},
methods: {
@ -90,6 +93,18 @@
}
})
}
},
initReportTimeInfo() {
if(this.reportId){
this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => {
let data = res.data;
if(data){
this.startTime = data.startTime;
this.endTime = data.endTime;
this.duration = data.duration;
}
})
}
}
},
mounted() {
@ -110,6 +125,7 @@
}
})
this.initBreadcrumb();
this.initReportTimeInfo();
},
watch: {
'$route'(to) {
@ -123,6 +139,14 @@
this.projectName = data.projectName;
}
});
this.result = this.$get("/performance/report/content/report_time/" + this.reportId, res => {
let data = res.data;
if(data){
this.startTime = data.startTime;
this.endTime = data.endTime;
this.duration = data.duration;
}
})
window.location.reload();
}
}

View File

@ -460,7 +460,6 @@
data() {
return {
result: {},
loading: false,
createVisible: false,
updateVisible: false,
memberVisible: false,