This commit is contained in:
shiziyuan9527 2020-04-22 14:18:32 +08:00
parent 58756c1ab6
commit 5ab0bed49b
2 changed files with 21 additions and 26 deletions

View File

@ -147,7 +147,6 @@ public class GenerateReport {
} }
public static ReportTimeInfo getReportTimeInfo(String jtlString) { public static ReportTimeInfo getReportTimeInfo(String jtlString) {
ReportTimeInfo reportTimeInfo = new ReportTimeInfo();
List<Metric> totalLineList = GenerateReport.resolver(jtlString); List<Metric> totalLineList = GenerateReport.resolver(jtlString);
totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp()))); totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp())));
@ -158,16 +157,12 @@ public class GenerateReport {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); 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.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 时间问题 // 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();
ReportTimeInfo reportTimeInfo = new ReportTimeInfo();
reportTimeInfo.setStartTime(startTime);
reportTimeInfo.setEndTime(endTime);
reportTimeInfo.setDuration(String.valueOf(seconds)); reportTimeInfo.setDuration(String.valueOf(seconds));
return reportTimeInfo; return reportTimeInfo;

View File

@ -29,13 +29,12 @@ public class ResultDataParse {
ListResultData items = (ListResultData) mapResultData.getResult("items"); ListResultData items = (ListResultData) mapResultData.getResult("items");
if (items.getSize() > 0) { if (items.getSize() > 0) {
for (int i = 0; i < items.getSize(); i++) { for (int i = 0; i < items.getSize(); i++) {
try {
MapResultData resultData = (MapResultData) items.get(i); MapResultData resultData = (MapResultData) items.get(i);
ListResultData data = (ListResultData) resultData.getResult("data"); ListResultData data = (ListResultData) resultData.getResult("data");
int size = data.getSize(); int size = data.getSize();
String[] strArray = new String[size]; String[] strArray = new String[size];
T t = clazz.newInstance();
if (size > 0) { if (size > 0) {
T t = null;
for (int j = 0; j < size; j++) { for (int j = 0; j < size; j++) {
ValueResultData valueResultData = (ValueResultData) data.get(j); ValueResultData valueResultData = (ValueResultData) data.get(j);
if (valueResultData.getValue() == null) { if (valueResultData.getValue() == null) {
@ -45,13 +44,14 @@ public class ResultDataParse {
strArray[j] = accept.replace("\\", ""); strArray[j] = accept.replace("\\", "");
} }
} }
try {
t = setParam(clazz, strArray); t = setParam(clazz, strArray);
}
list.add(t);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
list.add(t);
}
} }
} }
} }