From 7d6b494b462d9bb74658a67c055e61de741dc58d Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 10 Apr 2020 14:44:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E5=91=8A=E6=8C=81?= =?UTF-8?q?=E7=BB=AD=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/report/JtlResolver.java | 13 ++++++++++--- .../performance/report/PerformanceReportView.vue | 9 +++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/report/JtlResolver.java b/backend/src/main/java/io/metersphere/report/JtlResolver.java index 2801927e00..4f7d8dce69 100644 --- a/backend/src/main/java/io/metersphere/report/JtlResolver.java +++ b/backend/src/main/java/io/metersphere/report/JtlResolver.java @@ -7,6 +7,7 @@ import io.metersphere.report.base.*; import io.metersphere.report.dto.ErrorsTop5DTO; import io.metersphere.report.dto.RequestStatisticsDTO; import org.apache.commons.lang3.StringUtils; + import java.io.Reader; import java.io.StringReader; import java.math.BigDecimal; @@ -18,6 +19,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; @@ -418,7 +420,7 @@ public class JtlResolver { totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp()))); String startTimeStamp = totalLineList.get(0).getTimestamp(); - String endTimeStamp = totalLineList.get(totalLineList.size()-1).getTimestamp(); + String endTimeStamp = totalLineList.get(totalLineList.size() - 1).getTimestamp(); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); String startTime = dtf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(startTimeStamp)), ZoneId.systemDefault())); @@ -426,9 +428,14 @@ public class JtlResolver { reportTimeInfo.setStartTime(startTime); reportTimeInfo.setEndTime(endTime); - // todo 时间问题 long seconds = Duration.between(Instant.ofEpochMilli(Long.parseLong(startTimeStamp)), Instant.ofEpochMilli(Long.parseLong(endTimeStamp))).getSeconds(); - reportTimeInfo.setDuration(String.valueOf(seconds)); + String duration; + if (seconds / 60 == 0) { + duration = String.valueOf(1); + } else { + duration = String.valueOf(seconds / 60); + } + reportTimeInfo.setDuration(duration); return reportTimeInfo; } diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 3122b407c8..2326cb5493 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -20,7 +20,7 @@ - 持续时间: {{minutes}} 分钟 {{seconds}} 秒 + 持续时间: {{minutes}} 分钟 开始时间: {{startTime}} @@ -79,7 +79,6 @@ startTime: '0', endTime: '0', minutes: '0', - seconds: '0' } }, methods: { @@ -102,9 +101,7 @@ if(data){ this.startTime = data.startTime; this.endTime = data.endTime; - let duration = data.duration; - this.minutes = Math.floor(duration / 60); - this.seconds = duration % 60; + this.minutes = data.duration; } }) } @@ -147,7 +144,7 @@ if(data){ this.startTime = data.startTime; this.endTime = data.endTime; - this.duration = data.duration; + this.minutes = data.duration; } }) window.location.reload();