|
@@ -200,14 +200,17 @@ public class ClassStudentService {
|
200
|
200
|
if (!N_Utils.isEmpty(model.getStudentno())) {
|
201
|
201
|
String headpic = model.getHeadpic();
|
202
|
202
|
TUser user = userMapper.getObjByLoginName(model.getStudentno());
|
|
203
|
+ String examno = model.getExamno();
|
203
|
204
|
if (user == null) {//学生信息在用户表不存在,添加学生信息
|
204
|
205
|
user = saveUser(model);//保存用户信息
|
205
|
206
|
} else if (user.getUsertype() != 2) {
|
206
|
207
|
throw new Exception("禁止添加非学生账号");
|
207
|
208
|
} else if (!schoolid.equals(user.getSchoolid())) {
|
208
|
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
|
212
|
TUser stu = new TUser();
|
|
213
|
+ stu.setExamno(examno);
|
211
|
214
|
Integer userid = user.getUserid();
|
212
|
215
|
stu.setUserid(userid);
|
213
|
216
|
if (N_Utils.isNotEmpty(headpic)) {
|
|
@@ -382,6 +385,7 @@ public class ClassStudentService {
|
382
|
385
|
user.setUsersex(model.getUsersex());
|
383
|
386
|
user.setUsername(model.getStudentname());
|
384
|
387
|
user.setStudentno(model.getStudentno());
|
|
388
|
+ user.setExamno(model.getExamno());
|
385
|
389
|
user.setLoginname(model.getStudentno());
|
386
|
390
|
user.setUserphone(model.getUserphone());
|
387
|
391
|
user.setUsertime(model.getUsertime());
|
|
@@ -431,6 +435,12 @@ public class ClassStudentService {
|
431
|
435
|
if (stunum.compareTo(lnum) != 0) {
|
432
|
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
|
444
|
Integer usernum = schoolMapper.getUserNumById(schoolid);
|
435
|
445
|
if (usernum != null) {
|
436
|
446
|
Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
|
|
@@ -452,8 +462,12 @@ public class ClassStudentService {
|
452
|
462
|
List<TUser> studentsExisted = new ArrayList<>();//已存在学生列表
|
453
|
463
|
List<TUser> usersExisted = new ArrayList<>();//已存在非本校账号列表
|
454
|
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
|
469
|
for (TUser user : students) {
|
456
|
|
- TUser u = userMapper.getObjByLoginName(user.getLoginname());
|
|
470
|
+ TUser u = userMap.get(user.getLoginname());
|
457
|
471
|
if (null == u) {
|
458
|
472
|
user.setSchoolid(schoolid);
|
459
|
473
|
user.setCreateid(createid);
|
|
@@ -516,10 +530,19 @@ public class ClassStudentService {
|
516
|
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
|
547
|
if (!CollectionUtils.isEmpty(users)) {
|
525
|
548
|
userMapper.insertList(users);
|
|
@@ -635,6 +658,12 @@ public class ClassStudentService {
|
635
|
658
|
if (stunum.compareTo(lnum) != 0) {
|
636
|
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
|
667
|
map.remove("users");//导入成功的学生信息不返回给前端
|
639
|
668
|
|
640
|
669
|
List<TClassStudent> classStudents = new ArrayList<>();
|
|
@@ -644,8 +673,12 @@ public class ClassStudentService {
|
644
|
673
|
// 以下学生信息不存在
|
645
|
674
|
List<TUser> usersNotExisted = new ArrayList<>();
|
646
|
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
|
680
|
for (TUser user : students) {
|
648
|
|
- TUser u = userMapper.getObjByLoginName(user.getLoginname());
|
|
681
|
+ TUser u = userMap.get(user.getLoginname());
|
649
|
682
|
if (null == u) {
|
650
|
683
|
user.setSchoolid(schoolid);
|
651
|
684
|
user.setCreateid(createid);
|
|
@@ -669,10 +702,19 @@ public class ClassStudentService {
|
669
|
702
|
List<Map> courses = listCourseByClassId(courseMap, classid);
|
670
|
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
|
719
|
if (!CollectionUtils.isEmpty(classStudents)) {
|
678
|
720
|
classStudentMapper.saveBatchClassStudent(classStudents);
|
|
@@ -830,7 +872,7 @@ public class ClassStudentService {
|
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
|
876
|
Integer timestamp = N_Utils.getSecondTimestamp();
|
835
|
877
|
//班级学生
|
836
|
878
|
TClassStudent cs = new TClassStudent();
|