Преглед изворни кода

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan пре 5 година
родитељ
комит
3deae4c3d5

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.Practice4ExercisesSituationDto;
 import com.ym.mec.biz.dal.dto.StudentAttendanceStatisticsResponse;
 import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
@@ -244,8 +245,8 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @param monday:
      * @return java.util.List<java.lang.Integer>
      */
-    List<Integer> findNoPracticeStudentIdsOnWeek(@Param("monday")String monday,
-                                                 @Param("sunday")String sunday);
+    List<Practice4ExercisesSituationDto> findNoPracticeStudentIdsOnWeek(@Param("monday")String monday,
+                                                                        @Param("sunday")String sunday);
 
     Integer findNoPracticeStudentTeacherId(@Param("studentId") Integer studentId);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentExtracurricularExercisesSituationDao.java

@@ -30,5 +30,7 @@ public interface StudentExtracurricularExercisesSituationDao extends BaseDAO<Lon
 
     List<StudentExercisesSituationDto> findExercisesSituations(Map<String, Object> params);
     int countExercisesSituations(Map<String, Object> params);
+
+    List<StudentExercisesSituationDto> findExercisesSituationsById(@Param("ids") List<Long> ids);
 	
 }

+ 40 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/Practice4ExercisesSituationDto.java

@@ -0,0 +1,40 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/4/12
+ */
+public class Practice4ExercisesSituationDto {
+
+    private Integer userId;
+
+    private Date courseStartTime;
+
+    private Integer actualTeacherId;
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Date getCourseStartTime() {
+        return courseStartTime;
+    }
+
+    public void setCourseStartTime(Date courseStartTime) {
+        this.courseStartTime = courseStartTime;
+    }
+
+    public Integer getActualTeacherId() {
+        return actualTeacherId;
+    }
+
+    public void setActualTeacherId(Integer actualTeacherId) {
+        this.actualTeacherId = actualTeacherId;
+    }
+}

+ 10 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesReplyServiceImpl.java

@@ -4,6 +4,7 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto;
 import com.ym.mec.biz.dal.dto.ExtraExerciseStudentsDto;
+import com.ym.mec.biz.dal.dto.Practice4ExercisesSituationDto;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
@@ -187,23 +188,26 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 		LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
 		LocalDate monDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
 		LocalDate sunDayDate = nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
-		List<Integer> noPracticeStudentIds = courseScheduleStudentPaymentDao.findNoPracticeStudentIdsOnWeek(monDayDate.toString(),sunDayDate.toString());
-		if(CollectionUtils.isEmpty(noPracticeStudentIds)){
+		List<Practice4ExercisesSituationDto> noPracticeStudents = courseScheduleStudentPaymentDao.findNoPracticeStudentIdsOnWeek(monDayDate.toString(),sunDayDate.toString());
+		if(CollectionUtils.isEmpty(noPracticeStudents)){
 			return;
 		}
+		Map<Integer, List<Practice4ExercisesSituationDto>> studentCourseMap = noPracticeStudents.stream().filter(e->Objects.nonNull(e.getCourseStartTime())).collect(Collectors.groupingBy(Practice4ExercisesSituationDto::getUserId));
+
 		List<ExtracurricularExercisesReply> noPracticeStudentExercisesInWeek = extracurricularExercisesReplyDao.findNoPracticeStudentExercisesInWeek(monDayDate.toString(), sunDayDate.toString());
 		Map<Integer, List<ExtracurricularExercisesReply>> studentExercisesMap = noPracticeStudentExercisesInWeek.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getUserId));
 
 		List<StudentExtracurricularExercisesSituation> results=new ArrayList<>();
