Selaa lähdekoodia

Merge branch 'master' of http://git.dayaedu.com/yonge/edu-saas into zouxuan

zouxuan 5 vuotta sitten
vanhempi
commit
a67acd93b1

+ 2 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamReviewDao.java

@@ -22,6 +22,8 @@ public interface ExamReviewDao extends BaseDAO<Long, ExamReview> {
     List<ExamReviewDto> findExamResult(Map<String, Object> params);
     int countExamResult(Map<String, Object> params);
 
+    int deleteWithRegist(@Param("registIds") List<Long> registIds);
+
     /**
      * 监考页面评审列表查询
      * @param params

+ 2 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamRoomDao.java

@@ -92,6 +92,8 @@ public interface ExamRoomDao extends BaseDAO<Long, ExamRoom> {
      */
     int updateExamRoomStudentNum(@Param("examId") Long examId);
 
+    int updateExamRoomStudentNumWithExams(@Param("examIds") List<Long> examIds);
+
     ExamRoom lockRoom(@Param("examRoomId") Long examRoomId);
 
     /**

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

@@ -39,6 +39,22 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
     List<ExamRoomStudentRelation> findStudentsWithExamRooms(@Param("examRoomIds") List<Long> examRoomIds);
 
     /**
+     * @describe 获取考场中未完成考试的报名编号
+     * @author Joburgess
+     * @date 2020.08.18
+     * @return java.util.List<java.lang.Long>
+     */
+    List<Long> findNoFinishedExamRegistIdsWIthExamRooms();
+
+    /**
+     * @describe 获取考场中未完成考试的报名编号
+     * @author Joburgess
+     * @date 2020.08.18
+     * @return java.util.List<java.lang.Long>
+     */
+    List<ExamRoomStudentRelation> findNoFinishedExamRegistsWIthExamRooms();
+
+    /**
      * @describe 删除指定教室的学员
      * @author Joburgess
      * @date 2020.06.24
@@ -50,6 +66,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

+ 3 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -139,6 +139,9 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
             amount = amount.add(theoryLevelFee);
         }
 
+        if(Objects.isNull(examRegistration.getSubjectId())){
+            examRegistration.setSubjectId(0);
+        }
         examRegistration.setTenantId(organization.getTenantId());
         examRegistration.setStatus(StudentRegistrationStatusEnum.PAY_WAIT);
         examRegistration.setLevelFee(registrationFee);

+ 24 - 6
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.*;
@@ -172,7 +173,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			throw new BizException("线下考试请指定考试地址");
 		}
 		if(StringUtils.isBlank(examRoom.getSubjectIdList())){
-			throw new BizException("请指定考试专业");
+			examRoom.setSubjectIdList("0");
 		}
 		if(Objects.isNull(examRoom.getMainTeacherUserId())){
 			throw new BizException("请指定主考老师");
@@ -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("无权操作");
@@ -896,15 +901,28 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 	@Transactional(rollbackFor = Exception.class)
 	public void cleanExamRoom() {
 		List<ExamRoom> examRooms = examRoomDao.getHistoryOpenExamRoom();
-		if(CollectionUtils.isEmpty(examRooms)){
-			return;
-		}
+
 		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);
+		if(!CollectionUtils.isEmpty(examRooms)){
+			examRoomDao.batchUpdate(examRooms);
+		}
+
+		List<ExamRoomStudentRelation> students = examRoomStudentRelationDao.findNoFinishedExamRegistsWIthExamRooms();
+		if(CollectionUtils.isEmpty(students)){
+			return;
+		}
+
+		Set<Long> registIds = students.stream().map(ExamRoomStudentRelation::getExamRegistrationId).collect(Collectors.toSet());
+		examRoomStudentRelationDao.deleteStudentRoomRegistRelations(new ArrayList<>(registIds));
+		examCertificationDao.deleteWithRegist(new ArrayList<>(registIds));
+		examReviewDao.deleteWithRegist(new ArrayList<>(registIds));
+		studentExamResultDao.deleteWithRegists(new ArrayList<>(registIds));
+
+		Set<Long> examIds = students.stream().map(ExamRoomStudentRelation::getExaminationBasicId).collect(Collectors.toSet());
+		examRoomDao.updateExamRoomStudentNumWithExams(new ArrayList<>(examIds));
 	}
 }

+ 9 - 2
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamReviewMapper.xml

@@ -90,8 +90,15 @@
 	<delete id="delete" >
 		DELETE FROM exam_review WHERE id_ = #{id} 
 	</delete>
-	
-	<!-- 分页查询 -->
+
+    <delete id="deleteWithRegist">
+		DELETE FROM	exam_review WHERE exam_registration_id_ IN
+		<foreach collection="registIds" item="registId" separator="," open="(" close=")">
+			#{registId}
+		</foreach>
+	</delete>
+
+    <!-- 分页查询 -->
 	<select id="queryPage" resultMap="ExamReview" parameterType="map">
 		SELECT * FROM exam_review
 		ORDER BY id_

+ 16 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRoomMapper.xml

@@ -250,6 +250,22 @@
 			er.examination_basic_id_ = #{examId} AND er.id_ = ers.exam_room_id_
 	</update>
 
+	<update id="updateExamRoomStudentNumWithExams">
+		UPDATE exam_room er
+		LEFT JOIN ( SELECT exam_room_id_, COUNT( exam_registration_id_ ) stu_num_ FROM exam_room_student_relation
+		WHERE examination_basic_id_ IN
+		<foreach collection="examIds" item="examId" separator="," open="(" close=")">
+			#{examId}
+		</foreach>
+		GROUP BY exam_room_id_ ) ers ON er.id_ = ers.exam_room_id_
+		SET er.exam_room_student_num_ = CASE WHEN ers.stu_num_ IS NULL THEN 0 ELSE ers.stu_num_ END
+		WHERE
+			er.examination_basic_id_ IN
+			<foreach collection="examIds" item="examId" separator="," open="(" close=")">
+				#{examId}
+			</foreach>
+	</update>
+
     <!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM exam_room WHERE id_ = #{id} 

+ 35 - 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,32 @@
 				#{examRoomId}
 			</foreach>
 	</select>
+
+    <select id="findNoFinishedExamRegistIdsWIthExamRooms" resultType="long">
+		SELECT
+			DISTINCT ser.exam_registration_id_
+		FROM
+			student_exam_result ser
+			LEFT JOIN exam_room er ON ser.exam_room_id_ = er.id_
+			LEFT JOIN examination_basic eb ON ser.examination_basic_id_ = eb.id_
+		WHERE
+			ser.is_finished_exam_ != 5
+			AND eb.status_ != 'RESULT_CONFIRM'
+			AND er.exam_end_time_ &lt; NOW( )
+			AND ser.result_ IS NULL
+	</select>
+
+	<select id="findNoFinishedExamRegistsWIthExamRooms" resultMap="ExamRoomStudentRelation">
+		SELECT
+			DISTINCT ser.*
+		FROM
+			student_exam_result ser
+			LEFT JOIN exam_room er ON ser.exam_room_id_ = er.id_
+			LEFT JOIN examination_basic eb ON ser.examination_basic_id_ = eb.id_
+		WHERE
+			ser.is_finished_exam_ != 5
+			AND eb.status_ != 'RESULT_CONFIRM'
+			AND er.exam_end_time_ &lt; NOW( )
+			AND ser.result_ IS NULL
+	</select>
 </mapper>

BIN
edu-user/edu-user-server/src/main/resources/excelTemplate/examSong.xls


+ 7 - 3
edu-util/src/main/java/com/keao/edu/util/excel/POIUtil.java

@@ -526,16 +526,20 @@ public class POIUtil {
                         currentCellNum++;
                     }
                 }
+
                 if (picMap != null) {
                     for (Entry<String, List<PictureData>> pics : picMap.entrySet()) {
                         String key = pics.getKey();
                         String[] split = key.split("-");
-                        obj.put(fieldsName[Integer.parseInt(split[1])], pics.getValue());
+                        int rowIndex = Integer.parseInt(split[0]);
+                        int cellIndex = Integer.parseInt(split[1]);
+                        if (rowIndex != (currentRowNum - 1)) continue;
+                        obj.put(fieldsName[cellIndex], pics.getValue());
                     }
                 }
+
                 if (obj != null && hasVal)
                     datas.add(obj);
-
             }
             if (!datas.isEmpty())
                 result.put(sheet.getSheetName(), datas);
@@ -641,7 +645,7 @@ public class POIUtil {
      */
     public static Map<String, List<PictureData>> getXlsPictures(HSSFSheet sheet) throws IOException {
         Map<String, List<PictureData>> map = new HashMap<>();
-        if(sheet.getDrawingPatriarch() == null || sheet.getDrawingPatriarch().getChildren()==null){
+        if (sheet.getDrawingPatriarch() == null || sheet.getDrawingPatriarch().getChildren() == null) {
             return map;
         }
         List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();