Commit 81da93ca authored by Ryan Loong's avatar Ryan Loong

update 通过excel导入的时候增加对重复学号的校验

parent 2e15b0eb
...@@ -249,6 +249,12 @@ public class StudentInfoService { ...@@ -249,6 +249,12 @@ public class StudentInfoService {
Map<String, StudentInfo> existStudent = selectStudentInfoByUniqueId(importVoList.stream().map(StudentInfoExcelImportVo::getStudentUid).filter(org.apache.commons.lang3.StringUtils::isNotBlank).collect(Collectors.toSet())) Map<String, StudentInfo> existStudent = selectStudentInfoByUniqueId(importVoList.stream().map(StudentInfoExcelImportVo::getStudentUid).filter(org.apache.commons.lang3.StringUtils::isNotBlank).collect(Collectors.toSet()))
.stream().collect(Collectors.toMap(StudentInfo::getStudentUniqueId, x -> x, (k1, k2) -> k1)); .stream().collect(Collectors.toMap(StudentInfo::getStudentUniqueId, x -> x, (k1, k2) -> k1));
Set<String> duplicateStudentUid = importVoList.stream()
.map(StudentInfoExcelImportVo::getStudentUid)
.filter(org.apache.commons.lang3.StringUtils::isNotBlank)
.collect(Collectors.groupingBy(String::trim, Collectors.counting()))
.entrySet().stream().filter(entry -> entry.getValue() > 1).map(Map.Entry::getKey).collect(Collectors.toSet());
Map<Integer, String> classNameMap = classService.listAll().stream().collect(Collectors.toMap(ClassInfo::getId, ClassInfo::getClassName)); Map<Integer, String> classNameMap = classService.listAll().stream().collect(Collectors.toMap(ClassInfo::getId, ClassInfo::getClassName));
return importVoList.stream().map(vo -> { return importVoList.stream().map(vo -> {
...@@ -256,6 +262,8 @@ public class StudentInfoService { ...@@ -256,6 +262,8 @@ public class StudentInfoService {
if (org.apache.commons.lang3.StringUtils.isBlank(vo.getStudentUid())) { if (org.apache.commons.lang3.StringUtils.isBlank(vo.getStudentUid())) {
err.add("学号不能为空"); err.add("学号不能为空");
} else if (duplicateStudentUid.contains(vo.getStudentUid().trim())) {
err.add("学号不能重复");
} }
if (org.apache.commons.lang3.StringUtils.isBlank(vo.getName())) { if (org.apache.commons.lang3.StringUtils.isBlank(vo.getName())) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment