Browse Source

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

zouxuan 5 years ago
parent
commit
489f6ee150

+ 2 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamRegistrationDao.java

@@ -176,7 +176,8 @@ public interface ExamRegistrationDao extends BaseDAO<Long, ExamRegistration> {
      * @param examId:
      * @return java.util.List<com.keao.edu.user.entity.ExamRegistration>
      */
-    List<ExamRegistration> getNotInRoomStudents(@Param("examId") Long examId);
+    List<ExamRegistration> getNotInRoomStudents(@Param("examId") Long examId,
+                                                @Param("organIds") List<Integer> organIds);
 
     /**
      * @describe 统计合作单位的招生人数

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

@@ -78,7 +78,8 @@ public interface ExamRoomDao extends BaseDAO<Long, ExamRoom> {
      * @return java.util.List<com.keao.edu.user.api.entity.ExamRoom>
      */
     List<ExamRoom> getWithExamAndSubjects(@Param("examId") Long examId,
-                                          @Param("subjectIds") List<Integer> subjectIds);
+                                          @Param("subjectIds") List<Integer> subjectIds,
+                                          @Param("organIds") List<Integer> organIds);
 
     int updateSL(ExamRoom examRoom);
 
@@ -128,7 +129,8 @@ public interface ExamRoomDao extends BaseDAO<Long, ExamRoom> {
      * @param examId:
      * @return int
      */
-    int countSendExamPlanRooms(@Param("examId") Long examId);
+    int countSendExamPlanRooms(@Param("examId") Long examId,
+                               @Param("organIds") List<Integer> organIds);
 
     /**
      * @describe 统计指定项目中教师所在考场数量

+ 2 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/StudentExamResultDao.java

@@ -2,6 +2,7 @@ package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.api.enums.StudentExamResultApiDto;
+import com.keao.edu.user.dto.StudentExamResultDto;
 import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
 import com.keao.edu.user.entity.StudentExamResult;
 import org.apache.ibatis.annotations.Param;
@@ -32,7 +33,7 @@ public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
      * @param params:
      * @return java.util.List<com.keao.edu.user.entity.StudentExamResult>
      */
-    List<StudentExamResult> queryStudentExamResult(Map<String, Object> params);
+    List<StudentExamResultDto> queryStudentExamResult(Map<String, Object> params);
 
     int countStudentExamResult(Map<String, Object> params);
 

+ 21 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dto/StudentExamResultDto.java

@@ -0,0 +1,21 @@
+package com.keao.edu.user.dto;
+
+import com.keao.edu.user.api.enums.ExamModeEnum;
+import com.keao.edu.user.entity.StudentExamResult;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.08.14
+ */
+public class StudentExamResultDto extends StudentExamResult {
+
+    private ExamModeEnum examMode;
+
+    public ExamModeEnum getExamMode() {
+        return examMode;
+    }
+
+    public void setExamMode(ExamModeEnum examMode) {
+        this.examMode = examMode;
+    }
+}

+ 12 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/page/StudentExamResultQueryInfo.java

@@ -2,6 +2,7 @@ package com.keao.edu.user.page;
 
 import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.user.api.enums.ExamEvaluationResultEnum;
+import com.keao.edu.user.api.enums.ExamModeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.util.Date;
@@ -51,6 +52,9 @@ public class StudentExamResultQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "考级项目状态")
     private Integer resultConfirm;
 
+    @ApiModelProperty(value = "考试模式")
+    private ExamModeEnum examMode;
+
     public Integer getStudentId() {
         return studentId;
     }
@@ -154,4 +158,12 @@ public class StudentExamResultQueryInfo extends QueryInfo {
     public void setResultConfirm(Integer resultConfirm) {
         this.resultConfirm = resultConfirm;
     }
+
+    public ExamModeEnum getExamMode() {
+        return examMode;
+    }
+
+    public void setExamMode(ExamModeEnum examMode) {
+        this.examMode = examMode;
+    }
 }

