| 
					
				 | 
			
			
				@@ -1,15 +1,15 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.StudentServeCourseDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.StudentServeCourseHomeworkDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.StudentServeDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.StudentServiceHomeworkDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dto.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.GroupType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.TeachModeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.TeachTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.YesOrNoEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.StudentServeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.SysConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.ArrayUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,6 +47,10 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StudentServeService studentServeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ClassGroupTeacherMapperDao classGroupTeacherMapperDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysConfigService sysConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -307,6 +311,26 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LocalDate sunDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Date nextMonday = Date.from(sunDayDate.plusDays(1).atStartOfDay(DateUtil.zoneId).toInstant()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String> holidayDays = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SysConfig holidaySetting = sysConfigService.findByParamName(SysConfigService.HOLIDAY_SETTING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(Objects.nonNull(holidaySetting)&&StringUtils.isNotBlank(holidaySetting.getParanValue())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            holidayDays = new HashSet<>(JSON.parseArray(holidaySetting.getParanValue(), String.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LocalDate everyDay=monDayDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        boolean weekInHoliday = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        while (everyDay.compareTo(sunDayDate)<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(!holidayDays.contains(everyDay.toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                weekInHoliday = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            everyDay = everyDay.plusDays(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(weekInHoliday){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), studentIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //        int weekServiceNum = studentExtracurricularExercisesSituationDao.countWeekServiceNum(monDayDate.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //        if(weekServiceNum>0&&CollectionUtils.isEmpty(studentIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //            return; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -318,6 +342,14 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map<Integer, List<StudentServeCourseDto>> studentCourseMap = studentFutureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<Integer> haveCourseBeServeStudentIds = studentCourseMap.keySet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Integer> allServeStudentIds = studentDao.getServeStudentIds(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<Integer> noCourseServeStudentIds = allServeStudentIds.stream().filter(id -> !haveCourseBeServeStudentIds.contains(id)).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentServeCourseDto> noCourseBeServeStudentInfo = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!CollectionUtils.isEmpty(noCourseServeStudentIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            noCourseBeServeStudentInfo = studentDao.getNoCourseBeServeStudentInfo(new ArrayList<>(noCourseServeStudentIds)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<StudentExtracurricularExercisesSituation> results=new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (Map.Entry<Integer, List<StudentServeCourseDto>> studentCourseMapEntry : studentCourseMap.entrySet()) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -411,8 +443,12 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Map<Integer, Integer> teacherNumMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (String groupId : groupCourseInfo.keySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    CourseSchedule studentHistoryLastCourse = courseScheduleStudentPaymentDao.getStudentHistoryLastCourse(studentCourseMapEntry.getKey(), monDayDate.toString(), groupId, CourseSchedule.CourseScheduleType.SINGLE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Integer teacherId = Objects.isNull(studentHistoryLastCourse)?studentCourseMapEntry.getValue().get(0).getLeadTeacherId():studentHistoryLastCourse.getActualTeacherId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Integer teacherId = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    List<BaseMapDto<Integer, Integer>> studentTeacherIdList = courseScheduleStudentPaymentDao.getStudentClassGroupBishopTeacherMap(null, groupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(!CollectionUtils.isEmpty(studentTeacherIdList)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        teacherId = studentTeacherIdList.get(0).getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherId = Objects.isNull(teacherId)?studentCourseMapEntry.getValue().get(0).getLeadTeacherId():teacherId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if(Objects.isNull(teacherId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -468,6 +504,40 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Integer, Set<String>> noCourseStudentMusicIdsMap = noCourseBeServeStudentInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId, Collectors.mapping(StudentServeCourseDto::getMusicGroupId, Collectors.toSet()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Integer, List<StudentServeCourseDto>> noCourseStudentCourseMap = noCourseBeServeStudentInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (Map.Entry<Integer, Set<String>> noCourseStudentMusicIdsMapEntry : noCourseStudentMusicIdsMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<Integer, Integer> teacherNumMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (String groupId : noCourseStudentMusicIdsMapEntry.getValue()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Integer teacherId = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<BaseMapDto<Integer, Integer>> studentTeacherIdList = courseScheduleStudentPaymentDao.getStudentClassGroupBishopTeacherMap(null, groupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!CollectionUtils.isEmpty(studentTeacherIdList)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherId = studentTeacherIdList.get(0).getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                teacherId = Objects.isNull(teacherId)?noCourseStudentCourseMap.get(noCourseStudentMusicIdsMapEntry.getKey()).get(0).getLeadTeacherId():teacherId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(Objects.isNull(teacherId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!teacherNumMap.containsKey(teacherId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherNumMap.put(teacherId, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherNumMap.put(teacherId, teacherNumMap.get(teacherId)+1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (Map.Entry<Integer, Integer> teacherNumMapEntry : teacherNumMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(noCourseStudentMusicIdsMapEntry.getKey(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        teacherNumMapEntry.getKey(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        nowDate.get(DateUtil.weekFields.weekOfYear()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "EXERCISE", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherNumMapEntry.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                results.add(studentExtracurricularExercisesSituation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(!CollectionUtils.isEmpty(results)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(CollectionUtils.isEmpty(studentIds)){ 
			 |