Browse Source

班级学生添加、修改、导入,添加准考证号

tags/正式版本
雍文秀 2 years ago
parent
commit
a0d20f3ccb

+ 6
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserMapper.java View File

252
 
252
 
253
     //批量更新用户状态
253
     //批量更新用户状态
254
     void batchUpdateUserState(@Param("userstate") Integer userstate, @Param("userids") List<Integer> userids);
254
     void batchUpdateUserState(@Param("userstate") Integer userstate, @Param("userids") List<Integer> userids);
255
+
256
+    //根据登录名查找用户集合
257
+    List<TUser> listByLoginNames(@Param("loginnames") List<String> loginnames);
258
+
259
+    //批量更新用户信息
260
+    void batchUpdateUser(@Param("users") List<TUser> users);
255
 }
261
 }

+ 4
- 0
suser/src/main/java/com/xhkjedu/suser/model/gradeclass/TClassStudent.java View File

33
     @Transient
33
     @Transient
34
     private String studentno;
34
     private String studentno;
35
 
35
 
36
+    @Transient
37
+    //准考证号
38
+    private String examno;
39
+
36
     //学生姓名
40
     //学生姓名
37
     @Transient
41
     @Transient
38
     private String studentname;
42
     private String studentname;

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/model/system/TUser.java View File

31
     //学生学号
31
     //学生学号
32
     private String studentno;
32
     private String studentno;
33
 
33
 
34
+    //准考证号
35
+    private String examno;
36
+
34
     //登录密码
37
     //登录密码
35
     private String loginpwd;
38
     private String loginpwd;
36
 
39
 

+ 46
- 4
suser/src/main/java/com/xhkjedu/suser/service/gradeclass/ClassStudentService.java View File

