fix(测试跟踪): 功能用例导入报错

--bug=1019205 --user=陈建星 【测试跟踪】导入8000+条用例,导入失败,报500 https://www.tapd.cn/55049933/s/1285154
This commit is contained in:
chenjianxing 2022-11-01 15:37:18 +08:00 committed by jianxing
parent c554f6cd22
commit 6cf24e5152
5 changed files with 24 additions and 6 deletions

View File

@ -16,6 +16,9 @@ public class TestCaseExportVersionConverter implements TestCaseExportConverter {
public TestCaseExportVersionConverter() { public TestCaseExportVersionConverter() {
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
if (projectVersionService == null) {
return;
}
List<ProjectVersionDTO> projectVersions = projectVersionService.getProjectVersions(SessionUtils.getCurrentProjectId()); List<ProjectVersionDTO> projectVersions = projectVersionService.getProjectVersions(SessionUtils.getCurrentProjectId());
projectVersions.forEach(i -> versionMap.put(i.getId(), i.getName())); projectVersions.forEach(i -> versionMap.put(i.getId(), i.getName()));
} }

View File

@ -798,6 +798,9 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
for (Map.Entry<Integer, String> headEntry : headMap.entrySet()) { for (Map.Entry<Integer, String> headEntry : headMap.entrySet()) {
Integer index = headEntry.getKey(); Integer index = headEntry.getKey();
String field = headEntry.getValue(); String field = headEntry.getValue();
if (StringUtils.isBlank(field)) {
continue;
}
String value = StringUtils.isEmpty(row.get(index)) ? StringUtils.EMPTY : row.get(index); String value = StringUtils.isEmpty(row.get(index)) ? StringUtils.EMPTY : row.get(index);
if (excelHeadToFieldNameDic.containsKey(field)) { if (excelHeadToFieldNameDic.containsKey(field)) {

View File

@ -117,12 +117,16 @@ public class TestPlanTestCaseService {
.stream().collect(Collectors.toMap(User::getId, User::getName)); .stream().collect(Collectors.toMap(User::getId, User::getName));
List<String> versionIds = list.stream().map(TestPlanCaseDTO::getVersionId).collect(Collectors.toList()); List<String> versionIds = list.stream().map(TestPlanCaseDTO::getVersionId).collect(Collectors.toList());
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
if (projectVersionService != null) {
Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream()
.collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName));
list.forEach(item -> {
item.setVersionName(projectVersionMap.get(item.getVersionId()));
});
}
list.forEach(item -> { list.forEach(item -> {
item.setExecutorName(userMap.get(item.getExecutor())); item.setExecutorName(userMap.get(item.getExecutor()));
item.setMaintainerName(userMap.get(item.getMaintainer())); item.setMaintainerName(userMap.get(item.getMaintainer()));
item.setVersionName(projectVersionMap.get(item.getVersionId()));
}); });
} }
return list; return list;

View File

@ -2853,6 +2853,9 @@ public class TestCaseService {
public void buildVersionInfo(List<TestCaseDTO> testCases) { public void buildVersionInfo(List<TestCaseDTO> testCases) {
List<String> versionIds = testCases.stream().map(TestCaseDTO::getVersionId).collect(Collectors.toList()); List<String> versionIds = testCases.stream().map(TestCaseDTO::getVersionId).collect(Collectors.toList());
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
if (projectVersionService == null) {
return;
}
Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream()
.collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName));
testCases.forEach(testCase -> { testCases.forEach(testCase -> {

View File

@ -75,14 +75,19 @@ public class TestReviewTestCaseService {
.stream().collect(Collectors.toMap(User::getId, User::getName)); .stream().collect(Collectors.toMap(User::getId, User::getName));
List<String> versionIds = list.stream().map(TestReviewCaseDTO::getVersionId).collect(Collectors.toList()); List<String> versionIds = list.stream().map(TestReviewCaseDTO::getVersionId).collect(Collectors.toList());
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
if (projectVersionService != null) {
Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream()
.collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName));
list.forEach(item -> {
item.setVersionName(projectVersionMap.get(item.getVersionId()));
});
}
list.forEach(item -> { list.forEach(item -> {
String reviewId = item.getReviewId(); String reviewId = item.getReviewId();
List<String> userIds = getReviewUserIds(reviewId); List<String> userIds = getReviewUserIds(reviewId);
item.setReviewerName(getReviewName(userIds, userMap)); item.setReviewerName(getReviewName(userIds, userMap));
item.setMaintainerName(userMap.get(item.getMaintainer())); item.setMaintainerName(userMap.get(item.getMaintainer()));
item.setVersionName(projectVersionMap.get(item.getVersionId()));
}); });
return list; return list;
} }