|
@@ -1,18 +1,16 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentClassInfoDto;
|
|
|
import com.ym.mec.biz.dal.enums.FivePlusGradeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.GradeTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.SixPlusGradeEnum;
|
|
|
import com.ym.mec.common.page.QueryInfo;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -43,6 +41,9 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
@Autowired
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StudentRegistrationDao studentRegistrationDao;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Integer, Student> getDAO() {
|
|
|
return studentDao;
|
|
@@ -200,4 +201,36 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
}
|
|
|
return grade;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateStudentTeacherAndSubject() {
|
|
|
+ List<Student> noTeacherOrNoSubjectStudent = studentDao.getNoTeacherOrNoSubjectStudent();
|
|
|
+ if(CollectionUtils.isEmpty(noTeacherOrNoSubjectStudent)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Integer> studentIds = noTeacherOrNoSubjectStudent.stream().map(Student::getUserId).collect(Collectors.toList());
|
|
|
+ List<StudentClassInfoDto> studentClassInfo = studentRegistrationDao.getStudentClassInfo(studentIds);
|
|
|
+ if(CollectionUtils.isEmpty(studentClassInfo)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Student> needUpdateStudents = new ArrayList<>();
|
|
|
+ Map<Integer, List<StudentClassInfoDto>> scm = studentClassInfo.stream().collect(Collectors.groupingBy(StudentClassInfoDto::getStudentId));
|
|
|
+ for (Student student : noTeacherOrNoSubjectStudent) {
|
|
|
+ if(!scm.containsKey(student.getUserId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<StudentClassInfoDto> studentClassInfoDtos = scm.get(student.getUserId());
|
|
|
+ StudentClassInfoDto studentClassInfoDto = studentClassInfoDtos.stream().max(Comparator.comparing(StudentClassInfoDto::getClassGroupId)).get();
|
|
|
+ if(Objects.isNull(student.getTeacherId())){
|
|
|
+ student.setTeacherId(studentClassInfoDto.getMainTeacherId());
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(student.getSubjectIdList())){
|
|
|
+ student.setSubjectIdList(studentClassInfoDto.getSubjectId().toString());
|
|
|
+ }
|
|
|
+ needUpdateStudents.add(student);
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(needUpdateStudents)){
|
|
|
+ studentDao.batchUpdate(needUpdateStudents);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|