fix(性能测试): 修复性能测试详情顺序随机的问题

--bug=1010958 --user=刘瑞斌 【性能测试】github#11242,版本更新后,性能测试报告-请求统计中执行的顺序显示乱了 https://www.tapd.cn/55049933/s/1115533

Closes #11242
This commit is contained in:
CaptainB 2022-03-09 11:51:48 +08:00 committed by 刘瑞斌
parent f4907da833
commit 6ef5e9607f
1 changed files with 14 additions and 5 deletions

View File

@ -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> statistics = JSON.parseArray(reportValue, Statistics.class);
List<LoadTestExportJmx> jmxContent = getJmxContent(id);
String jmx = jmxContent.get(0).getJmx();
// 按照JMX顺序重新排序
statistics.sort(Comparator.comparingInt(a -> jmx.indexOf(a.getLabel())));
// total 放到最后
List<Statistics> total = statistics.stream()
.filter(r -> StringUtils.equalsAnyIgnoreCase(r.getLabel(), "Total"))
.collect(Collectors.toList());
statistics.removeAll(total);
statistics.addAll(total);
return statistics;
}
public List<Errors> getReportErrors(String id) {