| 
					
				 | 
			
			
				@@ -1,33 +1,70 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 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.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.enums.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.StudentServeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.SysConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.SysTenantConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.common.tenant.TenantContextHolder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.ArrayUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-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.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.DayOfWeek; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.Instant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.ZoneId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Comparator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.HashSet; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map.Entry; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Optional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Set; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.CourseScheduleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.ExtracurricularExercisesReplyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.MusicGroupDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.StudentDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.StudentExtracurricularExercisesSituationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dao.StudentRegistrationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dto.BasicUserDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dto.ClassGroupStudentMapperDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dto.IndexBaseDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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.entity.CourseSchedule; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.IndexBaseMonthData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.MusicGroup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.StudentCourseHomework; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.StudentExtracurricularExercisesSituation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.StudentRegistration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.CourseStatusEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.GroupType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.IndexDataType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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.biz.service.SysTenantConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.common.tenant.TenantContextHolder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @Author Joburgess 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @Date 2020.05.27 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -57,7 +94,7 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private MusicGroupDao musicGroupDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StudentRegistrationDao studentRegistrationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void exercisesSituationStatistics(String monday, Integer tenantId) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -301,11 +338,15 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void exercisesSituationStatistics2(String monday, List<Integer> studentIds, Integer tenantId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void exercisesSituationStatistics2(String monday, Integer tenantId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //统计上周的服务指标总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int preWeekServiceNum = studentExtracurricularExercisesSituationDao.countWeekServiceNum(nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue()).plusDays(-7).toString(), tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //统计上周数据今日更新的条数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int lastWeekTodayUpdateNum = studentExtracurricularExercisesSituationDao.findLastWeekTodayUpdateNum(nowDate.plusDays(-nowDate.getDayOfWeek().getValue()).toString(), tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(preWeekServiceNum>0 && lastWeekTodayUpdateNum<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             nowDate = nowDate.plusDays(-nowDate.getDayOfWeek().getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -317,6 +358,19 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 学员在读才生成服务指标,若本周有声部课或合奏课,则布置课后训练;否则,布置课外训练(课外训练看是指定由哪个班级的老师来布置) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 学员在每一个进行中的乐团,且已开始上课都需要布置作业 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询进行中乐团在读的学生列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentRegistration> studentRegistrationList = studentRegistrationDao.queryServiceStudentByMusicGroupStatus(DateUtil.dateToString(nextMonday, "yyyy-MM-dd"), tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(studentRegistrationList == null || studentRegistrationList.size() == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Integer> studentIds = studentRegistrationList.stream().map(t -> t.getUserId()).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Set<String> holidayDays = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String holidaySetting = sysTenantConfigService.getTenantConfigValue(SysConfigService.HOLIDAY_SETTING,tenantId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -333,303 +387,164 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //查询需要生成服务指标的学员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<StudentServeCourseDto> studentFutureCourseInfo = studentDao.getStudentFutureCourseInfo(monDayDate.toString(), DateUtil.dateToString(nextMonday, "yyyy-MM-dd"), studentIds, tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(CollectionUtils.isEmpty(studentFutureCourseInfo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<Integer, List<StudentServeCourseDto>> studentCourseMap = studentFutureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //有单技课或合奏课,且需要服务的学员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Set<Integer> musicCourseStudentIds = studentFutureCourseInfo.stream().filter(s -> CourseSchedule.CourseScheduleType.SINGLE.equals(s.getType()) || CourseSchedule.CourseScheduleType.MIX.equals(s.getType())).map(StudentServeCourseDto::getStudentId).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //有课且被服务的学生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Set<Integer> haveCourseBeServeStudentIds = studentCourseMap.keySet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //查询所有开启了服务状态的学员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<Integer> allServeStudentIds = studentDao.getServeStudentIds(tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //没课但需要服务的学员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Set<Integer> noCourseServeStudentIds = allServeStudentIds.stream().filter(id -> !haveCourseBeServeStudentIds.contains(id)).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Set<Integer> musicStudentIds = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(!Objects.isNull(noCourseServeStudentIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            musicStudentIds.addAll(noCourseServeStudentIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(!CollectionUtils.isEmpty(musicCourseStudentIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            musicStudentIds.addAll(musicCourseStudentIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询截止到本周有课的信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentServeCourseDto> studentCutoffWeekCourseInfo = studentDao.getStudentFutureCourseInfo("2019-01-01", sunDayDate.toString(), studentIds, tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String,List<Integer>> musicGroupStudentIdListMap = new HashMap<String, List<Integer>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, List<StudentServeCourseDto>> musicGroupStudentServiceCourseMap = studentCutoffWeekCourseInfo.stream().collect((Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //学员在单乐团中课程去重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(Entry<String, List<StudentServeCourseDto>> entry : musicGroupStudentServiceCourseMap.entrySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	musicGroupStudentIdListMap.put(entry.getKey(), entry.getValue().stream().map(t -> t.getStudentId()).distinct().collect(Collectors.toList())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<StudentServeCourseDto> noCourseBeServeStudentInfo = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(!CollectionUtils.isEmpty(musicStudentIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        	//查询进行中的乐团,且需要服务的学生、老师、乐团信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            noCourseBeServeStudentInfo = studentDao.getNoCourseBeServeStudentInfo(new ArrayList<>(musicStudentIds), tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询本周有声部或合奏的学生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentServeCourseDto> studentCurrentWeekCourseInfo = studentDao.getStudentFutureCourseInfo(monDayDate.toString(), sunDayDate.toString(), studentIds, tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, List<StudentServeCourseDto>> studentCurrentWeekCourseMap = studentCurrentWeekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //本周学生在不同乐团中上的第一节课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String,Map<Integer,StudentServeCourseDto>> musicGroupStudentCurrentWeekCourseMap = new HashMap<String, Map<Integer,StudentServeCourseDto>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Integer,List<StudentServeCourseDto>> userCourseListMap = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Integer,StudentServeCourseDto> userCourseMap = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String musicGroupId = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Optional<StudentServeCourseDto> optional = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询学生在乐团中的第一节课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(Entry<String, List<StudentServeCourseDto>> entry : studentCurrentWeekCourseMap.entrySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	musicGroupId = entry.getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	userCourseMap = musicGroupStudentCurrentWeekCourseMap.get(musicGroupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	if(userCourseMap == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        		userCourseMap = new HashMap<Integer, StudentServeCourseDto>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	//获取学生本周所有课程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	userCourseListMap = entry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto :: getStudentId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	for(Entry<Integer, List<StudentServeCourseDto>> stuCourseListEntry : userCourseListMap.entrySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            	//获取学生本周第一节课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        		optional = stuCourseListEntry.getValue().stream().filter(dto -> (dto.getType() == CourseScheduleType.SINGLE || dto.getType() == CourseScheduleType.TRAINING_SINGLE)).min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        		if(optional.isPresent()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        			userCourseMap.put(stuCourseListEntry.getKey(), optional.get()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        		}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        			userCourseMap.put(stuCourseListEntry.getKey(), stuCourseListEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    		musicGroupStudentCurrentWeekCourseMap.put(musicGroupId, userCourseMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Integer userId = studentCourseMapEntry.getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(Objects.isNull(musicGroupIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                musicGroupIds = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //查询用户在指定乐团截止本周末的课程数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<Mapper> mapperList = new ArrayList<Mapper>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(musicGroupIds.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            	mapperList = courseScheduleStudentPaymentDao.queryUserMusicGroupCourseNumByClassTime(GroupType.MUSIC, musicGroupIds, userId, new Date(0, 1, 1), LocalDateToUdate(sunDayDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Map<Object, Object> map = mapperList.stream().collect(Collectors.toMap(Mapper :: getKey, Mapper :: getValue)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //是否在乐团生成服务指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            boolean isServiceWithMusicGroup = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //判断截止本周末是否有乐团课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for(Mapper m : mapperList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            	if((long)m.getValue() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            		isServiceWithMusicGroup = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //有未上的单技课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.SINGLE) && isServiceWithMusicGroup){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(!CollectionUtils.isEmpty(weekCourseInfo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<Integer, Set<Long>> teacherNotOverCourseIds = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(musicGroupIds.contains(groupCourseInfoEntry.getKey())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            musicGroupIds.remove(groupCourseInfoEntry.getKey()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        //学生在当前乐团没有上过课,就不需要生成服务指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(map.get(groupCourseInfoEntry.getKey()) != null && (long)map.get(groupCourseInfoEntry.getKey()) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        	continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(!teacherNotOverCourseIds.containsKey(courseInfo.getActualTeacherId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            teacherNotOverCourseIds.put(courseInfo.getActualTeacherId(), new HashSet<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(!CourseStatusEnum.OVER.equals(courseInfo.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            teacherNotOverCourseIds.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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        studentExtracurricularExercisesSituation.setNotOverCourseIds(StringUtils.join(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()), ",")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        studentExtracurricularExercisesSituation.setNotOverCourseNum(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()).size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        results.add(studentExtracurricularExercisesSituation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(CollectionUtils.isEmpty(musicGroupIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Map<Integer, Integer> teacherNumMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                for (String groupId : musicGroupIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Integer teacherId = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(studentCourseMapEntry.getKey()), groupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(!CollectionUtils.isEmpty(studentTeacherIdList)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        teacherId = studentTeacherIdList.get(0).getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    teacherId = Objects.isNull(teacherId)?noCourseStudentCourseMap.get(studentCourseMapEntry.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(studentCourseMapEntry.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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.VIP)){ //有未上的VIP 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(CollectionUtils.isEmpty(weekCourseInfo)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<Integer, List<StudentServeCourseDto>> teacherCourseMap = futureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    for (Integer teacherId : teacherCourseMap.keySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                teacherId,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<Integer, List<StudentServeCourseDto>> teacherCourseMap = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    for (Map.Entry<Integer, List<StudentServeCourseDto>> teacherCourseMapEntry : teacherCourseMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        StudentServeCourseDto courseInfo = teacherCourseMapEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(TeachModeEnum.OFFLINE.equals(courseInfo.getTeachMode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    teacherCourseMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    "EXERCISE", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    teacherCourseMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    "HOMEWORK", String.valueOf(courseInfo.getCourseScheduleId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if(!CourseStatusEnum.OVER.equals(courseInfo.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                studentExtracurricularExercisesSituation.setNotOverCourseIds(String.valueOf(courseInfo.getCourseScheduleId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                studentExtracurricularExercisesSituation.setNotOverCourseNum(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        results.add(studentExtracurricularExercisesSituation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.MIX)){//有未上的合奏课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Map<Integer, Integer> teacherNumMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                for (String groupId : musicGroupIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //学生在当前乐团没有上过课,就不需要生成服务指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(map.get(groupId) == null || (long)map.get(groupId) == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    	continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentServeCourseDto studentServeCourseDto = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<StudentExtracurricularExercisesSituation> results=new ArrayList<StudentExtracurricularExercisesSituation>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Integer,Map<Integer,Set<Long>>> studentTeacherCourseMap = new HashMap<Integer, Map<Integer,Set<Long>>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Integer,Map<Integer,Set<Long>>> studentTeacherNotOverCourseMap = new HashMap<Integer, Map<Integer,Set<Long>>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Integer,Map<Integer,Integer>> studentTeacherCourseNumMap = new HashMap<Integer, Map<Integer,Integer>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Map<Integer, Set<Long>> teacherCourseMap = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Map<Integer, Set<Long>> teacherNotOverCourseMap = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Integer teacherId = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Set<Long> courseIdList = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		ClassGroupTypeEnum teacherType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Map<Integer,Integer> teacherCourseNumMap = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //理论上一个学生一个乐团只布置一次作业 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for (Entry<String, List<Integer>> entry : musicGroupStudentIdListMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			musicGroupId = entry.getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			MusicGroup musicGroup = musicGroupDao.get(musicGroupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(musicGroup == null || musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Map<Integer,Integer> studentTeacherMapper = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			teacherType = musicGroup.getExtracurricularTeacher() == null ? ClassGroupTypeEnum.NORMAL : musicGroup.getExtracurricularTeacher(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List<ClassGroupStudentMapperDto> classGroupStudentMapperDtoList = classGroupStudentMapperDao.queryByClassGroupType(musicGroupId, teacherType, TeachTypeEnum.BISHOP, entry.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(classGroupStudentMapperDtoList != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				studentTeacherMapper = classGroupStudentMapperDtoList.stream().collect(Collectors.toMap(ClassGroupStudentMapperDto :: getUserId, ClassGroupStudentMapperDto :: getTeacherId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			userCourseMap = musicGroupStudentCurrentWeekCourseMap.get(musicGroupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for(Integer studentId : entry.getValue()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				//在当前乐团,学生本周是否有课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if(userCourseMap == null || userCourseMap.get(studentId) == null){//如果本周没课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(studentTeacherMapper == null || (teacherId = studentTeacherMapper.get(studentId)) == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					teacherCourseNumMap = studentTeacherCourseNumMap.get(studentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(teacherCourseNumMap == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						teacherCourseNumMap = new HashMap<Integer, Integer>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					teacherCourseNumMap.put(teacherId, teacherCourseNumMap.get(teacherId) == null ? 1 : teacherCourseNumMap.get(teacherId) + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					studentTeacherCourseNumMap.put(studentId, teacherCourseNumMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					//本周没有课,布置课外训练 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					studentExtracurricularExercisesSituation = new StudentExtracurricularExercisesSituation(studentId, teacherId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							nowDate.get(DateUtil.weekFields.weekOfYear()), DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									sunDayDate.toString(), "yyyy-MM-dd"), "EXERCISE", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherCourseNumMap.get(teacherId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(results.contains(studentExtracurricularExercisesSituation)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						results.remove(studentExtracurricularExercisesSituation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					results.add(studentExtracurricularExercisesSituation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				}else{//如果本周有课 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					studentServeCourseDto = userCourseMap.get(studentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					teacherId = studentServeCourseDto.getActualTeacherId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					teacherCourseMap = studentTeacherCourseMap.get(studentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(teacherCourseMap == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						teacherCourseMap = new HashMap<Integer, Set<Long>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					courseIdList = teacherCourseMap.get(teacherId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(courseIdList == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						courseIdList = new HashSet<Long>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					courseIdList.add(studentServeCourseDto.getCourseScheduleId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					teacherCourseMap.put(teacherId, courseIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					studentTeacherCourseMap.put(studentId, teacherCourseMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					studentExtracurricularExercisesSituation = new StudentExtracurricularExercisesSituation(studentId, teacherId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							nowDate.get(DateUtil.weekFields.weekOfYear()), DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									sunDayDate.toString(), "yyyy-MM-dd"), "HOMEWORK", StringUtils.join(courseIdList, ",")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    studentExtracurricularExercisesSituation.setExpectExercisesNum(courseIdList.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Integer teacherId = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(studentCourseMapEntry.getKey()), groupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if(!CollectionUtils.isEmpty(studentTeacherIdList)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        teacherId = studentTeacherIdList.get(0).getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    teacherId = Objects.isNull(teacherId)?noCourseStudentCourseMap.get(studentCourseMapEntry.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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherNotOverCourseMap = studentTeacherNotOverCourseMap.get(studentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(teacherNotOverCourseMap == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						teacherNotOverCourseMap = new HashMap<Integer, Set<Long>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					courseIdList = teacherNotOverCourseMap.get(teacherId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(courseIdList == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						courseIdList = new HashSet<Long>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(studentServeCourseDto.getStatus() != CourseStatusEnum.OVER){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    					courseIdList.add(studentServeCourseDto.getCourseScheduleId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    					teacherNotOverCourseMap.put(teacherId, courseIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    					studentTeacherNotOverCourseMap.put(studentId, teacherCourseMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                for (Map.Entry<Integer, Integer> teacherNumMapEntry : teacherNumMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    studentExtracurricularExercisesSituation.setNotOverCourseIds(StringUtils.join(courseIdList, ",")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    studentExtracurricularExercisesSituation.setNotOverCourseNum(courseIdList.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if(results.contains(studentExtracurricularExercisesSituation)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						results.remove(studentExtracurricularExercisesSituation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     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)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Set<Integer> teacherIds = futureCourseInfo.stream().map(StudentServeCourseDto::getActualTeacherId).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    for (Integer teacherId : teacherIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                teacherId,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<Integer, List<StudentServeCourseDto>> teacherCourseMap = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getActualTeacherId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<Integer, Set<Long>> teacherNotOverCourseIds = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    for (Map.Entry<Integer, List<StudentServeCourseDto>> teacherCourseMapEntry : teacherCourseMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        StudentServeCourseDto courseInfo = teacherCourseMapEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        teacherServiceCourseIdMap.put(teacherCourseMapEntry.getKey(), new HashSet<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        teacherServiceCourseIdMap.get(teacherCourseMapEntry.getKey()).add(courseInfo.getCourseScheduleId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(!teacherNotOverCourseIds.containsKey(courseInfo.getActualTeacherId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            teacherNotOverCourseIds.put(courseInfo.getActualTeacherId(), new HashSet<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if(!CourseStatusEnum.OVER.equals(courseInfo.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            teacherNotOverCourseIds.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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        studentExtracurricularExercisesSituation.setNotOverCourseIds(StringUtils.join(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()), ",")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        studentExtracurricularExercisesSituation.setNotOverCourseNum(teacherNotOverCourseIds.get(teacherServiceCourseIdMapEntry.getKey()).size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        results.add(studentExtracurricularExercisesSituation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (Integer noCourseServeStudentId : noCourseServeStudentIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(noCourseServeStudentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(CollectionUtils.isEmpty(musicGroupIds)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Map<Integer, Integer> teacherNumMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (String groupId : musicGroupIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Integer teacherId = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(noCourseServeStudentId), groupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(!CollectionUtils.isEmpty(studentTeacherIdList)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    teacherId = studentTeacherIdList.get(0).getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                teacherId = Objects.isNull(teacherId)?noCourseStudentCourseMap.get(noCourseServeStudentId).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(noCourseServeStudentId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        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)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<Integer> allStudentIds = new ArrayList<>(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -666,7 +581,7 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         .collect(Collectors.groupingBy(StudentServeCourseHomeworkDto::getUserId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<ExtracurricularExercisesReply> allStudentExercises = extracurricularExercisesReplyDao.getStudentExercisesWithTimeZone(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(allStudentIds), TenantContextHolder.getTenantId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<ExtracurricularExercisesReply> allStudentExercises = extracurricularExercisesReplyDao.getStudentExercisesWithTimeZone(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(allStudentIds), tenantId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(!CollectionUtils.isEmpty(allStudentExercises)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 studentExercisesMap = allStudentExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getUserId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -745,7 +660,7 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), studentIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             BigDecimal currentPage1=BigDecimal.ONE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     pageSize1=new BigDecimal(10000), 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -754,51 +669,6 @@ public class StudentServeServiceImpl implements StudentServeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             while (currentPage1.compareTo(totalPage1)<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                Set<String> newCodes = rows.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 : rows) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                    if(codeServeMap.containsKey(result.getStuAndTeaCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        Set<Long> courseIds = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        if(StringUtils.isNotBlank(result.getCourseIds())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                            courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        s.setServeType(result.getServeType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        if(s.getServeType().equals("HOMEWORK")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                            s.setCourseIds(StringUtils.join(courseIds, ",")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                            s.setCourseIds(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        if(StringUtils.isBlank(s.getCourseIds())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                            s.setExpectExercisesNum(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 studentExtracurricularExercisesSituationDao.batchInsert(rows); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |