zouxuan 5 лет назад
Родитель
Сommit
a01e732f2b

+ 18 - 22
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -670,7 +670,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 //        List<ClassGroupStudentMapper> classGroupStudentMappers = new ArrayList<>();
 //        List<ImGroupMember> imGroupMemberList = new ArrayList<>();
         Integer classGroupId = classGroup.getId();
-        ClassGroupRelation classGroupRelation = classGroupRelationService.findClassGroupRelation(classGroupId);
 
         //校验是否存在历史记录
         ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
@@ -688,35 +687,32 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             classGroupStudentMapper.setGroupType(GroupType.MUSIC);
             classGroupStudentMapperDao.insert(classGroupStudentMapper);
         }
-        ClassGroupStudentMapper classGroupStudentMapperMix = classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupRelation.getClassGroupId());
-        if(classGroupStudentMapperMix != null){
-            classGroupStudentMapperMix.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-            classGroupStudentMapperMix.setClassGroupId(classGroupRelation.getClassGroupId());
-            classGroupStudentMapperDao.update(classGroupStudentMapperMix);
-        }else {
-            classGroupStudentMapperMix = new ClassGroupStudentMapper();
-            classGroupStudentMapperMix.setMusicGroupId(classGroup.getMusicGroupId());
-            classGroupStudentMapperMix.setClassGroupId(classGroupRelation.getClassGroupId());
-            classGroupStudentMapperMix.setUserId(userId);
-            classGroupStudentMapperMix.setCreateTime(nowDate);
-            classGroupStudentMapperMix.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-            classGroupStudentMapperMix.setGroupType(GroupType.MUSIC);
-            classGroupStudentMapperDao.insert(classGroupStudentMapperMix);
-        }
-//        imGroupMemberList.add(new ImGroupMember(userId.toString()));
+
         //添加进IM群组
         ImGroupMember[] imGroupMembers = {new ImGroupMember(userId.toString())};
         imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, classGroup.getName()));
-
         //2、班级人数调整
         classGroupDao.updateClassStudentNum(classGroupId.longValue(), 1);
-
         //3、学生加入新班级未开始课程
         List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
 
-        //4、班级在合奏班、添加合奏课程
-        if (classGroupRelation != null) {
-            //合奏班增加人数
+        ClassGroupRelation classGroupRelation = classGroupRelationService.findClassGroupRelation(classGroupId);
+        if(classGroupRelation != null){
+            ClassGroupStudentMapper classGroupStudentMapperMix = classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupRelation.getClassGroupId());
+            if(classGroupStudentMapperMix != null){
+                classGroupStudentMapperMix.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+                classGroupStudentMapperMix.setClassGroupId(classGroupRelation.getClassGroupId());
+                classGroupStudentMapperDao.update(classGroupStudentMapperMix);
+            }else {
+                classGroupStudentMapperMix = new ClassGroupStudentMapper();
+                classGroupStudentMapperMix.setMusicGroupId(classGroup.getMusicGroupId());
+                classGroupStudentMapperMix.setClassGroupId(classGroupRelation.getClassGroupId());
+                classGroupStudentMapperMix.setUserId(userId);
+                classGroupStudentMapperMix.setCreateTime(nowDate);
+                classGroupStudentMapperMix.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+                classGroupStudentMapperMix.setGroupType(GroupType.MUSIC);
+                classGroupStudentMapperDao.insert(classGroupStudentMapperMix);
+            }
             classGroupDao.updateClassStudentNum(classGroupRelation.getClassGroupId().longValue(), 1);
             List<CourseSchedule> mixCourseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupRelation.getClassGroupId());
             courseScheduleList.addAll(mixCourseScheduleList);

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/ClassGroupRelationMapper.xml

@@ -81,7 +81,7 @@
 
     <!-- 查询班级父班级id -->
     <select id="findClassGroupRelation" resultMap="ClassGroupRelation">
-        SELECT * FROM class_group_relation WHERE sub_class_group_id_ = #{subClassGroupId}
+        SELECT * FROM class_group_relation WHERE sub_class_group_id_ = #{subClassGroupId} LIMIT 1
     </select>
     <select id="queryClassRelationIdMap" resultType="java.util.Map">
         SELECT class_group_id_ 'value',sub_class_group_id_ 'key' FROM class_group_relation cgr

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

@@ -319,9 +319,9 @@
     <!-- 根据乐团和声部获取未分班人数 -->
     <select id="getNoClassStuCountByMusicGroupId" resultMap="getNoClassStuCountByMusicGroupId">
         SELECT actual_subject_id_ ,COUNT(*) nums FROM student_registration
-        WHERE music_group_id_ = #{musicGroupId} AND payment_status_=2 AND (class_group_id_= 0 OR class_group_id_ IS NULL)
+        WHERE music_group_id_ = #{musicGroupId} AND payment_status_ = 2 AND (class_group_id_= 0 OR class_group_id_ IS NULL)
         AND music_group_status_ != 'QUIT'
-        GROUP BY actual_subject_id_;
+        GROUP BY actual_subject_id_
     </select>
 
     <update id="updateByUserIdAndMusicGroupId" parameterType="com.ym.mec.biz.dal.entity.StudentRegistration">
@@ -345,7 +345,7 @@
     <select id="queryByUserIdAndMusicGroupId" resultMap="StudentRegistration">
         SELECT sr.*,su.id_card_no_ FROM student_registration sr
         LEFT JOIN sys_user su ON su.id_ =sr.user_id_
-        WHERE sr.music_group_id_ = #{musicGroupId} AND sr.user_id_ = #{userId} AND sr.music_group_status_ != 'QUIT'
+        WHERE sr.music_group_id_ = #{musicGroupId} AND sr.user_id_ = #{userId} AND sr.music_group_status_ != 'QUIT' LIMIT 1
     </select>
 
     <!-- 根据乐团编号和手机号查询注册乐团注册信息-->