200
             if (!N_Utils.isEmpty(model.getStudentno())) {
200
             if (!N_Utils.isEmpty(model.getStudentno())) {
201
                 String headpic = model.getHeadpic();
201
                 String headpic = model.getHeadpic();
202
                 TUser user = userMapper.getObjByLoginName(model.getStudentno());
202
                 TUser user = userMapper.getObjByLoginName(model.getStudentno());
203
+                String examno = model.getExamno();
203
                 if (user == null) {//学生信息在用户表不存在,添加学生信息
204
                 if (user == null) {//学生信息在用户表不存在,添加学生信息
204
                     user = saveUser(model);//保存用户信息
205
                     user = saveUser(model);//保存用户信息
205
                 } else if (user.getUsertype() != 2) {
206
                 } else if (user.getUsertype() != 2) {
206
                     throw new Exception("禁止添加非学生账号");
207
                     throw new Exception("禁止添加非学生账号");
207
                 } else if (!schoolid.equals(user.getSchoolid())) {
208
                 } else if (!schoolid.equals(user.getSchoolid())) {
208
                     throw new Exception("禁止添加非本校学生账号");
209
                     throw new Exception("禁止添加非本校学生账号");
209
-                } else if (N_Utils.isNotEmpty(headpic) || 1 != user.getUserstate()) {
210
+                } else if (N_Utils.isNotEmpty(headpic) || 1 != user.getUserstate()
211
+                        || (N_Utils.isNotEmpty(examno) && !examno.equals(user.getExamno()))) {
210
                     TUser stu = new TUser();
212
                     TUser stu = new TUser();
213
+                    stu.setExamno(examno);
211
                     Integer userid = user.getUserid();
214
                     Integer userid = user.getUserid();
212
                     stu.setUserid(userid);
215
                     stu.setUserid(userid);
213
                     if (N_Utils.isNotEmpty(headpic)) {
216
                     if (N_Utils.isNotEmpty(headpic)) {
382
         user.setUsersex(model.getUsersex());
385
         user.setUsersex(model.getUsersex());
383
         user.setUsername(model.getStudentname());
386
         user.setUsername(model.getStudentname());
384
         user.setStudentno(model.getStudentno());
387
         user.setStudentno(model.getStudentno());
388
+        user.setExamno(model.getExamno());
385
         user.setLoginname(model.getStudentno());
389
         user.setLoginname(model.getStudentno());
386
         user.setUserphone(model.getUserphone());
390
         user.setUserphone(model.getUserphone());
387
         user.setUsertime(model.getUsertime());
391
         user.setUsertime(model.getUsertime());
431
             if (stunum.compareTo(lnum) != 0) {
435
             if (stunum.compareTo(lnum) != 0) {
432
                 return new ResultVo(1, "有重复的登录学号");
436
                 return new ResultVo(1, "有重复的登录学号");
433
             }
437
             }
438
+            List<String> elist = students.stream().filter(u -> N_Utils.isNotEmpty(u.getExamno())).map(TUser::getExamno).collect(Collectors.toList());
439
+            long examnum2 = elist.stream().distinct().count();
440
+            Integer examnum = elist.size();
441
+            if (examnum2 < examnum) {
442
+                return new ResultVo(1, "有重复的准考证号");
443
+            }
434
             Integer usernum = schoolMapper.getUserNumById(schoolid);
444
             Integer usernum = schoolMapper.getUserNumById(schoolid);
435
             if (usernum != null) {
445
             if (usernum != null) {
436
                 Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
446
                 Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
452
             List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
462
             List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
453
             List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
463
             List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
454
             List<TUser> delUsers = new ArrayList<>();//已删除学生列表
464
             List<TUser> delUsers = new ArrayList<>();//已删除学生列表
465
+            List<TUser> updateUsers = new ArrayList<>();//要更新学生列表
466
+            List<String> loginnames = students.stream().map(s -> s.getLoginname()).collect(Collectors.toList());
467
+            Map<String, TUser> userMap = userMapper.listByLoginNames(loginnames).stream()
468
+                    .collect(Collectors.toMap(u -> u.getLoginname(), u -> u));
455
             for (TUser user : students) {
469
             for (TUser user : students) {
456
-                TUser u = userMapper.getObjByLoginName(user.getLoginname());
470
+                TUser u = userMap.get(user.getLoginname());
457
                 if (null == u) {
471
                 if (null == u) {
458
                     user.setSchoolid(schoolid);
472
                     user.setSchoolid(schoolid);
459
                     user.setCreateid(createid);
473
                     user.setCreateid(createid);
516
                                 handleDelClassCourse2(delStudentList, changeCourseidList, courses2, studentid);//处理关联的直播课以及需要删除学生的直播班id
530
                                 handleDelClassCourse2(delStudentList, changeCourseidList, courses2, studentid);//处理关联的直播课以及需要删除学生的直播班id
517
                             }
531
                             }
518
                         }
532
                         }
533
+                        String examno = user.getExamno();
534
+                        if (N_Utils.isNotEmpty(examno) && !examno.equals(u.getExamno())) {
535
+                            user.setUserid(u.getUserid());
536
+                            updateUsers.add(user);
537
+                        }
519
                     }
538
                     }
520
                 }
539
                 }
521
             }
540
             }
522
 
541
 
542
+            if(N_Utils.isListNotEmpty(updateUsers)){
543
+                userMapper.batchUpdateUser(updateUsers);//批量更新用户信息
544
+            }
545
+
523
             //保存用户信息
546
             //保存用户信息
524
             if (!CollectionUtils.isEmpty(users)) {
547
             if (!CollectionUtils.isEmpty(users)) {
525
                 userMapper.insertList(users);
548
                 userMapper.insertList(users);
635
             if (stunum.compareTo(lnum) != 0) {
658
             if (stunum.compareTo(lnum) != 0) {
636
                 return new ResultVo(1, "有重复的登录学号");
659
                 return new ResultVo(1, "有重复的登录学号");
637
             }
660
             }
661
+            List<String> elist = students.stream().filter(u -> N_Utils.isNotEmpty(u.getExamno())).map(TUser::getExamno).collect(Collectors.toList());
662
+            long examnum2 = elist.stream().distinct().count();
663
+            Integer examnum = elist.size();
664
+            if (examnum2 < examnum) {
665
+                return new ResultVo(1, "有重复的准考证号");
666
+            }
638
             map.remove("users");//导入成功的学生信息不返回给前端
667
             map.remove("users");//导入成功的学生信息不返回给前端
639
 
668
 
640
             List<TClassStudent> classStudents = new ArrayList<>();
669
             List<TClassStudent> classStudents = new ArrayList<>();
644
             // 以下学生信息不存在
673
             // 以下学生信息不存在
645
             List<TUser> usersNotExisted = new ArrayList<>();
674
             List<TUser> usersNotExisted = new ArrayList<>();
646
             List<TUser> delUsers = new ArrayList<>();//已删除学生列表
675
             List<TUser> delUsers = new ArrayList<>();//已删除学生列表
676
+            List<TUser> updateUsers = new ArrayList<>();//要更新学生列表
677
+            List<String> loginnames = students.stream().map(s -> s.getLoginname()).collect(Collectors.toList());
678
+            Map<String, TUser> userMap = userMapper.listByLoginNames(loginnames).stream()
679
+                    .collect(Collectors.toMap(u -> u.getLoginname(), u -> u));
647
             for (TUser user : students) {
680
             for (TUser user : students) {
648
-                TUser u = userMapper.getObjByLoginName(user.getLoginname());
681
+                TUser u = userMap.get(user.getLoginname());
649
                 if (null == u) {
682
                 if (null == u) {
650
                     user.setSchoolid(schoolid);
683
                     user.setSchoolid(schoolid);
651
                     user.setCreateid(createid);
684
                     user.setCreateid(createid);
669
                             List<Map> courses = listCourseByClassId(courseMap, classid);
702
                             List<Map> courses = listCourseByClassId(courseMap, classid);
670
                             handleAddClassCourse(classStudents, groupStudents, changeCourseidList, courses, studentid);//处理班级加入学生中关联的直播课加入学生
703
                             handleAddClassCourse(classStudents, groupStudents, changeCourseidList, courses, studentid);//处理班级加入学生中关联的直播课加入学生
671
                         }
704
                         }
705
+                        String examno = user.getExamno();
706
+                        if (N_Utils.isNotEmpty(examno) && !examno.equals(u.getExamno())) {
707
+                            user.setUserid(u.getUserid());
708
+                            updateUsers.add(user);
709
+                        }
672
                     }
710
                     }
673
                 }
711
                 }
674
             }
712
             }
