diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index e17ac4c887..adbe0ce916 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1551,8 +1551,9 @@ public class TestCaseService { List list = new ArrayList<>(); Map> customSelectValueMap = new HashMap<>(); Map customNameMap = new HashMap<>(); + String projectId = testCaseList.get(0).getProjectId(); TestCaseTemplateService testCaseTemplateService = CommonBeanFactory.getBean(TestCaseTemplateService.class); - TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(testCaseList.get(0).getProjectId()); + TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(projectId); List customFieldList; if (testCaseTemplate == null) { @@ -1562,7 +1563,11 @@ public class TestCaseService { } Set textFields = new HashSet<>(); - buildExportCustomFieldMap(customSelectValueMap, customNameMap, customFieldList, textFields); + Map userMap = userService.getProjectMemberOption(projectId) + .stream() + .collect(Collectors.toMap(User::getId, User::getName)); + + buildExportCustomFieldMap(userMap, customSelectValueMap, customNameMap, customFieldList, textFields); for (int rowIndex = 0; rowIndex < testCaseList.size(); rowIndex++) { TestCaseDTO t = testCaseList.get(rowIndex); @@ -1572,6 +1577,7 @@ public class TestCaseService { setExportSystemField(t, customNameMap, customSelectValueMap); BeanUtils.copyBean(data, t); + data.setMaintainer(userMap.get(data.getMaintainer())); buildExportCustomNum(isUseCustomId, t, data); buildExportStep(t, stepDescList, stepResultList, data); buildExportCustomField(customSelectValueMap, customNameMap, t, data, textFields); @@ -1715,8 +1721,8 @@ public class TestCaseService { } } - private void buildExportCustomFieldMap(Map> customSelectValueMap, Map customNameMap, - List customFieldList, Set textFields) { + private void buildExportCustomFieldMap(Map userMap, Map> customSelectValueMap, + Map customNameMap, List customFieldList, Set textFields) { for (CustomFieldDao dto : customFieldList) { Map map = new HashMap<>(); if (CustomFieldType.getHasOptionValueSet().contains(dto.getType())) { @@ -1744,7 +1750,11 @@ public class TestCaseService { if (StringUtils.equalsAny(dto.getType(), CustomFieldType.TEXTAREA.getValue(), CustomFieldType.RICH_TEXT.getValue())) { textFields.add(dto.getId()); } - customSelectValueMap.put(dto.getId(), map); + if (StringUtils.equalsAny(dto.getType(), CustomFieldType.MULTIPLE_MEMBER.getValue(), CustomFieldType.MEMBER.getValue())) { + customSelectValueMap.put(dto.getId(), userMap); + } else { + customSelectValueMap.put(dto.getId(), map); + } customNameMap.put(dto.getId(), dto.getName()); } } diff --git a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java index 3d1cef5bb5..28a61d79e9 100644 --- a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java +++ b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMemberValidator.java @@ -22,8 +22,8 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator { this.isKVOption = true; UserService userService = CommonBeanFactory.getBean(UserService.class); List memberOption = userService.getProjectMemberOption(SessionUtils.getCurrentProjectId()); - userIdMap = memberOption.stream().collect(Collectors.toMap(User::getId, User::getName)); - userNameMap = memberOption.stream().collect(Collectors.toMap(User::getName, User::getId)); + userIdMap = memberOption.stream().collect(Collectors.toMap(user -> user.getId().toLowerCase(), user -> user.getName().toLowerCase())); + userNameMap = memberOption.stream().collect(Collectors.toMap(user -> user.getName().toLowerCase(), user -> user.getId().toLowerCase())); } @Override @@ -41,8 +41,8 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator { @Override public Object parse2Key(String keyOrValue, CustomFieldDao customField) { - if (userNameMap.containsKey(keyOrValue)) { - return userNameMap.get(keyOrValue); + if (userNameMap.containsKey(keyOrValue.toLowerCase())) { + return userNameMap.get(keyOrValue.toLowerCase()); } return keyOrValue; } diff --git a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java index 0cefe22cac..2e48a00568 100644 --- a/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java +++ b/backend/src/main/java/io/metersphere/track/validate/CustomFieldMultipleMemberValidator.java @@ -1,6 +1,5 @@ package io.metersphere.track.validate; -import com.alibaba.fastjson.JSONArray; import io.metersphere.commons.exception.CustomFieldValidateException; import io.metersphere.dto.CustomFieldDao; import io.metersphere.i18n.Translator; @@ -34,7 +33,7 @@ public class CustomFieldMultipleMemberValidator extends CustomFieldMemberValidat List keyOrValues = parse2Array(keyOrValuesStr); for (int i = 0; i < keyOrValues.size(); i++) { - String item = keyOrValues.get(i); + String item = keyOrValues.get(i).toLowerCase(); if (userNameMap.containsKey(item)) { keyOrValues.set(i, userNameMap.get(item)); }