cy 2 سال پیش
والد
کامیت
400d89e1b1
17فایلهای تغییر یافته به همراه294 افزوده شده و 449 حذف شده
  1. 9 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java
  2. 0 12
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleTeacherTimeDao.java
  3. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/UserBindingTeacherDao.java
  4. 54 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseScheduleStudent.java
  5. 0 126
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseScheduleTeacherTime.java
  6. 12 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserBindingTeacher.java
  7. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java
  8. 0 23
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleTeacherTimeService.java
  9. 149 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java
  10. 0 196
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleTeacherTimeServiceImpl.java
  11. 10 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseStudentVo.java
  12. 8 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  13. 0 5
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleTeacherTimeMapper.xml
  14. 12 2
      cooleshow-user/user-biz/src/main/resources/config/mybatis/UserBindingTeacherMapper.xml
  15. 0 63
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/CourseScheduleTeacherTimeController.java
  16. 24 17
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherCourseScheduleController.java
  17. 12 0
      toolset/utils/src/main/java/com/yonge/toolset/utils/date/DateUtil.java

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

@@ -211,13 +211,21 @@ public interface CourseScheduleDao extends BaseMapper<CourseSchedule> {
     //查询老师声部价格
     BigDecimal selectPrice(@Param("teacherId") Long teacherId, @Param("subjectId") Long subjectId);
 
+    //查询课程
     List<CourseSchedule> selectSchedule(Integer courseId);
 
-    void updateStartTime();
+    //更新课程状态
+    void updateStartTime(List<Long> list);
 
+    //更新课程状态
     void updateEndTime();
 
+    //根据日期查课程id
     List<Long> selectIdList(String day);
 
+    //更新老师课酬
     void updateTeacherSalary(List<Long> list);
+
+    //查询课程id(开课时间 ≤ NOW ≤ 结束时间)
+    List<Long> selectUpStartIds();
 }

+ 0 - 12
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleTeacherTimeDao.java

@@ -1,12 +0,0 @@
-package com.yonge.cooleshow.biz.dal.dao;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.yonge.cooleshow.biz.dal.entity.CourseScheduleTeacherTime;
-
-/**
- * @Author: cy
- * @Date: 2022/5/26
- */
-public interface CourseScheduleTeacherTimeDao extends BaseMapper<CourseScheduleTeacherTime> {
-
-}

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/UserBindingTeacherDao.java

@@ -14,6 +14,6 @@ import java.util.Map;
  * @Date: 2022/5/26
  */
 public interface UserBindingTeacherDao extends BaseMapper<UserBindingTeacher> {
-    //我的学员
-    IPage<CourseStudentVo> myStudent(Page<CourseStudentVo> pageInfo,@Param("param") Map<String, Object> param);
+    //查询学员
+    IPage<CourseStudentVo> selectStudent(Page<CourseStudentVo> pageInfo,@Param("param") Map<String, Object> param);
 }

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

@@ -0,0 +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 String 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 String getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(String studentId) {
+        this.studentId = studentId;
+    }
+}
+

+ 0 - 126
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseScheduleTeacherTime.java

@@ -1,126 +0,0 @@
-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 CourseScheduleTeacherTime implements Serializable {
-    @TableId(value = "id_", type = IdType.AUTO)
-    @ApiModelProperty(value = "主键")
-    private Long id;
-
-    @TableField("course_group_id_")
-    @ApiModelProperty(value = "课程组id")
-    private Long courseGroupId;
-
-    @TableField("course_schedule_id_")
-    @ApiModelProperty(value = "课程id")
-    private Long courseScheduleId;
-
-    @TableField("teacher_id_")
-    @ApiModelProperty(value = "老师id")
-    private Long teacherId;
-
-    @TableField("student_id_list_")
-    @ApiModelProperty(value = "学生id集合")
-    private String studentIdList;
-
-    @TableField("class_num_")
-    @ApiModelProperty(value = "课堂编号-第几堂课")
-    private Integer classNum;
-
-    @TableField("consume_time_")
-    @ApiModelProperty(value = "消耗时长(分钟)")
-    private Long consumeTime;
-
-    @TableField("created_time_")
-    @ApiModelProperty(value = "创建时间")
-    private Date createdTime;
-
-    @TableField("update_time_")
-    @ApiModelProperty(value = "更新时间")
-    private Date updateTime;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getCourseGroupId() {
-        return courseGroupId;
-    }
-
-    public void setCourseGroupId(Long courseGroupId) {
-        this.courseGroupId = courseGroupId;
-    }
-
-    public Long getCourseScheduleId() {
-        return courseScheduleId;
-    }
-
-    public void setCourseScheduleId(Long courseScheduleId) {
-        this.courseScheduleId = courseScheduleId;
-    }
-
-    public Long getTeacherId() {
-        return teacherId;
-    }
-
-    public void setTeacherId(Long teacherId) {
-        this.teacherId = teacherId;
-    }
-
-    public String getStudentIdList() {
-        return studentIdList;
-    }
-
-    public void setStudentIdList(String studentIdList) {
-        this.studentIdList = studentIdList;
-    }
-
-    public Integer getClassNum() {
-        return classNum;
-    }
-
-    public void setClassNum(Integer classNum) {
-        this.classNum = classNum;
-    }
-
-    public Long getConsumeTime() {
-        return consumeTime;
-    }
-
-    public void setConsumeTime(Long consumeTime) {
-        this.consumeTime = consumeTime;
-    }
-
-    public Date getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Date createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    public Date getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
-    }
-}
-

