修改报告持续时间

This commit is contained in:
shiziyuan9527 2020-04-14 15:06:55 +08:00
parent eead5f2e3f
commit 12512357c5
2 changed files with 17 additions and 12 deletions

View File

@ -434,22 +434,22 @@ public class JtlResolver {
totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp()))); totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
String startTimeStamp = totalLineList.get(0).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(DATE_TIME_PATTERN); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
String startTime = dtf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(startTimeStamp)), ZoneId.systemDefault())); String startTime = dtf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(startTimeStamp)), ZoneId.systemDefault()));
String endTime = dtf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(endTimeStamp)), ZoneId.systemDefault())); String endTime = dtf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(endTimeStamp)), ZoneId.systemDefault()));
reportTimeInfo.setStartTime(startTime); reportTimeInfo.setStartTime(startTime);
reportTimeInfo.setEndTime(endTime); 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));
// todo 时间问题
long seconds = Duration.between(Instant.ofEpochMilli(Long.parseLong(startTimeStamp)), Instant.ofEpochMilli(Long.parseLong(endTimeStamp))).getSeconds(); long seconds = Duration.between(Instant.ofEpochMilli(Long.parseLong(startTimeStamp)), Instant.ofEpochMilli(Long.parseLong(endTimeStamp))).getSeconds();
String duration; reportTimeInfo.setDuration(String.valueOf(seconds));
if (seconds / 60 == 0) {
duration = String.valueOf(1);
} else {
duration = String.valueOf(seconds / 60);
}
reportTimeInfo.setDuration(duration);
return reportTimeInfo; return reportTimeInfo;
} }

View File

@ -20,7 +20,7 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<span class="ms-report-time-desc"> <span class="ms-report-time-desc">
持续时间 {{minutes}} 分钟 持续时间 {{minutes}} 分钟 {{seconds}}
</span> </span>
<span class="ms-report-time-desc"> <span class="ms-report-time-desc">
开始时间 {{startTime}} 开始时间 {{startTime}}
@ -79,6 +79,7 @@
startTime: '0', startTime: '0',
endTime: '0', endTime: '0',
minutes: '0', minutes: '0',
seconds: '0'
} }
}, },
methods: { methods: {
@ -101,7 +102,9 @@
if(data){ if(data){
this.startTime = data.startTime; this.startTime = data.startTime;
this.endTime = data.endTime; this.endTime = data.endTime;
this.minutes = data.duration; let duration = data.duration;
this.minutes = Math.floor(duration / 60);
this.seconds = duration % 60;
} }
}) })
} }
@ -144,7 +147,9 @@
if(data){ if(data){
this.startTime = data.startTime; this.startTime = data.startTime;
this.endTime = data.endTime; this.endTime = data.endTime;
this.minutes = data.duration; let duration = data.duration;
this.minutes = Math.floor(duration / 60);
this.seconds = duration % 60;
} }
}) })
window.location.reload(); window.location.reload();