Browse Source

琴房课

cy 3 years ago
parent
commit
65e0282986
20 changed files with 392 additions and 77 deletions
  1. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java
  2. 22 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleRecordDao.java
  3. 4 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleStudentDao.java
  4. 23 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/PianoRoomTimeDao.java
  5. 0 14
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/PinaoRoomTimeDao.java
  6. 114 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseScheduleRecord.java
  7. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/PianoRoomTime.java
  8. 3 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java
  9. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/PianoRoomTimeService.java
  10. 52 21
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java
  11. 20 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PianoRoomTimeServiceImpl.java
  12. 0 20
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PinaoRoomTimeServiceImpl.java
  13. 74 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseScheduleStudentVo.java
  14. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/PianoRoomTimeVo.java
  15. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  16. 20 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleRecordMapper.xml
  17. 13 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleStudentMapper.xml
  18. 26 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/PianoRoomTimeDao.xml
  19. 0 12
      cooleshow-user/user-biz/src/main/resources/config/mybatis/PinaoRoomTimeMapper.xml
  20. 14 2
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherCourseScheduleController.java

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java

@@ -218,7 +218,7 @@ public interface CourseScheduleDao extends BaseMapper<CourseSchedule> {
     void updateStartTime(List<CourseSchedule> list);
 
     //更新课程状态
-    void updateEndTime(List<CourseSchedule> list);
+    void updateEndTime(List<CourseScheduleStudentVo> list);
 
     //根据日期查课程id
     List<Long> selectIdList(String day);

+ 22 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleRecordDao.java

@@ -0,0 +1,22 @@
+package com.yonge.cooleshow.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yonge.cooleshow.biz.dal.entity.CourseScheduleRecord;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @Author: cy
+ * @Date: 2022/5/30
+ */
+public interface CourseScheduleRecordDao extends BaseMapper<CourseScheduleRecord> {
+    //统计人数&时长
+    List<CourseScheduleRecord> sumCourseTime();
+
+    //批量添加
+    void insertBatch(@Param("recordList") List<CourseScheduleRecord> recordList);
+
+    //消耗时长
+    Long countTimeByTeacherId(@Param("teacherId")Long teacherId,@Param("month") String month);
+}

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

@@ -2,6 +2,7 @@ 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;
 
@@ -12,4 +13,7 @@ import java.util.List;
 public interface CourseScheduleStudentDao extends BaseMapper<CourseScheduleStudent> {
     //批量添加学员
     void insertBatch(List<CourseScheduleStudent> list);
+
+    //查询课程对应的老师学员
+    List<CourseScheduleStudentVo> selectUser();
 }

+ 23 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/PianoRoomTimeDao.java

@@ -0,0 +1,23 @@
+package com.yonge.cooleshow.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yonge.cooleshow.biz.dal.entity.PianoRoomTime;
+import com.yonge.cooleshow.biz.dal.vo.CourseScheduleStudentVo;
+import com.yonge.cooleshow.biz.dal.vo.PianoRoomTimeVo;
+
+import java.util.List;
+
+/**
+ * @Author: cy
+ * @Date: 2022/5/26
+ */
+public interface PianoRoomTimeDao extends BaseMapper<PianoRoomTime> {
+    //查询琴房剩余时长、冻结时长、统计学员人数
+    PianoRoomTimeVo selectRemainTime(Long teacherId);
+
+    //更新结课时间
+    void updateEndTime(List<CourseScheduleStudentVo> list);
+
+    //释放冻结时间
+    void updateBatch(List<PianoRoomTime> list);
+}

+ 0 - 14
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/PinaoRoomTimeDao.java

@@ -1,14 +0,0 @@
-package com.yonge.cooleshow.biz.dal.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.yonge.cooleshow.biz.dal.entity.PinaoRoomTime;
-import com.yonge.cooleshow.biz.dal.vo.PinaoRoomTimeVo;
-
-/**
- * @Author: cy
- * @Date: 2022/5/26
- */
-public interface PinaoRoomTimeDao extends BaseMapper<PinaoRoomTime> {
-    //查询琴房剩余时长、冻结时长、统计学员人数
-    PinaoRoomTimeVo selectRemainTime(Long teacherId);
-}

+ 114 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseScheduleRecord.java

@@ -0,0 +1,114 @@
+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/30
+ */
+@ApiModel
+public class CourseScheduleRecord implements Serializable {
+    @TableId(value = "id_", type = IdType.AUTO)
+    @ApiModelProperty(value = "主键")
+    private Long id;
+
+    @TableField("course_id_")
+    @ApiModelProperty(value = "课程id")
+    private Long courseId;
+
+    @TableField("teacher_id_")
+    @ApiModelProperty(value = "老师id")
+    private Long teacherId;
+
+    @TableField("student_count_")
+    @ApiModelProperty(value = "上课学员人数")
+    private Integer studentCount;
+
+    @TableField("consum_time_")
+    @ApiModelProperty(value = "总消耗时长")
+    private Integer consumTime;
+
+    @TableField("end_time_")
+    @ApiModelProperty(value = "结课时间")
+    private Date endTime;
+
+    @TableField("created_time_")
+    @ApiModelProperty(value = "创建时间")
+    private Date createdTime;
+
+    @TableField("updated_time_")
+    @ApiModelProperty(value = "更新时间")
+    private Date updatedTime;
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Long getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Long teacherId) {
+        this.teacherId = teacherId;
+    }
+
+    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 Integer getStudentCount() {
+        return studentCount;
+    }
+
+    public void setStudentCount(Integer studentCount) {
+        this.studentCount = studentCount;
+    }
+
+    public Integer getConsumTime() {
+        return consumTime;
+    }
+
+    public void setConsumTime(Integer consumTime) {
+        this.consumTime = consumTime;
+    }
+
+    public Date getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Date createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    public Date getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Date updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+}
+

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/PinaoRoomTime.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/PianoRoomTime.java

