diff --git a/backend/src/main/java/io/metersphere/report/GenerateReport.java b/backend/src/main/java/io/metersphere/report/GenerateReport.java index 856edeb4fb..12d7f17686 100644 --- a/backend/src/main/java/io/metersphere/report/GenerateReport.java +++ b/backend/src/main/java/io/metersphere/report/GenerateReport.java @@ -147,7 +147,6 @@ public class GenerateReport { } public static ReportTimeInfo getReportTimeInfo(String jtlString) { - ReportTimeInfo reportTimeInfo = new ReportTimeInfo(); List totalLineList = GenerateReport.resolver(jtlString); 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"); 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())); - 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 时间问题 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)); return reportTimeInfo; diff --git a/backend/src/main/java/io/metersphere/report/parse/ResultDataParse.java b/backend/src/main/java/io/metersphere/report/parse/ResultDataParse.java index 75e441ca99..527bfc51a1 100644 --- a/backend/src/main/java/io/metersphere/report/parse/ResultDataParse.java +++ b/backend/src/main/java/io/metersphere/report/parse/ResultDataParse.java @@ -29,29 +29,29 @@ public class ResultDataParse { ListResultData items = (ListResultData) mapResultData.getResult("items"); if (items.getSize() > 0) { for (int i = 0; i < items.getSize(); i++) { - try { - MapResultData resultData = (MapResultData) items.get(i); - ListResultData data = (ListResultData) resultData.getResult("data"); - int size = data.getSize(); - String[] strArray = new String[size]; - T t = clazz.newInstance(); - if (size > 0) { - for (int j = 0; j < size; j++) { - ValueResultData valueResultData = (ValueResultData) data.get(j); - if (valueResultData.getValue() == null) { - strArray[j] = ""; - } else { - String accept = valueResultData.accept(new JsonizerVisitor()); - strArray[j] = accept.replace("\\", ""); - } + MapResultData resultData = (MapResultData) items.get(i); + ListResultData data = (ListResultData) resultData.getResult("data"); + int size = data.getSize(); + String[] strArray = new String[size]; + if (size > 0) { + T t = null; + for (int j = 0; j < size; j++) { + ValueResultData valueResultData = (ValueResultData) data.get(j); + if (valueResultData.getValue() == null) { + strArray[j] = ""; + } else { + String accept = valueResultData.accept(new JsonizerVisitor()); + strArray[j] = accept.replace("\\", ""); } + } + + try { t = setParam(clazz, strArray); + } catch (Exception e) { + e.printStackTrace(); } list.add(t); - } catch (Exception e) { - e.printStackTrace(); } - } } }