Bladeren bron

班级调整增加,班级类型

周箭河 5 jaren geleden
bovenliggende
commit
86743c80e4

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroup4MixDto.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dto;
 
 import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.util.List;
@@ -41,6 +42,9 @@ public class ClassGroup4MixDto {
     @ApiModelProperty(value = "排课方式", required = true)
     private List<CourseTimeDto> courseTimeDtoList;
 
+    @ApiModelProperty(value = "班级类型", required = true)
+    private ClassGroupTypeEnum type;
+
     public String getMusicGroupId() {
         return musicGroupId;
     }
@@ -128,4 +132,12 @@ public class ClassGroup4MixDto {
     public void setCourseType(CourseSchedule.CourseScheduleType courseType) {
         this.courseType = courseType;
     }
+
+    public ClassGroupTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(ClassGroupTypeEnum type) {
+        this.type = type;
+    }
 }

+ 17 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -723,6 +723,15 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         classGroupStudentMapperDao.deleteByClassId(classGroupId);
         //删除班级关系
         classGroupRelationDao.deleteByClassId(classGroupId);
+        //删除班级未开始课程
+        List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
+        if (courseScheduleList.size() > 0) {
+            List<Long> courseScheduleIds = courseScheduleList.stream().map(courseSchedule -> courseSchedule.getId()).collect(Collectors.toList());
+            courseScheduleDao.batchDeleteCourseSchedules(courseScheduleIds);
+            courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
+            teacherAttendanceDao.batchDeleteByCourseSchedules(courseScheduleIds);
+            courseScheduleStudentPaymentDao.deleteByCourseSchedule(courseScheduleIds);
+        }
         //删除合奏班
         classGroupDao.delete(classGroupId);
         //删除im群组
@@ -978,6 +987,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         String subjectIds = subjectList.stream().map(subject -> subject.getId().toString()).collect(Collectors.joining(","));
         String subjectNames = subjectList.stream().map(subject -> subject.getName()).collect(Collectors.joining("/"));
 
+        if(classGroup4MixDto.getType() == null){
+            classGroup4MixDto.setType(ClassGroupTypeEnum.NORMAL);
+        }
         //1、新建班级
         ClassGroup classGroup = new ClassGroup();
         classGroup.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
@@ -985,7 +997,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         classGroup.setName(classGroup4MixDto.getClassGroupName());
         classGroup.setExpectStudentNum(studentList.size());
         classGroup.setStudentNum(studentList.size());
-        classGroup.setType(ClassGroupTypeEnum.NORMAL);
+        classGroup.setType(classGroup4MixDto.getType());
         classGroup.setDelFlag(0);
         classGroup.setGroupType(GroupType.MUSIC);
         classGroup.setCurrentClassTimes(0);
@@ -999,8 +1011,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
         List<Integer> userIds = new ArrayList<>(); //用户ids
         for (StudentRegistration studentRegistration : studentList) {
-            studentRegistration.setClassGroupId(classGroup.getId());
-            studentRegistrationService.update(studentRegistration);
+            if (classGroup4MixDto.getType().equals(ClassGroupTypeEnum.NORMAL)) {
+                studentRegistration.setClassGroupId(classGroup.getId());
+                studentRegistrationService.update(studentRegistration);
+            }
 
             ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
             classGroupStudentMapper.setMusicGroupId(musicGroupId);

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

@@ -154,7 +154,7 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
         while (iterator.hasNext()) {
         	Integer userId = Integer.parseInt(iterator.next());
             List<ClassGroupStudentMapper> highClassGroupHasUser = classGroupStudentMapperDao.findHighClassGroupHasUser(classGroup.getMusicGroupId(), userId, classGroup.getType());
-            if (highClassGroupHasUser != null && highClassGroupHasUser.size() > 0) {
+            if (!classGroup.getType().equals(ClassGroupTypeEnum.SNAP) && highClassGroupHasUser != null && highClassGroupHasUser.size() > 0) {
             	iterator.remove();
                 continue;
             }

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -905,13 +905,15 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     public List<StudentRegistration> findMusicGroupStuNoClassType(String musicGroupId, ClassGroupTypeEnum type, Integer subjectId) {
         List<StudentRegistration> students = studentRegistrationDao.findMusicGroupStudent(musicGroupId, subjectId);
         List<ClassGroupStudentMapper> classGroupStudentMappers = classGroupStudentMapperDao.findMusicGroupClassGroupByType(musicGroupId, type);
-        for (StudentRegistration student : students) {
+        Iterator<StudentRegistration> iterator = students.iterator();
+        while (iterator.hasNext()){
+            StudentRegistration student = iterator.next();
             for (ClassGroupStudentMapper classGroupStudentMapper : classGroupStudentMappers) {
-                if (classGroupStudentMapper.getUserId().equals(student.getUserId())) {
-                    students.remove(student);
+                if (student.getUserId().equals(classGroupStudentMapper.getUserId())) {
+                    iterator.remove();
                 }
             }
         }
-        return null;
+        return students;
     }
 }