+ 12 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserBindingTeacher.java

@@ -27,6 +27,10 @@ public class UserBindingTeacher implements Serializable {
     @ApiModelProperty(value = "学生id")
     private Long studentId;
 
+    @TableField("last_end_class_")
+    @ApiModelProperty(value = "最近结课日期")
+    private Date lastEndClass;
+
     @TableField("created_time_")
     @ApiModelProperty(value = "创建时间")
     private Date createdTime;
@@ -35,6 +39,14 @@ public class UserBindingTeacher implements Serializable {
     @ApiModelProperty(value = "更新时间")
     private Date updateTime;
 
+    public Date getLastEndClass() {
+        return lastEndClass;
+    }
+
+    public void setLastEndClass(Date lastEndClass) {
+        this.lastEndClass = lastEndClass;
+    }
+
     public Long getId() {
         return id;
     }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java

@@ -238,5 +238,7 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
     void scheduleTask();
 
     void teacherSalaryTask();
+
+    PinaoRoomTimeVo selectRemainTime(Long teacherId);
 }
 

+ 0 - 23
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleTeacherTimeService.java

@@ -1,23 +0,0 @@
-package com.yonge.cooleshow.biz.dal.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.yonge.cooleshow.biz.dal.entity.CourseScheduleTeacherTime;
-import com.yonge.cooleshow.biz.dal.vo.ArrangeCourseVo;
-import com.yonge.cooleshow.biz.dal.vo.CourseStudentVo;
-import com.yonge.cooleshow.biz.dal.vo.PinaoRoomTimeVo;
-import com.yonge.toolset.base.page.PageInfo;
-
-import java.util.Map;
-
-/**
- * @Author: cy
- * @Date: 2022/5/26
- */
-public interface CourseScheduleTeacherTimeService extends IService<CourseScheduleTeacherTime> {
-    PinaoRoomTimeVo selectRemainTime(Long teacherId);
-
-    PageInfo<CourseStudentVo> myStudent(Map<String, Object> param);
-
-    void arrangeCourse(ArrangeCourseVo arrangeCourseVo);
-}
-

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

@@ -94,6 +94,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     private SysMessageService sysMessageService;
     @Autowired
     private HolidaysFestivalsDao holidaysFestivalsDao;
+    @Autowired
+    private PinaoRoomTimeDao pinaoRoomTimeDao;
 
     @Override
     public CourseScheduleDao getDao() {
@@ -1483,7 +1485,11 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      */
     @Transactional(rollbackFor = Exception.class)
     public void scheduleTask() {
-        baseMapper.updateStartTime();
+        //查询课程id(开课时间 ≤ NOW ≤ 结束时间)
+        List<Long> startIds=baseMapper.selectUpStartIds();
+        if (CollectionUtils.isNotEmpty(startIds)){
+            baseMapper.updateStartTime(startIds);
+        }
         baseMapper.updateEndTime();
     }
 
@@ -1503,4 +1509,146 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         //更新老师课酬表
         baseMapper.updateTeacherSalary(idList);
     }
+
+    public PinaoRoomTimeVo selectRemainTime(Long teacherId) {
+        return pinaoRoomTimeDao.selectRemainTime(teacherId);
+    }
+
+//    public PageInfo<CourseStudentVo> selectStudent(Map<String, Object> param) {
+//        Integer courseId = (Integer) param.get("courseId");
+//        if (courseId != null) {
+//            CourseScheduleStudent teacherTime = baseMapper.selectOne(Wrappers.<CourseScheduleStudent>lambdaQuery().eq(CourseScheduleStudent::getCourseScheduleId, courseId));
+//            if (teacherTime == null) {
+//                throw new BizException("未查到课程");
+//            }
+//            String studentIdList = teacherTime.getStudentIdList();
+//            List<String> idList = Arrays.asList(studentIdList.split(","));
+//            param.put("idList", idList);//根据课程id查询报课学员
+//        }
+//        return PageUtil.pageInfo(userBindingTeacherDao.selectStudent(PageUtil.getPageInfo(param), param));
+//    }
+//
+//    public void arrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
+//        DistributedLock.of(redissonClient)
+//                .runIfLockCanGet(CacheNameEnum.LOCK_EXECUTE_ORDER.getRedisKey("teacherId:" + teacherId)
+//                        , () -> this.checkArrangeCourse(arrangeCourseVo, teacherId), 60L, TimeUnit.SECONDS);
+//    }
+//
+//    @Transactional(rollbackFor = Exception.class)
+//    public void checkArrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
+//        Integer classNum = arrangeCourseVo.getClassNum();//课时数
+//        Integer singleClssTime = arrangeCourseVo.getSingleClssTime();//单课时长
+//        List<Long> studentIds = arrangeCourseVo.getStudentIds();//学员id集合
+//        Integer consumTime = classNum * singleClssTime * studentIds.size();//消耗时长
+//        List<CourseTimeEntity> timeList = arrangeCourseVo.getTimeList();//选课时间
+//        Integer consumeTime = arrangeCourseVo.getConsumeTime();
+//
+//        //校验课时
+//        if (timeList.size() != classNum) {
+//            throw new BizException("课时数与排课数不符");
+//        }
+//
+//        //校验消耗时长
+//        if (!consumTime.equals(consumeTime)) {
+//            throw new BizException("时长计算错误");
+//        }
+//
+//        //校验上下课时间
+//        for (int i = 1; i <= timeList.size(); i++) {
+//            if (!DateUtil.offsetMinute(timeList.get(i).getStartTime(), singleClssTime).equals(timeList.get(i).getEndTime())) {
+//                throw new BizException("第{}节课结束时间计算错误", i);
+//            }
+//        }
+//
+//        //校验时长
+//        PinaoRoomTime pinaoRoomTime = pinaoRoomTimeDao.selectOne(Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
+//        if (pinaoRoomTime == null) {
+//            throw new BizException("未查询到老师剩余时长");
+//        }
+//        Long remainTime = pinaoRoomTime.getRemainTime();
+//        Long frozenTime = pinaoRoomTime.getFrozenTime();
+//        if (consumTime > remainTime) {
+//            throw new BizException("剩余时长不足");
+//        }
+//
+//        //校验学员是否绑定
+//        List<UserBindingTeacher> bindingTeachers = userBindingTeacherDao.selectList(Wrappers.<UserBindingTeacher>lambdaQuery().eq(UserBindingTeacher::getTeacherId, teacherId));
+//        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(bindingTeachers)) {
+//            throw new BizException("无绑定学员");
+//        }
+//        List<Long> studentList = bindingTeachers.stream().map(UserBindingTeacher::getStudentId).collect(Collectors.toList());
+//        for (Long studentId : studentIds) {
+//            if (!studentList.contains(studentId)) {
+//                throw new BizException("学员id:{},未绑定", studentId);
+//            }
+//        }
+//
+//        //校验传入时间是否交集
+//        if (timeList.size() > 1) {
+//            for (int i = 0; i < timeList.size(); i++) {
+//                if (i == timeList.size() - 1) {
+//                    break;
+//                }
+//                CourseTimeEntity o = timeList.get(i);
+//                List<CourseTimeEntity> newList = timeList.subList(i + 1, timeList.size());
+//                boolean checkParamTime = courseScheduleService.checkCourseTime(newList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, o.getStartTime(), o.getEndTime());
+//                if (checkParamTime) {
+//                    throw new BizException(DateUtil.dateToString(o.getStartTime(), "yyyy年MM月dd号 HH点mm分") + "的课程时间重复!");
+//                }
+//            }
+//        }
+//
+//        //批量检查老师课时在数据库是否重复
+//        groupService.batchCheckTeacherCourseTime(teacherId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
+//
+//        //校验购买的课程组每节课时间是否和自己的课时冲突
+//        for (Long studentId : studentIds) {
+//            groupService.batchCheckStudentCourseTime(studentId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
+//        }
+//
+//        //添加课程组
+//        CourseGroup courseGroup = new CourseGroup();
+//        courseGroup.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
+//        courseGroup.setTeacherId(teacherId);
+//        courseGroup.setName(arrangeCourseVo.getCourseName());
+//        courseGroup.setSubjectId(arrangeCourseVo.getSubjectId());
+//        courseGroup.setSingleCourseMinutes(singleClssTime);
+//        courseGroup.setCourseNum(classNum);
+//        courseGroup.setStatus(CourseGroupEnum.NOT_SALE.getCode());
+//        courseGroup.setCreatedBy(teacherId);
+//        courseGroupDao.insert(courseGroup);
+//
+//        for (int i = 0; i < timeList.size(); i++) {
+//            //添加课程
+//            CourseTimeEntity courseTimeEntity = timeList.get(i);
+//            CourseSchedule schedule = new CourseSchedule();
+//            schedule.setCourseGroupId(courseGroup.getId());
+//            schedule.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
+//            schedule.classNum(i + 1);
+//            schedule.setTeacherId(teacherId);
+//            schedule.setClassDate(DateUtil.trunc(courseTimeEntity.getStartTime()));
+//            schedule.setStartTime(courseTimeEntity.getStartTime());
+//            schedule.setEndTime(courseTimeEntity.getEndTime());
+//            schedule.setLock(0);
+//            schedule.setStatus(CourseScheduleEnum.NOT_START.getCode());
+//            schedule.setCreatedBy(teacherId);
+//            courseScheduleDao.insert(schedule);
+//
+//            //添加course_schedule_teacher_time
+//            CourseScheduleStudent teacherTime = new CourseScheduleStudent();
+//            teacherTime.setCourseGroupId(courseGroup.getId());
+//            teacherTime.setCourseScheduleId(schedule.getId());
+//            teacherTime.setTeacherId(teacherId);
+//            teacherTime.setStudentIdList(org.apache.commons.lang.StringUtils.join(studentIds, ","));
+//            teacherTime.setClassNum(i + 1);
+//            teacherTime.setConsumeTime(Long.valueOf(singleClssTime));
+//            baseMapper.insert(teacherTime);
+//        }
+//
+//        //扣减pinao_room_time
+//        PinaoRoomTime roomTime = new PinaoRoomTime();
+//        roomTime.setRemainTime(remainTime - consumTime);
+//        roomTime.setFrozenTime(frozenTime + consumTime);
+//        pinaoRoomTimeDao.update(roomTime, Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
+//    }
 }

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

