mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-01 11:38:57 +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.Stream;
|
||||
|
||||
import static io.metersphere.xpack.ui.constants.ArgTypeEnum.testCase;
|
||||
|
||||
/**
|
||||
* 由于功能案例中含有自定义字段。导入的时候使用无模板对象的读取方式
|
||||
*
|
||||
@ -158,7 +156,11 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||
}});
|
||||
// 记录下数据并返回
|
||||
this.currentMergeData = testCaseExcelData;
|
||||
return;
|
||||
if (!this.isMergeLastRow) {
|
||||
return;
|
||||
} else {
|
||||
this.currentMergeData = null;
|
||||
}
|
||||
} else {
|
||||
// 获取存储的数据,并添加多个步骤
|
||||
this.currentMergeData.getMergeStepDesc()
|
||||
@ -246,18 +248,17 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||
if (StringUtils.isNotBlank(cellData)) {
|
||||
data.put(col, cellData);
|
||||
}
|
||||
// 如果合并单元格的最后一个单元格,标记下
|
||||
if (rowIndex == mergeInfo.getLastRowIndex()) {
|
||||
// 根据名称列是否是合并单元格判断是不是同一条用例
|
||||
if (getNameColIndex().equals(col)) {
|
||||
this.isMergeLastRow = true;
|
||||
}
|
||||
}
|
||||
// 如果合并单元格的最后一个单元格,标记下
|
||||
if (rowIndex == mergeInfo.getLastRowIndex()) {
|
||||
// 根据名称列是否是合并单元格判断是不是同一条用例
|
||||
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,保存
|
||||
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);
|
||||
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.PRIORITY.getValue())) {
|
||||
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.PRIORITY.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import com.alibaba.excel.metadata.CellExtra;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.excel.domain.ExcelMergeInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -14,15 +16,25 @@ import java.util.Set;
|
||||
*/
|
||||
public class TestCasePretreatmentListener extends AnalysisEventListener {
|
||||
|
||||
|
||||
Set<ExcelMergeInfo> mergeInfoSet;
|
||||
private Integer lastRowIndex = 0;
|
||||
Map<Integer, Integer> emptyRowIndexMap = new HashMap<>();
|
||||
|
||||
public TestCasePretreatmentListener(Set<ExcelMergeInfo> mergeInfoSet) {
|
||||
this.mergeInfoSet = mergeInfoSet;
|
||||
}
|
||||
|
||||
@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
|
||||
public void extra(CellExtra extra, AnalysisContext context) {
|
||||
@ -30,6 +42,10 @@ public class TestCasePretreatmentListener extends AnalysisEventListener {
|
||||
// 将合并单元格信息保留
|
||||
ExcelMergeInfo mergeInfo = new ExcelMergeInfo();
|
||||
BeanUtils.copyBean(mergeInfo, extra);
|
||||
if (emptyRowIndexMap.keySet().contains(mergeInfo.getLastRowIndex())) {
|
||||
// 如果合并单元格的最后一行是空行,则将最后一行设置成非空的行
|
||||
mergeInfo.setLastRowIndex(emptyRowIndexMap.get(mergeInfo.getLastRowIndex()));
|
||||
}
|
||||
this.mergeInfoSet.add(mergeInfo);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user