zouxuan 5 роки тому
батько
коміт
053a3a20e7

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -99,7 +99,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @param classGroupId
      * @return
      */
-    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(@Param("userId") Integer userId, @Param("classGroupId") Integer classGroupId);
+    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(@Param("userId") Integer userId, @Param("classGroupId") Integer classGroupId,@Param("status") String status);
 
     /**
      * @param classGroupIds: 班级编号列表

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

@@ -48,7 +48,7 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
     @Override
     public ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId) {
-        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
+        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId,"NORMAL");
     }
 
     @Override
@@ -152,23 +152,28 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
         Iterator<String> iterator = userIdStrSet.iterator();
         while (iterator.hasNext()) {
-        	String userIdStr = iterator.next();
-            List<ClassGroupStudentMapper> highClassGroupHasUser = classGroupStudentMapperDao.findHighClassGroupHasUser(classGroup.getMusicGroupId(), Integer.parseInt(userIdStr), classGroup.getType());
+        	Integer userId = Integer.parseInt(iterator.next());
+            List<ClassGroupStudentMapper> highClassGroupHasUser = classGroupStudentMapperDao.findHighClassGroupHasUser(classGroup.getMusicGroupId(), userId, classGroup.getType());
             if (highClassGroupHasUser != null && highClassGroupHasUser.size() > 0) {
             	iterator.remove();
                 continue;
             }
-
-            ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
-            classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
-            classGroupStudentMapper.setClassGroupId(classGroupId);
-            classGroupStudentMapper.setUserId(Integer.parseInt(userIdStr));
-            classGroupStudentMapper.setCreateTime(nowDate);
-            classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-            classGroupStudentMapper.setGroupType(GroupType.MUSIC);
-            classGroupStudentMappers.add(classGroupStudentMapper);
+            //校验是否存在历史记录
+            ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId, null);
+            if(classGroupStudentMapper != null){
+                classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            }else {
+                classGroupStudentMapper = new ClassGroupStudentMapper();
+                classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+                classGroupStudentMapper.setClassGroupId(classGroupId);
+                classGroupStudentMapper.setUserId(userId);
+                classGroupStudentMapper.setCreateTime(nowDate);
+                classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+                classGroupStudentMapper.setGroupType(GroupType.MUSIC);
+                classGroupStudentMappers.add(classGroupStudentMapper);
+            }
             if (classGroup.getType().equals(ClassGroupTypeEnum.NORMAL)) {
-                StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(Integer.parseInt(userIdStr), classGroup.getMusicGroupId());
+                StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, classGroup.getMusicGroupId());
                 studentRegistration.setClassGroupId(classGroupId);
                 studentRegistrationService.update(studentRegistration);
             }
@@ -177,13 +182,13 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
                 classGroupStudentMapper = new ClassGroupStudentMapper();
                 classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
                 classGroupStudentMapper.setClassGroupId(classGroupRelation.getClassGroupId());
-                classGroupStudentMapper.setUserId(Integer.parseInt(userIdStr));
+                classGroupStudentMapper.setUserId(userId);
                 classGroupStudentMapper.setCreateTime(nowDate);
                 classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
                 classGroupStudentMapper.setGroupType(GroupType.MUSIC);
                 classGroupStudentMappers.add(classGroupStudentMapper);
             }
-            imGroupMemberList.add(new ImGroupMember(userIdStr));
+            imGroupMemberList.add(new ImGroupMember(userId.toString()));
         }
 		if (classGroupStudentMappers.size() > 0) {
 			classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);

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

@@ -353,7 +353,8 @@
     </select>
     <select id="findNoClassSubjects" resultMap="ClassGroup">
         SELECT cg.* FROM class_group cg LEFT JOIN class_group_relation cgr ON cgr.sub_class_group_id_=cg.id_
-        WHERE cg.music_group_id_=#{musicGroupId} AND cg.type_ = 'NORMAL' AND cg.group_type_='MUSIC' AND cg.del_flag_ = '0' AND cgr.id_ IS NULL
+        WHERE cg.music_group_id_=#{musicGroupId} AND cg.type_ = 'NORMAL'
+        AND cg.group_type_='MUSIC' AND cg.del_flag_ = '0'
     </select>
 
     <select id="countTeacherNum" resultType="java.lang.Integer">

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

@@ -150,7 +150,11 @@
 
     <select id="findClassStudentMapperByUserIdAndClassGroupId" resultMap="ClassGroupStudentMapper">
         SELECT * FROM class_group_student_mapper
-        WHERE user_id_=#{userId} AND class_group_id_=#{classGroupId} AND status_ = 'NORMAL'
+        WHERE user_id_=#{userId} AND class_group_id_=#{classGroupId}
+        <if test="status != null">
+            AND status_ = #{status}
+        </if>
+        LIMIT 1
     </select>
     <select id="findByClassGroups" resultMap="ClassGroupStudentMapper">
         SELECT * FROM class_group_student_mapper WHERE class_group_id_ IN