-		for (Integer noPracticeStudentId : noPracticeStudentIds) {
+		for (Map.Entry<Integer, List<Practice4ExercisesSituationDto>> studentCourseEntry : studentCourseMap.entrySet()) {
 			StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation();
-			studentExtracurricularExercisesSituation.setStudentId(noPracticeStudentId);
-			studentExtracurricularExercisesSituation.setTeacherId(courseScheduleStudentPaymentDao.findNoPracticeStudentTeacherId(noPracticeStudentId));
+			studentExtracurricularExercisesSituation.setStudentId(studentCourseEntry.getKey());
+			studentCourseEntry.getValue().sort(Comparator.comparing(Practice4ExercisesSituationDto::getCourseStartTime).reversed());
+			studentExtracurricularExercisesSituation.setTeacherId(studentCourseEntry.getValue().get(0).getActualTeacherId());
 			studentExtracurricularExercisesSituation.setExpectExercisesNum(1);
 			studentExtracurricularExercisesSituation.setWeekOfYear(nowDate.get(DateUtil.weekFields.weekOfYear()));
 			studentExtracurricularExercisesSituation.setMonday(DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"));
 			studentExtracurricularExercisesSituation.setSunday(DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"));
-			List<ExtracurricularExercisesReply> studentExercises = studentExercisesMap.get(noPracticeStudentId);
+			List<ExtracurricularExercisesReply> studentExercises = studentExercisesMap.get(studentCourseEntry.getKey());
 			if(CollectionUtils.isEmpty(studentExercises)){
 				studentExtracurricularExercisesSituation.setActualExercisesNum(0);
 				studentExtracurricularExercisesSituation.setExercisesReplyNum(0);

+ 10 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -303,9 +303,17 @@
 		GROUP BY cssp.course_schedule_id_
 	</select>
 
-    <select id="findNoPracticeStudentIdsOnWeek" resultType="java.lang.Integer">
+	<resultMap id="Practice4ExercisesSituationDto" type="com.ym.mec.biz.dal.dto.Practice4ExercisesSituationDto">
+		<result property="userId" column="user_id_"/>
+		<result property="courseStartTime" column="start_class_time_"/>
+		<result property="actualTeacherId" column="actual_teacher_id_"/>
+	</resultMap>
+
+    <select id="findNoPracticeStudentIdsOnWeek" resultMap="Practice4ExercisesSituationDto">
 		SELECT
-			DISTINCT cssp.user_id_
+			cssp.user_id_,
+			CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
+			cs.actual_teacher_id_
 		FROM
 			course_schedule_student_payment cssp
 			LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_

+ 20 - 14
mec-biz/src/main/resources/config/mybatis/ExtracurricularExercisesReplyMapper.xml

@@ -307,20 +307,26 @@
 		WHERE
 			DATE_FORMAT( eer.create_time_, '%Y-%m-%d' ) BETWEEN #{monday} AND #{sunday}
 			AND EXISTS (
-			SELECT
-				cssp.user_id_
-			FROM
-				course_schedule_student_payment cssp
-			LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
-			WHERE
-			cssp.group_type_ = 'PRACTICE'
-			AND eer.user_id_ = cssp.user_id_
-			GROUP BY
-			cssp.user_id_
-			HAVING
-			MAX( cs.class_date_ ) &lt; #{monday}
-			ORDER BY
-			cssp.user_id_
+				SELECT
+					cssp.user_id_
+				FROM
+					course_schedule_student_payment cssp
+					LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
+					LEFT JOIN student s ON cssp.user_id_ = s.user_id_
+				WHERE
+					cssp.group_type_ = 'PRACTICE'
+					AND cssp.user_id_=eer.user_id_
+					AND s.service_tag_ = 1
+					AND cssp.user_id_ NOT IN (
+					SELECT
+						cssp1.user_id_
+					FROM
+						course_schedule_student_payment cssp1
+						LEFT JOIN course_schedule cs1 ON cssp1.course_schedule_id_ = cs1.id_
+					WHERE
+						cssp1.group_type_ = 'PRACTICE'
+						AND cs1.class_date_ BETWEEN #{monday} AND #{sunday}
+					)
 			)
 	</select>
 </mapper>

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

@@ -121,6 +121,7 @@
 
 	<select id="findExercisesSituations" resultMap="StudentExercisesSituationDto">
 		SELECT
+			MAX(id_) id_,
 			student_id_,
 			stu.username_ student_name_,
 			MAX(tea.real_name_) teacher_name_,
@@ -226,4 +227,10 @@
 			</trim>
 		) tmp
 	</select>
+	<select id="findExercisesSituationsById" resultMap="StudentExtracurricularExercisesSituation">
+		SELECT * FROM student_extracurricular_exercises_situation_ WHERE id_ IN
+		<foreach collection="ids" item="id" separator="," open="(" close=")">
+			#{id}
+		</foreach>
+	</select>
 </mapper>