浏览代码

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

zouxuan 5 年之前
父节点
当前提交
e3ecd94922

+ 18 - 9
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -47,20 +47,20 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
     Integer[] countStudentInClass(List<Integer> classGroupIDs);
 
     /**
+     * @param courseScheduleIds: 课程编号列表
+     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
      * @describe 根据课程编号列表获取课程列表
      * @author Joburgess
      * @date 2019/10/22
-     * @param courseScheduleIds: 课程编号列表
-     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
      */
     List<CourseSchedule> findByCourseScheduleIds(List<Long> courseScheduleIds);
 
     /**
+     * @param courseScheduleIds: 课程编号列表
+     * @return java.util.List<java.util.Map < java.lang.Integer, java.lang.Integer>>
      * @describe 根据课程编号列表获取助教列表
      * @author Joburgess
      * @date 2019/10/23
-     * @param courseScheduleIds: 课程编号列表
-     * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>>
      */
     List<CourseScheduleTeacherSalary> findTeachingTeachers(List<Long> courseScheduleIds);
 
@@ -370,15 +370,24 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return
      */
     List<CourseSchedule> findCourseScheduleByClassGroupIdAndDate(@Param("classGroupId") Integer classGroupId, @Param("startDate") String startDate, @Param("times") int times);
-    
+
     /**
      * 根据时间范围查询老师指定类型的课程列表
+     *
      * @param teacherId 老师编号
-     * @param type 课程类型 (如果为null,查询所有类型)
+     * @param type      课程类型 (如果为null,查询所有类型)
      * @param startTime 开始时间
-     * @param endTime 结束时间
+     * @param endTime   结束时间
+     * @return
+     */
+    List<CourseSchedule> queryTeacherCourseScheduleListByTimeRangeAndType(@Param("teacherId") Integer teacherId, @Param("type") CourseScheduleType type,
+                                                                          @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    /**
+     * 查询班级未开始的课程
+     *
+     * @param classGroupId
      * @return
      */
-	List<CourseSchedule> queryTeacherCourseScheduleListByTimeRangeAndType(@Param("teacherId") Integer teacherId, @Param("type") CourseScheduleType type,
-			@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+    List<CourseSchedule> findNoStartCoursesByClassGroupId(@Param("classGroupId") Integer classGroupId);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java

@@ -145,8 +145,18 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
 
     /**
      * 批量插入
+     *
      * @param studentRegistrationList
      * @return
      */
     int batchInsert(@Param("studentRegistrationList") List<StudentRegistration> studentRegistrationList);
+
+
+    /**
+     * 根据userId 和班级id查询学生
+     * @param userId
+     * @param classGroupId
+     * @return
+     */
+    StudentRegistration findStudentByClassGroupIdAndUserId(@Param("userId") Integer userId, @Param("classGroupId") Integer classGroupId);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupAdjustDto.java

@@ -17,6 +17,9 @@ public class ClassGroupAdjustDto {
     @ApiModelProperty(value = "班级名称", required = true)
     private String classGroupName;
 
+    @ApiModelProperty(value = "班级id", required = true)
+    private Integer classGroupId;
+
     @ApiModelProperty(value = "学生-班级", required = true)
     private List<ClassGroupStudentMapperDto> classGroupStudentMapperDtoList;
 
@@ -120,4 +123,12 @@ public class ClassGroupAdjustDto {
     public void setCourseTimes(Integer courseTimes) {
         this.courseTimes = courseTimes;
     }
+
+    public Integer getClassGroupId() {
+        return classGroupId;
+    }
+
+    public void setClassGroupId(Integer classGroupId) {
+        this.classGroupId = classGroupId;
+    }
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java

@@ -16,4 +16,12 @@ public interface ClassGroupStudentMapperService extends BaseService<Long, ClassG
      * @return
      */
     ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId);
+
+    /**
+     * 删除班级学生
+     * @param userId
+     * @param classGroupId
+     * @return
+     */
+    boolean delClassGroupStudent(Integer userId, Integer classGroupId) throws Exception;
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java

@@ -11,6 +11,7 @@ import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
 import com.ym.mec.biz.dal.page.StudentCourseScheduleRecordQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
 import java.util.List;
@@ -204,4 +205,12 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @return java.util.Map<java.lang.Integer,java.lang.Integer>
 	 */
 	Map<Integer,Integer> findCourseScheduleCurrentTimes(List<Integer> courseSchedules);
+
+    /**
+     * 查询班级未开始的课程
+     *
+     * @param classGroupId
+     * @return
+     */
+    List<CourseSchedule> findNoStartCoursesByClassGroupId(Integer classGroupId);
 }

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java

@@ -1,7 +1,11 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface CourseScheduleStudentPaymentService extends BaseService<Long, CourseScheduleStudentPayment> {
 
@@ -14,4 +18,13 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	 */
 	int createCourseScheduleStudentPaymentForVipGroup(Long vipGroupId, Integer userId);
 
+
+	/**
+	 * 删除学生对应的课程
+	 * @param userId
+	 * @param courseScheduleList
+	 * @return
+	 */
+	int deleteStudentCourseSchedule(Integer userId, List<CourseSchedule> courseScheduleList);
+
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -172,4 +172,14 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
 	 */
 	int batchInsert(List<StudentRegistration> studentRegistrationList);
 
+
+	/**
+	 * 根据userId 和班级id查询学生
+	 * @param userId
+	 * @param classGroupId
+	 * @return
+	 */
+	StudentRegistration findStudentByClassGroupIdAndUserId(Integer userId, Integer classGroupId);
+
+
 }

+ 43 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -1,5 +1,11 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.service.CourseScheduleService;
+import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.biz.service.StudentRegistrationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -8,22 +14,50 @@ import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
 import com.ym.mec.biz.service.ClassGroupStudentMapperService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
 @Service
-public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper>  implements ClassGroupStudentMapperService {
-	
-	@Autowired
-	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
 
-	@Override
-	public BaseDAO<Long, ClassGroupStudentMapper> getDAO() {
-		return classGroupStudentMapperDao;
-	}
+    @Autowired
+    private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+
+    @Autowired
+    private CourseScheduleService courseScheduleService;
+    @Autowired
+    StudentRegistrationService studentRegistrationService;
+    @Autowired
+    private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
+
+    @Override
+    public BaseDAO<Long, ClassGroupStudentMapper> getDAO() {
+        return classGroupStudentMapperDao;
+    }
 
     @Override
     public ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId) {
-        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId,classGroupId);
+        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean delClassGroupStudent(Integer userId, Integer classGroupId) throws Exception {
+        ClassGroupStudentMapper classStudentMapper = findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
+        if (classStudentMapper == null) {
+            throw new Exception("班级学生不存在");
+        }
+        //1、删除班级学生对应班级关系
+        classStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
+        update(classStudentMapper);
+        StudentRegistration student = studentRegistrationService.findStudentByClassGroupIdAndUserId(userId, classGroupId);
+        student.setClassGroupId(null);
+        studentRegistrationService.update(student);
+
+        //2、删除学生对应班级的单技课程和对应合奏课程
+        List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
+        courseScheduleStudentPaymentService.deleteStudentCourseSchedule(userId, courseScheduleList);
+        return true;
     }
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -650,4 +650,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		List<Map<Integer, Integer>> courseScheduleCurrentTimes = courseScheduleDao.findCourseScheduleCurrentTimes(courseSchedules);
 		return MapUtil.convertMybatisMap(courseScheduleCurrentTimes);
 	}
+
+    @Override
+    public List<CourseSchedule> findNoStartCoursesByClassGroupId(Integer classGroupId) {
+		return courseScheduleDao.findNoStartCoursesByClassGroupId(classGroupId);
+    }
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -122,4 +122,9 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 		}
 		return courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 	}
