Parcourir la source

Merge branch 'online1' of http://git.dayaedu.com/yonge/mec into music_score_zouxuan

zouxuan il y a 3 ans
Parent
commit
f57e2d2712

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

@@ -42,7 +42,7 @@ public interface ExtracurricularExercisesReplyDao extends BaseDAO<Long, Extracur
      * @param extraExerciseIds:
      * @return java.util.List<com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply>
      */
-    List<ExtracurricularExercisesReply> findExtraExerciseStudentsByExtraExercises(@Param("extraExerciseIds") List<Long> extraExerciseIds);
+    List<ExtracurricularExercisesReply> findExtraExerciseStudentsByExtraExercises(@Param("extraExerciseIds") List extraExerciseIds);
 
     /**
      * @describe 获取学生课外训练详情

+ 60 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesServiceImpl.java

@@ -4,9 +4,11 @@ import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.ExtracurricularExercises;
 import com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply;
+import com.ym.mec.biz.dal.entity.StudentCourseHomework;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.ImSendTypeEnum;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.ExtraExercilseQueryInfo;
 import com.ym.mec.biz.service.ExtracurricularExercisesService;
 import com.ym.mec.biz.service.StudentServeService;
@@ -49,6 +51,8 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
 	private CourseHomeworkDao courseHomeworkDao;
 	@Autowired
 	private StudentServeService studentServeService;
+	@Autowired
+	private StudentCourseHomeworkDao studentCourseHomeworkDao;
 
 	@Override
 	public BaseDAO<Long, ExtracurricularExercises> getDAO() {
@@ -236,13 +240,67 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
 			List<ExtracurricularExercisesHomeworkListDto> exercises = homeworksExercises.stream().filter(e -> e.getType().equals("EXERCISES")).collect(Collectors.toList());
 			if(exercises.size() > 0){
 				List<Integer> exercisesIdList = exercises.stream().map(e -> e.getHomeworkId()).collect(Collectors.toList());
-				dataList.addAll(extracurricularExercisesDao.findByIdList(exercisesIdList));
+				List<TeacherHomeworkListDto> byIdList = extracurricularExercisesDao.findByIdList(exercisesIdList);
+				if(byIdList != null && byIdList.size() > 0){
+					List<Integer> extraExerciseIds = byIdList.stream().map(TeacherHomeworkListDto::getHomeworkId).collect(Collectors.toList());
+					List<ExtracurricularExercisesReply> extraExerciseStudentsByExtraExercises = extracurricularExercisesReplyDao.findExtraExerciseStudentsByExtraExercises(extraExerciseIds);
+					Map<Long, List<ExtracurricularExercisesReply>> idStudentsMap = extraExerciseStudentsByExtraExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getExtracurricularExercisesId));
+					for (TeacherHomeworkListDto homeworkListDto : byIdList) {
+						List<ExtracurricularExercisesReply> extracurricularExercisesReplies = idStudentsMap.get(homeworkListDto.getHomeworkId().longValue());
+						if(CollectionUtils.isEmpty(extracurricularExercisesReplies)){
+							continue;
+						}
+						long noRepliedNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus()==1&&e.getIsReplied() == 0).count();
+						if(noRepliedNum<=0){
+							homeworkListDto.setIsReplied(1);
+						}
+						long notSubmitNum = extracurricularExercisesReplies.stream().filter(e -> e.getStatus() == 0).count();
+						if(notSubmitNum<=0){
+							homeworkListDto.setIsSubmit(1);
+						}
+						if(noRepliedNum>0){
+							homeworkListDto.setStatus(1);
+						}else if(noRepliedNum<=0&&notSubmitNum>0){
+							homeworkListDto.setStatus(2);
+						}else if(noRepliedNum<=0&&notSubmitNum<=0){
+							homeworkListDto.setStatus(3);
+						}
+					}
+					dataList.addAll(byIdList);
+				}
 			}
 			//课后作业
 			List<ExtracurricularExercisesHomeworkListDto> homeworkList = homeworksExercises.stream().filter(e -> e.getType().equals("HOMEWORK")).collect(Collectors.toList());
 			if(homeworkList.size() > 0){
 				List<Integer> homeworkIdList = homeworkList.stream().map(e -> e.getHomeworkId()).collect(Collectors.toList());
-				dataList.addAll(courseHomeworkDao.findByIdList(homeworkIdList));
+				List<TeacherHomeworkListDto> byIdList = courseHomeworkDao.findByIdList(homeworkIdList);
+				if(byIdList != null && byIdList.size() > 0){
+					List<Long> courseIds = byIdList.stream().mapToLong(TeacherHomeworkListDto::getCourseScheduleId).boxed().collect(Collectors.toList());
+					List<StudentCourseHomework> allStudentCourseHomeworks = studentCourseHomeworkDao.findByCourses(courseIds);
+					Map<Long, List<StudentCourseHomework>> homeworkStudentMap = allStudentCourseHomeworks.stream().collect(Collectors.groupingBy(StudentCourseHomework::getCourseScheduleId));
+					for (TeacherHomeworkListDto teacherHomeworkListDto : byIdList) {
+						List<StudentCourseHomework> studentCourseHomeworks = homeworkStudentMap.get(teacherHomeworkListDto.getCourseScheduleId().longValue());
+						if(CollectionUtils.isEmpty(studentCourseHomeworks)){
+							continue;
+						}
+						long noRepliedNum=studentCourseHomeworks.stream().filter(e -> YesOrNoEnum.YES.equals(e.getStatus())&&YesOrNoEnum.NO.equals(e.getIsReplied())).count();
+						if(noRepliedNum<=0){
+							teacherHomeworkListDto.setIsReplied(YesOrNoEnum.YES.getCode());
+						}
+						long notSubmitNum = studentCourseHomeworks.stream().filter(e -> e.getStatus().equals(YesOrNoEnum.NO)).count();
+						if(notSubmitNum<=0){
+							teacherHomeworkListDto.setIsSubmit(1);
+						}
+						if(noRepliedNum>0){
+							teacherHomeworkListDto.setStatus(1);
+						}else if(noRepliedNum<=0&&notSubmitNum>0){
+							teacherHomeworkListDto.setStatus(2);
+						}else if(noRepliedNum<=0&&notSubmitNum<=0){
+							teacherHomeworkListDto.setStatus(3);
+						}
+					}
+					dataList.addAll(byIdList);
+				}
 			}
 			dataList.removeAll(Collections.singleton(null));
 			dataList = dataList.stream().sorted(Comparator.comparing(TeacherHomeworkListDto::getDay).reversed()).collect(Collectors.toList());

+ 2 - 1
mec-biz/src/main/resources/config/mybatis/ExtracurricularExercisesMapper.xml

@@ -268,7 +268,8 @@
 		<include refid="global.limit"/>
 	</select>
 	<select id="findByIdList" resultMap="com.ym.mec.biz.dal.dao.CourseHomeworkDao.teacherHomeworkListDto">
-		SELECT id_ homework_id_,title_,content_,completed_num_,expect_num_,music_score_id_,expire_date_ expiry_date_,DATE_FORMAT(create_time_,'%Y-%m-%d') 'day_'
+		SELECT id_ homework_id_,title_,content_,completed_num_,expect_num_,music_score_id_,
+		       expire_date_ expiry_date_,DATE_FORMAT(create_time_,'%Y-%m-%d') 'day_'
 		FROM extracurricular_exercises WHERE id_ IN
 		<foreach collection="exercisesIdList" separator="," item="item" open="(" close=")">
 			#{item}