@@ -14,7 +14,7 @@ import java.util.Date;
  * @Date: 2022/5/26
  */
 @ApiModel
-public class PinaoRoomTime implements Serializable {
+public class PianoRoomTime implements Serializable {
     @TableId(value = "id_", type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
     private Long id;

+ 3 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java

@@ -238,10 +238,12 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
 
     void teacherSalaryTask();
 
-    PinaoRoomTimeVo selectRemainTime(Long teacherId);
+    PianoRoomTimeVo selectRemainTime(Long teacherId);
 
     PageInfo<CourseStudentVo> selectStudent(Map<String, Object> param);
 
     void arrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId);
+
+    Map<String, Object> selectConsumeTime(String month, Long teacherId);
 }
 

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/PinaoRoomTimeService.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/PianoRoomTimeService.java

@@ -1,12 +1,12 @@
 package com.yonge.cooleshow.biz.dal.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.yonge.cooleshow.biz.dal.entity.PinaoRoomTime;
+import com.yonge.cooleshow.biz.dal.entity.PianoRoomTime;
 
 /**
  * @Author: cy
  * @Date: 2022/5/26
  */
-public interface PinaoRoomTimeService extends IService<PinaoRoomTime> {
+public interface PianoRoomTimeService extends IService<PianoRoomTime> {
 }
 

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

@@ -95,11 +95,13 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     @Autowired
     private HolidaysFestivalsDao holidaysFestivalsDao;
     @Autowired
-    private PinaoRoomTimeDao pinaoRoomTimeDao;
+    private PianoRoomTimeDao pianoRoomTimeDao;
     @Autowired
     private UserBindingTeacherDao userBindingTeacherDao;
     @Autowired
     private CourseScheduleStudentDao courseScheduleStudentDao;
+    @Autowired
+    private CourseScheduleRecordDao recordDao;
 
     @Override
     public CourseScheduleDao getDao() {
@@ -1489,25 +1491,45 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      */
     @Transactional(rollbackFor = Exception.class)
     public void scheduleTask() {
-        //更新课程开始状态(开课时间 ≤ NOW ≤ 结束时间)
+        //课程开始(开课时间 ≤ NOW ≤ 结束时间)
         List<CourseSchedule> courseStart = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
                 .eq(CourseSchedule::getLock, 0)
-                .eq(CourseSchedule::getType, CourseScheduleEnum.NOT_START)
+                .eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START)
                 .le(CourseSchedule::getStartTime, new Date())
                 .ge(CourseSchedule::getEndTime, new Date()));
         if (CollectionUtils.isNotEmpty(courseStart)) {
+            //课程状态更新为ING
             baseMapper.updateStartTime(courseStart);
         }
 
-        //更新课程结束状态(NOW ≥ 结束时间)
-        List<String> typeList = Arrays.asList(CourseScheduleEnum.ING.getCode(), CourseScheduleEnum.NOT_START.getCode());
-        List<CourseSchedule> courseEnd = baseMapper.selectList(Wrappers.<CourseSchedule>lambdaQuery()
-                .in(CourseSchedule::getType, typeList)
-                .eq(CourseSchedule::getLock, 0)
-                .le(CourseSchedule::getEndTime, new Date()));
-        if (CollectionUtils.isNotEmpty(courseEnd)) {
-            baseMapper.updateEndTime(courseEnd);
-            //TODO 根据老师&学生id 更新绑定学员结课时间
+        //课程结束(NOW ≥ 结束时间)
+        List<CourseScheduleStudentVo> userList = courseScheduleStudentDao.selectUser();
+        if (CollectionUtils.isNotEmpty(userList)) {
+            //更新学生最近结课时间
+            pianoRoomTimeDao.updateEndTime(userList);
+
+            List<CourseScheduleRecord> recordList = recordDao.sumCourseTime();
+            if (CollectionUtils.isNotEmpty(recordList)) {
+                //记录消耗课时
+                recordDao.insertBatch(recordList);
+
+                //释放冻结课时
+                List<PianoRoomTime> roomTimeList = new ArrayList<>();
+                Map<Long, List<CourseScheduleRecord>> collect = recordList.stream().collect(Collectors.groupingBy(CourseScheduleRecord::getTeacherId, Collectors.toList()));
+                collect.forEach((key, list) -> {
+                    PianoRoomTime pianoRoomTime = pianoRoomTimeDao.selectOne(Wrappers.<PianoRoomTime>lambdaQuery().eq(PianoRoomTime::getTeacherId, key));
+                    Long frozenTime = pianoRoomTime.getFrozenTime();
+
+                    PianoRoomTime roomTime = new PianoRoomTime();
+                    roomTime.setTeacherId(key);
+                    roomTime.setFrozenTime(frozenTime - Long.valueOf(list.stream().mapToInt(CourseScheduleRecord::getConsumTime).sum()));
+                    roomTimeList.add(roomTime);
+                });
+                pianoRoomTimeDao.updateBatch(roomTimeList);
+            }
+
+            //课程状态更新为COMPLETE
+            baseMapper.updateEndTime(userList);
         }
     }
 
@@ -1533,8 +1555,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @Author: cy
      * @Date: 2022/5/27
      */
-    public PinaoRoomTimeVo selectRemainTime(Long teacherId) {
-        return pinaoRoomTimeDao.selectRemainTime(teacherId);
+    public PianoRoomTimeVo selectRemainTime(Long teacherId) {
+        return pianoRoomTimeDao.selectRemainTime(teacherId);
     }
 
     /**
@@ -1589,12 +1611,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         }
 
         //校验时长
-        PinaoRoomTime pinaoRoomTime = pinaoRoomTimeDao.selectOne(Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
-        if (pinaoRoomTime == null) {
+        PianoRoomTime pianoRoomTime = pianoRoomTimeDao.selectOne(Wrappers.<PianoRoomTime>lambdaQuery().eq(PianoRoomTime::getTeacherId, teacherId));
+        if (pianoRoomTime == null) {
             throw new BizException("未查询到老师剩余时长");
         }
-        Long remainTime = pinaoRoomTime.getRemainTime();
-        Long frozenTime = pinaoRoomTime.getFrozenTime();
+        Long remainTime = pianoRoomTime.getRemainTime();
+        Long frozenTime = pianoRoomTime.getFrozenTime();
         if (consumTime > remainTime) {
             throw new BizException("剩余时长不足");
         }
@@ -1674,10 +1696,19 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
             courseScheduleStudentDao.insertBatch(list);
         }
 
-        //扣减pinao_room_time
-        PinaoRoomTime roomTime = new PinaoRoomTime();
+        //扣减piano_room_time
+        PianoRoomTime roomTime = new PianoRoomTime();
         roomTime.setRemainTime(remainTime - consumTime);
         roomTime.setFrozenTime(frozenTime + consumTime);
-        pinaoRoomTimeDao.update(roomTime, Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
+        pianoRoomTimeDao.update(roomTime, Wrappers.<PianoRoomTime>lambdaQuery().eq(PianoRoomTime::getTeacherId, teacherId));
+    }
+
+    /**
+     * 根据月份查询消耗记录
+     */
+    public Map<String, Object> selectConsumeTime(String month, Long teacherId) {
+        Map<String, Object> map = new HashMap();
+        map.put("consumeTime", recordDao.countTimeByTeacherId(teacherId, month));
+        return map;
     }
 }

+ 20 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PianoRoomTimeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.yonge.cooleshow.biz.dal.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yonge.cooleshow.biz.dal.dao.PianoRoomTimeDao;
+import com.yonge.cooleshow.biz.dal.entity.PianoRoomTime;
+import com.yonge.cooleshow.biz.dal.service.PianoRoomTimeService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author: cy
+ * @Date: 2022/5/26
+ */
+@Service("pianoRoomTimeService")
+public class PianoRoomTimeServiceImpl extends ServiceImpl<PianoRoomTimeDao, PianoRoomTime> implements PianoRoomTimeService {
+    private final static Logger log = LoggerFactory.getLogger(PianoRoomTimeServiceImpl.class);
+
+}
+

+ 0 - 20
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PinaoRoomTimeServiceImpl.java

@@ -1,20 +0,0 @@
-package com.yonge.cooleshow.biz.dal.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yonge.cooleshow.biz.dal.dao.PinaoRoomTimeDao;
-import com.yonge.cooleshow.biz.dal.entity.PinaoRoomTime;
-import com.yonge.cooleshow.biz.dal.service.PinaoRoomTimeService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-/**
- * @Author: cy
- * @Date: 2022/5/26
- */
-@Service("pinaoRoomTimeService")
-public class PinaoRoomTimeServiceImpl extends ServiceImpl<PinaoRoomTimeDao, PinaoRoomTime> implements PinaoRoomTimeService {
-    private final static Logger log = LoggerFactory.getLogger(PinaoRoomTimeServiceImpl.class);
-
-}
-

+ 74 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseScheduleStudentVo.java

@@ -0,0 +1,74 @@
+package com.yonge.cooleshow.biz.dal.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Author: cy
+ * @Date: 2022/5/30
+ */
+@ApiModel
+public class CourseScheduleStudentVo implements Serializable {
+    @ApiModelProperty(value = "课程id")
+    private Long courseId;
+
+    @ApiModelProperty(value = "老师id")
+    private Long teacherId;
+
+    @ApiModelProperty(value = "学生id")
+    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;
+
+    public Integer getSingleCourseTime() {
+        return singleCourseTime;
+    }
+
+    public void setSingleCourseTime(Integer singleCourseTime) {
+        this.singleCourseTime = singleCourseTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public Long getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Long teacherId) {
+        this.teacherId = teacherId;
+    }
+
+    public Long getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Long studentId) {
+        this.studentId = studentId;
+    }
+}
+

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/PinaoRoomTimeVo.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/PianoRoomTimeVo.java

@@ -1,6 +1,6 @@
 package com.yonge.cooleshow.biz.dal.vo;
 
-import com.yonge.cooleshow.biz.dal.entity.PinaoRoomTime;
+import com.yonge.cooleshow.biz.dal.entity.PianoRoomTime;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
  * @Date: 2022/5/26
  */
 @ApiModel
-public class PinaoRoomTimeVo extends PinaoRoomTime {
+public class PianoRoomTimeVo extends PianoRoomTime {
     @ApiModelProperty(value = "我的学员")
     private Integer studentCount;
 

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

@@ -801,7 +801,7 @@
     <update id="updateEndTime">
         UPDATE course_schedule SET status_='COMPLETE' WHERE id_ IN(
         <foreach collection="list" item="item" index="index" open="" close="" separator=",">
-            #{item.id}
+            #{item.courseId}
         </foreach>)
     </update>
     <update id="updateTeacherSalary" parameterType="java.util.List">

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

@@ -0,0 +1,20 @@
+<?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.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>
+    <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}
+    </select>
+    <insert id="insertBatch">
+        INSERT INTO course_schedule_record (course_id_, teacher_id_, student_count_, consum_time_, end_time_) VALUES
+        <foreach collection ="recordList" item="item" index="index" separator =",">
+            (#{item.courseId},#{item.teacherId},#{item.studentCount}, #{item.consumTime}, #{item.endTime})
+        </foreach>
+    </insert>
+</mapper>

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

@@ -7,4 +7,17 @@
             (#{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>

+ 26 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/PianoRoomTimeDao.xml

@@ -0,0 +1,26 @@
+<?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.PianoRoomTimeDao">
+    <select id="selectRemainTime" resultType="com.yonge.cooleshow.biz.dal.vo.PianoRoomTimeVo"
+            parameterType="java.lang.Long">
+        SELECT *,
+        (SELECT COUNT(1) FROM user_binding_teacher WHERE teacher_id_=#{teacherId}) AS studentCount
+        FROM piano_room_time
+        WHERE teacher_id_=#{teacherId}
+    </select>
+    <update id="updateEndTime">
+        <foreach collection="list" item="item" index="index" separator=";">
+            UPDATE user_binding_teacher
+            SET last_end_class_ = #{item.endTime}
+            WHERE teacher_id_ = #{item.teacherId}
+            AND student_id_ = #{item.studentId}
+        </foreach>
+    </update>
+    <update id="updateBatch">
+        <foreach collection="list" item="item" index="index" separator=";">
+            UPDATE piano_room_time
+            SET frozen_time_ = #{item.frozenTime}
+            WHERE teacher_id_ = #{item.teacherId}
+        </foreach>
+    </update>
+</mapper>

+ 0 - 12
cooleshow-user/user-biz/src/main/resources/config/mybatis/PinaoRoomTimeMapper.xml

@@ -1,12 +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.PinaoRoomTimeDao">
-
-    <select id="selectRemainTime" resultType="com.yonge.cooleshow.biz.dal.vo.PinaoRoomTimeVo"
-            parameterType="java.lang.Long">
-        SELECT *,
-        (SELECT COUNT(1) FROM user_binding_teacher WHERE teacher_id_=#{teacherId}) AS studentCount
-        FROM pinao_room_time
-        WHERE teacher_id_=#{teacherId}
-    </select>
-</mapper>

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

@@ -156,12 +156,14 @@ public class TeacherCourseScheduleController extends BaseController {
     //测试未约满课老师
     @GetMapping("/test")
     public HttpResponseResult<Object> test(Integer amount) {
-        return succeed(courseScheduleService.getTeacherId(amount));
+//        return succeed(courseScheduleService.getTeacherId(amount));
+        courseScheduleService.scheduleTask();
+        return succeed();
     }
 
     @ApiOperation("查询琴房剩余时长、冻结时长、统计学员人数")
     @GetMapping("/selectRemainTime")
-    public HttpResponseResult<PinaoRoomTimeVo> selectRemainTime() {
+    public HttpResponseResult<PianoRoomTimeVo> selectRemainTime() {
         SysUser user = sysUserFeignService.queryUserInfo();
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
@@ -195,5 +197,15 @@ public class TeacherCourseScheduleController extends BaseController {
         courseScheduleService.arrangeCourse(arrangeCourseVo, user.getId());
         return succeed();
     }
+
+    @ApiOperation("根据月份查询消耗时长")
+    @GetMapping("/selectConsumeTime")
+    public HttpResponseResult<Object> selectConsumeTime(String month) {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        return succeed(courseScheduleService.selectConsumeTime(month, user.getId()));
+    }
 }