fix(项目报告): 修复项目报告样式问题

--bug=1008232 --user=宋天阳 项目报告图表样式问题
https://www.tapd.cn/55049933/s/1073131
This commit is contained in:
song-tianyang 2021-11-23 18:20:15 +08:00 committed by 刘瑞斌
parent 396a01c3eb
commit 4b8f018b03
5 changed files with 203 additions and 150 deletions

View File

@ -43,7 +43,12 @@ public class TestCaseCountService {
List<Series> seriesList = new LinkedList<>(); List<Series> seriesList = new LinkedList<>();
XAxis xAxis = new XAxis(); XAxis xAxis = new XAxis();
xAxis.setAxisLabel(new HashMap<String,Integer>(){ {this.put("interval",0);this.put("rotate",0);}}); xAxis.setAxisLabel(new HashMap<String, Integer>() {
{
this.put("interval", 0);
this.put("rotate", 0);
}
});
Legend legend = new Legend(); Legend legend = new Legend();
formatLegend(legend, request.getYaxis(), request); formatLegend(legend, request.getYaxis(), request);
@ -134,18 +139,18 @@ public class TestCaseCountService {
Object valueObj = filterMap.get("values"); Object valueObj = filterMap.get("values");
if (valueObj instanceof List) { if (valueObj instanceof List) {
List<String> searchList = (List) valueObj; List<String> searchList = (List) valueObj;
if(!searchList.isEmpty()){ if (!searchList.isEmpty()) {
request.setFilterSearchList(filterType, searchList); request.setFilterSearchList(filterType, searchList);
} }
} }
if (StringUtils.equalsIgnoreCase(filterType, "caselevel")) { if (StringUtils.equalsIgnoreCase(filterType, "caselevel")) {
selectLoad = false; selectLoad = false;
}else if (StringUtils.equalsIgnoreCase(filterType, "maintainer")) { } else if (StringUtils.equalsIgnoreCase(filterType, "maintainer")) {
selectApi = false; selectApi = false;
selectLoad = false; selectLoad = false;
} }
}else if(StringUtils.equalsAnyIgnoreCase(filterType, "casestatus")){ } else if (StringUtils.equalsAnyIgnoreCase(filterType, "casestatus")) {
List<String> searchList = new ArrayList<>(); List<String> searchList = new ArrayList<>();
Object valueObj = filterMap.get("values"); Object valueObj = filterMap.get("values");
if (valueObj instanceof List) { if (valueObj instanceof List) {
@ -154,22 +159,22 @@ public class TestCaseCountService {
} }
} }
//如果包含Running //如果包含Running
if(searchList.contains("RUNNING")){ if (searchList.contains("RUNNING")) {
if(!searchList.contains("Starting")){ if (!searchList.contains("Starting")) {
searchList.add("STARTING"); searchList.add("STARTING");
} }
if(!searchList.contains("Underway")){ if (!searchList.contains("Underway")) {
searchList.add("UNDERWAY"); searchList.add("UNDERWAY");
} }
} }
if(searchList.contains("FINISHED")){ if (searchList.contains("FINISHED")) {
if(!searchList.contains("Completed")){ if (!searchList.contains("Completed")) {
searchList.add("Completed"); searchList.add("Completed");
} }
} }
if(!searchList.isEmpty()){ if (!searchList.isEmpty()) {
request.setFilterSearchList(filterType, searchList); request.setFilterSearchList(filterType, searchList);
} }
selectApi = false; selectApi = false;
@ -202,7 +207,7 @@ public class TestCaseCountService {
} }
} }
//没有选择的话默认搜索条件是所有类型的案例 //没有选择的话默认搜索条件是所有类型的案例
if(moreOptionsAboutCaseType.isEmpty()){ if (moreOptionsAboutCaseType.isEmpty()) {
moreOptionsAboutCaseType.add("testCase"); moreOptionsAboutCaseType.add("testCase");
moreOptionsAboutCaseType.add("apiCase"); moreOptionsAboutCaseType.add("apiCase");
moreOptionsAboutCaseType.add("scenarioCase"); moreOptionsAboutCaseType.add("scenarioCase");
@ -210,20 +215,20 @@ public class TestCaseCountService {
} }
//解析Y轴判断要查询的案例类型 //解析Y轴判断要查询的案例类型
if(CollectionUtils.isNotEmpty(request.getYaxis())){ if (CollectionUtils.isNotEmpty(request.getYaxis())) {
for (String selectType:request.getYaxis()) { for (String selectType : request.getYaxis()) {
if(moreOptionsAboutCaseType.contains(selectType)){ if (moreOptionsAboutCaseType.contains(selectType)) {
if (StringUtils.equalsIgnoreCase(selectType, "testCase")) { if (StringUtils.equalsIgnoreCase(selectType, "testCase")) {
yAxisSelectTestCase = true; yAxisSelectTestCase = true;
} else if (StringUtils.equalsIgnoreCase(selectType, "apiCase")) { } else if (StringUtils.equalsIgnoreCase(selectType, "apiCase")) {
if(selectApi){ if (selectApi) {
yAxisSelectApi = true; yAxisSelectApi = true;
} }
} else if (StringUtils.equalsIgnoreCase(selectType, "scenarioCase")) { } else if (StringUtils.equalsIgnoreCase(selectType, "scenarioCase")) {
yAxisSelectScenarioCase = true; yAxisSelectScenarioCase = true;
} else if (StringUtils.equalsIgnoreCase(selectType, "loadCase")) { } else if (StringUtils.equalsIgnoreCase(selectType, "loadCase")) {
if(selectLoad){ if (selectLoad) {
yAxisSelectLoad = true; yAxisSelectLoad = true;
} }
} }
@ -232,73 +237,95 @@ public class TestCaseCountService {
} }
if(yAxisSelectTestCase){ if (yAxisSelectTestCase) {
functionCaseCountResult = extTestCaseCountMapper.getFunctionCaseCount(request); functionCaseCountResult = extTestCaseCountMapper.getFunctionCaseCount(request);
if (functionCaseCountResult.isEmpty() && StringUtils.equalsIgnoreCase(request.getXaxis(), "casetype")) {
TestCaseCountChartResult result = new TestCaseCountChartResult();
result.setCountNum(0);
result.setGroupName(request.getTestCaseGroupColumn().substring(1, request.getTestCaseGroupColumn().length() - 1));
functionCaseCountResult.add(result);
}
} }
if (yAxisSelectApi) { if (yAxisSelectApi) {
Map<String,List<String>> apiCaseFilterList = new HashMap<>(); Map<String, List<String>> apiCaseFilterList = new HashMap<>();
if(MapUtils.isNotEmpty(request.getFilterSearchList())){ if (MapUtils.isNotEmpty(request.getFilterSearchList())) {
for (Map.Entry<String,List<String>> entry : request.getFilterSearchList().entrySet()) { for (Map.Entry<String, List<String>> entry : request.getFilterSearchList().entrySet()) {
String type = entry.getKey(); String type = entry.getKey();
if(!StringUtils.equalsAnyIgnoreCase(type,"maintainer","casestatus")){ if (!StringUtils.equalsAnyIgnoreCase(type, "maintainer", "casestatus")) {
apiCaseFilterList.put(entry.getKey(),entry.getValue()); apiCaseFilterList.put(entry.getKey(), entry.getValue());
} }
} }
} }
request.setApiFilterSearchList(apiCaseFilterList); request.setApiFilterSearchList(apiCaseFilterList);
apiCaseCountResult = extTestCaseCountMapper.getApiCaseCount(request); apiCaseCountResult = extTestCaseCountMapper.getApiCaseCount(request);
if (apiCaseCountResult.isEmpty() && StringUtils.equalsIgnoreCase(request.getXaxis(), "casetype")) {
TestCaseCountChartResult result = new TestCaseCountChartResult();
result.setCountNum(0);
result.setGroupName(request.getApiCaseGroupColumn().substring(1, request.getApiCaseGroupColumn().length() - 1));
apiCaseCountResult.add(result);
}
} }
if(yAxisSelectScenarioCase){ if (yAxisSelectScenarioCase) {
scenarioCaseCount = extTestCaseCountMapper.getScenarioCaseCount(request); scenarioCaseCount = extTestCaseCountMapper.getScenarioCaseCount(request);
if (scenarioCaseCount.isEmpty() && StringUtils.equalsIgnoreCase(request.getXaxis(), "casetype")) {
TestCaseCountChartResult result = new TestCaseCountChartResult();
result.setCountNum(0);
result.setGroupName(request.getScenarioCaseGroupColumn().substring(1, request.getScenarioCaseGroupColumn().length() - 1));
scenarioCaseCount.add(result);
}
} }
if (yAxisSelectLoad) { if (yAxisSelectLoad) {
Map<String,List<String>> loadCaseFilterMap = new HashMap<>(); Map<String, List<String>> loadCaseFilterMap = new HashMap<>();
if(MapUtils.isNotEmpty(request.getFilterSearchList())){ if (MapUtils.isNotEmpty(request.getFilterSearchList())) {
for (Map.Entry<String,List<String>> entry : request.getFilterSearchList().entrySet()) { for (Map.Entry<String, List<String>> entry : request.getFilterSearchList().entrySet()) {
String type = entry.getKey(); String type = entry.getKey();
if(!StringUtils.equalsAnyIgnoreCase(type,"maintainer","caselevel")){ if (!StringUtils.equalsAnyIgnoreCase(type, "maintainer", "caselevel")) {
loadCaseFilterMap.put(entry.getKey(),entry.getValue()); loadCaseFilterMap.put(entry.getKey(), entry.getValue());
} }
} }
} }
request.setLoadFilterSearchList(loadCaseFilterMap); request.setLoadFilterSearchList(loadCaseFilterMap);
loadCaseCount = extTestCaseCountMapper.getLoadCaseCount(request); loadCaseCount = extTestCaseCountMapper.getLoadCaseCount(request);
if (loadCaseCount.isEmpty() && StringUtils.equalsIgnoreCase(request.getXaxis(), "casetype")) {
TestCaseCountChartResult result = new TestCaseCountChartResult();
result.setCountNum(0);
result.setGroupName(request.getLoadCaseGroupColumn().substring(1, request.getLoadCaseGroupColumn().length() - 1));
loadCaseCount.add(result);
}
} }
//默认值判断 用例类型为 接口功能性能 但是只查出了接口用例那么功能性能 //默认值判断 用例类型为 接口功能性能 但是只查出了接口用例那么功能性能
if(request.getFilterSearchList() != null){ if (request.getFilterSearchList() != null) {
List<String> xaxisColumnsList = new ArrayList<>(); List<String> xaxisColumnsList = new ArrayList<>();
if(request.getFilterSearchList().containsKey(request.getXaxis())){ if (request.getFilterSearchList().containsKey(request.getXaxis())) {
xaxisColumnsList = request.getFilterSearchList().get(request.getXaxis()); xaxisColumnsList = request.getFilterSearchList().get(request.getXaxis());
if(CollectionUtils.isNotEmpty(xaxisColumnsList)){ if (CollectionUtils.isNotEmpty(xaxisColumnsList)) {
for (String xcolum : xaxisColumnsList) { for (String xcolum : xaxisColumnsList) {
functionCaseCountResult = this.checkCountChartResultHasColumn(xcolum,functionCaseCountResult); functionCaseCountResult = this.checkCountChartResultHasColumn(xcolum, functionCaseCountResult);
apiCaseCountResult = this.checkCountChartResultHasColumn(xcolum,apiCaseCountResult); apiCaseCountResult = this.checkCountChartResultHasColumn(xcolum, apiCaseCountResult);
scenarioCaseCount = this.checkCountChartResultHasColumn(xcolum,scenarioCaseCount); scenarioCaseCount = this.checkCountChartResultHasColumn(xcolum, scenarioCaseCount);
loadCaseCount = this.checkCountChartResultHasColumn(xcolum,loadCaseCount); loadCaseCount = this.checkCountChartResultHasColumn(xcolum, loadCaseCount);
} }
} }
}else if(StringUtils.equalsIgnoreCase(request.getXaxis(),"caseType")){ } else if (StringUtils.equalsIgnoreCase(request.getXaxis(), "caseType")) {
functionCaseCountResult = this.checkCountChartResultHasColumn("功能用例",functionCaseCountResult); functionCaseCountResult = this.checkCountChartResultHasColumn("功能用例", functionCaseCountResult);
apiCaseCountResult = this.checkCountChartResultHasColumn("接口用例",apiCaseCountResult); apiCaseCountResult = this.checkCountChartResultHasColumn("接口用例", apiCaseCountResult);
scenarioCaseCount = this.checkCountChartResultHasColumn("场景用例",scenarioCaseCount); scenarioCaseCount = this.checkCountChartResultHasColumn("场景用例", scenarioCaseCount);
loadCaseCount = this.checkCountChartResultHasColumn("性能用例",loadCaseCount); loadCaseCount = this.checkCountChartResultHasColumn("性能用例", loadCaseCount);
} }
} }
Map<String, TestCaseCountSummary> summaryMap = this.summaryCountResult(parseUser, parseStatus, request.getProjectId(), request.getOrder(),
Map<String, TestCaseCountSummary> summaryMap = this.summaryCountResult(parseUser, parseStatus,request.getProjectId(),request.getOrder(),
functionCaseCountResult, apiCaseCountResult, scenarioCaseCount, loadCaseCount); functionCaseCountResult, apiCaseCountResult, scenarioCaseCount, loadCaseCount);
formatXaxisSeries(xAxis, seriesList, dto, summaryMap); formatXaxisSeries(xAxis, seriesList, dto, summaryMap, yAxisSelectTestCase, yAxisSelectApi, yAxisSelectScenarioCase, yAxisSelectLoad);
formatTable(dtos, summaryMap); formatTable(dtos, summaryMap);
formatPieChart(pieChartDTO, request.getXaxis(), summaryMap,yAxisSelectTestCase,yAxisSelectApi,yAxisSelectScenarioCase,yAxisSelectLoad); formatPieChart(pieChartDTO, request.getXaxis(), summaryMap, yAxisSelectTestCase, yAxisSelectApi, yAxisSelectScenarioCase, yAxisSelectLoad);
TestCaseCountTableDataDTO showTable = this.countShowTable(request.getXaxis(),request.getYaxis(),dtos); TestCaseCountTableDataDTO showTable = this.countShowTable(request.getXaxis(), request.getYaxis(), dtos);
TestCaseCountResponse testCaseCountResult = new TestCaseCountResponse(); TestCaseCountResponse testCaseCountResult = new TestCaseCountResponse();
testCaseCountResult.setBarChartDTO(dto); testCaseCountResult.setBarChartDTO(dto);
@ -311,7 +338,7 @@ public class TestCaseCountService {
private TestCaseCountTableDataDTO countShowTable(String groupName, List<String> yaxis, List<TestCaseCountTableDTO> dtos) { private TestCaseCountTableDataDTO countShowTable(String groupName, List<String> yaxis, List<TestCaseCountTableDTO> dtos) {
TestCaseCountTableDataDTO returnDTO = new TestCaseCountTableDataDTO(); TestCaseCountTableDataDTO returnDTO = new TestCaseCountTableDataDTO();
String [] headers = new String[]{groupName,"总计","testCase","apiCase","scenarioCase","loadCaseCount"}; String[] headers = new String[]{groupName, "总计", "testCase", "apiCase", "scenarioCase", "loadCaseCount"};
List<TestCaseCountTableItemDataDTO> heads = new ArrayList<>(); List<TestCaseCountTableItemDataDTO> heads = new ArrayList<>();
boolean showTestCase = true; boolean showTestCase = true;
@ -319,19 +346,19 @@ public class TestCaseCountService {
boolean showScenario = true; boolean showScenario = true;
boolean showLoad = true; boolean showLoad = true;
for (String head : headers) { for (String head : headers) {
if(StringUtils.equalsAnyIgnoreCase(head,groupName,"总计") || yaxis.contains(head)){ if (StringUtils.equalsAnyIgnoreCase(head, groupName, "总计") || yaxis.contains(head)) {
TestCaseCountTableItemDataDTO headData = new TestCaseCountTableItemDataDTO(); TestCaseCountTableItemDataDTO headData = new TestCaseCountTableItemDataDTO();
headData.setId(UUID.randomUUID().toString()); headData.setId(UUID.randomUUID().toString());
headData.setValue(head); headData.setValue(head);
heads.add(headData); heads.add(headData);
}else { } else {
if(StringUtils.equalsIgnoreCase(head,"testCase")){ if (StringUtils.equalsIgnoreCase(head, "testCase")) {
showTestCase = false; showTestCase = false;
}else if(StringUtils.equalsIgnoreCase(head,"apiCase")){ } else if (StringUtils.equalsIgnoreCase(head, "apiCase")) {
showApi = false; showApi = false;
}else if(StringUtils.equalsIgnoreCase(head,"scenarioCase")){ } else if (StringUtils.equalsIgnoreCase(head, "scenarioCase")) {
showScenario = false; showScenario = false;
}else if(StringUtils.equalsIgnoreCase(head,"loadCaseCount")){ } else if (StringUtils.equalsIgnoreCase(head, "loadCaseCount")) {
showLoad = false; showLoad = false;
} }
} }
@ -351,28 +378,28 @@ public class TestCaseCountService {
countData.setValue(data.getAllCount()); countData.setValue(data.getAllCount());
rowDataList.add(countData); rowDataList.add(countData);
if(showTestCase){ if (showTestCase) {
TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO(); TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO();
itemData.setId(UUID.randomUUID().toString()); itemData.setId(UUID.randomUUID().toString());
itemData.setValue(data.getTestCaseCount()); itemData.setValue(data.getTestCaseCount());
rowDataList.add(itemData); rowDataList.add(itemData);
} }
if(showApi){ if (showApi) {
TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO(); TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO();
itemData.setId(UUID.randomUUID().toString()); itemData.setId(UUID.randomUUID().toString());
itemData.setValue(data.getApiCaseCount()); itemData.setValue(data.getApiCaseCount());
rowDataList.add(itemData); rowDataList.add(itemData);
} }
if(showScenario){ if (showScenario) {
TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO(); TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO();
itemData.setId(UUID.randomUUID().toString()); itemData.setId(UUID.randomUUID().toString());
itemData.setValue(data.getScenarioCaseCount()); itemData.setValue(data.getScenarioCaseCount());
rowDataList.add(itemData); rowDataList.add(itemData);
} }
if(showLoad){ if (showLoad) {
TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO(); TestCaseCountTableItemDataDTO itemData = new TestCaseCountTableItemDataDTO();
itemData.setId(UUID.randomUUID().toString()); itemData.setId(UUID.randomUUID().toString());
itemData.setValue(data.getLoadCaseCount()); itemData.setValue(data.getLoadCaseCount());
@ -388,15 +415,15 @@ public class TestCaseCountService {
return returnDTO; return returnDTO;
} }
private List<TestCaseCountChartResult> checkCountChartResultHasColumn(String xcolumn,List<TestCaseCountChartResult> resultList) { private List<TestCaseCountChartResult> checkCountChartResultHasColumn(String xcolumn, List<TestCaseCountChartResult> resultList) {
boolean hasResult = false; boolean hasResult = false;
for (TestCaseCountChartResult result: resultList) { for (TestCaseCountChartResult result : resultList) {
if(StringUtils.equals(result.getGroupName(),xcolumn)){ if (StringUtils.equals(result.getGroupName(), xcolumn)) {
hasResult = true; hasResult = true;
break; break;
} }
} }
if(!hasResult){ if (!hasResult) {
TestCaseCountChartResult result = new TestCaseCountChartResult(); TestCaseCountChartResult result = new TestCaseCountChartResult();
result.setCountNum(0); result.setCountNum(0);
result.setGroupName(xcolumn); result.setGroupName(xcolumn);
@ -422,7 +449,7 @@ public class TestCaseCountService {
List<Object> dataList = new ArrayList<>(); List<Object> dataList = new ArrayList<>();
if(selectTestCase && summary.testCaseCount > 0){ if (selectTestCase && summary.testCaseCount > 0) {
PieData pieData = new PieData(); PieData pieData = new PieData();
pieData.setName(caseDescMap.get("testCaseDesc")); pieData.setName(caseDescMap.get("testCaseDesc"));
pieData.setValue(summary.testCaseCount); pieData.setValue(summary.testCaseCount);
@ -430,7 +457,7 @@ public class TestCaseCountService {
dataList.add(pieData); dataList.add(pieData);
} }
if(selectApi && summary.apiCaseCount > 0){ if (selectApi && summary.apiCaseCount > 0) {
PieData apicasePieData = new PieData(); PieData apicasePieData = new PieData();
apicasePieData.setName(caseDescMap.get("apiCaseDesc")); apicasePieData.setName(caseDescMap.get("apiCaseDesc"));
apicasePieData.setValue(summary.apiCaseCount); apicasePieData.setValue(summary.apiCaseCount);
@ -438,7 +465,7 @@ public class TestCaseCountService {
dataList.add(apicasePieData); dataList.add(apicasePieData);
} }
if(selectScenarioCase && summary.scenarioCaseCount > 0){ if (selectScenarioCase && summary.scenarioCaseCount > 0) {
PieData scenarioPieData = new PieData(); PieData scenarioPieData = new PieData();
scenarioPieData.setName(caseDescMap.get("scenarioCaseDesc")); scenarioPieData.setName(caseDescMap.get("scenarioCaseDesc"));
scenarioPieData.setValue(summary.scenarioCaseCount); scenarioPieData.setValue(summary.scenarioCaseCount);
@ -446,7 +473,7 @@ public class TestCaseCountService {
dataList.add(scenarioPieData); dataList.add(scenarioPieData);
} }
if(selectLoad && summary.loadCaseCount > 0){ if (selectLoad && summary.loadCaseCount > 0) {
PieData loadCasePieData = new PieData(); PieData loadCasePieData = new PieData();
loadCasePieData.setName(caseDescMap.get("loadCaseDesc")); loadCasePieData.setName(caseDescMap.get("loadCaseDesc"));
loadCasePieData.setValue(summary.loadCaseCount); loadCasePieData.setValue(summary.loadCaseCount);
@ -497,9 +524,9 @@ public class TestCaseCountService {
if (CollectionUtils.isNotEmpty(functionCaseCountResult)) { if (CollectionUtils.isNotEmpty(functionCaseCountResult)) {
for (TestCaseCountChartResult result : functionCaseCountResult) { for (TestCaseCountChartResult result : functionCaseCountResult) {
if(result.getGroupName() == null){ if (result.getGroupName() == null) {
result.setGroupName(groupNameParseMap.get("running")); result.setGroupName(groupNameParseMap.get("running"));
}else { } else {
if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) { if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) {
result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT))); result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT)));
} }
@ -519,9 +546,9 @@ public class TestCaseCountService {
if (CollectionUtils.isNotEmpty(apiCaseCountResult)) { if (CollectionUtils.isNotEmpty(apiCaseCountResult)) {
for (TestCaseCountChartResult result : apiCaseCountResult) { for (TestCaseCountChartResult result : apiCaseCountResult) {
if(result.getGroupName() == null){ if (result.getGroupName() == null) {
result.setGroupName(groupNameParseMap.get("running")); result.setGroupName(groupNameParseMap.get("running"));
}else { } else {
if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) { if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) {
result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT))); result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT)));
} }
@ -540,9 +567,9 @@ public class TestCaseCountService {
if (CollectionUtils.isNotEmpty(scenarioCaseCount)) { if (CollectionUtils.isNotEmpty(scenarioCaseCount)) {
for (TestCaseCountChartResult result : scenarioCaseCount) { for (TestCaseCountChartResult result : scenarioCaseCount) {
if(result.getGroupName() == null){ if (result.getGroupName() == null) {
result.setGroupName(groupNameParseMap.get("running")); result.setGroupName(groupNameParseMap.get("running"));
}else { } else {
if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) { if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) {
result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT))); result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT)));
} }
@ -561,9 +588,9 @@ public class TestCaseCountService {
if (CollectionUtils.isNotEmpty(loadCaseCount)) { if (CollectionUtils.isNotEmpty(loadCaseCount)) {
for (TestCaseCountChartResult result : loadCaseCount) { for (TestCaseCountChartResult result : loadCaseCount) {
if(result.getGroupName() == null){ if (result.getGroupName() == null) {
result.setGroupName(groupNameParseMap.get("running")); result.setGroupName(groupNameParseMap.get("running"));
}else { } else {
if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) { if (groupNameParseMap.containsKey(result.getGroupName().toLowerCase(Locale.ROOT))) {
result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT))); result.setGroupName(groupNameParseMap.get(result.getGroupName().toLowerCase(Locale.ROOT)));
} }
@ -582,15 +609,15 @@ public class TestCaseCountService {
Map<String, TestCaseCountSummary> returmMap = new LinkedHashMap<>(); Map<String, TestCaseCountSummary> returmMap = new LinkedHashMap<>();
if(StringUtils.equalsIgnoreCase(order,"desc")){ if (StringUtils.equalsIgnoreCase(order, "desc")) {
TreeMap<Long,List<TestCaseCountSummary>> treeMap = new TreeMap<>(); TreeMap<Long, List<TestCaseCountSummary>> treeMap = new TreeMap<>();
for (TestCaseCountSummary model : summaryMap.values()) { for (TestCaseCountSummary model : summaryMap.values()) {
if(treeMap.containsKey(model.getAllCount())){ if (treeMap.containsKey(model.getAllCount())) {
treeMap.get(model.getAllCount()).add(model); treeMap.get(model.getAllCount()).add(model);
}else { } else {
List<TestCaseCountSummary> list = new ArrayList<>(); List<TestCaseCountSummary> list = new ArrayList<>();
list.add(model); list.add(model);
treeMap.put(model.getAllCount(),list); treeMap.put(model.getAllCount(), list);
} }
} }
ArrayList<TestCaseCountSummary> sortedList = new ArrayList<>(); ArrayList<TestCaseCountSummary> sortedList = new ArrayList<>();
@ -598,27 +625,27 @@ public class TestCaseCountService {
sortedList.addAll(list); sortedList.addAll(list);
} }
for (int i = sortedList.size(); i > 0; i --) { for (int i = sortedList.size(); i > 0; i--) {
TestCaseCountSummary model = sortedList.get(i-1); TestCaseCountSummary model = sortedList.get(i - 1);
returmMap.put(model.groupName,model); returmMap.put(model.groupName, model);
} }
}else if(StringUtils.equalsIgnoreCase(order,"asc")){ } else if (StringUtils.equalsIgnoreCase(order, "asc")) {
TreeMap<Long,List<TestCaseCountSummary>> treeMap = new TreeMap<>(); TreeMap<Long, List<TestCaseCountSummary>> treeMap = new TreeMap<>();
for (TestCaseCountSummary model : summaryMap.values()) { for (TestCaseCountSummary model : summaryMap.values()) {
if(treeMap.containsKey(model.getAllCount())){ if (treeMap.containsKey(model.getAllCount())) {
treeMap.get(model.getAllCount()).add(model); treeMap.get(model.getAllCount()).add(model);
}else { } else {
List<TestCaseCountSummary> list = new ArrayList<>(); List<TestCaseCountSummary> list = new ArrayList<>();
list.add(model); list.add(model);
treeMap.put(model.getAllCount(),list); treeMap.put(model.getAllCount(), list);
} }
} }
for (List<TestCaseCountSummary> list : treeMap.values()) { for (List<TestCaseCountSummary> list : treeMap.values()) {
for (TestCaseCountSummary model : list ) { for (TestCaseCountSummary model : list) {
returmMap.put(model.groupName,model); returmMap.put(model.groupName, model);
} }
} }
}else { } else {
returmMap = summaryMap; returmMap = summaryMap;
} }
@ -672,8 +699,8 @@ public class TestCaseCountService {
} }
private void formatXaxisSeries(XAxis xAxis, List<Series> seriesList, TestAnalysisChartDTO dto, private void formatXaxisSeries(XAxis xAxis, List<Series> seriesList, TestAnalysisChartDTO dto, Map<String, TestCaseCountSummary> summaryMap,
Map<String, TestCaseCountSummary> summaryMap) { boolean selectTestCase, boolean selectApi, boolean selectScenarioCase, boolean selectLoad) {
List<String> xAxisDataList = new ArrayList<>(); List<String> xAxisDataList = new ArrayList<>();
List<Object> testCaseCountList = new ArrayList<>(); List<Object> testCaseCountList = new ArrayList<>();
@ -682,57 +709,82 @@ public class TestCaseCountService {
List<Object> loadCaseCountList = new ArrayList<>(); List<Object> loadCaseCountList = new ArrayList<>();
for (TestCaseCountSummary summary : summaryMap.values()) { for (TestCaseCountSummary summary : summaryMap.values()) {
xAxisDataList.add(summary.groupName); xAxisDataList.add(summary.groupName);
testCaseCountList.add(String.valueOf(summary.testCaseCount)); if (summary.testCaseCount > 0) {
apiCaseCountList.add(String.valueOf(summary.apiCaseCount)); testCaseCountList.add(String.valueOf(summary.testCaseCount));
scenarioCaseCountList.add(String.valueOf(summary.scenarioCaseCount)); } else {
loadCaseCountList.add(String.valueOf(summary.loadCaseCount)); testCaseCountList.add(null);
}
if (summary.apiCaseCount > 0) {
apiCaseCountList.add(String.valueOf(summary.apiCaseCount));
} else {
apiCaseCountList.add(null);
}
if (summary.scenarioCaseCount > 0) {
scenarioCaseCountList.add(String.valueOf(summary.scenarioCaseCount));
} else {
scenarioCaseCountList.add(null);
}
if (summary.loadCaseCount > 0) {
loadCaseCountList.add(String.valueOf(summary.loadCaseCount));
} else {
loadCaseCountList.add(null);
}
} }
xAxis.setData(xAxisDataList); xAxis.setData(xAxisDataList);
Map<String, String> caseDescMap = this.getCaseDescMap(); Map<String, String> caseDescMap = this.getCaseDescMap();
//柱状图上显示数字 //柱状图上显示数字
Map<String,Object> labelMap = new HashMap<>(); Map<String, Object> labelMap = new HashMap<>();
labelMap.put("show",true); labelMap.put("show", true);
labelMap.put("position","inside"); labelMap.put("position", "inside");
Series tetcaseSeries = new Series(); if (selectTestCase) {
tetcaseSeries.setName(caseDescMap.get("testCaseDesc")); Series tetcaseSeries = new Series();
tetcaseSeries.setColor("#F38F1F"); tetcaseSeries.setName(caseDescMap.get("testCaseDesc"));
tetcaseSeries.setRadius("20%"); tetcaseSeries.setColor("#F38F1F");
tetcaseSeries.setType("bar"); tetcaseSeries.setRadius("20%");
tetcaseSeries.setStack("total"); tetcaseSeries.setType("bar");
tetcaseSeries.setData(testCaseCountList); tetcaseSeries.setStack("total");
tetcaseSeries.setBarWidth("50"); tetcaseSeries.setData(testCaseCountList);
tetcaseSeries.setLabel(labelMap); tetcaseSeries.setBarWidth("50");
seriesList.add(tetcaseSeries); tetcaseSeries.setLabel(labelMap);
seriesList.add(tetcaseSeries);
Series apiSeries = new Series(); }
apiSeries.setName(caseDescMap.get("apiCaseDesc")); if (selectApi) {
apiSeries.setColor("#6FD999"); Series apiSeries = new Series();
apiSeries.setType("bar"); apiSeries.setName(caseDescMap.get("apiCaseDesc"));
apiSeries.setStack("total"); apiSeries.setColor("#6FD999");
apiSeries.setData(apiCaseCountList); apiSeries.setType("bar");
apiSeries.setLabel(labelMap); apiSeries.setStack("total");
seriesList.add(apiSeries); apiSeries.setData(apiCaseCountList);
apiSeries.setLabel(labelMap);
Series scenarioSeries = new Series(); seriesList.add(apiSeries);
scenarioSeries.setName(caseDescMap.get("scenarioCaseDesc")); }
scenarioSeries.setColor("#2884F3"); if (selectScenarioCase) {
scenarioSeries.setType("bar"); Series scenarioSeries = new Series();
scenarioSeries.setStack("total"); scenarioSeries.setName(caseDescMap.get("scenarioCaseDesc"));
scenarioSeries.setData(scenarioCaseCountList); scenarioSeries.setColor("#2884F3");
scenarioSeries.setLabel(labelMap); scenarioSeries.setType("bar");
seriesList.add(scenarioSeries); scenarioSeries.setStack("total");
scenarioSeries.setData(scenarioCaseCountList);
Series loadSeries = new Series(); scenarioSeries.setLabel(labelMap);
loadSeries.setName(caseDescMap.get("loadCaseDesc")); seriesList.add(scenarioSeries);
loadSeries.setColor("#F45E53"); }
loadSeries.setType("bar"); if (selectLoad) {
loadSeries.setStack("total"); Series loadSeries = new Series();
loadSeries.setData(loadCaseCountList); loadSeries.setName(caseDescMap.get("loadCaseDesc"));
loadSeries.setLabel(labelMap); loadSeries.setColor("#F45E53");
seriesList.add(loadSeries); loadSeries.setType("bar");
loadSeries.setStack("total");
loadSeries.setData(loadCaseCountList);
loadSeries.setLabel(labelMap);
seriesList.add(loadSeries);
}
dto.setXAxis(xAxis); dto.setXAxis(xAxis);
dto.setYAxis(new YAxis()); dto.setYAxis(new YAxis());
@ -836,8 +888,8 @@ public class TestCaseCountService {
JSONObject jsonObject = optionsArr.getJSONObject(i); JSONObject jsonObject = optionsArr.getJSONObject(i);
if (jsonObject.containsKey("value") && jsonObject.containsKey("text")) { if (jsonObject.containsKey("value") && jsonObject.containsKey("text")) {
String value = jsonObject.getString("value"); String value = jsonObject.getString("value");
if(!StringUtils.equalsAnyIgnoreCase(value, "Prepare", "Error", "Success", "Trash", "Underway", "Starting", "Saved", if (!StringUtils.equalsAnyIgnoreCase(value, "Prepare", "Error", "Success", "Trash", "Underway", "Starting", "Saved",
"Completed","test_track.case.status_finished")){ "Completed", "test_track.case.status_finished")) {
Map<String, String> statusMap = new HashMap<>(); Map<String, String> statusMap = new HashMap<>();
statusMap.put("id", jsonObject.getString("value")); statusMap.put("id", jsonObject.getString("value"));
statusMap.put("label", jsonObject.getString("text")); statusMap.put("label", jsonObject.getString("text"));

@ -1 +1 @@
Subproject commit 22b92e86e3426ddc38b5295b3e42239694ed66c3 Subproject commit 044899d93802a7a30ba7453aaa58bd78af3a84a9

View File

@ -2,23 +2,23 @@
<div class="ms-content"> <div class="ms-content">
<el-row class="row-class"> <el-row class="row-class">
<el-col :span="4" class="col-one"> <el-col :span="4" class="col-one">
<el-card :body-style="{ padding: '0px' }" class="ms-col" @click.native="openCard('trackTestCase')"> <el-card :body-style="{ padding: '0px' }" class="ms-col" @click.native="openCard('countTestCase')">
<img src="@/assets/test_case_analysis_png.png" class="image"> <img src="@/assets/test_case_analysis_png.png" class="image">
<div style="padding: 10px;"> <div style="padding: 10px;">
<span>{{ $t('commons.report_statistics.test_case_analysis') }}</span> <span>{{ $t('commons.report_statistics.test_case_count') }}</span>
<div class="bottom clearfix"> <div class="bottom clearfix">
<time class="time">{{ $t('commons.report_statistics.test_case_activity') }}</time> <time class="time">{{ $t('commons.report_statistics.test_case_count_activity') }}</time>
</div> </div>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<el-card :body-style="{ padding: '0px' }" class="ms-col" @click.native="openCard('countTestCase')"> <el-card :body-style="{ padding: '0px' }" class="ms-col" @click.native="openCard('trackTestCase')">
<img src="@/assets/track.jpg" class="image"> <img src="@/assets/track.jpg" class="image">
<div style="padding: 10px;"> <div style="padding: 10px;">
<span>{{ $t('commons.report_statistics.test_case_count') }}</span> <span>{{ $t('commons.report_statistics.test_case_analysis') }}</span>
<div class="bottom clearfix"> <div class="bottom clearfix">
<time class="time">{{ $t('commons.report_statistics.test_case_count_activity') }}</time> <time class="time">{{ $t('commons.report_statistics.test_case_activity') }}</time>
</div> </div>
</div> </div>
</el-card> </el-card>
@ -93,13 +93,15 @@ export default {
</script> </script>
<style scoped> <style scoped>
.row-class{ .row-class {
display: flex; display: flex;
} }
.col-one{
.col-one {
display: flex; display: flex;
align-items: stretch; align-items: stretch;
} }
.time { .time {
font-size: 13px; font-size: 13px;
color: #999; color: #999;

View File

@ -83,7 +83,6 @@ export default {
} }
}, },
created() { created() {
this.selectedPicType = this.chartType;
this.dataOption = this.loadOption; this.dataOption = this.loadOption;
if (this.needFullScreen) { if (this.needFullScreen) {
this.w = document.documentElement.clientWidth; this.w = document.documentElement.clientWidth;
@ -95,7 +94,7 @@ export default {
this.countChartWidth(); this.countChartWidth();
}, },
chartType() { chartType() {
this.$emit("updateChartType",this.chartType); this.$emit("updateChartType", this.chartType);
this.countChartWidth(); this.countChartWidth();
}, },
}, },
@ -111,7 +110,7 @@ export default {
this.$emit('orderCharts', this.order); this.$emit('orderCharts', this.order);
}, },
generateOption(chartTypeParam) { generateOption(chartTypeParam) {
if(chartTypeParam){ if (chartTypeParam) {
this.chartType = chartTypeParam; this.chartType = chartTypeParam;
} }
if (this.chartType === 'pie') { if (this.chartType === 'pie') {

@ -1 +1 @@
Subproject commit da6cc328b1601dae561d7f87b6fbf02293f39ee6 Subproject commit 337bc3dd307a3638aa38cf777a86473c89ef307a