diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java index 9d40ce6266..c68cb28bcd 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceReportService.java @@ -43,10 +43,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.io.OutputStream; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Service @@ -180,7 +177,19 @@ public class PerformanceReportService { return Collections.emptyList(); } String reportValue = getContent(id, ReportKeys.RequestStatistics); - return JSON.parseArray(reportValue, Statistics.class); + // 确定顺序 + List statistics = JSON.parseArray(reportValue, Statistics.class); + List jmxContent = getJmxContent(id); + String jmx = jmxContent.get(0).getJmx(); + // 按照JMX顺序重新排序 + statistics.sort(Comparator.comparingInt(a -> jmx.indexOf(a.getLabel()))); + // 把 total 放到最后 + List total = statistics.stream() + .filter(r -> StringUtils.equalsAnyIgnoreCase(r.getLabel(), "Total")) + .collect(Collectors.toList()); + statistics.removeAll(total); + statistics.addAll(total); + return statistics; } public List getReportErrors(String id) {