+
+    @Override
+    public int deleteStudentCourseSchedule(Integer userId, List<CourseSchedule> courseScheduleList) {
+		return courseScheduleStudentPaymentDao.deleteStudentCourseSchedule(userId,courseScheduleList);
+    }
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -478,4 +478,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     public int batchInsert(List<StudentRegistration> studentRegistrationList) {
         return studentRegistrationDao.batchInsert(studentRegistrationList);
     }
+
+    @Override
+    public StudentRegistration findStudentByClassGroupIdAndUserId(Integer userId, Integer classGroupId) {
+        return studentRegistrationDao.findStudentByClassGroupIdAndUserId(userId, classGroupId);
+    }
 }

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -934,4 +934,8 @@
         and type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
         </if>
     </select>
+    <!-- 查找班级未开始的课程 -->
+    <select id="findNoStartCoursesByClassGroupId" resultMap="CourseSchedule">
+        SELECT * FROM course_schedule WHERE class_group_id_ = #{classGroupId} AND status_ = 'NOT_START'
+    </select>
 </mapper>

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

@@ -311,8 +311,12 @@
 
     <!-- 获取班级下的学生 -->
     <select id="findClassGroupStu" resultMap="StudentRegistration">
-        SELECT * FROM student_registration WHERE music_group_id_= #{musicGroupId} AND
-        FIND_IN_SET(#{classGroupId},class_group_id_)
+        SELECT * FROM student_registration WHERE music_group_id_= #{musicGroupId} AND class_group_id_=#{classGroupId}
+    </select>
+
+    <!-- 根据班级和userId查询学生信息-->
+    <select id="findStudentByClassGroupIdAndUserId" resultMap="StudentRegistration">
+        SELECT * FROM student_registration WHERE user_id_= #{userId} AND class_group_id_=#{classGroupId}
     </select>
 
     <!-- 获取乐团的学生 -->

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

@@ -28,13 +28,8 @@ public class ClassGroupStudentController extends BaseController {
     @ApiOperation(value = "删除班级学生")
     @PostMapping("/del")
     @PreAuthorize("@pcs.hasPermissions('classGroupStudent/del')")
-    public HttpResponseResult add(Integer userId, Integer classGroupId) throws Exception {
-        ClassGroupStudentMapper classStudentMapper = classGroupStudentMapperService.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
-        if (classStudentMapper == null) {
-            return failed("班级学生不存在");
-        }
-        classStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
-        return succeed(classGroupStudentMapperService.update(classStudentMapper));
+    public HttpResponseResult del(Integer userId, Integer classGroupId) throws Exception {
+        return succeed(classGroupStudentMapperService.delClassGroupStudent(userId, classGroupId));
     }
 
 }