675
 
713
 
714
+            if(N_Utils.isListNotEmpty(updateUsers)){
715
+                userMapper.batchUpdateUser(updateUsers);//批量更新用户信息
716
+            }
717
+
676
             //保存学生关联信息
718
             //保存学生关联信息
677
             if (!CollectionUtils.isEmpty(classStudents)) {
719
             if (!CollectionUtils.isEmpty(classStudents)) {
678
                 classStudentMapper.saveBatchClassStudent(classStudents);
720
                 classStudentMapper.saveBatchClassStudent(classStudents);
830
     }
872
     }
831
 
873
 
832
     //处理要班级加入学生
874
     //处理要班级加入学生
833
-    private void moveClassHandleAddGroupStudent(List<TClassStudent> addClassStudentList,List<TGroupStudent> addGroupStudentList,ClassVo classVo,Integer studentid){
875
+    private void moveClassHandleAddGroupStudent(List<TClassStudent> addClassStudentList, List<TGroupStudent> addGroupStudentList, ClassVo classVo, Integer studentid) {
834
         Integer timestamp = N_Utils.getSecondTimestamp();
876
         Integer timestamp = N_Utils.getSecondTimestamp();
835
         //班级学生
877
         //班级学生
836
         TClassStudent cs = new TClassStudent();
878
         TClassStudent cs = new TClassStudent();

+ 2
- 0
suser/src/main/java/com/xhkjedu/suser/utils/PoiUtils.java View File

150
                                 throw new Exception("第" + (x + 1) + "行班级不存在");
150
                                 throw new Exception("第" + (x + 1) + "行班级不存在");
151
                             }
151
                             }
152
                         }
152
                         }
153
+                    } else if (y == 5) {//准考证号
154
+                        user.setExamno(getCellValue(cell));
153
                     }
155
                     }
154
                 }
156
                 }
155
 
157
 

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/vo/gradeclass/ClassStudentVo.java View File

10
     //学号
10
     //学号
11
     private String studentno;
11
     private String studentno;
12
 
12
 
13
+    //准考证号
14
+    private String examno;
15
+
13
     //学生姓名
16
     //学生姓名
14
     private String studentname;
17
     private String studentname;
15
 
18
 

+ 3
- 3
suser/src/main/resources/mapper/gradeclass/ClassStudentMapper.xml View File

4
     <!--班级学生列表-->
4
     <!--班级学生列表-->
5
     <select id="findAll" resultType="com.xhkjedu.suser.vo.gradeclass.ClassStudentVo">
5
     <select id="findAll" resultType="com.xhkjedu.suser.vo.gradeclass.ClassStudentVo">
6
         select cs.csid,cs.classid,c.classname,c.gradeid,u.username studentname,u.studentno,u.usersex,u.userid studentid,u.loginname,cs.createtime
6
         select cs.csid,cs.classid,c.classname,c.gradeid,u.username studentname,u.studentno,u.usersex,u.userid studentid,u.loginname,cs.createtime
7
-        ,u.bindmac,u.mac,u.headpic,u.usertime,u.userlock
7
+        ,u.bindmac,u.mac,u.headpic,u.usertime,u.userlock,u.examno
8
         ,(case when u.userphone='' then userphone else concat(left(u.userphone,3),'****',right(u.userphone,4)) end)userphone
8
         ,(case when u.userphone='' then userphone else concat(left(u.userphone,3),'****',right(u.userphone,4)) end)userphone
9
         from t_class_student cs left join t_user u on cs.studentid = u.userid
9
         from t_class_student cs left join t_user u on cs.studentid = u.userid
