Joburgess 5 năm trước cách đây
mục cha
commit
9302ec5f62

+ 18 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamRoomStudentRelationDao.java

@@ -39,6 +39,15 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
     List<ExamRoomStudentRelation> findStudentsWithExamRooms(@Param("examRoomIds") List<Long> examRoomIds);
 
     /**
+     * @describe 获取考场中未完成考试的报名编号
+     * @author Joburgess
+     * @date 2020.08.18
+     * @param examRoomIds:
+     * @return java.util.List<java.lang.Long>
+     */
+    List<Long> findNoFinishedExamRegistIdsWIthExamRooms(@Param("examRoomIds") List<Long> examRoomIds);
+
+    /**
      * @describe 删除指定教室的学员
      * @author Joburgess
      * @date 2020.06.24
@@ -50,6 +59,15 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
                                     @Param("registIds") List<Long> registIds);
 
     /**
+     * @describe 删除指定报名学员的考场关联记录
+     * @author Joburgess
+     * @date 2020.08.18
+     * @param registIds:
+     * @return int
+     */
+    int deleteStudentRoomRegistRelations(@Param("registIds") List<Long> registIds);
+
+    /**
      * @describe 根据班级删除记录
      * @author Joburgess
      * @date 2020.06.24

+ 12 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomServiceImpl.java

@@ -28,6 +28,7 @@ import com.keao.edu.user.api.enums.ExamModeEnum;
 import com.keao.edu.user.dao.*;
 import com.keao.edu.user.dto.*;
 import com.keao.edu.user.entity.*;
+import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.page.ExamRoomListQueryInfo;
 import com.keao.edu.user.page.ExamRoomQueryInfo;
 import com.keao.edu.user.service.*;
@@ -430,6 +431,10 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			throw new BizException("考级项目不存在");
 		}
 
+		if(exam.getStatus().getOrder()< ExamStatusEnum.APPLIED.getOrder()){
+			throw new BizException("项目报名中,不能发送考试安排");
+		}
+
 		ExamOrganizationRelation examOrganizationRelation = examOrganizationRelationDao.getExamOrganizationRelation(exam.getId(), organId);
 		if(Objects.isNull(examOrganizationRelation)||examOrganizationRelation.getIsAllowArrangeExam()==0){
 			throw new BizException("无权操作");
@@ -901,10 +906,16 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 		}
 		for (ExamRoom examRoom : examRooms) {
 			examRoom.setOpenFlag(0);
-//			imFeignService.dismissGroup(examRoom.getMainTeacherUserId().toString(),examRoom.getId().toString());
 			imFeignService.destroyRoom(examRoom.getId(),examRoom.getMainTeacherUserId().toString());
 			studentExamResultService.calculateStudentExamAvgScore(examRoom.getId());
 		}
 		examRoomDao.batchUpdate(examRooms);
+		Set<Long> examRoomIds = examRooms.stream().map(ExamRoom::getId).collect(Collectors.toSet());
+		List<Long> registIds = examRoomStudentRelationDao.findNoFinishedExamRegistIdsWIthExamRooms(new ArrayList<>(examRoomIds));
+		if(!CollectionUtils.isEmpty(registIds)){
+			examRoomStudentRelationDao.deleteStudentRoomRegistRelations(registIds);
+			examCertificationDao.deleteWithRegist(registIds);
+			studentExamResultDao.deleteWithRegists(registIds);
+		}
 	}
 }

+ 20 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRoomStudentRelationMapper.xml

@@ -111,6 +111,13 @@
 		</foreach>
 	</delete>
 
+	<delete id="deleteStudentRoomRegistRelations">
+		DELETE FROM exam_room_student_relation WHERE exam_registration_id_ IN
+		<foreach collection="registIds" item="registId" separator="," open="(" close=")">
+			#{registId}
+		</foreach>
+	</delete>
+
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="ExamRoomStudentRelation" parameterType="map">
 		SELECT * FROM exam_room_student_relation ORDER BY id_ <include refid="global.limit"/>
@@ -319,4 +326,17 @@
 				#{examRoomId}
 			</foreach>
 	</select>
+
+    <select id="findNoFinishedExamRegistIdsWIthExamRooms" resultType="long">
+		SELECT
+			exam_registration_id_
+		FROM
+			student_exam_result
+		WHERE
+			is_finished_exam_ != 5
+			AND exam_room_id_ IN
+			<foreach collection="examRoomIds" item="examRoomId" separator="," open="(" close=")">
+				#{examRoomId}
+			</foreach>
+	</select>
 </mapper>