fix(测试跟踪): 缺陷管理导入导出级联类型字段显示文本
--bug=1027215 --user=宋昌昌 [测试跟踪]github#25014与jira集成,在jira中创建的字段为二级列表类型,该字段内容在ms系统中可以正常显示,但是导出内容是错误的 https://www.tapd.cn/55049933/s/1387595
This commit is contained in:
parent
f845c967c3
commit
7ce8a89b4f
|
@ -118,8 +118,8 @@ public class IssueTemplateHeadWriteHandler implements RowWriteHandler, SheetWrit
|
|||
Translator.get("options").concat(memberMap.keySet().toString()));
|
||||
}
|
||||
if (StringUtils.equalsAnyIgnoreCase(field.getType(), CustomFieldType.CASCADING_SELECT.getValue())) {
|
||||
commentText = Translator.get("multiple_input_import_cell_format_comment").concat(", " +
|
||||
Translator.get("options_tips").concat(JSON.toJSONString(getCascadSelect(field.getOptions()))));
|
||||
commentText = Translator.get("cascading_select_import_cell_format_comment").concat(", " +
|
||||
Translator.get("options_key_tips").concat(JSON.toJSONString(getCascadSelect(field.getOptions()))));
|
||||
}
|
||||
return field.getRequired() ? Translator.get("required").concat("; " + commentText) : commentText;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.alibaba.excel.context.AnalysisContext;
|
|||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.base.domain.Issues;
|
||||
import io.metersphere.commons.constants.CustomFieldType;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
|
@ -340,25 +341,33 @@ public class IssueExcelListener extends AnalysisEventListener<Map<Integer, Strin
|
|||
if (!v.toString().contains("[")) {
|
||||
v = List.of("\"" + v + "\"");
|
||||
}
|
||||
customFieldItemDTO.setValue(parseOptionText(customFieldDao.getOptions(), v.toString()));
|
||||
customFieldResourceDTO.setValue(parseOptionText(customFieldDao.getOptions(), v.toString()));
|
||||
String parseStr = parseOptionText(customFieldDao.getOptions(), v.toString());
|
||||
customFieldItemDTO.setValue(parseStr);
|
||||
customFieldResourceDTO.setValue(parseStr);
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(type, CustomFieldType.SELECT.getValue(),
|
||||
CustomFieldType.RADIO.getValue())) {
|
||||
customFieldItemDTO.setValue(parseOptionText(customFieldDao.getOptions(), v.toString()));
|
||||
customFieldResourceDTO.setValue("\"" + parseOptionText(customFieldDao.getOptions(), v.toString()) + "\"");
|
||||
String parseStr = parseOptionText(customFieldDao.getOptions(), v.toString());
|
||||
customFieldItemDTO.setValue(parseStr);
|
||||
customFieldResourceDTO.setValue("\"" + parseStr + "\"");
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(type, CustomFieldType.MULTIPLE_INPUT.getValue())) {
|
||||
if (!v.toString().contains("[")) {
|
||||
v = List.of("\"" + v + "\"");
|
||||
}
|
||||
customFieldItemDTO.setValue(v);
|
||||
customFieldResourceDTO.setValue(v.toString());
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(type, CustomFieldType.MULTIPLE_MEMBER.getValue(),
|
||||
CustomFieldType.CASCADING_SELECT.getValue())) {
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(type, CustomFieldType.MULTIPLE_MEMBER.getValue())) {
|
||||
if (!v.toString().contains("[")) {
|
||||
v = List.of("\"" + v + "\"");
|
||||
}
|
||||
customFieldItemDTO.setValue(v.toString());
|
||||
customFieldResourceDTO.setValue(v.toString());
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(type, CustomFieldType.CASCADING_SELECT.getValue())) {
|
||||
if (!v.toString().contains("[")) {
|
||||
v = List.of("\"" + v + "\"");
|
||||
}
|
||||
String parseStr = parseCascadingOptionText(customFieldDao.getOptions(), v.toString());
|
||||
customFieldItemDTO.setValue(parseStr);
|
||||
customFieldResourceDTO.setValue(parseStr);
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(type, CustomFieldType.DATE.getValue())) {
|
||||
Date vdate = DateUtils.parseDate(v.toString(), "yyyy/MM/dd");
|
||||
v = DateUtils.format(vdate, "yyyy-MM-dd");
|
||||
|
@ -477,4 +486,39 @@ public class IssueExcelListener extends AnalysisEventListener<Map<Integer, Strin
|
|||
return tarVal.substring(0, tarVal.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public String parseCascadingOptionText(String cascadingOption, String tarVal) {
|
||||
List<String> values = new ArrayList<>();
|
||||
if (StringUtils.isEmpty(cascadingOption)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
JSONArray options = JSONArray.parseArray(cascadingOption);
|
||||
JSONArray talVals = JSONArray.parseArray(tarVal);
|
||||
if (options.size() == 0 || talVals.size() == 0) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
for (int i = 0; i < talVals.size(); i++) {
|
||||
String val = talVals.get(i).toString();
|
||||
JSONObject jsonOption = this.findJsonOption(options, val);
|
||||
if (jsonOption == null) {
|
||||
return StringUtils.EMPTY;
|
||||
} else {
|
||||
values.add("\"" + jsonOption.get("value").toString() + "\"");
|
||||
options = jsonOption.getJSONArray("children");
|
||||
}
|
||||
}
|
||||
return values.toString();
|
||||
}
|
||||
|
||||
private JSONObject findJsonOption(JSONArray options, String tarVal) {
|
||||
if (options.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<JSONObject> jsonObjects = options.stream().map(option -> (JSONObject) option).filter(option -> StringUtils.equals(tarVal, option.get("text").toString())).toList();
|
||||
if (jsonObjects.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return jsonObjects.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -823,6 +823,9 @@ public class IssuesService {
|
|||
&& !StringUtils.equalsAnyIgnoreCase(customField.getName(), SystemCustomField.ISSUE_STATUS)) {
|
||||
fieldDao.setValue(parseOptionValue(customField.getOptions(), fieldDao.getValue()));
|
||||
}
|
||||
if (StringUtils.equalsAnyIgnoreCase(customField.getType(), CustomFieldType.CASCADING_SELECT.getValue())) {
|
||||
fieldDao.setValue(parseCascadingOptionValue(customField.getOptions(), fieldDao.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1936,6 +1939,41 @@ public class IssuesService {
|
|||
return tarVal;
|
||||
}
|
||||
|
||||
public String parseCascadingOptionValue(String cascadingOption, String tarVal) {
|
||||
List<String> values = new ArrayList<>();
|
||||
if (StringUtils.isEmpty(cascadingOption)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
JSONArray options = JSONArray.parseArray(cascadingOption);
|
||||
JSONArray talVals = JSONArray.parseArray(tarVal);
|
||||
if (options.size() == 0 || talVals.size() == 0) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
for (int i = 0; i < talVals.size(); i++) {
|
||||
String val = talVals.get(i).toString();
|
||||
JSONObject jsonOption = this.findJsonOption(options, val);
|
||||
if (jsonOption == null) {
|
||||
return StringUtils.EMPTY;
|
||||
} else {
|
||||
values.add("\"" + jsonOption.get("text").toString() + "\"");
|
||||
options = jsonOption.getJSONArray("children");
|
||||
}
|
||||
}
|
||||
return values.toString();
|
||||
}
|
||||
|
||||
private JSONObject findJsonOption(JSONArray options, String tarVal) {
|
||||
if (options.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<JSONObject> jsonObjects = options.stream().map(option -> (JSONObject) option).filter(option -> StringUtils.equals(tarVal, option.get("value").toString())).toList();
|
||||
if (jsonObjects.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return jsonObjects.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
public Issues checkIssueExist(Integer num, String projectId) {
|
||||
IssuesExample example = new IssuesExample();
|
||||
example.createCriteria().andNumEqualTo(num).andProjectIdEqualTo(projectId);
|
||||
|
|
|
@ -51,7 +51,9 @@ datetime_import_cell_format_comment=The date and time cell format is YYYY/MM/DD
|
|||
int_import_cell_format_comment=cell format: 100001
|
||||
float_import_cell_format_comment=cell format: 24
|
||||
multiple_input_import_cell_format_comment=This field has multiple values. Separate multiple values with commas or semicolons
|
||||
cascading_select_import_cell_format_comment=This cell is a cascade selection. Please separate the child options under the parent option with a comma or semicolon (v; v1; v11)
|
||||
options_tips=(format{key:value}, please fill in the corresponding value)Option value:
|
||||
options_key_tips=(format{key:value},please fill in the corresponding key)Option value:
|
||||
# issue import and issue export
|
||||
title==Title
|
||||
description=Description
|
||||
|
|
|
@ -28,7 +28,9 @@ datetime_import_cell_format_comment=日期时间类型单元格格式为: YYYY/M
|
|||
int_import_cell_format_comment=整型单元格格式为: 100001
|
||||
float_import_cell_format_comment=浮点单元格格式为: 24
|
||||
multiple_input_import_cell_format_comment=该单元格可输入多个值,多个值请用逗号或分号隔开(v1;v2)
|
||||
cascading_select_import_cell_format_comment=该单元格为级联选择,选择父级选项下的子级选项请用逗号或者分号隔开(v;v1;v11)
|
||||
options_tips=(格式{key:value},请填写对应的value)选项:
|
||||
options_key_tips=(格式{key:value},请填写对应的key)选项:
|
||||
# issue import and issue export
|
||||
title=缺陷标题
|
||||
description=缺陷描述
|
||||
|
|
|
@ -28,7 +28,9 @@ datetime_import_cell_format_comment=日期時間單元格格式爲: YYYY/MM/DD H
|
|||
int_import_cell_format_comment=單元格格式: 100001
|
||||
float_import_cell_format_comment=單元格格式: 24
|
||||
multiple_input_import_cell_format_comment=該單元格可輸入多個值,多個值請用逗號或分號隔開(v1;v2)
|
||||
cascading_select_import_cell_format_comment=該單元格爲級聯選擇,選擇父級選項下的子級選項請用逗號或者分號隔開(v;v1;v11)
|
||||
options_tips=(格式{key:value},請填寫對應value)選項:
|
||||
options_key_tips=(格式{key:value},請填寫對應key)選項:
|
||||
# issue import and issue export
|
||||
title=缺陷標題
|
||||
description=缺陷描述
|
||||
|
|
Loading…
Reference in New Issue