mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 04:28:51 +08:00
fix(测试跟踪): 功能用例导入合并单元格中存在空行,导入错乱
--bug=1015965 --user=陈建星 【测试跟踪】导入功能用例,导入后的步骤描述信息和导入前不一致 https://www.tapd.cn/55049933/s/1228606
This commit is contained in:
parent
7b3701482b
commit
e57f96a017
@ -39,8 +39,6 @@ import java.util.*;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static io.metersphere.xpack.ui.constants.ArgTypeEnum.testCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 由于功能案例中含有自定义字段。导入的时候使用无模板对象的读取方式
|
* 由于功能案例中含有自定义字段。导入的时候使用无模板对象的读取方式
|
||||||
*
|
*
|
||||||
@ -158,7 +156,11 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||||||
}});
|
}});
|
||||||
// 记录下数据并返回
|
// 记录下数据并返回
|
||||||
this.currentMergeData = testCaseExcelData;
|
this.currentMergeData = testCaseExcelData;
|
||||||
return;
|
if (!this.isMergeLastRow) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.currentMergeData = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 获取存储的数据,并添加多个步骤
|
// 获取存储的数据,并添加多个步骤
|
||||||
this.currentMergeData.getMergeStepDesc()
|
this.currentMergeData.getMergeStepDesc()
|
||||||
@ -246,18 +248,17 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||||||
if (StringUtils.isNotBlank(cellData)) {
|
if (StringUtils.isNotBlank(cellData)) {
|
||||||
data.put(col, cellData);
|
data.put(col, cellData);
|
||||||
}
|
}
|
||||||
// 如果合并单元格的最后一个单元格,标记下
|
}
|
||||||
if (rowIndex == mergeInfo.getLastRowIndex()) {
|
// 如果合并单元格的最后一个单元格,标记下
|
||||||
// 根据名称列是否是合并单元格判断是不是同一条用例
|
if (rowIndex == mergeInfo.getLastRowIndex()) {
|
||||||
if (getNameColIndex().equals(col)) {
|
// 根据名称列是否是合并单元格判断是不是同一条用例
|
||||||
this.isMergeLastRow = true;
|
if (getNameColIndex().equals(col)) {
|
||||||
}
|
this.isMergeLastRow = true;
|
||||||
|
// 清除掉上一次已经遍历完成的数据,提高查询效率
|
||||||
|
iterator.remove();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (rowIndex > mergeInfo.getLastRowIndex()) {
|
|
||||||
// TreeSet 按照行号排序了
|
|
||||||
// 清除掉上一次已经遍历完成的数据,提高查询效率
|
|
||||||
iterator.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -404,11 +405,11 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
|||||||
// 这里如果填的是选项值,替换成选项ID,保存
|
// 这里如果填的是选项值,替换成选项ID,保存
|
||||||
customData.put(fieldName, customFieldValidator.parse2Key(value, customField));
|
customData.put(fieldName, customFieldValidator.parse2Key(value, customField));
|
||||||
}
|
}
|
||||||
if (StringUtils.equals(fieldName, TestCaseImportFiled.STATUS.getValue())) {
|
if (StringUtils.equals(fieldName, TestCaseImportFiled.STATUS.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) {
|
||||||
data.setStatus(value);
|
data.setStatus(value);
|
||||||
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.PRIORITY.getValue())) {
|
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.PRIORITY.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) {
|
||||||
data.setPriority(value);
|
data.setPriority(value);
|
||||||
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.MAINTAINER.getValue())) {
|
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.MAINTAINER.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) {
|
||||||
data.setMaintainer(value);
|
data.setMaintainer(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import com.alibaba.excel.metadata.CellExtra;
|
|||||||
import io.metersphere.commons.utils.BeanUtils;
|
import io.metersphere.commons.utils.BeanUtils;
|
||||||
import io.metersphere.excel.domain.ExcelMergeInfo;
|
import io.metersphere.excel.domain.ExcelMergeInfo;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,15 +16,25 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class TestCasePretreatmentListener extends AnalysisEventListener {
|
public class TestCasePretreatmentListener extends AnalysisEventListener {
|
||||||
|
|
||||||
|
|
||||||
Set<ExcelMergeInfo> mergeInfoSet;
|
Set<ExcelMergeInfo> mergeInfoSet;
|
||||||
|
private Integer lastRowIndex = 0;
|
||||||
|
Map<Integer, Integer> emptyRowIndexMap = new HashMap<>();
|
||||||
|
|
||||||
public TestCasePretreatmentListener(Set<ExcelMergeInfo> mergeInfoSet) {
|
public TestCasePretreatmentListener(Set<ExcelMergeInfo> mergeInfoSet) {
|
||||||
this.mergeInfoSet = mergeInfoSet;
|
this.mergeInfoSet = mergeInfoSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(Object integerStringMap, AnalysisContext analysisContext) {}
|
public void invoke(Object integerStringMap, AnalysisContext analysisContext) {
|
||||||
|
Integer rowIndex = analysisContext.readRowHolder().getRowIndex();
|
||||||
|
if (rowIndex - lastRowIndex > 1) {
|
||||||
|
// 记录空行的行号
|
||||||
|
for (int i = lastRowIndex + 1; i < rowIndex; i++) {
|
||||||
|
emptyRowIndexMap.put(i, lastRowIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.lastRowIndex = rowIndex;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extra(CellExtra extra, AnalysisContext context) {
|
public void extra(CellExtra extra, AnalysisContext context) {
|
||||||
@ -30,6 +42,10 @@ public class TestCasePretreatmentListener extends AnalysisEventListener {
|
|||||||
// 将合并单元格信息保留
|
// 将合并单元格信息保留
|
||||||
ExcelMergeInfo mergeInfo = new ExcelMergeInfo();
|
ExcelMergeInfo mergeInfo = new ExcelMergeInfo();
|
||||||
BeanUtils.copyBean(mergeInfo, extra);
|
BeanUtils.copyBean(mergeInfo, extra);
|
||||||
|
if (emptyRowIndexMap.keySet().contains(mergeInfo.getLastRowIndex())) {
|
||||||
|
// 如果合并单元格的最后一行是空行,则将最后一行设置成非空的行
|
||||||
|
mergeInfo.setLastRowIndex(emptyRowIndexMap.get(mergeInfo.getLastRowIndex()));
|
||||||
|
}
|
||||||
this.mergeInfoSet.add(mergeInfo);
|
this.mergeInfoSet.add(mergeInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user