@@ -1,196 +0,0 @@
-package com.yonge.cooleshow.biz.dal.service.impl;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
-import com.yonge.cooleshow.auth.api.entity.SysUser;
-import com.yonge.cooleshow.biz.dal.dao.*;
-import com.yonge.cooleshow.biz.dal.entity.*;
-import com.yonge.cooleshow.biz.dal.enums.CourseGroupEnum;
-import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
-import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
-import com.yonge.cooleshow.biz.dal.service.CourseScheduleTeacherTimeService;
-import com.yonge.cooleshow.biz.dal.support.PageUtil;
-import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
-import com.yonge.cooleshow.biz.dal.vo.*;
-import com.yonge.toolset.base.exception.BizException;
-import com.yonge.toolset.base.page.PageInfo;
-import com.yonge.toolset.utils.date.DateUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * @Author: cy
- * @Date: 2022/5/26
- */
-@Service("courseScheduleTeacherTimeService")
-public class CourseScheduleTeacherTimeServiceImpl extends ServiceImpl<CourseScheduleTeacherTimeDao, CourseScheduleTeacherTime> implements CourseScheduleTeacherTimeService {
-    private final static Logger log = LoggerFactory.getLogger(CourseScheduleTeacherTimeServiceImpl.class);
-
-    @Autowired
-    private SysUserFeignService sysUserFeignService;
-    @Autowired
-    private PinaoRoomTimeDao pinaoRoomTimeDao;
-    @Autowired
-    private UserBindingTeacherDao userBindingTeacherDao;
-    @Autowired
-    private CourseScheduleService courseScheduleService;
-    @Autowired
-    private CourseGroupServiceImpl groupService;
-    @Autowired
-    private CourseGroupDao courseGroupDao;
-    @Autowired
-    private CourseScheduleDao courseScheduleDao;
-
-    /**
-     * @Description: 查询琴房剩余时长、冻结时长、统计学员人数
-     * @Author: cy
-     * @Date: 2022/5/26
-     */
-    @Override
-    public PinaoRoomTimeVo selectRemainTime(Long teacherId) {
-        return pinaoRoomTimeDao.selectRemainTime(teacherId);
-    }
-
-    /**
-     * @Description: 我的学员
-     * @Author: cy
-     * @Date: 2022/5/26
-     */
-    @Override
-    public PageInfo<CourseStudentVo> myStudent(Map<String, Object> param) {
-        Page<CourseStudentVo> pageInfo = PageUtil.getPageInfo(param);
-        IPage<CourseStudentVo> page = userBindingTeacherDao.myStudent(pageInfo, param);
-        return PageUtil.pageInfo(page);
-    }
-
-    /**
-     * @Description: 排课
-     * @Author: cy
-     * @Date: 2022/5/26
-     */
-    @Transactional(rollbackFor = Exception.class)
-    public void arrangeCourse(ArrangeCourseVo arrangeCourseVo) {
-        Integer classNum = arrangeCourseVo.getClassNum();//课时数
-        Integer singleClssTime = arrangeCourseVo.getSingleClssTime();//单课时长
-        List<Long> studentIds = arrangeCourseVo.getStudentIds();//学员id集合
-        Integer consumTime = classNum * singleClssTime * studentIds.size();//消耗时长
-        List<CourseTimeEntity> timeList = arrangeCourseVo.getTimeList();//选课时间
-        Integer consumeTime = arrangeCourseVo.getConsumeTime();
-        SysUser user = sysUserFeignService.queryUserInfo();
-        Long teacherId = user.getId();
-
-        //校验课时
-        if (timeList.size() != classNum) {
-            throw new BizException("课时数与排课数不符");
-        }
-
-        //校验消耗时长
-        if (!consumTime.equals(consumeTime)){
-            throw new BizException("时长计算错误");
-        }
-
-        //校验时长
-        PinaoRoomTime pinaoRoomTime = pinaoRoomTimeDao.selectOne(Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
-        if (pinaoRoomTime == null) {
-            throw new BizException("未查询到老师剩余时长");
-        }
-        Long remainTime = pinaoRoomTime.getRemainTime();
-        Long frozenTime = pinaoRoomTime.getFrozenTime();
-        if (consumTime > remainTime) {
-            throw new BizException("剩余时长不足");
-        }
-
-        //校验学员是否绑定
-        List<UserBindingTeacher> bindingTeachers = userBindingTeacherDao.selectList(Wrappers.<UserBindingTeacher>lambdaQuery().eq(UserBindingTeacher::getTeacherId, teacherId));
-        if (CollectionUtils.isEmpty(bindingTeachers)) {
-            throw new BizException("无绑定学员");
-        }
-        List<Long> studentList = bindingTeachers.stream().map(UserBindingTeacher::getStudentId).collect(Collectors.toList());
-        for (Long studentId : studentIds) {
-            if (!studentList.contains(studentId)) {
-                throw new BizException("学员id:{},未绑定", studentId);
-            }
-        }
-
-        //校验传入时间是否交集
-        if (timeList.size() > 1) {
-            for (int i = 0; i < timeList.size(); i++) {
-                if (i == timeList.size() - 1) {
-                    break;
-                }
-                CourseTimeEntity o = timeList.get(i);
-                List<CourseTimeEntity> newList = timeList.subList(i + 1, timeList.size());
-                boolean checkParamTime = courseScheduleService.checkCourseTime(newList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, o.getStartTime(), o.getEndTime());
-                if (checkParamTime) {
-                    throw new BizException(DateUtil.dateToString(o.getStartTime(), "yyyy年MM月dd号 HH点mm分") + "的课程时间重复!");
-                }
-            }
-        }
-
-        //批量检查老师课时在数据库是否重复
-        groupService.batchCheckTeacherCourseTime(teacherId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
-
-        //校验购买的课程组每节课时间是否和自己的课时冲突
-        for (Long studentId : studentIds) {
-            groupService.batchCheckStudentCourseTime(studentId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
-        }
-
-        //添加课程组
-        CourseGroup courseGroup = new CourseGroup();
-        courseGroup.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
-        courseGroup.setTeacherId(teacherId);
-        courseGroup.setName(arrangeCourseVo.getCourseName());
-        courseGroup.setSubjectId(arrangeCourseVo.getSubjectId());
-        courseGroup.setSingleCourseMinutes(singleClssTime);
-        courseGroup.setCourseNum(classNum);
-        courseGroup.setStatus(CourseGroupEnum.NOT_SALE.getCode());
-        courseGroup.setCreatedBy(teacherId);
-        courseGroupDao.insert(courseGroup);
-
-        for (int i = 0; i < timeList.size(); i++) {
-            //添加课程
-            CourseTimeEntity courseTimeEntity = timeList.get(i);
-            CourseSchedule schedule = new CourseSchedule();
-            schedule.setCourseGroupId(courseGroup.getId());
-            schedule.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
-            schedule.classNum(i + 1);
-            schedule.setTeacherId(teacherId);
-            schedule.setClassDate(DateUtil.trunc(courseTimeEntity.getStartTime()));
-            schedule.setStartTime(courseTimeEntity.getStartTime());
-            schedule.setEndTime(courseTimeEntity.getEndTime());
-            schedule.setLock(0);
-            schedule.setStatus(CourseScheduleEnum.NOT_START.getCode());
-            schedule.setCreatedBy(teacherId);
-            courseScheduleDao.insert(schedule);
-
-            //添加course_schedule_teacher_time
-            CourseScheduleTeacherTime teacherTime = new CourseScheduleTeacherTime();
-            teacherTime.setCourseGroupId(courseGroup.getId());
-            teacherTime.setCourseScheduleId(schedule.getId());
-            teacherTime.setTeacherId(teacherId);
-            teacherTime.setStudentIdList(studentIds.toString());
-            teacherTime.setClassNum(i + 1);
-            teacherTime.setConsumeTime(Long.valueOf(singleClssTime));
-            baseMapper.insert(teacherTime);
-        }
-
-        //扣减pinao_room_time
-        PinaoRoomTime roomTime = new PinaoRoomTime();
-        roomTime.setRemainTime(remainTime - consumTime);
-        roomTime.setFrozenTime(frozenTime + consumTime);
-        pinaoRoomTimeDao.update(roomTime,Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId,teacherId));
-    }
-}

+ 10 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseStudentVo.java

@@ -23,6 +23,16 @@ public class CourseStudentVo implements Serializable {
     private String subjectName;
     @ApiModelProperty("手机号")
     private String phone;
+    @ApiModelProperty("最近结课日期(天)")
+    private Integer lastEndClass;
+
+    public Integer getLastEndClass() {
+        return lastEndClass;
+    }
+
+    public void setLastEndClass(Integer lastEndClass) {
+        this.lastEndClass = lastEndClass;
+    }
 
     public String getUserId() {
         return userId;

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

@@ -792,8 +792,15 @@
     <select id="selectIdList" resultType="java.lang.Long">
         SELECT id_ FROM course_schedule WHERE lock_=0 AND class_date_ &lt;= #{day}
     </select>
+    <select id="selectUpStartIds" resultType="java.lang.Long">
+        SELECT id_ FROM course_schedule WHERE lock_=0
+        AND status_='NOT_START' AND start_time_ &lt;= NOW() AND NOW() &lt;= end_time_
+    </select>
     <update id="updateStartTime">
-        UPDATE course_schedule SET status_='ING' WHERE status_ != 'CANCEL' <![CDATA[ AND start_time_ <= NOW() ]]> <![CDATA[ AND NOW() <= end_time_ ]]>
+        UPDATE course_schedule SET status_='ING' WHERE id_ IN(
+        <foreach collection="list" item="item" index="index" open="" close="" separator=",">
+            #{item}
+        </foreach>)
     </update>
     <update id="updateEndTime">
         UPDATE course_schedule SET status_='COMPLETE' WHERE status_ != 'CANCEL' <![CDATA[ AND end_time_ <= NOW() ]]>

+ 0 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleTeacherTimeMapper.xml

@@ -1,5 +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.CourseScheduleTeacherTimeDao">
-
-</mapper>

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

@@ -2,14 +2,15 @@
 <!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.UserBindingTeacherDao">
 
-    <select id="myStudent" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudentVo">
+    <select id="selectStudent" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudentVo">
         SELECT
         su.id_ AS userId,
         su.username_ AS userName,
         su.real_name_ AS realName,
         su.avatar_ AS avatar,
         su.phone_ AS phone,
-        (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,s.subject_id_)) AS subjectName
+        (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,s.subject_id_)) AS subjectName,
+        IFNULL(TIMESTAMPDIFF(DAY,b.last_end_class_,NOW()),TIMESTAMPDIFF(DAY,b.created_time_,NOW())) AS lastEndClass
         FROM user_binding_teacher b
         LEFT JOIN sys_user su ON b.student_id_=su.id_
         LEFT JOIN student s ON b.student_id_=s.user_id_
@@ -17,9 +18,18 @@
             <if test="param.subjectId != null">
                 find_in_set(#{param.subjectId},s.subject_id_)
             </if>
+            <if test="param.teacherId !=null">
+                AND b.teacher_id_ = #{param.teacherId}
+            </if>
             <if test="param.userName !=null and param.userName !=''">
                 AND su.username_ LIKE CONCAT('%', #{param.userName}, '%')
             </if>
+            <if test="param.idList !=null and param.idList.size>0">
+                AND su.id_ IN
+                <foreach collection="param.idList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
         </where>
     </select>
 </mapper>

+ 0 - 63
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/CourseScheduleTeacherTimeController.java

@@ -1,63 +0,0 @@
-package com.yonge.cooleshow.teacher.controller;
-
-import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
-import com.yonge.cooleshow.auth.api.entity.SysUser;
-import com.yonge.cooleshow.biz.dal.service.CourseScheduleTeacherTimeService;
-import com.yonge.cooleshow.biz.dal.vo.ArrangeCourseVo;
-import com.yonge.cooleshow.biz.dal.vo.CourseStudentVo;
-import com.yonge.cooleshow.biz.dal.vo.PinaoRoomTimeVo;
-import com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo;
-import com.yonge.cooleshow.common.controller.BaseController;
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
-import com.yonge.toolset.base.page.PageInfo;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Map;
-
-/**
- * @Author: cy
- * @Date: 2022/5/26
- */
-@Api("琴房")
-@RestController
-@RequestMapping("/pinaoRoom")
-public class CourseScheduleTeacherTimeController extends BaseController {
-    @Autowired
-    private SysUserFeignService sysUserFeignService;
-    @Autowired
-    private CourseScheduleTeacherTimeService courseScheduleTeacherTimeService;
-
-    @ApiOperation("查询琴房剩余时长、冻结时长、统计学员人数")
-    @GetMapping("/selectRemainTime")
-    public HttpResponseResult<PinaoRoomTimeVo> selectRemainTime() {
-        SysUser user = sysUserFeignService.queryUserInfo();
-        if (user == null || null == user.getId()) {
-            return failed(HttpStatus.FORBIDDEN, "请登录");
-        }
-        return succeed(courseScheduleTeacherTimeService.selectRemainTime(user.getId()));
-    }
-
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "subjectId", dataType = "Long", value = "声部id"),
-            @ApiImplicitParam(name = "userName", dataType = "String", value = "学员姓名"),
-    })
-    @ApiOperation("我的学员")
-    @PostMapping("/myStudent")
-    public HttpResponseResult<PageInfo<CourseStudentVo>> myStudent(@RequestBody Map<String, Object> param) {
-        return succeed(courseScheduleTeacherTimeService.myStudent(param));
-    }
-
-    @ApiOperation("排课")
-    @PostMapping("/arrangeCourse")
-    public HttpResponseResult<Object> arrangeCourse(@RequestBody ArrangeCourseVo arrangeCourseVo){
-        courseScheduleTeacherTimeService.arrangeCourse(arrangeCourseVo);
-        return succeed();
-    }
-}
-

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

@@ -7,10 +7,7 @@ import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
 import com.yonge.cooleshow.biz.dal.entity.CourseCalendarEntity;
 import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
-import com.yonge.cooleshow.biz.dal.vo.CourseAdjustVo;
-import com.yonge.cooleshow.biz.dal.vo.MyCourseVo;
-import com.yonge.cooleshow.biz.dal.vo.StudentHomePage;
-import com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo;
+import com.yonge.cooleshow.biz.dal.vo.*;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
@@ -86,16 +83,16 @@ public class TeacherCourseScheduleController extends BaseController {
 
     @ApiOperation(value = "陪练课查询",
             notes = "老师端-首页-我的课程-陪练课\n" +
-            "search:{\"classMonth\":\"2022-03\",\"status\":\"COMPLETE\",\"subjectId\":1}\n" +
-            "老师端-首页-课后评价\n" +
-            "search:{\"classMonth\":\"2022-03\",\"replied\":0,\"studentName\":\"测试王\"}\n" +
-            "老师端-我的-我的主页\n" +
-            "search:{\"classMonth\":\"2022-03\"}\n" +
-            "老师端-课表\n" +
-            "search:{\"classDate\":\"2022-03-27\"}\n" +
-            "     search:{\"classMonth\":\"2022-03\"}\n" +
-            "老师端-课表-陪练课\n" +
-            "     search:{\"classDate\":\"2022-03-27\"}")
+                    "search:{\"classMonth\":\"2022-03\",\"status\":\"COMPLETE\",\"subjectId\":1}\n" +
+                    "老师端-首页-课后评价\n" +
+                    "search:{\"classMonth\":\"2022-03\",\"replied\":0,\"studentName\":\"测试王\"}\n" +
+                    "老师端-我的-我的主页\n" +
+                    "search:{\"classMonth\":\"2022-03\"}\n" +
+                    "老师端-课表\n" +
+                    "search:{\"classDate\":\"2022-03-27\"}\n" +
+                    "     search:{\"classMonth\":\"2022-03\"}\n" +
+                    "老师端-课表-陪练课\n" +
+                    "     search:{\"classDate\":\"2022-03-27\"}")
     @PostMapping("/queryTeacherPracticeCourse")
     public HttpResponseResult<PageInfo<MyCourseVo>> queryTeacherPracticeCourse(@RequestBody MyCourseSearch search) {
         SysUser user = sysUserFeignService.queryUserInfo();
@@ -118,9 +115,9 @@ public class TeacherCourseScheduleController extends BaseController {
         return succeed(courseScheduleService.queryCourseSchedule(search));
     }
 
-    @ApiOperation(value = "老师端-课表-日历-用户",notes = "search:{\"classDate\":\"2022-03-27\"}")
+    @ApiOperation(value = "老师端-课表-日历-用户", notes = "search:{\"classDate\":\"2022-03-27\"}")
     @PostMapping("/queryCourseUser")
-    public HttpResponseResult<Map<String,Object>> queryCourseUser(@RequestBody MyCourseSearch search) {
+    public HttpResponseResult<Map<String, Object>> queryCourseUser(@RequestBody MyCourseSearch search) {
         SysUser user = sysUserFeignService.queryUserInfo();
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
@@ -136,7 +133,7 @@ public class TeacherCourseScheduleController extends BaseController {
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        courseScheduleService.courseAdjust(adjustVo,user.getId());
+        courseScheduleService.courseAdjust(adjustVo, user.getId());
         return succeed();
     }
 
@@ -161,5 +158,15 @@ public class TeacherCourseScheduleController extends BaseController {
     public HttpResponseResult<Object> test(Integer amount) {
         return succeed(courseScheduleService.getTeacherId(amount));
     }
+
+    @ApiOperation("查询琴房剩余时长、冻结时长、统计学员人数")
+    @GetMapping("/selectRemainTime")
+    public HttpResponseResult<PinaoRoomTimeVo> selectRemainTime() {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || null == user.getId()) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        return succeed(courseScheduleService.selectRemainTime(user.getId()));
+    }
 }
 

+ 12 - 0
toolset/utils/src/main/java/com/yonge/toolset/utils/date/DateUtil.java

@@ -1367,6 +1367,18 @@ public class DateUtil {
 		return null;
 	}
 
+	public static Date offsetMinute(Date parse,int offset){
+		try {
+			Calendar beforeTime = Calendar.getInstance();
+			beforeTime.setTime(parse);
+			beforeTime.add(Calendar.MINUTE, offset);
+			return beforeTime.getTime();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
 	/**
 	 * 获取未来n天(不包含当天)
 	 * @param amount