+ 2 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/StudentExamResultService.java

@@ -4,6 +4,7 @@ import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.user.api.enums.StudentExamResultApiDto;
 import com.keao.edu.user.dto.RecordNotify;
+import com.keao.edu.user.dto.StudentExamResultDto;
 import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
 import com.keao.edu.user.entity.StudentExamResult;
 import com.keao.edu.user.page.StudentExamResultQueryInfo;
@@ -17,7 +18,7 @@ public interface StudentExamResultService extends BaseService<Long, StudentExamR
      * @param queryInfo:
      * @return com.keao.edu.common.page.PageInfo<com.keao.edu.user.entity.StudentExamResult>
      */
-    PageInfo<StudentExamResult> queryStudentExamResult(StudentExamResultQueryInfo queryInfo);
+    PageInfo<StudentExamResultDto> queryStudentExamResult(StudentExamResultQueryInfo queryInfo);
 
     /**
      * @describe 更新考试结果

+ 11 - 3
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -250,19 +250,27 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		if(Objects.isNull(examinationBasic)){
 			throw new BizException("考级项目不存在");
 		}
-		int sendExamPlanRooms = examRoomDao.countSendExamPlanRooms(examId);
+
+		ExamOrganizationRelation examOrganizationRelation = examOrganizationRelationDao.getExamOrganizationRelation(examId, selfOrganId);
+		if(Objects.isNull(examOrganizationRelation)||examOrganizationRelation.getIsAllowArrangeExam()==0){
+			throw new BizException("无权操作");
+		}
+
+		List<Integer> childOrganIds = organizationService.getChildOrganIds(selfOrganId, true);
+
+		int sendExamPlanRooms = examRoomDao.countSendExamPlanRooms(examId, childOrganIds);
 		if(sendExamPlanRooms>0){
 			throw new BizException("已发送考试安排,请手动处理未排考学员");
 		}
 		//未排考学员
-		List<ExamRegistration> notInRoomStudents = examRegistrationDao.getNotInRoomStudents(examId);
+		List<ExamRegistration> notInRoomStudents = examRegistrationDao.getNotInRoomStudents(examId, childOrganIds);
 		if(CollectionUtils.isEmpty(notInRoomStudents)){
 			throw new BizException("所有学员都已安排考场");
 		}
 		Map<Integer, List<ExamRegistration>> subjectRegistMap = notInRoomStudents.stream().collect(Collectors.groupingBy(ExamRegistration::getSubjectId));
 		Set<Integer> subjectIds = subjectRegistMap.keySet();
 		//未排考学员可排考考场
-		List<ExamRoom> examRooms = examRoomDao.getWithExamAndSubjects(examId, new ArrayList<>(subjectIds));
+		List<ExamRoom> examRooms = examRoomDao.getWithExamAndSubjects(examId, new ArrayList<>(subjectIds), childOrganIds);
 		if(CollectionUtils.isEmpty(examRooms)){
 			throw new BizException("请先建立考场");
 		}

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

@@ -261,7 +261,7 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
     @Override
     public PageInfo<ExaminationBasicDto> findExaminationBasics(ExaminationQueryInfo queryInfo) {
         PageInfo<ExaminationBasicDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
-        Map<String, Object> params = new HashMap<String, Object>();
+        Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
 
         List<Integer> childOrganIds = organizationService.getChildOrganIds(queryInfo.getOrganId(), true);

+ 4 - 3
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/StudentExamResultServiceImpl.java

@@ -26,6 +26,7 @@ import com.keao.edu.user.dao.ExaminationBasicDao;
 import com.keao.edu.user.dao.StudentExamResultDao;
 import com.keao.edu.user.dto.ExaminationBasicDto;
 import com.keao.edu.user.dto.RecordNotify;
+import com.keao.edu.user.dto.StudentExamResultDto;
 import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
 import com.keao.edu.user.entity.*;
 import com.keao.edu.user.enums.ExamStatusEnum;
@@ -80,15 +81,15 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
 	}
 
 	@Override
-	public PageInfo<StudentExamResult> queryStudentExamResult(StudentExamResultQueryInfo queryInfo) {
-		PageInfo<StudentExamResult> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+	public PageInfo<StudentExamResultDto> queryStudentExamResult(StudentExamResultQueryInfo queryInfo) {
+		PageInfo<StudentExamResultDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 		Map<String, Object> params = new HashMap<String, Object>();
 		MapUtil.populateMap(params, queryInfo);
 
 		List<Integer> childOrganIds = organizationService.getChildOrganIds(queryInfo.getOrganId(), true);
 		params.put("organIds", childOrganIds);
 
-		List<StudentExamResult> dataList = new ArrayList<>();
+		List<StudentExamResultDto> dataList = new ArrayList<>();
 		int count = studentExamResultDao.countStudentExamResult(params);
 		if (count > 0) {
 			pageInfo.setTotal(count);

+ 6 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRegistrationMapper.xml

@@ -645,6 +645,12 @@
 			examination_basic_id_ = #{examId}
 			AND er.status_ IN ('AUDIT_PASS', 'AUDIT_WAIT')
 			AND NOT EXISTS ( SELECT id_ FROM exam_room_student_relation WHERE examination_basic_id_ = #{examId} AND er.id_ = exam_registration_id_ )
+			<if test="organIds!=null">
+				AND er.organ_id_ IN
+				<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+					#{organId}
+				</foreach>
+			</if>
 	</select>
 
     <select id="getOrganExamRegistStatistics" resultType="com.keao.edu.user.dto.OrganExamRegistStatisticsDto">

+ 17 - 3
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRoomMapper.xml

@@ -245,9 +245,9 @@
     <update id="updateExamRoomStudentNum">
 		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_ = #{examId} GROUP BY exam_room_id_ ) ers ON er.id_ = ers.exam_room_id_
-		SET er.exam_room_student_num_ = ers.stu_num_
+		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_ = #{examId}
+			er.examination_basic_id_ = #{examId} AND er.id_ = ers.exam_room_id_
 	</update>
 
     <!-- 根据主键删除一条记录 -->
@@ -447,7 +447,15 @@
 	</select>
 
     <select id="countSendExamPlanRooms" resultType="int">
-		SELECT COUNT(id_) FROM exam_room WHERE examination_basic_id_=#{examId} AND exam_plan_push_flag_=1
+		SELECT COUNT(id_) FROM exam_room
+		WHERE examination_basic_id_=#{examId}
+		AND exam_plan_push_flag_=1
+		<if test="organIds!=null">
+			AND organ_id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
+		</if>
 	</select>
 
 	<select id="getWithExamAndSubjects" resultMap="ExamRoom">
@@ -457,6 +465,12 @@
 		<foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
 			#{subjectId}
 		</foreach>
+		<if test="organIds!=null">
+			AND organ_id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
+		</if>
 	</select>
 
     <select id="countTeacherRooms" resultType="int">

+ 4 - 2
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExaminationBasicMapper.xml

@@ -313,14 +313,16 @@
 			COUNT(id_) 'totalExamNum',
 			SUM(CASE WHEN status_!='RESULT_CONFIRM' THEN 1 ELSE 0 END) 'underWayExamNum'
 		FROM
-			examination_basic
+			examination_basic eb
 		WHERE
 			status_ NOT IN ( 'CLOSE', 'DELETE' )
 			<if test="organIds!=null">
-				AND organ_id_ IN
+				AND EXISTS (SELECT examination_basic_id_ FROM exam_organization_relation WHERE
+				eb.id_=examination_basic_id_ AND organ_id_ IN
 				<foreach collection="organIds" item="organId" separator="," open="(" close=")">
 					#{organId}
 				</foreach>
+				)
 			</if>
 	</select>
 </mapper>

+ 13 - 3
edu-user/edu-user-biz/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -27,7 +27,11 @@
 		<result column="exam_room_id_" property="examRoomId" />
 		<association property="examRegistration" columnPrefix="regist_" resultMap="com.keao.edu.user.dao.ExamRegistrationDao.ExamRegistration"/>
 	</resultMap>
-	
+
+	<resultMap id="StudentExamResultDto" type="com.keao.edu.user.dto.StudentExamResultDto" extends="StudentExamResult">
+		<result column="exam_mode_" property="examMode" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
+	</resultMap>
+
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="StudentExamResult" >
 		SELECT * FROM student_exam_result WHERE id_ = #{id} 
@@ -194,13 +198,16 @@
 			<if test="resultConfirm!=null and resultConfirm==0">
 				AND eb.status_='EXAM_END'
 			</if>
+			<if test="examMode!=null">
+				AND ero.exam_mode_ = #{examMode, typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
+			</if>
 			<!--<if test="resultConfirm==null">-->
 				<!--AND eb.status_ IN ('EXAM_ING', 'EXAM_END','RESULT_CONFIRM')-->
 			<!--</if>-->
 		</where>
 	</sql>
 
-	<select id="queryStudentExamResult" resultMap="StudentExamResult" parameterType="map">
+	<select id="queryStudentExamResult" resultMap="StudentExamResultDto" parameterType="map">
 		SELECT
 			ser.*,
 			er.id_ regist_id_,
@@ -208,12 +215,14 @@
 			er.student_id_ regist_student_id_,
 			er.organ_id_ regist_organ_id_,
 			er.subject_id_ regist_subject_id_,
-			er.level_ regist_level_
+			er.level_ regist_level_,
+			ero.exam_mode_
 		FROM
 			student_exam_result ser
 			LEFT JOIN examination_basic eb ON ser.examination_basic_id_=eb.id_
 			LEFT JOIN exam_registration er ON ser.exam_registration_id_=er.id_
 			LEFT JOIN sys_user su ON ser.student_id_=su.id_
+			LEFT JOIN exam_room ero ON ser.exam_room_id_=ero.id_
 		<include refid="queryStudentExamResultCondition"/>
 		ORDER BY er.id_ <include refid="global.limit"/>
 	</select>
@@ -226,6 +235,7 @@
 			LEFT JOIN examination_basic eb ON ser.examination_basic_id_=eb.id_
 			LEFT JOIN exam_registration er ON ser.exam_registration_id_=er.id_
 			LEFT JOIN sys_user su ON ser.student_id_=su.id_
+			LEFT JOIN exam_room ero ON ser.exam_room_id_=ero.id_
 		<include refid="queryStudentExamResultCondition"/>
 	</select>
 

+ 2 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/StudentExamResultController.java

@@ -8,6 +8,7 @@ import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.user.api.enums.StudentExamResultApiDto;
 import com.keao.edu.user.dto.RecordNotify;
+import com.keao.edu.user.dto.StudentExamResultDto;
 import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
 import com.keao.edu.user.entity.Employee;
 import com.keao.edu.user.entity.StudentExamResult;
@@ -48,7 +49,7 @@ public class StudentExamResultController extends BaseController {
     @ApiOperation("查询考试结果")
     @GetMapping(value = "/queryStudentExamResult")
     @PreAuthorize("@pcs.hasPermissions('studentExamResult/queryStudentExamResult')")
-    public HttpResponseResult<PageInfo<StudentExamResult>> queryStudentExamResult(StudentExamResultQueryInfo queryInfo){
+    public HttpResponseResult<PageInfo<StudentExamResultDto>> queryStudentExamResult(StudentExamResultQueryInfo queryInfo){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(!sysUser.getIsSuperAdmin()&&Objects.isNull(queryInfo.getOrganId())){
             Employee employee = employeeService.get(sysUser.getId());