fix(测试跟踪): 用例状态添加新选项导出后显示错误
--bug=1015649 --user=陈建星 【测试跟踪】功能用例,用例状态字段值修改为自定义内容后,导出文件里显示的编码 https://www.tapd.cn/55049933/s/1219125
This commit is contained in:
parent
8c14a3871d
commit
78b1d7b921
|
@ -0,0 +1,11 @@
|
||||||
|
package io.metersphere.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class CustomFieldOption {
|
||||||
|
private String text;
|
||||||
|
private String value;
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
import io.metersphere.dto.CustomFieldDao;
|
import io.metersphere.dto.CustomFieldDao;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -46,33 +45,9 @@ public class TestCaseExcelData {
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
private String priority;
|
private String priority;
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
Map<String,String> customDatas = new LinkedHashMap<>();
|
Map<String, String> customDatas = new LinkedHashMap<>();
|
||||||
|
|
||||||
public Set<String> getExcludeColumnFiledNames(boolean needNum){
|
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields) {
|
||||||
Set<String> excludeColumnFiledNames = new HashSet<>();
|
|
||||||
if(!needNum){
|
|
||||||
excludeColumnFiledNames.add("customNum");
|
|
||||||
}
|
|
||||||
excludeColumnFiledNames.add("id");
|
|
||||||
excludeColumnFiledNames.add("num");
|
|
||||||
return excludeColumnFiledNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String parseStatus(String parseStatus){
|
|
||||||
String caseStatusValue = "";
|
|
||||||
if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Underway","进行中","進行中")){
|
|
||||||
caseStatusValue = "Underway";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Prepare","未开始","未開始")){
|
|
||||||
caseStatusValue = "Prepare";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Completed","已完成","已完成")){
|
|
||||||
caseStatusValue = "Completed";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Trash")){
|
|
||||||
caseStatusValue = "Trash";
|
|
||||||
}
|
|
||||||
return caseStatusValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields){
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,9 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
|
||||||
private String priority;
|
private String priority;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields){
|
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields) {
|
||||||
List<List<String>> returnList = new ArrayList<>();
|
List<List<String>> returnList = new ArrayList<>();
|
||||||
if(needNum){
|
if (needNum) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
list.add("ID");
|
list.add("ID");
|
||||||
returnList.add(list);
|
returnList.add(list);
|
||||||
|
@ -129,9 +129,9 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
|
||||||
list9.add("用例等级");
|
list9.add("用例等级");
|
||||||
returnList.add(list9);
|
returnList.add(list9);
|
||||||
|
|
||||||
if(CollectionUtils.isNotEmpty(customFields)){
|
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||||
for (CustomFieldDao dto:customFields) {
|
for (CustomFieldDao dto : customFields) {
|
||||||
if(StringUtils.equals(dto.getName(),"用例等级")){
|
if (StringUtils.equals(dto.getName(), "用例等级")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
|
@ -145,19 +145,4 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
|
||||||
}
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String parseStatus(String parseStatus){
|
|
||||||
String caseStatusValue = "";
|
|
||||||
if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Underway","进行中","進行中")){
|
|
||||||
caseStatusValue = "进行中";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Prepare","未开始","未開始")){
|
|
||||||
caseStatusValue = "未开始";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Completed","已完成","已完成")){
|
|
||||||
caseStatusValue = "已完成";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Trash","废弃","廢棄")){
|
|
||||||
caseStatusValue = "废弃";
|
|
||||||
}
|
|
||||||
return caseStatusValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,9 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
|
||||||
private String maintainer;
|
private String maintainer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields){
|
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields) {
|
||||||
List<List<String>> returnList = new ArrayList<>();
|
List<List<String>> returnList = new ArrayList<>();
|
||||||
if(needNum){
|
if (needNum) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
list.add("ID");
|
list.add("ID");
|
||||||
returnList.add(list);
|
returnList.add(list);
|
||||||
|
@ -133,12 +133,12 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
|
||||||
list10.add("用例狀態");
|
list10.add("用例狀態");
|
||||||
returnList.add(list10);
|
returnList.add(list10);
|
||||||
|
|
||||||
if(CollectionUtils.isNotEmpty(customFields)){
|
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||||
for (CustomFieldDao dto:customFields) {
|
for (CustomFieldDao dto : customFields) {
|
||||||
if(StringUtils.equals(dto.getName(),"用例等級")){
|
if (StringUtils.equals(dto.getName(), "用例等級")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(StringUtils.equals(dto.getName(),"用例状态")){
|
if (StringUtils.equals(dto.getName(), "用例状态")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
|
@ -152,19 +152,4 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
|
||||||
}
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String parseStatus(String parseStatus){
|
|
||||||
String caseStatusValue = "";
|
|
||||||
if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Underway","进行中","進行中")){
|
|
||||||
caseStatusValue = "進行中";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Prepare","未开始","未開始")){
|
|
||||||
caseStatusValue = "未開始";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Completed","已完成","已完成")){
|
|
||||||
caseStatusValue = "已完成";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Trash","废弃","廢棄")){
|
|
||||||
caseStatusValue = "廢棄";
|
|
||||||
}
|
|
||||||
return caseStatusValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,9 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
|
||||||
private String maintainer;
|
private String maintainer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields){
|
public List<List<String>> getHead(boolean needNum, List<CustomFieldDao> customFields) {
|
||||||
List<List<String>> returnList = new ArrayList<>();
|
List<List<String>> returnList = new ArrayList<>();
|
||||||
if(needNum){
|
if (needNum) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
list.add("ID");
|
list.add("ID");
|
||||||
returnList.add(list);
|
returnList.add(list);
|
||||||
|
@ -133,12 +133,12 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
|
||||||
list10.add("Case status");
|
list10.add("Case status");
|
||||||
returnList.add(list10);
|
returnList.add(list10);
|
||||||
|
|
||||||
if(CollectionUtils.isNotEmpty(customFields)){
|
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||||
for (CustomFieldDao dto:customFields) {
|
for (CustomFieldDao dto : customFields) {
|
||||||
if(StringUtils.equals(dto.getName(),"用例等级")){
|
if (StringUtils.equals(dto.getName(), "用例等级")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(StringUtils.equals(dto.getName(),"用例状态")){
|
if (StringUtils.equals(dto.getName(), "用例状态")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
|
@ -152,19 +152,4 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
|
||||||
}
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String parseStatus(String parseStatus){
|
|
||||||
String caseStatusValue = "";
|
|
||||||
if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Underway","进行中","進行中")){
|
|
||||||
caseStatusValue = "Underway";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Prepare","未开始","未開始")){
|
|
||||||
caseStatusValue = "Prepare";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Completed","已完成","已完成")){
|
|
||||||
caseStatusValue = "Completed";
|
|
||||||
}else if(StringUtils.equalsAnyIgnoreCase(parseStatus,"Trash")){
|
|
||||||
caseStatusValue = "Trash";
|
|
||||||
}
|
|
||||||
return caseStatusValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.commons.constants.TestCaseConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.dto.CustomFieldDao;
|
import io.metersphere.dto.CustomFieldDao;
|
||||||
|
import io.metersphere.dto.CustomFieldOption;
|
||||||
import io.metersphere.excel.annotation.NotRequired;
|
import io.metersphere.excel.annotation.NotRequired;
|
||||||
import io.metersphere.excel.domain.ExcelErrData;
|
import io.metersphere.excel.domain.ExcelErrData;
|
||||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||||
|
@ -207,10 +208,14 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||||
if (field.getRequired()) {
|
if (field.getRequired()) {
|
||||||
String value = null;
|
String value = null;
|
||||||
if (StringUtils.equals(customName, "status")) {
|
if (StringUtils.equals(customName, "status")) {
|
||||||
value = data.getStatus();
|
Map<String, String> valueMap = new HashMap<>() {{
|
||||||
if (!checkCaseStatus(value)) {
|
put("Prepare", Translator.get("test_case_status_prepare"));
|
||||||
stringBuilder.append(Translator.get("case_status_not_exist") + "; ");
|
put("Underway", Translator.get("test_case_status_running"));
|
||||||
}
|
put("Completed", Translator.get("test_case_status_finished"));
|
||||||
|
}};
|
||||||
|
value = getCustomFieldValue(Translator.get("test_case_status"), data.getStatus(), field.getOptions(),
|
||||||
|
stringBuilder, valueMap);
|
||||||
|
data.setStatus(value);
|
||||||
} else if (StringUtils.equals(customName, "priority")) {
|
} else if (StringUtils.equals(customName, "priority")) {
|
||||||
value = data.getPriority();
|
value = data.getPriority();
|
||||||
} else if (StringUtils.equals(customName, "maintainer")) {
|
} else if (StringUtils.equals(customName, "maintainer")) {
|
||||||
|
@ -313,6 +318,36 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据自定义字段的选项值获取对应的选项id
|
||||||
|
* @param name
|
||||||
|
* @param text
|
||||||
|
* @param optionsStr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCustomFieldValue(String name, String text, String optionsStr, StringBuilder error,
|
||||||
|
Map<String, String> systemValueMap) {
|
||||||
|
List<String> textList = new ArrayList<>();
|
||||||
|
if (StringUtils.isNotEmpty(optionsStr)) {
|
||||||
|
List<CustomFieldOption> options = JSONObject.parseArray(optionsStr, CustomFieldOption.class);
|
||||||
|
for (CustomFieldOption option : options) {
|
||||||
|
// 系统字段需要翻译
|
||||||
|
String i18nText = systemValueMap.get(option.getValue());
|
||||||
|
if (i18nText != null) {
|
||||||
|
option.setText(i18nText);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(option.getValue(), text) ||
|
||||||
|
// 系统字段填写对应内容,而不是key的情况,比如用例状态填未开始而不是 Prepare
|
||||||
|
StringUtils.equals(option.getText(), text)) {
|
||||||
|
return option.getValue();
|
||||||
|
}
|
||||||
|
textList.add(option.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error.append(String.format(Translator.get("custom_field_option_not_exist"), name, textList.toString()));
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getNames() {
|
public List<String> getNames() {
|
||||||
return this.names;
|
return this.names;
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,7 +730,6 @@ public class TestCaseService {
|
||||||
buildProjectInfoWidthoutProject(list);
|
buildProjectInfoWidthoutProject(list);
|
||||||
}
|
}
|
||||||
buildCustomField(list);
|
buildCustomField(list);
|
||||||
list = this.parseStatus(list);
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -780,7 +779,6 @@ public class TestCaseService {
|
||||||
ServiceUtils.buildVersionInfo(returnList);
|
ServiceUtils.buildVersionInfo(returnList);
|
||||||
ServiceUtils.buildProjectInfo(returnList);
|
ServiceUtils.buildProjectInfo(returnList);
|
||||||
buildUserInfo(returnList);
|
buildUserInfo(returnList);
|
||||||
returnList = this.parseStatus(returnList);
|
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,41 +789,6 @@ public class TestCaseService {
|
||||||
request.setOrders(orders);
|
request.setOrders(orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TestCaseDTO> parseStatus(List<TestCaseDTO> returnList) {
|
|
||||||
if (CollectionUtils.isNotEmpty(returnList)) {
|
|
||||||
TestCaseExcelData excelData = new TestCaseExcelDataFactory().getTestCaseExcelDataLocal();
|
|
||||||
List<String> testCaseIdList = new ArrayList<>();
|
|
||||||
returnList.forEach(item -> {
|
|
||||||
testCaseIdList.add(item.getId());
|
|
||||||
});
|
|
||||||
|
|
||||||
for (TestCaseDTO data : returnList) {
|
|
||||||
String dataStatus = excelData.parseStatus(data.getStatus());
|
|
||||||
if (StringUtils.equalsAnyIgnoreCase(data.getStatus(), "Trash")) {
|
|
||||||
try {
|
|
||||||
JSONArray arr = JSONArray.parseArray(data.getCustomFields());
|
|
||||||
JSONArray newArr = new JSONArray();
|
|
||||||
for (int i = 0; i < arr.size(); i++) {
|
|
||||||
JSONObject obj = arr.getJSONObject(i);
|
|
||||||
if (obj.containsKey("name") && obj.containsKey("value")) {
|
|
||||||
String name = obj.getString("name");
|
|
||||||
if (StringUtils.equalsAny(name, "用例状态", "用例狀態", "Case status")) {
|
|
||||||
obj.put("value", dataStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newArr.add(obj);
|
|
||||||
}
|
|
||||||
data.setCustomFields(newArr.toJSONString());
|
|
||||||
} catch (Exception e) {
|
|
||||||
LogUtil.error("Parse case exec status error:" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.setStatus(dataStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化部分参数
|
* 初始化部分参数
|
||||||
*
|
*
|
||||||
|
@ -1166,7 +1129,9 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
|
testCase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
|
||||||
|
if (StringUtils.isBlank(testCase.getStatus())) {
|
||||||
testCase.setStatus(TestCaseReviewStatus.Prepare.name());
|
testCase.setStatus(TestCaseReviewStatus.Prepare.name());
|
||||||
|
}
|
||||||
testCase.setOrder(Long.valueOf(testCases.size() - (num - beforeInsertId)) * ServiceUtils.ORDER_STEP);
|
testCase.setOrder(Long.valueOf(testCases.size() - (num - beforeInsertId)) * ServiceUtils.ORDER_STEP);
|
||||||
testCase.setRefId(testCase.getId());
|
testCase.setRefId(testCase.getId());
|
||||||
testCase.setVersionId(request.getVersionId());
|
testCase.setVersionId(request.getVersionId());
|
||||||
|
@ -1414,24 +1379,18 @@ public class TestCaseService {
|
||||||
|
|
||||||
public void testCaseExport(HttpServletResponse response, TestCaseBatchRequest request) {
|
public void testCaseExport(HttpServletResponse response, TestCaseBatchRequest request) {
|
||||||
try {
|
try {
|
||||||
// EasyExcelExporter easyExcelExporter = new EasyExcelExporter(new TestCaseExcelDataFactory().getExcelDataByLocal());
|
|
||||||
// List<TestCaseExcelData> datas = generateTestCaseExcel(request);
|
|
||||||
// easyExcelExporter.export(response,datas,Translator.get("test_case_import_template_name"), Translator.get("test_case_import_template_sheet"));
|
|
||||||
|
|
||||||
TestCaseExcelData testCaseExcelData = new TestCaseExcelDataFactory().getTestCaseExcelDataLocal();
|
TestCaseExcelData testCaseExcelData = new TestCaseExcelDataFactory().getTestCaseExcelDataLocal();
|
||||||
List<TestCaseExcelData> datas = generateTestCaseExcel(request);
|
|
||||||
boolean importFileNeedNum = true;
|
|
||||||
TestCaseTemplateService testCaseTemplateService = CommonBeanFactory.getBean(TestCaseTemplateService.class);
|
TestCaseTemplateService testCaseTemplateService = CommonBeanFactory.getBean(TestCaseTemplateService.class);
|
||||||
TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(request.getProjectId());
|
TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(request.getProjectId());
|
||||||
List<CustomFieldDao> customFields = Optional.ofNullable(testCaseTemplate.getCustomFields()).orElse(new ArrayList<>());
|
List<CustomFieldDao> customFields = Optional.ofNullable(testCaseTemplate.getCustomFields()).orElse(new ArrayList<>());
|
||||||
|
|
||||||
List<List<String>> headList = testCaseExcelData.getHead(importFileNeedNum, customFields);
|
List<List<String>> headList = testCaseExcelData.getHead(true, customFields);
|
||||||
List<List<Object>> testCaseDataByExcelList = this.generateTestCaseExcel(headList, datas);
|
List<List<Object>> testCaseDataByExcelList = this.generateTestCaseExcel(headList, generateTestCaseExcel(request));
|
||||||
EasyExcelExporter easyExcelExporter = new EasyExcelExporter(testCaseExcelData.getClass());
|
EasyExcelExporter easyExcelExporter = new EasyExcelExporter(testCaseExcelData.getClass());
|
||||||
easyExcelExporter.exportByCustomWriteHandler(response, headList, testCaseDataByExcelList,
|
easyExcelExporter.exportByCustomWriteHandler(response, headList, testCaseDataByExcelList,
|
||||||
Translator.get("test_case_import_template_name"), Translator.get("test_case_import_template_sheet"));
|
Translator.get("test_case_import_template_name"), Translator.get("test_case_import_template_sheet"));
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
MSException.throwException(e);
|
MSException.throwException(e);
|
||||||
|
@ -1572,8 +1531,8 @@ public class TestCaseService {
|
||||||
List<TestCaseDTO> testCaseList = this.getExportData(request);
|
List<TestCaseDTO> testCaseList = this.getExportData(request);
|
||||||
boolean isUseCustomId = projectService.useCustomNum(request.getProjectId());
|
boolean isUseCustomId = projectService.useCustomNum(request.getProjectId());
|
||||||
List<TestCaseExcelData> list = new ArrayList<>();
|
List<TestCaseExcelData> list = new ArrayList<>();
|
||||||
StringBuilder step = new StringBuilder("");
|
StringBuilder step = new StringBuilder();
|
||||||
StringBuilder result = new StringBuilder("");
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
Map<String, Map<String, String>> customSelectValueMap = new HashMap<>();
|
Map<String, Map<String, String>> customSelectValueMap = new HashMap<>();
|
||||||
Map<String, String> customNameMap = new HashMap<>();
|
Map<String, String> customNameMap = new HashMap<>();
|
||||||
|
@ -1617,6 +1576,7 @@ public class TestCaseService {
|
||||||
|
|
||||||
|
|
||||||
testCaseList.forEach(t -> {
|
testCaseList.forEach(t -> {
|
||||||
|
setExportSystemField(t, customNameMap, customSelectValueMap);
|
||||||
TestCaseExcelData data = new TestCaseExcelData();
|
TestCaseExcelData data = new TestCaseExcelData();
|
||||||
data.setNum(t.getNum());
|
data.setNum(t.getNum());
|
||||||
data.setName(t.getName());
|
data.setName(t.getName());
|
||||||
|
@ -1723,6 +1683,21 @@ public class TestCaseService {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExportSystemField(TestCaseDTO testCase, Map<String, String> customNameMap,
|
||||||
|
Map<String, Map<String, String>> customSelectValueMap) {
|
||||||
|
String statusKey = null;
|
||||||
|
for (String k : customNameMap.keySet()) {
|
||||||
|
String v = customNameMap.get(k);
|
||||||
|
if (StringUtils.equals(v, "用例状态")) {
|
||||||
|
statusKey = k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(statusKey)) {
|
||||||
|
Map<String, String> valueMap = customSelectValueMap.get(statusKey);
|
||||||
|
testCase.setStatus(valueMap.get(testCase.getStatus()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新自定义字段
|
* 更新自定义字段
|
||||||
*
|
*
|
||||||
|
|
|
@ -172,6 +172,7 @@ id_required=ID required
|
||||||
id_repeat_in_table=ID is repeat in table
|
id_repeat_in_table=ID is repeat in table
|
||||||
step_model_tip=Step description fill in STEP, text description please fill in TEXT (not required)
|
step_model_tip=Step description fill in STEP, text description please fill in TEXT (not required)
|
||||||
case_status_not_exist=The use case status must be Prepare, Underway way and Completed
|
case_status_not_exist=The use case status must be Prepare, Underway way and Completed
|
||||||
|
custom_field_option_not_exist=%s must be %s
|
||||||
issue_project_not_exist=ID does not exist or other errors
|
issue_project_not_exist=ID does not exist or other errors
|
||||||
tapd_project_not_exist=The associated TAPD item ID does not exist
|
tapd_project_not_exist=The associated TAPD item ID does not exist
|
||||||
zentao_get_project_builds_fail=Get Affecting Version Errors
|
zentao_get_project_builds_fail=Get Affecting Version Errors
|
||||||
|
|
|
@ -172,6 +172,7 @@ id_required=ID必填
|
||||||
id_repeat_in_table=表格内ID重复
|
id_repeat_in_table=表格内ID重复
|
||||||
step_model_tip=步骤描述填写 STEP,文本描述请填写 TEXT (非必填)
|
step_model_tip=步骤描述填写 STEP,文本描述请填写 TEXT (非必填)
|
||||||
case_status_not_exist=用例状态必须为未开始(Prepare)、进行中(Underway)、已完成(Completed)
|
case_status_not_exist=用例状态必须为未开始(Prepare)、进行中(Underway)、已完成(Completed)
|
||||||
|
custom_field_option_not_exist=%s必须为%s
|
||||||
issue_project_not_exist=ID不存在或其它错误
|
issue_project_not_exist=ID不存在或其它错误
|
||||||
tapd_project_not_exist=关联的TAPD项目ID不存在
|
tapd_project_not_exist=关联的TAPD项目ID不存在
|
||||||
zentao_get_project_builds_fail=获取影响版本错误
|
zentao_get_project_builds_fail=获取影响版本错误
|
||||||
|
|
|
@ -172,6 +172,7 @@ id_required=ID必填
|
||||||
id_repeat_in_table=表格內ID重復
|
id_repeat_in_table=表格內ID重復
|
||||||
step_model_tip=步驟描述填寫 STEP,文本描述請填寫 TEXT (非必填)
|
step_model_tip=步驟描述填寫 STEP,文本描述請填寫 TEXT (非必填)
|
||||||
case_status_not_exist=用例狀態必須為未開始(Prepare)、進行中(Underway)、已完成(Completed)
|
case_status_not_exist=用例狀態必須為未開始(Prepare)、進行中(Underway)、已完成(Completed)
|
||||||
|
custom_field_option_not_exist=%s必須為%s
|
||||||
issue_project_not_exist=ID不存在或其它錯誤
|
issue_project_not_exist=ID不存在或其它錯誤
|
||||||
tapd_project_not_exist=關聯的TAPD項目ID不存在
|
tapd_project_not_exist=關聯的TAPD項目ID不存在
|
||||||
zentao_get_project_builds_fail=獲取影響版本錯誤
|
zentao_get_project_builds_fail=獲取影響版本錯誤
|
||||||
|
|
|
@ -698,8 +698,6 @@ export default {
|
||||||
return row.priority;
|
return row.priority;
|
||||||
} else if (field.name === '责任人') {
|
} else if (field.name === '责任人') {
|
||||||
return row.maintainerName;
|
return row.maintainerName;
|
||||||
} else if (field.name === '用例状态') {
|
|
||||||
return row.status;
|
|
||||||
}
|
}
|
||||||
return value ? value : defaultVal;
|
return value ? value : defaultVal;
|
||||||
},
|
},
|
||||||
|
|
|
@ -448,6 +448,17 @@ export function saveCustomTableWidth(key, fieldKey, colWith) {
|
||||||
localStorage.setItem(key + '_WITH', JSON.stringify(fields));
|
localStorage.setItem(key + '_WITH', JSON.stringify(fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseStatus(row, options) {
|
||||||
|
if (options) {
|
||||||
|
for (let option of options) {
|
||||||
|
if (option.value === row.status) {
|
||||||
|
return option.system ? i18n.t(option.text) : option.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return row.status;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取列表的自定义字段的显示值
|
* 获取列表的自定义字段的显示值
|
||||||
* @param row
|
* @param row
|
||||||
|
@ -456,6 +467,9 @@ export function saveCustomTableWidth(key, fieldKey, colWith) {
|
||||||
* @returns {VueI18n.TranslateResult|*}
|
* @returns {VueI18n.TranslateResult|*}
|
||||||
*/
|
*/
|
||||||
export function getCustomFieldValue(row, field, members) {
|
export function getCustomFieldValue(row, field, members) {
|
||||||
|
if (field.name === '用例状态' && field.system) {
|
||||||
|
return parseStatus(row, field.options);
|
||||||
|
}
|
||||||
if (row.fields) {
|
if (row.fields) {
|
||||||
for (let i = 0; i < row.fields.length; i++) {
|
for (let i = 0; i < row.fields.length; i++) {
|
||||||
let item = row.fields[i];
|
let item = row.fields[i];
|
||||||
|
|
Loading…
Reference in New Issue