fix: 导入数据重复校验
This commit is contained in:
@@ -85,10 +85,9 @@ public class ImportUtil {
|
|||||||
|
|
||||||
public List<String> validExcelData(Sheet sheet, List<LawsTag> headerList, Map<String, File> fileMap, List<Map<String, Object>> insertDataList) {
|
public List<String> validExcelData(Sheet sheet, List<LawsTag> headerList, Map<String, File> fileMap, List<Map<String, Object>> insertDataList) {
|
||||||
List<String> errMsgList = new ArrayList<>();
|
List<String> errMsgList = new ArrayList<>();
|
||||||
|
Map<String, Integer> keyMap = new HashMap<>();
|
||||||
// 从数据行开始遍历
|
// 从数据行开始遍历
|
||||||
for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) {
|
for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) {
|
||||||
Map<String, Integer> keyMap = new HashMap<>();
|
|
||||||
int line = i + 1;
|
int line = i + 1;
|
||||||
String standardNumber = "";
|
String standardNumber = "";
|
||||||
String standardClass = "";
|
String standardClass = "";
|
||||||
@@ -168,6 +167,13 @@ public class ImportUtil {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
standardClass = this.convertDictValue("standard_type" , standardClass);
|
standardClass = this.convertDictValue("standard_type" , standardClass);
|
||||||
|
// 判断是否有重复数据
|
||||||
|
if (keyMap.containsKey(domesticStandardNumber)) {
|
||||||
|
errMsgList.add("第" + keyMap.get(domesticStandardNumber) + "行'标准编号'与第" + line + "行数据重复。");
|
||||||
|
} else {
|
||||||
|
// 5. 如果不存在,则将 GradeName 和其行号添加到 HashMap 中
|
||||||
|
keyMap.put(domesticStandardNumber, line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(tag.getIsModel()))) {
|
if ((TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(tag.getIsModel()))) {
|
||||||
@@ -188,6 +194,12 @@ public class ImportUtil {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
standardClass = this.convertDictValue("standard_type_overseas" , standardClass);
|
standardClass = this.convertDictValue("standard_type_overseas" , standardClass);
|
||||||
|
// 判断是否有重复数据
|
||||||
|
if (keyMap.containsKey(foreignStandardNumber)) {
|
||||||
|
errMsgList.add("第" + keyMap.get(foreignStandardNumber) + "行'标准编号'与第" + line + "行数据重复。");
|
||||||
|
} else {
|
||||||
|
keyMap.put(foreignStandardNumber, line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 将转好的值加入Map
|
// 将转好的值加入Map
|
||||||
|
|||||||
Reference in New Issue
Block a user