Ver Fonte

修改定时任务

cy há 3 anos atrás
pai
commit
68a337e1fb

+ 19 - 19
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleStudentDao.java

@@ -1,19 +1,19 @@
-package com.yonge.cooleshow.biz.dal.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.yonge.cooleshow.biz.dal.entity.CourseScheduleStudent;
-import com.yonge.cooleshow.biz.dal.vo.CourseScheduleStudentVo;
-
-import java.util.List;
-
-/**
- * @Author: cy
- * @Date: 2022/5/27
- */
-public interface CourseScheduleStudentDao extends BaseMapper<CourseScheduleStudent> {
-    //批量添加学员
-    void insertBatch(List<CourseScheduleStudent> list);
-
-    //查询课程对应的老师学员
-    List<CourseScheduleStudentVo> selectUser();
-}
+//package com.yonge.cooleshow.biz.dal.dao;
+//
+//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+//import com.yonge.cooleshow.biz.dal.entity.CourseScheduleStudent;
+//import com.yonge.cooleshow.biz.dal.vo.CourseScheduleStudentVo;
+//
+//import java.util.List;
+//
+///**
+// * @Author: cy
+// * @Date: 2022/5/27
+// */
+//public interface CourseScheduleStudentDao extends BaseMapper<CourseScheduleStudent> {
+//    //批量添加学员
+//    void insertBatch(List<CourseScheduleStudent> list);
+//
+//    //查询课程对应的老师学员
+//    List<CourseScheduleStudentVo> selectUser();
+//}

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -3,6 +3,7 @@ package com.yonge.cooleshow.biz.dal.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.yonge.cooleshow.biz.dal.entity.CourseScheduleStudentPayment;
 import com.yonge.cooleshow.biz.dal.vo.CourseScheduleStudentPaymentVo;
+import com.yonge.cooleshow.biz.dal.vo.CourseScheduleStudentVo;
 import com.yonge.cooleshow.biz.dal.vo.LiveCourseInfoVo;
 import org.apache.ibatis.annotations.Param;
 
@@ -84,5 +85,8 @@ public interface CourseScheduleStudentPaymentDao extends BaseMapper<CourseSchedu
      * @date 2022/5/7 16:44
      */
     void adjustPlayMidiAndMusicSheet(Long scheduleId, Long userId, String content, String musicSheetJson);
+
+    //查询报课学员
+    List<CourseScheduleStudentVo> selectUser();
 }
 

+ 54 - 54
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseScheduleStudent.java

@@ -1,54 +1,54 @@
-package com.yonge.cooleshow.biz.dal.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * @Author: cy
- * @Date: 2022/5/26
- */
-@ApiModel
-public class CourseScheduleStudent implements Serializable {
-    @TableId(value = "id_", type = IdType.AUTO)
-    @ApiModelProperty(value = "主键")
-    private Long id;
-
-    @TableField("course_id_")
-    @ApiModelProperty(value = "课程id")
-    private Long courseId;
-
-    @TableField("student_id_")
-    @ApiModelProperty(value = "学生id")
-    private Long studentId;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getCourseId() {
-        return courseId;
-    }
-
-    public void setCourseId(Long courseId) {
-        this.courseId = courseId;
-    }
-
-    public Long getStudentId() {
-        return studentId;
-    }
-
-    public void setStudentId(Long studentId) {
-        this.studentId = studentId;
-    }
-}
-
+//package com.yonge.cooleshow.biz.dal.entity;
+//
+//import com.baomidou.mybatisplus.annotation.IdType;
+//import com.baomidou.mybatisplus.annotation.TableField;
+//import com.baomidou.mybatisplus.annotation.TableId;
+//import io.swagger.annotations.ApiModel;
+//import io.swagger.annotations.ApiModelProperty;
+//
+//import java.io.Serializable;
+//import java.util.Date;
+//
+///**
+// * @Author: cy
+// * @Date: 2022/5/26
+// */
+//@ApiModel
+//public class CourseScheduleStudent implements Serializable {
+//    @TableId(value = "id_", type = IdType.AUTO)
+//    @ApiModelProperty(value = "主键")
+//    private Long id;
+//
+//    @TableField("course_id_")
+//    @ApiModelProperty(value = "课程id")
+//    private Long courseId;
+//
+//    @TableField("student_id_")
+//    @ApiModelProperty(value = "学生id")
+//    private Long studentId;
+//
+//    public Long getId() {
+//        return id;
+//    }
+//
+//    public void setId(Long id) {
+//        this.id = id;
+//    }
+//
+//    public Long getCourseId() {
+//        return courseId;
+//    }
+//
+//    public void setCourseId(Long courseId) {
+//        this.courseId = courseId;
+//    }
+//
+//    public Long getStudentId() {
+//        return studentId;
+//    }
+//
+//    public void setStudentId(Long studentId) {
+//        this.studentId = studentId;
+//    }
+//}
+//

