|
@@ -1,21 +1,10 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
import com.ym.mec.biz.dal.dto.StudentCourseTimesDto;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentTeacherCourseDto;
|
|
|
+import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
|
import com.ym.mec.biz.dal.entity.Student;
|
|
|
import com.ym.mec.biz.dal.page.StudentQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentService;
|
|
@@ -23,6 +12,15 @@ import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implements StudentService {
|
|
@@ -98,4 +96,55 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initTeacherId() {
|
|
|
+ List<StudentTeacherCourseDto> allStudentCourseInfo = courseScheduleStudentPaymentDao.findAllStudentCourseInfo();
|
|
|
+ Map<Integer, List<StudentTeacherCourseDto>> studentCoursesMap = allStudentCourseInfo.stream().collect(Collectors.groupingBy(StudentTeacherCourseDto::getStudentId));
|
|
|
+ List<Student> students=new ArrayList<>();
|
|
|
+ for (Map.Entry<Integer, List<StudentTeacherCourseDto>> studentCoursesEntry : studentCoursesMap.entrySet()) {
|
|
|
+ Map<CourseSchedule.CourseScheduleType, List<StudentTeacherCourseDto>> courseTypeCourseMap = studentCoursesEntry.getValue().stream().collect(Collectors.groupingBy(StudentTeacherCourseDto::getCourseScheduleType));
|
|
|
+ List<StudentTeacherCourseDto> practiceCourses = courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
|
+ if (!CollectionUtils.isEmpty(practiceCourses)) {
|
|
|
+ practiceCourses.sort(Comparator.comparing(StudentTeacherCourseDto::getClassesStartTime).reversed());
|
|
|
+ Student student=new Student(studentCoursesEntry.getKey());
|
|
|
+ student.setTeacherId(practiceCourses.get(0).getTeacherId());
|
|
|
+ students.add(student);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentTeacherCourseDto> vipCourses = courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.VIP);
|
|
|
+ if (!CollectionUtils.isEmpty(vipCourses)) {
|
|
|
+ Student student=new Student(studentCoursesEntry.getKey());
|
|
|
+ vipCourses.sort(Comparator.comparing(StudentTeacherCourseDto::getClassesStartTime).reversed());
|
|
|
+ student.setTeacherId(vipCourses.get(0).getTeacherId());
|
|
|
+ students.add(student);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentTeacherCourseDto> singleCourses = courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE);
|
|
|
+ if (!CollectionUtils.isEmpty(singleCourses)) {
|
|
|
+ Student student=new Student(studentCoursesEntry.getKey());
|
|
|
+ singleCourses.sort(Comparator.comparing(StudentTeacherCourseDto::getClassesStartTime).reversed());
|
|
|
+ student.setTeacherId(singleCourses.get(0).getTeacherId());
|
|
|
+ students.add(student);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentTeacherCourseDto> mixCourses = courseTypeCourseMap.get(CourseSchedule.CourseScheduleType.MIX);
|
|
|
+ if (!CollectionUtils.isEmpty(mixCourses)) {
|
|
|
+ Student student=new Student(studentCoursesEntry.getKey());
|
|
|
+ mixCourses.sort(Comparator.comparing(StudentTeacherCourseDto::getClassesStartTime).reversed());
|
|
|
+ student.setTeacherId(mixCourses.get(0).getTeacherId());
|
|
|
+ students.add(student);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(students)){
|
|
|
+ studentDao.batchUpdate(students);
|
|
|
+ }
|
|
|
+ students=null;
|
|
|
+ studentCoursesMap=null;
|
|
|
+ allStudentCourseInfo=null;
|
|
|
+ }
|
|
|
}
|