|
@@ -45,6 +45,8 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
private ExtracurricularExercisesReplyDao extracurricularExercisesReplyDao;
|
|
|
@Autowired
|
|
|
private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentServeService studentServeService;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -288,8 +290,197 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> checkeIsAssignHomework(Long courseScheduleId, String studentIdsStr) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void exercisesSituationStatistics2(String monday, List<Integer> studentIds) {
|
|
|
+ LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(monday)){
|
|
|
+ nowDate=LocalDate.parse(monday, DateUtil.dateFormatter);
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
+ LocalDate sunDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
|
|
|
+ Date nextMonday = Date.from(sunDayDate.plusDays(1).atStartOfDay(DateUtil.zoneId).toInstant());
|
|
|
+
|
|
|
+ int weekServiceNum = studentExtracurricularExercisesSituationDao.countWeekServiceNum(monDayDate.toString());
|
|
|
+ if(weekServiceNum>0&&CollectionUtils.isEmpty(studentIds)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentServeCourseDto> studentFutureCourseInfo = studentDao.getStudentFutureCourseInfo(monDayDate.toString(), studentIds);
|
|
|
+ Map<Integer, List<StudentServeCourseDto>> studentCourseMap = studentFutureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId));
|
|
|
+
|
|
|
+ List<StudentExtracurricularExercisesSituation> results=new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<Integer, List<StudentServeCourseDto>> studentCourseMapEntry : studentCourseMap.entrySet()) {
|
|
|
+ Map<CourseSchedule.CourseScheduleType, List<StudentServeCourseDto>> typeCourseMap = studentCourseMapEntry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto::getType));
|
|
|
+
|
|
|
+ if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.SINGLE)){
|
|
|
+ List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE);
|
|
|
+ List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(weekCourseInfo)){
|
|
|
+ StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
|
|
|
+ futureCourseInfo.get(0).getActualTeacherId(),nowDate.get(DateUtil.weekFields.weekOfYear()),
|
|
|
+ DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
|
|
|
+ "EXERCISE", null);
|
|
|
+ results.add(studentExtracurricularExercisesSituation);
|
|
|
+ }else{
|
|
|
+ Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
|
|
|
+ Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
|
|
|
+ for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
|
|
|
+ StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
|
|
|
+ if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
|
|
|
+ teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
|
|
|
+ }
|
|
|
+ teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
|
|
|
+ }
|
|
|
+ for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
|
|
|
+ StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
|
|
|
+ teacherServiceCourseIdMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
|
|
|
+ DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
|
|
|
+ "HOMEWORK", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
|
|
|
+ studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
|
|
|
+ results.add(studentExtracurricularExercisesSituation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.VIP)){
|
|
|
+ List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP);
|
|
|
+ List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP).stream().filter(c -> TeachModeEnum.ONLINE.equals(c.getTeachMode()) && c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(weekCourseInfo)){
|
|
|
+ StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
|
|
|
+ futureCourseInfo.get(0).getActualTeacherId(),nowDate.get(DateUtil.weekFields.weekOfYear()),
|
|
|
+ DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
|
|
|
+ "EXERCISE", null);
|
|
|
+ results.add(studentExtracurricularExercisesSituation);
|
|
|
+ }else{
|
|
|
+ Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
|
|
|
+ Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
|
|
|
+ for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
|
|
|
+ StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
|
|
|
+ if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
|
|
|
+ teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
|
|
|
+ }
|
|
|
+ for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
|
|
|
+ StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
|
|
|
+ teacherServiceCourseIdMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
|
|
|
+ DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
|
|
|
+ "HOMEWORK", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
|
|
|
+ studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
|
|
|
+ results.add(studentExtracurricularExercisesSituation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.MIX)){
|
|
|
+ CourseSchedule studentHistoryLastCourse = courseScheduleStudentPaymentDao.getStudentHistoryLastCourse(studentCourseMapEntry.getKey(), monDayDate.toString(), CourseSchedule.CourseScheduleType.SINGLE);
|
|
|
+ StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
|
|
|
+ Objects.isNull(studentHistoryLastCourse)?studentCourseMapEntry.getValue().get(0).getLeadTeacherId():studentHistoryLastCourse.getActualTeacherId(),
|
|
|
+ nowDate.get(DateUtil.weekFields.weekOfYear()),
|
|
|
+ DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
|
|
|
+ "EXERCISE", null);
|
|
|
+ if(Objects.isNull(studentExtracurricularExercisesSituation.getTeacherId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ results.add(studentExtracurricularExercisesSituation);
|
|
|
+ }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.PRACTICE)){
|
|
|
+ List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
|
+ List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isEmpty(weekCourseInfo)){
|
|
|
+ StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
|
|
|
+ futureCourseInfo.get(0).getActualTeacherId(),nowDate.get(DateUtil.weekFields.weekOfYear()),
|
|
|
+ DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
|
|
|
+ "EXERCISE", null);
|
|
|
+ results.add(studentExtracurricularExercisesSituation);
|
|
|
+ }else{
|
|
|
+ Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
|
|
|
+ Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
|
|
|
+ for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
|
|
|
+ StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
|
|
|
+ if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
|
|
|
+ teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
|
|
|
+ }
|
|
|
+ for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
|
|
|
+ StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
|
|
|
+ teacherServiceCourseIdMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
|
|
|
+ DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
|
|
|
+ "HOMEWORK", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
|
|
|
+ studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
|
|
|
+ results.add(studentExtracurricularExercisesSituation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CollectionUtils.isEmpty(studentIds)){
|
|
|
+ studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
|
|
|
+ BigDecimal currentPage1=BigDecimal.ONE,
|
|
|
+ pageSize1=new BigDecimal(10000),
|
|
|
+ total1=new BigDecimal(results.size()),
|
|
|
+ totalPage1=total1.divide(pageSize1, BigDecimal.ROUND_UP);
|
|
|
+
|
|
|
+ while (currentPage1.compareTo(totalPage1)<=0){
|
|
|
+ List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
|
|
|
+ studentExtracurricularExercisesSituationDao.batchInsert(rows);
|
|
|
+ currentPage1=currentPage1.add(BigDecimal.ONE);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), studentIds);
|
|
|
+ Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
|
|
|
+
|
|
|
+ Set<String> newCodes = results.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
|
|
|
+ for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
|
|
|
+ if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
|
|
|
+ List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
|
|
|
+ for (StudentExtracurricularExercisesSituation result : results) {
|
|
|
+ if(codeServeMap.containsKey(result.getStuAndTeaCode())){
|
|
|
+ StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
|
|
|
+ List<Long> courseIds = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
|
|
|
+ courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(result.getCourseIds())){
|
|
|
+ courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ s.setCourseIds(StringUtils.join(courseIds, ","));
|
|
|
+ s.setExpectExercisesNum(courseIds.size());
|
|
|
+ updateService.add(s);
|
|
|
+ }else{
|
|
|
+ newService.add(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(updateService))
|
|
|
+ studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
|
|
|
+ if(!CollectionUtils.isEmpty(newService))
|
|
|
+ studentExtracurricularExercisesSituationDao.batchInsert(newService);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkeIsAssignHomework(Long courseScheduleId, String studentIdsStr, Integer teacherId) {
|
|
|
Map<String, Object> result=new HashMap<>();
|
|
|
+
|
|
|
+ Set<Long> teacherServeCourseIds = studentServeService.getTeacherServeCourseIds(teacherId);
|
|
|
+ if(teacherServeCourseIds.contains(courseScheduleId)){
|
|
|
+ result.put("enableAssignHomework", 0);
|
|
|
+ }else{
|
|
|
+ result.put("enableAssignHomework", 0);
|
|
|
+ }
|
|
|
+
|
|
|
if(Objects.isNull(courseScheduleId)&&Objects.isNull(studentIdsStr)){
|
|
|
result.put("isAssignHomework", 0);
|
|
|
return result;
|
|
@@ -330,4 +521,15 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
result.put("isAssignHomework", 1);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Set<Long> getTeacherServeCourseIds(Integer teacherId) {
|
|
|
+ List<StudentExtracurricularExercisesSituation> teacherNoStartServices = studentExtracurricularExercisesSituationDao.findTeacherNoStartServices(teacherId);
|
|
|
+ List<String> courseIdsList = teacherNoStartServices.stream().filter(s->StringUtils.isNotBlank(s.getCourseIds())).map(StudentExtracurricularExercisesSituation::getCourseIds).collect(Collectors.toList());
|
|
|
+ Set<Long> courseIds = new HashSet<>();
|
|
|
+ for (String courseIdStr : courseIdsList) {
|
|
|
+ courseIds.addAll(Arrays.stream(courseIdStr.split(",")).mapToLong(Long::valueOf).boxed().collect(Collectors.toSet()));
|
|
|
+ }
|
|
|
+ return courseIds;
|
|
|
+ }
|
|
|
}
|