yonge 3 年之前
父節點
當前提交
923f5290b3

+ 8 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupTeacherMapperDao.java

@@ -1,14 +1,16 @@
 package com.ym.mec.biz.dal.dao;
 
+import java.util.List;
+import java.util.Set;
+
+import org.apache.ibatis.annotations.Param;
+
 import com.ym.mec.biz.dal.dto.ClassGroupTeacherMapDto;
 import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.TeachTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Set;
 
 public interface ClassGroupTeacherMapperDao extends BaseDAO<Long, ClassGroupTeacherMapper> {
 
@@ -149,4 +151,6 @@ public interface ClassGroupTeacherMapperDao extends BaseDAO<Long, ClassGroupTeac
     Set<Integer> queryTeacherIdsByClassGroupId(@Param("classGroupId") Integer classGroupId,
                                                @Param("musicGroupId") String musicGroupId,
                                                @Param("groupType") GroupType groupType);
+    
+    List<ClassGroupTeacherMapper> queryByClassGroupType(@Param("musicGroupId") String musicGroupId,@Param("classGroupType") ClassGroupTypeEnum classGroupType,@Param("teacherRole") TeachTypeEnum teacherRole);
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -102,7 +102,7 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
     List<StudentServeCourseDto> getServeStudentCourseStartTimes(@Param("monday") String monday, @Param("tenantId") Integer tenantId);
 
     List<StudentServeCourseDto> getStudentFutureCourseInfo(@Param("monday") String monday,
-                                                           @Param("nextMonday") String nextMonday,
+                                                           @Param("sunday") String sunday,
                                                            @Param("studentIds") List<Integer> studentIds, @Param("tenantId") Integer tenantId);
 
     List<StudentServeCourseDto> getNoCourseBeServeStudentInfo(@Param("studentIds") List<Integer> noCourseStudentIds, @Param("tenantId") Integer tenantId);

+ 28 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java

@@ -1,16 +1,37 @@
 package com.ym.mec.biz.dal.dao;
 
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
-
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import org.apache.ibatis.annotations.Param;
 
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.Mapper;
+import com.ym.mec.biz.dal.dto.MusicGroupRegAndMoneyDto;
+import com.ym.mec.biz.dal.dto.NoClassMusicStudentDto;
+import com.ym.mec.biz.dal.dto.OrderStatisDto;
+import com.ym.mec.biz.dal.dto.RegisterDto;
+import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
+import com.ym.mec.biz.dal.dto.StudentClassInfoDto;
+import com.ym.mec.biz.dal.dto.StudentFeeDetailDto;
+import com.ym.mec.biz.dal.dto.StudentInfo;
+import com.ym.mec.biz.dal.dto.StudentMusicDetailDto;
+import com.ym.mec.biz.dal.dto.StudentMusicGroupDto;
+import com.ym.mec.biz.dal.dto.StudentRegisterInstrumentsDetailDto;
+import com.ym.mec.biz.dal.dto.StudentRegisterPerDto;
+import com.ym.mec.biz.dal.dto.SubjectApplyDetailDto;
+import com.ym.mec.biz.dal.dto.UserGroupDto;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
 
 public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistration> {
@@ -738,4 +759,6 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
     * @date 2022/3/16 14:10
     */
     List<Map<Integer,String>> getLastMusicGroupName(@Param("userIds") List<Integer> userIds);
+    
+    List<StudentRegistration> queryServiceStudentByMusicGroupStatus(@Param("nextMonday") String nextMonday,@Param("tenantId") Integer tenantId);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroup.java

@@ -8,6 +8,7 @@ import java.util.Date;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.biz.dal.entity.CooperationOrgan.OwnershipType;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.SalarySettlementTypeEnum;
@@ -202,6 +203,8 @@ public class MusicGroup extends BaseEntity {
 	
 	@ApiModelProperty(value = "是否赠送辅件",required = false)
 	private Boolean isGiveAccessories;
+	
+	private ClassGroupTypeEnum extracurricularTeacher;
 
 	public Integer getHasInstrumentNum() {
 		return hasInstrumentNum;
@@ -700,4 +703,12 @@ public class MusicGroup extends BaseEntity {
 	public void setIsGiveAccessories(Boolean isGiveAccessories) {
 		this.isGiveAccessories = isGiveAccessories;
 	}
+
+	public ClassGroupTypeEnum getExtracurricularTeacher() {
+		return extracurricularTeacher;
+	}
+
+	public void setExtracurricularTeacher(ClassGroupTypeEnum extracurricularTeacher) {
+		this.extracurricularTeacher = extracurricularTeacher;
+	}
 }

+ 3 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/StudentServeService.java

@@ -1,13 +1,12 @@
 package com.ym.mec.biz.service;
 
-import com.ym.mec.biz.dal.dto.IndexBaseDto;
-import org.apache.ibatis.annotations.Param;
-
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.ym.mec.biz.dal.dto.IndexBaseDto;
+
 /**
  * @Author Joburgess
  * @Date 2020.05.27
@@ -23,7 +22,7 @@ public interface StudentServeService {
      */
     void exercisesSituationStatistics(String monday, Integer tenantId);
 
-    void exercisesSituationStatistics2(String monday, List<Integer> studentIds, Integer tenantId);
+    void exercisesSituationStatistics2(String monday, Integer tenantId);
 
     /**
      * @describe

+ 218 - 355
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -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.ClassGroupTeacherMapperDao;
+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.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.ClassGroupTeacherMapper;
+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.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,6 +94,9 @@ public class StudentServeServiceImpl implements StudentServeService {
     private MusicGroupDao musicGroupDao;
     @Autowired
     private StudentRegistrationDao studentRegistrationDao;
+    
+    @Autowired
+    private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -301,11 +341,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 +361,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 +390,154 @@ 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){
+				continue;
+			}
+			
+			teacherType = musicGroup.getExtracurricularTeacher();
+			List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroupTeacherMapperDao.queryByClassGroupType(musicGroupId, teacherType, TeachTypeEnum.BISHOP);
+			
+			userCourseMap = musicGroupStudentCurrentWeekCourseMap.get(musicGroupId);
+			
+			for(Integer studentId : entry.getValue()){
+				//在当前乐团,学生本周是否有课
+				studentServeCourseDto = userCourseMap.get(studentId);
+				if(studentServeCourseDto == null){//如果本周没课
+					
+					if(classGroupTeacherMapperList == null || classGroupTeacherMapperList.size() == 0){
+						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);
+					
+					teacherId = classGroupTeacherMapperList.get(0).getUserId();
+
+					//本周没有课,布置课外训练
+					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));
+					results.add(studentExtracurricularExercisesSituation);
+				}else{//如果本周有课
+					
+					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());
                     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 +574,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));
             }
@@ -754,51 +662,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);
 

+ 7 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupTeacherMapperMapper.xml

@@ -243,4 +243,11 @@
             </if>
         </where>
     </sql>
+    
+    <select id="queryByClassGroupType" resultMap="ClassGroupTeacherMapper">
+        SELECT cgtm.* FROM class_group_teacher_mapper cgtm left join class_group cg on cgtm.class_group_id_ = cg.id_ 
+        where music_group_id_ = #{musicGroupId} and cg.type_ = #{classGroupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} 
+        and cgtm.teacher_role_ = #{teacherRole,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and cg.del_flag_ = 0
+        ORDER BY id_
+    </select>
 </mapper>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -17,6 +17,7 @@
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
         <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="extracurricular_teacher_" property="extracurricularTeacher" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="bill_start_date_" property="billStartDate"/>
         <result column="improvent_classes_num_" property="improventClassesNum"/>
         <result column="enroll_classes_" property="enrollClasses"/>
@@ -107,7 +108,7 @@
                  settlement_type_, cooperation_organ_id_, enlightenment_course_time_,
                  parent_meeting_time_, img_, director_user_id_, is_classroom_lessons_, memo_, expect_start_group_date_,
                  ownership_type_, repair_user_id_, del_flag_, payment_valid_start_date_, payment_valid_end_date_,
-                 payment_pattern_, course_view_type_, transaction_teacher_id_,homework_push_flag_,member_course_show_flag_,tenant_id_,is_give_accessories_)
+                 payment_pattern_, course_view_type_, transaction_teacher_id_,homework_push_flag_,member_course_show_flag_,tenant_id_,is_give_accessories_,extracurricular_teacher_)
         VALUES (#{id}, #{name}, #{organId}, #{schoolId}, #{applyExpireDate}, #{preApplyExpireDate}, #{teamTeacherId},
                 #{educationalTeacherId},
                 #{chargeTypeId}, #{courseForm}, now(), now(),
@@ -119,7 +120,7 @@
                 #{isClassroomLessons}, #{memo}, #{expectStartGroupDate},
                 #{ownershipType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{repairUserId},
                 #{delFlag}, #{paymentValidStartDate}, #{paymentValidEndDate}, #{paymentPattern},
-                #{courseViewType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{transactionTeacherId},#{homeworkPushFlag},#{memberCourseShowFlag},#{tenantId},#{isGiveAccessories})
+                #{courseViewType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{transactionTeacherId},#{homeworkPushFlag},#{memberCourseShowFlag},#{tenantId},#{isGiveAccessories},#{extracurricularTeacher,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -234,6 +235,9 @@
             <if test="isGiveAccessories != null">
                 is_give_accessories_ = #{isGiveAccessories},
             </if>
+            <if test="extracurricularTeacher != null">
+                extracurricular_teacher_ = #{extracurricularTeacher,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>

+ 3 - 7
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -605,7 +605,6 @@
     <select id="getStudentFutureCourseInfo" resultMap="StudentServeCourseDto">
         SELECT
             cssp.user_id_ student_id_,
-            stu.teacher_id_ lead_teacher_id_,
             cs.id_ course_schedule_id_,
             cs.group_type_,
             cs.music_group_id_,
@@ -617,14 +616,11 @@
             cs.teach_mode_
         FROM course_schedule_student_payment cssp
             LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
-            LEFT JOIN student stu ON cssp.user_id_ = stu.user_id_
-        WHERE stu.service_tag_=1 and cssp.tenant_id_ = #{tenantId}
-            AND (stu.service_tag_update_time_ IS NULL OR stu.service_tag_update_time_&lt;#{nextMonday})
+        WHERE cssp.tenant_id_ = #{tenantId}
             AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
             AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
-            AND cs.class_date_&gt;=#{monday}
-            AND cs.type_ IN ('SINGLE', 'TRAINING_SINGLE', 'VIP', 'MIX', 'TRAINING_MIX', 'PRACTICE')
-            AND cssp.create_time_&lt;#{nextMonday}
+            AND cs.class_date_between #{monday} and #{sunday}
+            AND cs.type_ IN ('SINGLE', 'TRAINING_SINGLE', 'MIX', 'TRAINING_MIX')
             <if test="studentIds!=null and studentIds.size()>0">
                 AND cssp.user_id_ IN
                 <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -1808,4 +1808,12 @@
         </foreach>
         GROUP BY sr.user_id_)
     </select>
+    
+    <select id="queryServiceStudentByMusicGroupStatus" resultMap="StudentRegistration">
+    	select sr.* from student_registration sr 
+    	left join music_group mg ON mg.id_ = sr.music_group_id_
+    	left join student s on s.user_id_ = sr.user_id_
+    	where s.service_tag_ = 1 AND (stu.service_tag_update_time_ IS NULL OR stu.service_tag_update_time_&lt;#{nextMonday})
+    	and sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS' and sr.tenant_id_ = #{tenantId}
+    </select>
 </mapper>