diff --git a/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMultipleSelectValidator.java b/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMultipleSelectValidator.java index 8c48581057..b2e3c71c7f 100644 --- a/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMultipleSelectValidator.java +++ b/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldMultipleSelectValidator.java @@ -17,7 +17,7 @@ public class CustomFieldMultipleSelectValidator extends CustomFieldSelectValidat if (StringUtils.isBlank(value)) { return; } - prepareCatch(customField); + prepareCache(customField); Set idSet = optionValueSetCache.get(customField.getId()); Set textSet = optionTextSetCache.get(customField.getId()); for (String item : parse2Array(customField.getName(), value)) { diff --git a/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldSelectValidator.java b/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldSelectValidator.java index 09cbd19b33..674b76473d 100644 --- a/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldSelectValidator.java +++ b/test-track/backend/src/main/java/io/metersphere/validate/CustomFieldSelectValidator.java @@ -45,7 +45,7 @@ public class CustomFieldSelectValidator extends AbstractCustomFieldValidator { if (StringUtils.isBlank(value)) { return; } - prepareCatch(customField); + prepareCache(customField); Set idSet = optionValueSetCache.get(customField.getId()); Set textSet = optionTextSetCache.get(customField.getId()); if (!idSet.contains(value) && !textSet.contains(value)) { @@ -68,7 +68,7 @@ public class CustomFieldSelectValidator extends AbstractCustomFieldValidator { * * @param customField */ - protected void prepareCatch(CustomFieldDao customField) { + protected void prepareCache(CustomFieldDao customField) { if (optionValueSetCache.get(customField.getId()) == null) { List options = getOptions(customField.getId(), customField.getOptions()); @@ -87,21 +87,16 @@ public class CustomFieldSelectValidator extends AbstractCustomFieldValidator { */ private void translateSystemOption(CustomFieldDao customField, List options) { Map fieldI18nMap = i18nMap.get(customField.getName()); + // 不为空,说明需要翻译 if (fieldI18nMap != null) { - // 不为空,说明需要翻译 Iterator iterator = options.iterator(); - // 先将系统字段删掉 + // 替换成翻译后的值 while (iterator.hasNext()) { CustomFieldOptionDTO option = iterator.next(); - if (option.getSystem()) { - iterator.remove(); + if (option.getSystem() && fieldI18nMap.keySet().contains(option.getValue())) { + option.setText(fieldI18nMap.get(option.getValue())); } } - // 再填充翻译后的值 - for (String optionValue : fieldI18nMap.keySet()) { - CustomFieldOptionDTO option = new CustomFieldOptionDTO(optionValue, fieldI18nMap.get(optionValue), true); - options.add(option); - } } }