10
         left join t_class c on cs.classid=c.classid
10
         left join t_class c on cs.classid=c.classid
75
 
75
 
76
     <select id="listNoClassStu" resultType="com.xhkjedu.suser.vo.gradeclass.ClassStudentVo">
76
     <select id="listNoClassStu" resultType="com.xhkjedu.suser.vo.gradeclass.ClassStudentVo">
77
         select u.username studentname,u.studentno,u.usersex,u.userid studentid,u.loginname,u.createtime,
77
         select u.username studentname,u.studentno,u.usersex,u.userid studentid,u.loginname,u.createtime,
78
-        u.bindmac,u.mac,u.userstate,u.usertime,u.headpic,u.userlock
78
+        u.bindmac,u.mac,u.userstate,u.usertime,u.headpic,u.userlock,u.examno
79
         ,(case when u.userphone='' then userphone else concat(left(u.userphone,3),'****',right(u.userphone,4)) end)userphone
79
         ,(case when u.userphone='' then userphone else concat(left(u.userphone,3),'****',right(u.userphone,4)) end)userphone
80
         from t_user u left join
80
         from t_user u left join
81
         (select cs1.studentid,cs1.createtime from t_class_student cs1
81
         (select cs1.studentid,cs1.createtime from t_class_student cs1
105
     <!--获取全校学生-->
105
     <!--获取全校学生-->
106
     <select id="listAllStudents" resultType="com.xhkjedu.suser.vo.gradeclass.ClassStudentVo">
106
     <select id="listAllStudents" resultType="com.xhkjedu.suser.vo.gradeclass.ClassStudentVo">
107
         select u.username studentname,u.studentno,
107
         select u.username studentname,u.studentno,
108
-        u.usersex,u.userid studentid,u.loginname,cs.createtime,u.userlock,
108
+        u.usersex,u.userid studentid,u.loginname,cs.createtime,u.userlock,u.examno,
109
         u.bindmac,u.mac,u.headpic,u.usertime,c.gradeid,c.classname,c.classid
109
         u.bindmac,u.mac,u.headpic,u.usertime,c.gradeid,c.classname,c.classid
110
         ,(case when u.userphone='' then userphone else concat(left(u.userphone,3),'****',right(u.userphone,4)) end)userphone
110
         ,(case when u.userphone='' then userphone else concat(left(u.userphone,3),'****',right(u.userphone,4)) end)userphone
111
         from t_user u left join t_class_student cs on u.userid=cs.studentid
111
         from t_user u left join t_class_student cs on u.userid=cs.studentid

+ 16
- 1
suser/src/main/resources/mapper/system/UserMapper.xml View File

87
     </select>
87
     </select>
88
     <!--根据登录账号获取用户详情-->
88
     <!--根据登录账号获取用户详情-->
89
     <select id="getObjByLoginName" resultType="com.xhkjedu.suser.model.system.TUser">
89
     <select id="getObjByLoginName" resultType="com.xhkjedu.suser.model.system.TUser">
90
-        select u.userid,u.username,u.loginname,u.usersex,u.usertype,u.userstate,u.schoolid
90
+        select u.userid,u.username,u.loginname,u.examno,u.usersex,u.usertype,u.userstate,u.schoolid
91
         from t_user u where binary u.loginname=#{loginname} limit 1
91
         from t_user u where binary u.loginname=#{loginname} limit 1
92
     </select>
92
     </select>
93
     <!--修改用户状态-->
93
     <!--修改用户状态-->
283
         from t_cloud c,t_user u left join t_school s on u.schoolid = s.schoolid
283
         from t_cloud c,t_user u left join t_school s on u.schoolid = s.schoolid
284
         where u.userphone=#{userphone} limit 1
284
         where u.userphone=#{userphone} limit 1
285
     </select>
285
     </select>
286
+    <!--根据登录名查找用户集合-->
287
+    <select id="listByLoginNames" resultType="com.xhkjedu.suser.model.system.TUser">
288
+        select u.userid,u.username,u.loginname,u.examno,u.usersex,u.usertype,u.userstate,u.schoolid
289
+        from t_user u where
290
+        <foreach collection="loginnames" item="loginname" separator="or">
291
+            binary u.loginname=#{loginname}
292
+        </foreach>
293
+    </select>
294
+    <!--批量更新用户信息-->
295
+    <update id="batchUpdateUser">
296
+        <foreach collection="users" item="u" separator="or">
297
+            update t_user set username=#{u.username},examno=#{u.examno},usersex=#{u.usersex}
298
+            where userid=#{u.userid}
299
+        </foreach>
300
+    </update>
286
 </mapper>
301
 </mapper>

Loading…
Cancel
Save