Ver Fonte

Merge remote-tracking branch 'origin/dev_v3.2.2' into dev_v3.2.2

wangliang há 2 anos atrás
pai
commit
bc53d48550

+ 24 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicStudentServiceImpl.java

@@ -334,8 +334,10 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
      * @return 结果
      */
     private List<BasicStudent> editEntityHelp(List<BasicStudentParams> basicStudentParamsList, SysUser sysUser) {
+
         Long schoolId = sysUser.getSchoolId();
         List<BasicStudent> editEntityList = new ArrayList<>();
+        Map<String, BasicStudentParams> checkRepeatMap = new HashMap<>();
         for (BasicStudentParams basicStudentParams : basicStudentParamsList) {
             // 普通参数
             String studentName = basicStudentParams.getStudentName();
@@ -344,6 +346,28 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
             Long clazzId = basicStudentParams.getClazzId();
             Long majorId = basicStudentParams.getMajorId();
             Long collegeId = basicStudentParams.getCollegeId();
+            if (checkRepeatMap.containsKey(studentCode)) {
+                // 校验整个导入批次是否有重复数据
+                BasicStudentParams check = checkRepeatMap.get(studentCode);
+                if (!Objects.equals(studentName, check.getStudentName())) {
+                    throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同姓名");
+                }
+                if (!Objects.equals(phoneNumber, check.getPhoneNumber())) {
+                    throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同电话");
+                }
+                if (!Objects.equals(clazzId, check.getClazzId())) {
+                    throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同班级");
+                }
+                if (!Objects.equals(majorId, check.getMajorId())) {
+                    throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同专业");
+                }
+                if (!Objects.equals(collegeId, check.getCollegeId())) {
+                    throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同学院");
+                }
+                continue;
+            } else {
+                checkRepeatMap.put(studentCode, basicStudentParams);
+            }
 
             // 班级验证
             if (SystemConstant.longNotNull(clazzId)) {