|
@@ -21,6 +21,7 @@ import java.io.File;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@@ -37,6 +38,10 @@ public class TeacherImportAnalysis extends DataAnalysis<TeacherImportAnalysis> {
|
|
|
private final Map<String, TeacherImportWrapper.TeacherImport> recordMap = Maps.newHashMap();
|
|
|
private final Map<String, Long> subjectMap = Maps.newHashMap();
|
|
|
private final Map<String, Long> tenantMap = Maps.newHashMap();
|
|
|
+ private final List<String> phones = Lists.newArrayList();
|
|
|
+ private final List<String> idCardNos = Lists.newArrayList();
|
|
|
+ private final List<String> existPhones = Lists.newArrayList();
|
|
|
+ private final List<String> existIdCardNos = Lists.newArrayList();
|
|
|
public TeacherImportAnalysis(AnalysisContext context) {
|
|
|
super(context);
|
|
|
}
|
|
@@ -110,12 +115,32 @@ public class TeacherImportAnalysis extends DataAnalysis<TeacherImportAnalysis> {
|
|
|
//手机号校验
|
|
|
if (!item.getPhone().matches("^1[3-9]\\d{9}$")) {
|
|
|
ret.append("手机号格式不正确;");
|
|
|
+ }else {
|
|
|
+ //校验是否重复
|
|
|
+ if(phones.contains(item.getPhone())){
|
|
|
+ ret.append("手机号重复;");
|
|
|
+ }else {
|
|
|
+ if(existPhones.contains(item.getPhone())){
|
|
|
+ ret.append("手机号已存在;");
|
|
|
+ }
|
|
|
+ phones.add(item.getPhone());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(item.getIdCardNo())) {
|
|
|
//身份证校验
|
|
|
if (!item.getIdCardNo().matches("(^\\d{6}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}(\\d|X|x)$)|(^\\d{6}\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}$)")) {
|
|
|
ret.append("身份证格式不正确;");
|
|
|
+ }else {
|
|
|
+ //校验是否重复
|
|
|
+ if(idCardNos.contains(item.getIdCardNo())){
|
|
|
+ ret.append("身份证号重复;");
|
|
|
+ }else {
|
|
|
+ if(existIdCardNos.contains(item.getIdCardNo())){
|
|
|
+ ret.append("身份证号已存在;");
|
|
|
+ }
|
|
|
+ idCardNos.add(item.getIdCardNo());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isEmpty(item.getSubjectName())) {
|
|
@@ -159,9 +184,23 @@ public class TeacherImportAnalysis extends DataAnalysis<TeacherImportAnalysis> {
|
|
|
* 加载校验数据参数
|
|
|
*/
|
|
|
private void loadVerifyParamData() {
|
|
|
- //校验数据
|
|
|
- //获取所有手机号
|
|
|
-
|
|
|
+ //获取所有的手机号和身份证号
|
|
|
+ List<String> phones = getTeacherImportWrappers().stream()
|
|
|
+ .map(TeacherImportWrapper.TeacherImport::getPhone)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(phones)) {
|
|
|
+ existPhones.addAll(easyExcelService.getPhones(phones));
|
|
|
+ }
|
|
|
+ List<String> idCardNos = getTeacherImportWrappers().stream()
|
|
|
+ .map(TeacherImportWrapper.TeacherImport::getIdCardNo)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(idCardNos)) {
|
|
|
+ existIdCardNos.addAll(easyExcelService.getIdCardNos(idCardNos));
|
|
|
+ }
|
|
|
subjectMap.putAll(easyExcelService.getSubjectMap());
|
|
|
tenantMap.putAll(easyExcelService.getTenantMap());
|
|
|
}
|