+ 24 - 21
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -98,8 +98,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     private PianoRoomTimeDao pianoRoomTimeDao;
     @Autowired
     private UserBindingTeacherDao userBindingTeacherDao;
-    @Autowired
-    private CourseScheduleStudentDao courseScheduleStudentDao;
+    //    @Autowired
+//    private CourseScheduleStudentDao courseScheduleStudentDao;
     @Autowired
     private CourseScheduleRecordDao recordDao;
 
@@ -1503,14 +1503,18 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         }
 
         //课程结束(NOW ≥ 结束时间)
-        List<CourseScheduleStudentVo> userList = courseScheduleStudentDao.selectUser();
+        List<CourseScheduleStudentVo> userList = paymentDao.selectUser();
         if (CollectionUtils.isNotEmpty(userList)) {
             //更新学生最近结课时间
-            pianoRoomTimeDao.updateEndTime(userList);
+            List<CourseScheduleStudentVo> pianoUserList = userList.stream().filter((CourseScheduleStudentVo s) -> s.getType().equals(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode())).collect(Collectors.toList());
+            if (CollectionUtils.isNotEmpty(pianoUserList)) {
+                pianoRoomTimeDao.updateEndTime(pianoUserList);
+            }
 
+            //统计琴房课消耗时长
             List<CourseScheduleRecord> recordList = recordDao.sumCourseTime();
             if (CollectionUtils.isNotEmpty(recordList)) {
-                //记录消耗课时
+                //时长消费记录
                 recordDao.insertBatch(recordList);
 
                 //释放冻结课时
@@ -1533,28 +1537,27 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         }
 
         //查完完成的课程
-        List<CourseCompleteVo> completeList=baseMapper.selectComplete();
-        if (CollectionUtils.isNotEmpty(completeList)){
+        List<CourseCompleteVo> completeList = baseMapper.selectComplete();
+        if (CollectionUtils.isNotEmpty(completeList)) {
             List<Long> gids = completeList.stream().map(CourseCompleteVo::getCourseGroupId).collect(Collectors.toList());
             List<CourseGroup> courseGroups = courseGroupService.getDao().selectList(Wrappers.<CourseGroup>lambdaQuery().in(CourseGroup::getId, gids));
-            if(CollectionUtils.isNotEmpty(courseGroups)){
-                List<Long> ids=new ArrayList<>();
+            if (CollectionUtils.isNotEmpty(courseGroups)) {
+                List<Long> ids = new ArrayList<>();
                 for (CourseGroup group : courseGroups) {
                     for (CourseCompleteVo complete : completeList) {
                         Integer courseNum = group.getCourseNum();
                         Integer completeCount = complete.getCourseCount();
-                        if (courseNum.equals(completeCount)){
+                        if (courseNum.equals(completeCount)) {
                             ids.add(complete.getCourseGroupId());
                         }
                     }
                 }
-                if(CollectionUtils.isNotEmpty(ids)){
+                if (CollectionUtils.isNotEmpty(ids)) {
                     //同步课程组状态
                     courseGroupService.getDao().updateBatch(ids);
                 }
             }
         }
-
     }
 
     /**
@@ -1591,7 +1594,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     public PageInfo<CourseStudentVo> selectStudent(Map<String, Object> param) {
         Integer courseId = (Integer) param.get("courseId");
         if (courseId != null) {
-            List<CourseScheduleStudent> studentList = courseScheduleStudentDao.selectList(Wrappers.<CourseScheduleStudent>lambdaQuery().eq(CourseScheduleStudent::getCourseId, courseId));
+            List<CourseScheduleStudentPayment> studentList = paymentDao.selectList(Wrappers.<CourseScheduleStudentPayment>lambdaQuery().eq(CourseScheduleStudentPayment::getCourseId, courseId));
             param.put("studentList", studentList);//根据课程id查询报课学员
         }
         return PageUtil.pageInfo(userBindingTeacherDao.selectStudent(PageUtil.getPageInfo(param), param));
@@ -1647,7 +1650,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 
         //校验学员是否绑定
         List<UserBindingTeacher> bindingTeachers = userBindingTeacherDao.selectList(Wrappers.<UserBindingTeacher>lambdaQuery().eq(UserBindingTeacher::getTeacherId, teacherId));
-        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(bindingTeachers)) {
+        if (CollectionUtils.isEmpty(bindingTeachers)) {
             throw new BizException("无绑定学员");
         }
         List<Long> studentList = bindingTeachers.stream().map(UserBindingTeacher::getStudentId).collect(Collectors.toList());
@@ -1710,14 +1713,14 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
             baseMapper.insert(schedule);
 
             //添加course_schedule_student
-            List<CourseScheduleStudent> list = new ArrayList<>();
             for (Long studentId : studentIds) {
-                CourseScheduleStudent teacherTime = new CourseScheduleStudent();
-                teacherTime.setStudentId(studentId);
-                teacherTime.setCourseId(schedule.getId());
-                list.add(teacherTime);
+                CourseScheduleStudentPayment payment = new CourseScheduleStudentPayment();
+                payment.setCourseGroupId(courseGroup.getId());
+                payment.setCourseId(schedule.getId());
+                payment.setUserId(studentId);
+                payment.setCourseType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
+                courseScheduleStudentPaymentService.save(payment);
             }
-            courseScheduleStudentDao.insertBatch(list);
         }
 
         //扣减piano_room_time
@@ -1745,7 +1748,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      */
     @Override
     public PageInfo<CourseScheduleRecordVo> selectConsumeTimeList(Map<String, Object> param) {
-        param.put("type",CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
+        param.put("type", CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
         return PageUtil.pageInfo(recordDao.selectConsumeTimeList(PageUtil.getPageInfo(param), param));
     }
 }

+ 11 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseScheduleStudentVo.java

@@ -24,13 +24,22 @@ public class CourseScheduleStudentVo implements Serializable {
     private Long studentId;
 
     @ApiModelProperty(value = "结课时间")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endTime;
 
     @ApiModelProperty(value = "单课时长(分)")
     private Integer singleCourseTime;
 
+    @ApiModelProperty(value = "课程类型")
+    private String type;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
     public Integer getSingleCourseTime() {
         return singleCourseTime;
     }

+ 20 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleRecordMapper.xml

@@ -2,11 +2,26 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yonge.cooleshow.biz.dal.dao.CourseScheduleRecordDao">
     <select id="sumCourseTime" resultType="com.yonge.cooleshow.biz.dal.entity.CourseScheduleRecord">
-        SELECT * FROM(
-        SELECT teacherId, courseId, SUM(singleCourseTime) AS consumTime, COUNT(studentId) AS studentCount, endTime FROM (
-        SELECT c.id_ AS courseId, c.teacher_id_ AS teacherId, s.student_id_ AS studentId, c.end_time_ AS endTime, c.single_course_time_ AS singleCourseTime
-        FROM course_schedule c LEFT JOIN course_schedule_student s ON c.id_ = s.course_id_ WHERE c.lock_ = 0 AND c.status_ IN ('ING', 'NOT_START') AND NOW() >= c.end_time_ ) a GROUP BY courseId) b
-        WHERE b.studentCount!=0
+        SELECT
+            teacherId,
+            courseId,
+            SUM( singleCourseTime ) AS consumTime,
+            COUNT( studentId ) AS studentCount,
+            endTime
+        FROM
+            (SELECT
+                 c.id_ AS courseId,
+                 c.teacher_id_ AS teacherId,
+                 p.user_id_ AS studentId,
+                 c.end_time_ AS endTime,
+                 c.single_course_time_ AS singleCourseTime
+             FROM course_schedule c
+             LEFT JOIN course_schedule_student_payment p ON c.id_ = p.course_id_
+             WHERE c.type_ = 'PIANO_ROOM_CLASS'
+             AND c.lock_ = 0
+             AND c.status_ IN ( 'ING', 'NOT_START' )
+             AND NOW() >= c.end_time_) a
+        GROUP BY courseId
     </select>
     <select id="countTimeByTeacherId" resultType="java.lang.Long">
         SELECT SUM(consum_time_) FROM course_schedule_record WHERE teacher_id_=#{teacherId} AND  date_format(end_time_,'%Y-%m') = #{month}

+ 0 - 23
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleStudentMapper.xml

@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.yonge.cooleshow.biz.dal.dao.CourseScheduleStudentDao">
-    <insert id="insertBatch">
-        INSERT INTO course_schedule_student (course_id_, student_id_) VALUES
-        <foreach collection ="list" item="item" separator =",">
-            (#{item.courseId}, #{item.studentId})
-        </foreach >
-    </insert>
-    <select id="selectUser" resultType="com.yonge.cooleshow.biz.dal.vo.CourseScheduleStudentVo">
-        SELECT
-        c.id_ AS courseId,
-        c.teacher_id_ AS teacherId,
-        s.student_id_ AS studentId,
-        c.end_time_ AS endTime,
-        c.single_course_time_ AS singleCourseTime
-        FROM course_schedule c
-        LEFT JOIN course_schedule_student s ON c.id_ = s.course_id_
-        WHERE c.lock_ = 0
-        AND c.status_ IN ('ING','NOT_START')
-        AND NOW() &gt;= c.end_time_
-    </select>
-</mapper>

+ 15 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -147,4 +147,19 @@
         from course_schedule_student_payment cssp
         where cssp.course_group_id_ = #{courseGroupId}
     </select>
+    <select id="selectUser" resultType="com.yonge.cooleshow.biz.dal.vo.CourseScheduleStudentVo">
+        SELECT
+            c.id_ AS courseId,
+            c.teacher_id_ AS teacherId,
+            p.user_id_ AS studentId,
+            c.end_time_ AS endTime,
+            c.single_course_time_ AS singleCourseTime,
+            c.type_ AS type
+        FROM course_schedule c
+        LEFT JOIN course_schedule_student_payment p ON c.id_ = p.course_id_
+        WHERE c.lock_ = 0
+        AND c.status_ IN ('ING','NOT_START')
+        AND NOW() &gt;= c.end_time_
+        ORDER BY c.end_time_
+    </select>
 </mapper>

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserBindingTeacherMapper.xml

@@ -26,7 +26,7 @@
             <if test="param.studentList !=null and param.studentList.size>0">
                 AND su.id_ IN
                 <foreach collection="param.studentList" item="item" open="(" separator="," close=")">
-                    #{item.studentId}
+                    #{item.userId}
                 </foreach>
             </if>
         </where>

+ 1 - 1
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherCourseScheduleController.java

@@ -172,7 +172,7 @@ public class TeacherCourseScheduleController extends BaseController {
     }
 
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "subjectId", dataType = "Long", value = "声部id"),
+            @ApiImplicitParam(name = "subjectId", dataType = "Long", value = "学员声部id"),
             @ApiImplicitParam(name = "userName", dataType = "String", value = "学员姓名"),
             @ApiImplicitParam(name = "courseId", dataType = "Long", value = "课程id"),
     })