Browse Source

导入学生时判断准考证号重复

tags/正式版本
王宁 2 years ago
parent
commit
38db62dfe2

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

256
     //根据登录名查找用户集合
256
     //根据登录名查找用户集合
257
     List<TUser> listByLoginNames(@Param("loginnames") List<String> loginnames);
257
     List<TUser> listByLoginNames(@Param("loginnames") List<String> loginnames);
258
 
258
 
259
+    //根据准考证号查找用户集合
260
+    List<TUser> listByExamnos(@Param("examnos") List<String> examnos);
261
+
259
     //批量更新用户信息
262
     //批量更新用户信息
260
     void batchUpdateUser(@Param("users") List<TUser> users);
263
     void batchUpdateUser(@Param("users") List<TUser> users);
261
 
264
 

+ 18
- 2
suser/src/main/java/com/xhkjedu/suser/service/gradeclass/ClassStudentService.java View File

495
             List<TUser> teachersExisted = new ArrayList<>();//已存在教师列表
495
             List<TUser> teachersExisted = new ArrayList<>();//已存在教师列表
496
             List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
496
             List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
497
             List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
497
             List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
498
+            List<TUser> userexamnoExisted = new ArrayList<>();//已存在准考证号
498
             List<TUser> delUsers = new ArrayList<>();//已删除学生列表
499
             List<TUser> delUsers = new ArrayList<>();//已删除学生列表
499
             List<TUser> updateUsers = new ArrayList<>();//要更新学生列表
500
             List<TUser> updateUsers = new ArrayList<>();//要更新学生列表
500
             List<String> loginnames = students.stream().map(s -> s.getLoginname()).collect(Collectors.toList());
501
             List<String> loginnames = students.stream().map(s -> s.getLoginname()).collect(Collectors.toList());
502
+            List<String> examnos = students.stream().filter(s -> N_Utils.isNotEmpty(s.getExamno())).map(s -> s.getExamno()).collect(Collectors.toList());
501
             Map<String, TUser> userMap = userMapper.listByLoginNames(loginnames).stream()
503
             Map<String, TUser> userMap = userMapper.listByLoginNames(loginnames).stream()
502
                     .collect(Collectors.toMap(u -> u.getLoginname(), u -> u));
504
                     .collect(Collectors.toMap(u -> u.getLoginname(), u -> u));
505
+            Map<String,TUser> userexamnoMap = null;
506
+            if(N_Utils.isListNotEmpty(examnos)){
507
+                userexamnoMap = userMapper.listByExamnos(examnos).stream().collect(Collectors.toMap(u -> u.getExamno(), u -> u));
508
+            }
509
+
503
             for (TUser user : students) {
510
             for (TUser user : students) {
504
                 TUser u = userMap.get(user.getLoginname());
511
                 TUser u = userMap.get(user.getLoginname());
505
-                if (null == u) {
512
+                TUser uexamno = null;
513
+                if(N_Utils.isNotEmpty(user.getExamno()) && userexamnoMap!=null){
514
+                    uexamno = userexamnoMap.get(user.getExamno());
515
+                }
516
+                if (null == u && uexamno == null) {
506
                     user.setSchoolid(schoolid);
517
                     user.setSchoolid(schoolid);
507
                     user.setCreateid(createid);
518
                     user.setCreateid(createid);
508
                     user.setCreatetime(N_Utils.getSecondTimestamp());
519
                     user.setCreatetime(N_Utils.getSecondTimestamp());
512
                     user.setBindsecret(0);
523
                     user.setBindsecret(0);
513
                     user.setUserlock(0);
524
                     user.setUserlock(0);
514
                     users.add(user);
525
                     users.add(user);
526
+                } else if(null == u && uexamno != null){
527
+                    user.setLoginpwd("");
528
+                    userexamnoExisted.add(user);
529
+                    continue;
515
                 } else {
530
                 } else {
516
                     if (schoolid != u.getSchoolid()) {
531
                     if (schoolid != u.getSchoolid()) {
517
                         usersExisted.add(u);
532
                         usersExisted.add(u);
618
             map.put("studentsExisted", studentsExisted);
633
             map.put("studentsExisted", studentsExisted);
619
             map.put("usersExisted", usersExisted);
634
             map.put("usersExisted", usersExisted);
620
             map.put("delUsers", delUsers);
635
             map.put("delUsers", delUsers);
636
+            map.put("userexamnoExisted", userexamnoExisted);
621
             if (N_Utils.isListNotEmpty(teachersExisted) || N_Utils.isListNotEmpty(studentsExisted)
637
             if (N_Utils.isListNotEmpty(teachersExisted) || N_Utils.isListNotEmpty(studentsExisted)
622
-                    || N_Utils.isListNotEmpty(usersExisted) || N_Utils.isListNotEmpty(delUsers)) {
638
+                    || N_Utils.isListNotEmpty(usersExisted) || N_Utils.isListNotEmpty(delUsers) || N_Utils.isListNotEmpty(userexamnoExisted)) {
623
                 map.put("code", 1);
639
                 map.put("code", 1);
624
             } else {
640
             } else {
625
                 map.put("code", 0);
641
                 map.put("code", 0);

+ 10
- 0
suser/src/main/resources/mapper/system/UserMapper.xml View File

291
             binary u.loginname=#{loginname}
291
             binary u.loginname=#{loginname}
292
         </foreach>
292
         </foreach>
293
     </select>
293
     </select>
294
+    <!--根据准考证号查找用户集合-->
295
+    <select id="listByExamnos" resultType="com.xhkjedu.suser.model.system.TUser">
296
+        select u.userid,u.username,u.loginname,u.examno,u.usersex,u.usertype,u.userstate,u.schoolid
297
+        from t_user u where
298
+        <foreach collection="examnos" item="examno" separator="or">
299
+            <if test="examno!=null and examno!=''">
300
+                binary u.examno=#{examno}
301
+            </if>
302
+        </foreach>
303
+    </select>
294
     <!--批量更新用户信息-->
304
     <!--批量更新用户信息-->
295
     <update id="batchUpdateUser">
305
     <update id="batchUpdateUser">
296
         <foreach collection="users" item="u" separator="or">
306
         <foreach collection="users" item="u" separator="or">

Loading…
Cancel
Save