|  | @@ -9,12 +9,10 @@ import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.GroupType;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.TeacherRemindTypeEnum;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.page.StudentExercisesSituationQueryInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.page.StudentServiceDetailQueryInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.page.TeacherServeHomeworkQueryInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.page.TeacherServeQueryInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.page.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.StudentExtracurricularExercisesSituationService;
 | 
	
		
			
				|  |  |  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;
 | 
	
	
		
			
				|  | @@ -30,6 +28,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;
 | 
	
	
		
			
				|  | @@ -412,13 +411,20 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	public PageInfo<TeacherServeHomeworkPojo> queryTeacherServeHomeworkDetail1(TeacherServeHomeworkQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | -		if(Objects.isNull(queryInfo.getMonth())){
 | 
	
		
			
				|  |  | -			throw new BizException("请指定课程时间");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +//		if(Objects.isNull(queryInfo.getMonth())){
 | 
	
		
			
				|  |  | +//			throw new BizException("请指定课程时间");
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  |  		PageInfo<TeacherServeHomeworkPojo> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  |  		//获取时间段内有服务指标的课程(课后作业)
 | 
	
		
			
				|  |  | -		Date firstDayOfMonth = DateUtil.getFirstDayOfMonth(queryInfo.getMonth());
 | 
	
		
			
				|  |  | -		Date lastDayOfMonth = DateUtil.getLastDayOfMonth(queryInfo.getMonth());
 | 
	
		
			
				|  |  | +		Date firstDayOfMonth;
 | 
	
		
			
				|  |  | +		Date lastDayOfMonth;
 | 
	
		
			
				|  |  | +		if(Objects.isNull(queryInfo.getStartTime())){
 | 
	
		
			
				|  |  | +			firstDayOfMonth = DateUtil.getFirstDayOfMonth(queryInfo.getMonth());
 | 
	
		
			
				|  |  | +			lastDayOfMonth = DateUtil.getLastDayOfMonth(queryInfo.getMonth());
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			firstDayOfMonth = queryInfo.getStartTime();
 | 
	
		
			
				|  |  | +			lastDayOfMonth = queryInfo.getEndTime();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  		List<Long> courseIds = studentExtracurricularExercisesSituationDao.queryCourseIdByClassDate(firstDayOfMonth,lastDayOfMonth,queryInfo.getTeacherId());
 | 
	
		
			
				|  |  |  		if(courseIds == null || courseIds.size() == 0){
 | 
	
		
			
				|  |  |  			return pageInfo;
 | 
	
	
		
			
				|  | @@ -596,7 +602,7 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 | 
	
		
			
				|  |  |  			return;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		studentExtracurricularExercisesSituationDao.batchInsert(situations);
 | 
	
		
			
				|  |  | -		String collect = situations.stream().map(e -> e.getCourseIds()).filter(e -> StringUtils.isNotEmpty(e)).collect(Collectors.joining(","));
 | 
	
		
			
				|  |  | +		String collect = situations.stream().map(e -> e.getCourseIds()).filter(e -> StringUtils.isNotEmpty(e)).distinct().collect(Collectors.joining(","));
 | 
	
		
			
				|  |  |  		if(StringUtils.isNotEmpty(collect)){
 | 
	
		
			
				|  |  |  			//更新课程服务指标
 | 
	
		
			
				|  |  |  			courseScheduleStatisticsDao.updateCourseService(collect,1);
 | 
	
	
		
			
				|  | @@ -617,6 +623,42 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 | 
	
		
			
				|  |  |  		studentExtracurricularExercisesSituationDao.deleteByStudent(studentId,monday);
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  | +	public TeacherExercisesServiceDto getStatistics(ExtraExercilseQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +		TeacherExercisesServiceDto serviceDto = new TeacherExercisesServiceDto();
 | 
	
		
			
				|  |  | +		List<Integer> teacherIds = new ArrayList();
 | 
	
		
			
				|  |  | +		teacherIds.add(queryInfo.getTeacherId());
 | 
	
		
			
				|  |  | +		List<StudentExtracurricularExercisesSituation> teacherServeWithDate =
 | 
	
		
			
				|  |  | +				studentExtracurricularExercisesSituationDao.findTeacherServeWithDate(queryInfo.getStartTime(), queryInfo.getEndTime(), teacherIds, null);
 | 
	
		
			
				|  |  | +		if(!CollectionUtils.isEmpty(teacherServeWithDate)){
 | 
	
		
			
				|  |  | +			//预计训练次数
 | 
	
		
			
				|  |  | +			double expectExercisesNum = teacherServeWithDate.stream().mapToDouble(e -> e.getExpectExercisesNum()).sum();
 | 
	
		
			
				|  |  | +			//实际训练次数
 | 
	
		
			
				|  |  | +			double actualExercisesNum = teacherServeWithDate.stream().mapToInt(e -> e.getActualExercisesNum()).sum();
 | 
	
		
			
				|  |  | +			//布置率
 | 
	
		
			
				|  |  | +			BigDecimal oneHundred = new BigDecimal(100);
 | 
	
		
			
				|  |  | +			if(expectExercisesNum > 0d){
 | 
	
		
			
				|  |  | +				BigDecimal submitRate = new BigDecimal(actualExercisesNum).divide(new BigDecimal(expectExercisesNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHundred).setScale(0);
 | 
	
		
			
				|  |  | +				serviceDto.setExpectExercisesRate(submitRate + "%");
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			//训练提交次数
 | 
	
		
			
				|  |  | +			double exercisesReplyNum = teacherServeWithDate.stream().mapToInt(e -> e.getExercisesReplyNum()).sum();
 | 
	
		
			
				|  |  | +			//提交率
 | 
	
		
			
				|  |  | +			if(actualExercisesNum > 0d){
 | 
	
		
			
				|  |  | +				BigDecimal submitRate = new BigDecimal(exercisesReplyNum).divide(new BigDecimal(actualExercisesNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHundred).setScale(0);
 | 
	
		
			
				|  |  | +				serviceDto.setExercisesReplyRate(submitRate + "%");
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			//点评次数
 | 
	
		
			
				|  |  | +			double exercisesMessageNum = teacherServeWithDate.stream().mapToInt(e -> e.getExercisesMessageNum()).sum();
 | 
	
		
			
				|  |  | +			//点评率
 | 
	
		
			
				|  |  | +			if(exercisesReplyNum > 0d){
 | 
	
		
			
				|  |  | +				BigDecimal submitRate = new BigDecimal(exercisesMessageNum).divide(new BigDecimal(exercisesReplyNum), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP).multiply(oneHundred).setScale(0);
 | 
	
		
			
				|  |  | +				serviceDto.setExercisesMessageRate(submitRate + "%");
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return serviceDto;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |  	public void delSituations(List<StudentExtracurricularExercisesSituation> situations){
 | 
	
		
			
				|  |  |  		if (CollectionUtils.isEmpty(situations)){
 | 
	
	
		
			
				|  | @@ -624,7 +666,7 @@ public class StudentExtracurricularExercisesSituationServiceImpl extends BaseSer
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  //		List<Long> collect1 = situations.stream().map(e -> e.getId()).collect(Collectors.toList());
 | 
	
		
			
				|  |  |  //		studentExtracurricularExercisesSituationDao.batchDelete(collect1);
 | 
	
		
			
				|  |  | -		String collect = situations.stream().map(e -> e.getCourseIds()).filter(e -> StringUtils.isNotEmpty(e)).collect(Collectors.joining(","));
 | 
	
		
			
				|  |  | +		String collect = situations.stream().map(e -> e.getCourseIds()).filter(e -> StringUtils.isNotEmpty(e)).distinct().collect(Collectors.joining(","));
 | 
	
		
			
				|  |  |  		if(StringUtils.isNotEmpty(collect)){
 | 
	
		
			
				|  |  |  			//更新课程服务指标
 | 
	
		
			
				|  |  |  			courseScheduleStatisticsDao.updateCourseService(collect,0);
 |