|  | @@ -13,6 +13,7 @@ import com.ym.mec.biz.service.CourseHomeworkService;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.StudentCourseHomeworkService;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.StudentServeService;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.SysMessageService;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.constant.CommonConstants;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.page.PageInfo;
 | 
	
	
		
			
				|  | @@ -29,6 +30,7 @@ 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.LocalDate;
 | 
	
		
			
				|  |  |  import java.time.LocalDateTime;
 | 
	
	
		
			
				|  | @@ -73,6 +75,8 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
 | 
	
		
			
				|  |  |      private VipGroupDao vipGroupDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private PracticeGroupDao practiceGroupDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ExtracurricularExercisesReplyDao extracurricularExercisesReplyDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public BaseDAO<Long, StudentCourseHomework> getDAO() {
 | 
	
	
		
			
				|  | @@ -277,9 +281,6 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<StudentCourseHomework> findStudentCourseHomeworkByCourse(Long courseSchedule, Long homeworkId, String userName) {
 | 
	
		
			
				|  |  | -        if (Objects.isNull(courseSchedule)) {
 | 
	
		
			
				|  |  | -            throw new BizException("请指定课程");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |          return studentCourseHomeworkDao.findByCourseSchedule(courseSchedule, homeworkId, userName);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -510,10 +511,95 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
 | 
	
		
			
				|  |  |          if(!CollectionUtils.isEmpty(musicGroups)){
 | 
	
		
			
				|  |  |              List<String> groupIds = musicGroups.stream().map(MusicGroup::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |              List<StudentRegistration> studentRegistrations = studentRegistrationDao.findByMusicGroupIds(groupIds, StudentMusicGroupStatusEnum.NORMAL);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +            Map<String, Long> groupStudentNumMap = studentRegistrations.stream().collect(Collectors.groupingBy(StudentRegistration::getMusicGroupId, Collectors.counting()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<EduHomeworkCardDto> courseHomeworkStudentNumList = studentCourseHomeworkDao.countHomeworkStudentInfoWithMusicGroup(groupIds, queryInfo.getStartTime(), queryInfo.getEndTime());
 | 
	
		
			
				|  |  | +            List<EduHomeworkCardDto> homeworkStudentNumList = extracurricularExercisesReplyDao.countEduHomeworkStudentNumWithMusicGroup(groupIds, queryInfo.getStartTime(), queryInfo.getEndTime());
 | 
	
		
			
				|  |  | +            homeworkStudentNumList.addAll(courseHomeworkStudentNumList);
 | 
	
		
			
				|  |  | +            Map<String, List<EduHomeworkCardDto>> groupStudentListMap = homeworkStudentNumList.stream().collect(Collectors.groupingBy(EduHomeworkCardDto::getGroupId));
 | 
	
		
			
				|  |  | +            for (MusicGroup mg : musicGroups) {
 | 
	
		
			
				|  |  | +                EduHomeworkStatDto ehs = new EduHomeworkStatDto();
 | 
	
		
			
				|  |  | +                ehs.setGroupId(mg.getId());
 | 
	
		
			
				|  |  | +                ehs.setGroupName(mg.getName());
 | 
	
		
			
				|  |  | +                if(groupStudentNumMap.containsKey(mg.getId())){
 | 
	
		
			
				|  |  | +                    ehs.setGroupStudentNum(Math.toIntExact(groupStudentNumMap.get(mg.getId())));
 | 
	
		
			
				|  |  | +                }else{
 | 
	
		
			
				|  |  | +                    ehs.setGroupStudentNum(0);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                int exceptStudentNum = 0;
 | 
	
		
			
				|  |  | +                int submitStudentNum = 0;
 | 
	
		
			
				|  |  | +                if(groupStudentListMap.containsKey(mg.getId())){
 | 
	
		
			
				|  |  | +                    List<EduHomeworkCardDto> eduHomeworkCardDtos = groupStudentListMap.get(mg.getId());
 | 
	
		
			
				|  |  | +                    for (EduHomeworkCardDto eduHomeworkCardDto : eduHomeworkCardDtos) {
 | 
	
		
			
				|  |  | +                        exceptStudentNum += eduHomeworkCardDto.getExceptStudentNum();
 | 
	
		
			
				|  |  | +                        submitStudentNum += eduHomeworkCardDto.getSubmitStudentNum();
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                ehs.setExceptStudentNum(exceptStudentNum);
 | 
	
		
			
				|  |  | +                ehs.setSubmitStudentNum(submitStudentNum);
 | 
	
		
			
				|  |  | +                if(exceptStudentNum<=0){
 | 
	
		
			
				|  |  | +                    ehs.setSubmitRate(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +                }else{
 | 
	
		
			
				|  |  | +                    ehs.setSubmitRate(new BigDecimal(submitStudentNum).divide(new BigDecimal(exceptStudentNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                dataList.add(ehs);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  |          return pageInfo;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public List<EduHomeworkStatDto> queryEduHomeworkStatDetail(StudentCourseHomeWorkQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        List<EduHomeworkStatDto> dataList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        MusicGroup musicGroup = musicGroupDao.get(queryInfo.getGroupId());
 | 
	
		
			
				|  |  | +        if(Objects.isNull(musicGroup)){
 | 
	
		
			
				|  |  | +            return dataList;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<StudentRegistration> studentRegistrations = studentRegistrationDao.findByMusicGroupIds(Arrays.asList(queryInfo.getGroupId()), StudentMusicGroupStatusEnum.NORMAL);
 | 
	
		
			
				|  |  | +        Map<Integer, Long> subjectStudentNumMap = studentRegistrations.stream().collect(Collectors.groupingBy(StudentRegistration::getActualSubjectId, Collectors.counting()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map<Integer, Subject> idSubjectMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        if(!CollectionUtils.isEmpty(subjectStudentNumMap)){
 | 
	
		
			
				|  |  | +            List<Subject> subjects = subjectDao.findBySubjectIds(new ArrayList<>(subjectStudentNumMap.keySet()));
 | 
	
		
			
				|  |  | +            idSubjectMap = subjects.stream().collect(Collectors.toMap(Subject::getId, s -> s, (s1, s2) -> s1));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<EduHomeworkCardDto> courseHomeworkStudentNumList = studentCourseHomeworkDao.countHomeworkSubjectStudentInfoWithMusicGroup(queryInfo.getGroupId(), queryInfo.getStartTime(), queryInfo.getEndTime());
 | 
	
		
			
				|  |  | +        List<EduHomeworkCardDto> homeworkStudentNumList = extracurricularExercisesReplyDao.countEduHomeworkSubjectStudentNumWithMusicGroup(queryInfo.getGroupId(), queryInfo.getStartTime(), queryInfo.getEndTime());
 | 
	
		
			
				|  |  | +        homeworkStudentNumList.addAll(courseHomeworkStudentNumList);
 | 
	
		
			
				|  |  | +        Map<Integer, List<EduHomeworkCardDto>> subjectStudentListMap = homeworkStudentNumList.stream().collect(Collectors.groupingBy(EduHomeworkCardDto::getSubjectId));
 | 
	
		
			
				|  |  | +        for (Map.Entry<Integer, Long> subjectStudentNumEntry : subjectStudentNumMap.entrySet()) {
 | 
	
		
			
				|  |  | +            EduHomeworkStatDto ehs = new EduHomeworkStatDto();
 | 
	
		
			
				|  |  | +            if(idSubjectMap.containsKey(subjectStudentNumEntry.getKey())){
 | 
	
		
			
				|  |  | +                ehs.setSubjectName(idSubjectMap.get(subjectStudentNumEntry.getKey()).getName());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            ehs.setGroupId(queryInfo.getGroupId());
 | 
	
		
			
				|  |  | +            ehs.setGroupName(musicGroup.getName());
 | 
	
		
			
				|  |  | +            if(subjectStudentNumMap.containsKey(subjectStudentNumEntry.getKey())){
 | 
	
		
			
				|  |  | +                ehs.setGroupStudentNum(Math.toIntExact(subjectStudentNumMap.get(subjectStudentNumEntry.getKey())));
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                ehs.setGroupStudentNum(0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            int exceptStudentNum = 0;
 | 
	
		
			
				|  |  | +            int submitStudentNum = 0;
 | 
	
		
			
				|  |  | +            if(subjectStudentListMap.containsKey(subjectStudentNumEntry.getKey())){
 | 
	
		
			
				|  |  | +                List<EduHomeworkCardDto> eduHomeworkCardDtos = subjectStudentListMap.get(subjectStudentNumEntry.getKey());
 | 
	
		
			
				|  |  | +                for (EduHomeworkCardDto eduHomeworkCardDto : eduHomeworkCardDtos) {
 | 
	
		
			
				|  |  | +                    exceptStudentNum += eduHomeworkCardDto.getExceptStudentNum();
 | 
	
		
			
				|  |  | +                    submitStudentNum += eduHomeworkCardDto.getSubmitStudentNum();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            ehs.setExceptStudentNum(exceptStudentNum);
 | 
	
		
			
				|  |  | +            ehs.setSubmitStudentNum(submitStudentNum);
 | 
	
		
			
				|  |  | +            if(exceptStudentNum<=0){
 | 
	
		
			
				|  |  | +                ehs.setSubmitRate(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                ehs.setSubmitRate(new BigDecimal(submitStudentNum).divide(new BigDecimal(exceptStudentNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            dataList.add(ehs);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return dataList;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |