Forráskód Böngészése

fix:1、作业改造

Joburgess 4 éve
szülő
commit
bb5d9db131

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -440,4 +440,16 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
     BigDecimal countFinishCoursePriceWithMusicGroup(@Param("groupId") String groupId,
                                                     @Param("groupType") GroupType groupType,
                                                     @Param("userId") Integer userId);
+
+    /**
+     * @describe 获取学生指定日期之前指定类型的最后一节课
+     * @author Joburgess
+     * @date 2020/12/25 0025
+     * @param studentId:
+     * @param monday:
+     * @return com.ym.mec.biz.dal.entity.CourseSchedule
+     */
+    CourseSchedule getStudentHistoryLastCourse(@Param("studentId") Integer studentId,
+                                               @Param("monday") String monday,
+                                               @Param("courseType")CourseSchedule.CourseScheduleType courseType);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentServeCourseDto.java

@@ -14,6 +14,8 @@ public class StudentServeCourseDto {
 
     private Integer studentId;
 
+    private Integer leadTeacherId;
+
     private Long courseScheduleId;
 
     private GroupType groupType;
@@ -30,6 +32,14 @@ public class StudentServeCourseDto {
 
     private TeachModeEnum teachMode;
 
+    public Integer getLeadTeacherId() {
+        return leadTeacherId;
+    }
+
+    public void setLeadTeacherId(Integer leadTeacherId) {
+        this.leadTeacherId = leadTeacherId;
+    }
+
     public TeachModeEnum getTeachMode() {
         return teachMode;
     }

+ 23 - 27
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -290,6 +290,11 @@ public class StudentServeServiceImpl implements StudentServeService {
     @Override
     public void exercisesSituationStatistics2(String monday) {
         LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
+
+        if(StringUtils.isNotBlank(monday)){
+            nowDate=LocalDate.parse(monday, DateUtil.dateFormatter);
+        }
+
         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());
@@ -361,33 +366,13 @@ public class StudentServeServiceImpl implements StudentServeService {
                     }
                 }
             }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.MIX)){
-                List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.MIX);
-                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.MIX).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
-                if(CollectionUtils.isEmpty(weekCourseInfo)){
-                    StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-                            futureCourseInfo.get(0).getActualTeacherId(),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<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
-                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
-                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
-                        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());
-                    }
-                    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"),
-                                "EXERCISE", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
-                        studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
-                        results.add(studentExtracurricularExercisesSituation);
-                    }
-                }
+                CourseSchedule studentHistoryLastCourse = courseScheduleStudentPaymentDao.getStudentHistoryLastCourse(studentCourseMapEntry.getKey(), monday, CourseSchedule.CourseScheduleType.SINGLE);
+                StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
+                        Objects.isNull(studentHistoryLastCourse)?studentCourseMapEntry.getValue().get(0).getLeadTeacherId():studentHistoryLastCourse.getActualTeacherId(),
+                        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 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());
@@ -404,6 +389,8 @@ public class StudentServeServiceImpl implements StudentServeService {
                         StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
                         if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
                             teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
+                        }else{
+                            continue;
                         }
                         teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
                     }
@@ -420,7 +407,16 @@ public class StudentServeServiceImpl implements StudentServeService {
                 continue;
             }
         }
+        BigDecimal currentPage1=BigDecimal.ONE,
+                pageSize1=new BigDecimal(10000),
+                total1=new BigDecimal(results.size()),
+                totalPage1=total1.divide(pageSize1, BigDecimal.ROUND_UP);
 
+        while (currentPage1.compareTo(totalPage1)<=0){
+            List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
+            studentExtracurricularExercisesSituationDao.batchInsert(rows);
+            currentPage1=currentPage1.add(BigDecimal.ONE);
+        }
     }
 
     @Override

+ 9 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -674,4 +674,13 @@
 		SELECT SUM(expect_price_)-SUM(actual_price_) FROM course_schedule_student_payment
 		WHERE music_group_id_=#{groupId} AND user_id_=#{userId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 	</select>
+
+    <select id="getStudentHistoryLastCourse" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule">
+		SELECT cs.* FROM course_schedule_student_payment cssp
+		LEFT JOIN course_schedule cs ON cs.id_=cssp.user_id_
+		WHERE cssp.user_id_=#{studentId}
+		  AND cs.class_date_&lt;#{monday}
+		  AND cs.type_=#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		ORDER BY CONCAT(cs.class_date_, ' ', cs.start_class_time_) LIMIT 1
+	</select>
 </mapper>

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

@@ -473,6 +473,7 @@
 
     <resultMap id="StudentServeCourseDto" type="com.ym.mec.biz.dal.dto.StudentServeCourseDto">
         <result column="student_id_" property="studentId"/>
+        <result column="lead_teacher_id_" property="leadTeacherId"/>
         <result column="course_schedule_id_" property="courseScheduleId"/>
         <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="music_group_id_" property="musicGroupId"/>
@@ -485,6 +486,7 @@
     <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_,
@@ -493,8 +495,10 @@
             CONCAT(cs.class_date_, ' ', cs.start_class_time_) course_start_time_,
             cs.teach_mode_
         FROM course_schedule_student_payment cssp
-                 LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
-        WHERE cs.class_date_&gt;=#{monday}
+            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 cs.class_date_&gt;=#{monday}
           AND cs.type_ IN ('SINGLE','VIP','MIX','PRACTICE')
         ORDER BY cssp.user_id_,start_class_time_
     </select>

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -253,8 +253,8 @@ public class TaskController extends BaseController {
 	//学生服务信息统计
 	@GetMapping("/exercisesSituationStatistics")
 	public void exercisesSituationStatistics(){
-//		extracurricularExercisesReplyService.exercisesSituationStatistics2(null);
-		studentServeService.exercisesSituationStatistics(null);
+		studentServeService.exercisesSituationStatistics2(null);
+//		studentServeService.exercisesSituationStatistics(null);
 	}
 
 	//更新学生运营指标