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,6 +256,9 @@ public interface UserMapper extends TkMapper<TUser> {
256 256
     //根据登录名查找用户集合
257 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 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,14 +495,25 @@ public class ClassStudentService {
495 495
             List<TUser> teachersExisted = new ArrayList<>();//已存在教师列表
496 496
             List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
497 497
             List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
498
+            List<TUser> userexamnoExisted = new ArrayList<>();//已存在准考证号
498 499
             List<TUser> delUsers = new ArrayList<>();//已删除学生列表
499 500
             List<TUser> updateUsers = new ArrayList<>();//要更新学生列表
500 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 503
             Map<String, TUser> userMap = userMapper.listByLoginNames(loginnames).stream()
502 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 510
             for (TUser user : students) {
504 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 517
                     user.setSchoolid(schoolid);
507 518
                     user.setCreateid(createid);
508 519
                     user.setCreatetime(N_Utils.getSecondTimestamp());
@@ -512,6 +523,10 @@ public class ClassStudentService {
512 523
                     user.setBindsecret(0);
513 524
                     user.setUserlock(0);
514 525
                     users.add(user);
526
+                } else if(null == u && uexamno != null){
527
+                    user.setLoginpwd("");
528
+                    userexamnoExisted.add(user);
529
+                    continue;
515 530
                 } else {
516 531
                     if (schoolid != u.getSchoolid()) {
517 532
                         usersExisted.add(u);
@@ -618,8 +633,9 @@ public class ClassStudentService {
618 633
             map.put("studentsExisted", studentsExisted);
619 634
             map.put("usersExisted", usersExisted);
620 635
             map.put("delUsers", delUsers);
636
+            map.put("userexamnoExisted", userexamnoExisted);
621 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 639
                 map.put("code", 1);
624 640
             } else {
625 641
                 map.put("code", 0);

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

@@ -291,6 +291,16 @@
291 291
             binary u.loginname=#{loginname}
292 292
         </foreach>
293 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 305
     <update id="batchUpdateUser">
296 306
         <foreach collection="users" item="u" separator="or">

Loading…
Cancel
Save