Joburgess 5 anni fa
parent
commit
f899b5b059

+ 61 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/StudentExamResultController.java

@@ -0,0 +1,61 @@
+package com.keao.edu.user.controller;
+
+import com.keao.edu.auth.api.client.SysUserFeignService;
+import com.keao.edu.auth.api.entity.SysUser;
+import com.keao.edu.common.controller.BaseController;
+import com.keao.edu.common.entity.HttpResponseResult;
+import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
+import com.keao.edu.user.entity.ExamReview;
+import com.keao.edu.user.entity.StudentExamResult;
+import com.keao.edu.user.page.StudentExamResultQueryInfo;
+import com.keao.edu.user.service.StudentExamResultService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Objects;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.06.30
+ */
+@RestController
+@RequestMapping("studentExamResult")
+@Api(tags = "考试结果服务")
+public class StudentExamResultController extends BaseController {
+
+    @Autowired
+    private StudentExamResultService studentExamResultService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation("查询考试结果")
+    @GetMapping(value = "/queryStudentExamResult")
+    public HttpResponseResult<PageInfo<StudentExamResult>> queryStudentExamResult(StudentExamResultQueryInfo queryInfo){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(Objects.isNull(queryInfo.getOrganId())){
+            queryInfo.setOrganId(sysUser.getId());
+        }
+        return succeed(studentExamResultService.queryStudentExamResult(queryInfo));
+    }
+
+    @ApiOperation("修改考试结果")
+    @PostMapping(value = "/update")
+    public HttpResponseResult update(StudentExamResult examResult){
+        studentExamResultService.updateStudentExamResult(examResult);
+        return succeed();
+    }
+
+    @ApiOperation("考试结果统计信息")
+    @PostMapping(value = "/getStudentExamResultStatisticsInfo")
+    public HttpResponseResult<StudentExamResultStatisticsDto> getStudentExamResultStatisticsInfo(Integer examId){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        return succeed(studentExamResultService.getStudentExamResultStatisticsInfo(sysUser.getId(), examId));
+    }
+
+}

+ 26 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/StudentExamResultDao.java

@@ -1,9 +1,34 @@
 package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
 import com.keao.edu.user.entity.StudentExamResult;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
 
-	
+    /**
+     * @describe 查询考试结果
+     * @author Joburgess
+     * @date 2020.06.30
+     * @param params:
+     * @return java.util.List<com.keao.edu.user.entity.StudentExamResult>
+     */
+    List<StudentExamResult> queryStudentExamResult(Map<String, Object> params);
+    int countStudentExamResult(Map<String, Object> params);
+
+    /**
+     * @describe 考试结果统计信息
+     * @author Joburgess
+     * @date 2020.06.30
+     * @param organIds:
+     * @param examId:
+     * @return com.keao.edu.user.dto.StudentExamResultStatisticsDto
+     */
+    StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(@Param("organIds") List<Integer> organIds,
+                                                                      @Param("examId") Integer examId);
+
 }

+ 54 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/StudentExamResultStatisticsDto.java

@@ -0,0 +1,54 @@
+package com.keao.edu.user.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.06.30
+ */
+public class StudentExamResultStatisticsDto {
+
+    @ApiModelProperty(value = "总招生人数")
+    private int totalRegistrationStudentNum;
+
+    @ApiModelProperty(value = "参考人数")
+    private int examStudentNum;
+
+    @ApiModelProperty(value = "缺考人数")
+    private int notExamStudentNum;
+
+    @ApiModelProperty(value = "不及格人数")
+    private int examFailStudentNum;
+
+    public int getTotalRegistrationStudentNum() {
+        return totalRegistrationStudentNum;
+    }
+
+    public void setTotalRegistrationStudentNum(int totalRegistrationStudentNum) {
+        this.totalRegistrationStudentNum = totalRegistrationStudentNum;
+    }
+
+    public int getExamStudentNum() {
+        return examStudentNum;
+    }
+
+    public void setExamStudentNum(int examStudentNum) {
+        this.examStudentNum = examStudentNum;
+    }
+
+    public int getNotExamStudentNum() {
+        return notExamStudentNum;
+    }
+
+    public void setNotExamStudentNum(int notExamStudentNum) {
+        this.notExamStudentNum = notExamStudentNum;
+    }
+
+    public int getExamFailStudentNum() {
+        return examFailStudentNum;
+    }
+
+    public void setExamFailStudentNum(int examFailStudentNum) {
+        this.examFailStudentNum = examFailStudentNum;
+    }
+}

+ 8 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/Organization.java

@@ -54,6 +54,14 @@ public class Organization {
 
 	private SysUser sysUser;
 
+	public Organization() {
+	}
+
+	public Organization(Integer id, String name) {
+		this.id = id;
+		this.name = name;
+	}
+
 	public YesOrNoEnum getIsAllowArrangeExam() {
 		return isAllowArrangeExam;
 	}

+ 42 - 33
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/StudentExamResult.java

@@ -1,5 +1,7 @@
 package com.keao.edu.user.entity;
 
+import com.keao.edu.user.enums.ExamEvaluationResultEnum;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
@@ -7,34 +9,33 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
  */
 public class StudentExamResult {
 
-	/**  */
 	private Long id;
 	
-	/**  */
+	@ApiModelProperty(value = "考级项目编号")
 	private Integer examinationBasicId;
 	
-	/**  */
+	@ApiModelProperty(value = "学员编号")
 	private Integer studentId;
+
+	@ApiModelProperty(value = "学员注册信息")
+	private ExamRegistration examRegistration;
+
+	@ApiModelProperty(value = "考试结果")
+	private ExamEvaluationResultEnum result;
+
+	@ApiModelProperty(value = "考试结果确认")
+	private Boolean confirmStatus;
 	
-	/** 考试结果 */
-	private String result;
-	
-	/** 确认状态(1-已确认 0-未确认) */
-	private boolean confirmStatus;
-	
-	/**  */
+	@ApiModelProperty(value = "备注")
 	private String memo;
 	
-	/** 操作人编号 */
+	@ApiModelProperty(value = "操作者")
 	private Integer operatorId;
-	
-	/**  */
+
 	private java.util.Date createTime;
-	
-	/**  */
+
 	private java.util.Date updateTime;
-	
-	/**  */
+
 	private String tenantId;
 	
 	public void setId(Long id){
@@ -44,7 +45,23 @@ public class StudentExamResult {
 	public Long getId(){
 		return this.id;
 	}
-			
+
+	public ExamRegistration getExamRegistration() {
+		return examRegistration;
+	}
+
+	public void setExamRegistration(ExamRegistration examRegistration) {
+		this.examRegistration = examRegistration;
+	}
+
+	public Boolean getConfirmStatus() {
+		return confirmStatus;
+	}
+
+	public void setConfirmStatus(Boolean confirmStatus) {
+		this.confirmStatus = confirmStatus;
+	}
+
 	public void setExaminationBasicId(Integer examinationBasicId){
 		this.examinationBasicId = examinationBasicId;
 	}
@@ -60,23 +77,15 @@ public class StudentExamResult {
 	public Integer getStudentId(){
 		return this.studentId;
 	}
-			
-	public void setResult(String result){
-		this.result = result;
-	}
-	
-	public String getResult(){
-		return this.result;
-	}
-			
-	public void setConfirmStatus(boolean confirmStatus){
-		this.confirmStatus = confirmStatus;
+
+	public ExamEvaluationResultEnum getResult() {
+		return result;
 	}
-	
-	public boolean isConfirmStatus(){
-		return this.confirmStatus;
+
+	public void setResult(ExamEvaluationResultEnum result) {
+		this.result = result;
 	}
-			
+
 	public void setMemo(String memo){
 		this.memo = memo;
 	}

+ 1 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/enums/ExamStatusEnum.java

@@ -13,6 +13,7 @@ public enum ExamStatusEnum implements BaseEnum<String, ExamStatusEnum> {
     APPLIED("APPLIED", "报名结束"),
     EXAM_ING("EXAM_ING", "考试中"),
     EXAM_END("EXAM_END", "考试结束"),
+    RESULT_CONFIRM("RESULT_CONFIRM", "确认考试结果"),
     CLOSE("CLOSE", "关闭");
 
     private String code;

+ 60 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/StudentExamResultQueryInfo.java

@@ -0,0 +1,60 @@
+package com.keao.edu.user.page;
+
+import com.keao.edu.common.page.QueryInfo;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.06.30
+ */
+public class StudentExamResultQueryInfo extends QueryInfo {
+
+    private Integer organId;
+
+    private Integer examId;
+
+    private String cardNo;
+
+    private Integer subjectId;
+
+    private Integer level;
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public Integer getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Integer examId) {
+        this.examId = examId;
+    }
+
+    public String getCardNo() {
+        return cardNo;
+    }
+
+    public void setCardNo(String cardNo) {
+        this.cardNo = cardNo;
+    }
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public Integer getLevel() {
+        return level;
+    }
+
+    public void setLevel(Integer level) {
+        this.level = level;
+    }
+}

+ 26 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/StudentExamResultService.java

@@ -1,8 +1,34 @@
 package com.keao.edu.user.service;
 
+import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
+import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
 import com.keao.edu.user.entity.StudentExamResult;
+import com.keao.edu.user.page.StudentExamResultQueryInfo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface StudentExamResultService extends BaseService<Long, StudentExamResult> {
 
+    /**
+     * @describe 查询考试结果
+     * @author Joburgess
+     * @date 2020.06.30
+     * @param queryInfo:
+     * @return com.keao.edu.common.page.PageInfo<com.keao.edu.user.entity.StudentExamResult>
+     */
+    PageInfo<StudentExamResult> queryStudentExamResult(StudentExamResultQueryInfo queryInfo);
+
+    /**
+     * @describe 更新考试结果
+     * @author Joburgess
+     * @date 2020.06.30
+     * @param studentExamResult:
+     * @return void
+     */
+    void updateStudentExamResult(StudentExamResult studentExamResult);
+
+    StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(Integer organId, Integer examId);
+
 }

+ 78 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/StudentExamResultServiceImpl.java

@@ -1,22 +1,98 @@
 package com.keao.edu.user.service.impl;
 
+import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.exception.BizException;
+import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.user.dao.ExaminationBasicDao;
 import com.keao.edu.user.dao.StudentExamResultDao;
+import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
+import com.keao.edu.user.entity.ExaminationBasic;
+import com.keao.edu.user.entity.Organization;
 import com.keao.edu.user.entity.StudentExamResult;
+import com.keao.edu.user.entity.Subject;
+import com.keao.edu.user.enums.ExamStatusEnum;
+import com.keao.edu.user.page.StudentExamResultQueryInfo;
+import com.keao.edu.user.service.OrganizationService;
 import com.keao.edu.user.service.StudentExamResultService;
+import com.keao.edu.util.collection.MapUtil;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.*;
+import java.util.stream.Collectors;
+
 @Service
 public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentExamResult> implements StudentExamResultService {
-	
+
+	@Autowired
+	private ExaminationBasicDao examinationBasicDao;
 	@Autowired
 	private StudentExamResultDao studentExamResultDao;
+	@Autowired
+	private OrganizationService organizationService;
 
 	@Override
 	public BaseDAO<Long, StudentExamResult> getDAO() {
 		return studentExamResultDao;
 	}
-	
+
+	@Override
+	public PageInfo<StudentExamResult> queryStudentExamResult(StudentExamResultQueryInfo queryInfo) {
+		PageInfo<StudentExamResult> 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<>();
+		int count = this.findCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = this.getDAO().queryPage(params);
+			List<Integer> studentIds = dataList.stream().map(StudentExamResult::getStudentId).collect(Collectors.toList());
+			List<Integer> subjectIds = dataList.stream().map(e -> e.getExamRegistration().getSubjectId()).collect(Collectors.toList());
+			List<Integer> organIds = dataList.stream().map(e -> e.getExamRegistration().getOrganId()).collect(Collectors.toList());
+			Map<Integer, String> studentIdNameMap = this.getMap("sys_user", "id_", "real_name_", studentIds, Integer.class, String.class);
+			Map<Integer, String> subjectIdNameMap = this.getMap("subject", "id_", "name_", subjectIds, Integer.class, String.class);
+			Map<Integer, String> organIdNameMap = this.getMap("organization", "id_", "name_", organIds, Integer.class, String.class);
+			for (StudentExamResult s : dataList) {
+				s.getExamRegistration().setSysUser(new SysUser(s.getStudentId(), studentIdNameMap.get(s.getStudentId())));
+				s.getExamRegistration().setSubject(new Subject(s.getExamRegistration().getSubjectId(), subjectIdNameMap.get(s.getExamRegistration().getSubjectId())));
+				s.getExamRegistration().setOrganization(new Organization(s.getExamRegistration().getOrganId(), organIdNameMap.get(s.getExamRegistration().getSubjectId())));
+			}
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+	@Override
+	public void updateStudentExamResult(StudentExamResult studentExamResult) {
+		if(Objects.isNull(studentExamResult.getId())){
+			throw new BizException("请指定考试结果");
+		}
+		StudentExamResult oldStudentExamResult = studentExamResultDao.get(studentExamResult.getId());
+		if(Objects.isNull(oldStudentExamResult)){
+			throw new BizException("考试结果不存在");
+		}
+		ExaminationBasic examinationBasic = examinationBasicDao.get(studentExamResult.getExaminationBasicId().longValue());
+		if(Objects.isNull(examinationBasic)){
+			throw new BizException("考级项目不存在");
+		}
+		if(ExamStatusEnum.RESULT_CONFIRM.equals(examinationBasic.getStatus())||ExamStatusEnum.CLOSE.equals(examinationBasic.getStatus())){
+			throw new BizException("考试结果不可编辑");
+		}
+		studentExamResultDao.update(studentExamResult);
+	}
+
+	@Override
+	public StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(Integer organId, Integer examId) {
+		List<Integer> childOrganIds = organizationService.getChildOrganIds(organId, true);
+		StudentExamResultStatisticsDto studentExamResultStatisticsInfo = studentExamResultDao.getStudentExamResultStatisticsInfo(childOrganIds, examId);
+		return studentExamResultStatisticsInfo;
+	}
 }

+ 63 - 6
edu-user/edu-user-server/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -10,13 +10,14 @@
 		<result column="id_" property="id" />
 		<result column="examination_basic_id_" property="examinationBasicId" />
 		<result column="student_id_" property="studentId" />
-		<result column="result_" property="result" />
+		<result column="result_" property="result" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
 		<result column="confirm_status_" property="confirmStatus" />
 		<result column="memo_" property="memo" />
 		<result column="operator_id_" property="operatorId" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="tenant_id_" property="tenantId" />
+		<association property="examRegistration" columnPrefix="regist_" resultMap="com.keao.edu.user.dao.ExamRegistrationDao.ExamRegistration"/>
 	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -32,7 +33,7 @@
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.keao.edu.user.entity.StudentExamResult" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO student_exam_result (id_,examination_basic_id_,student_id_,result_,confirm_status_,memo_,operator_id_,create_time_,update_time_,tenant_id_)
-		VALUES(#{id},#{examinationBasicId},#{studentId},#{result},#{confirmStatus},#{memo},#{operatorId},NOW(),NOW(),#{tenantId})
+		VALUES(#{id},#{examinationBasicId},#{studentId},#{result,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{confirmStatus},#{memo},#{operatorId},NOW(),NOW(),#{tenantId})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -45,9 +46,6 @@
 			<if test="operatorId != null">
 				operator_id_ = #{operatorId},
 			</if>
-			<if test="id != null">
-				id_ = #{id},
-			</if>
 			<if test="tenantId != null">
 				tenant_id_ = #{tenantId},
 			</if>
@@ -58,7 +56,7 @@
 				student_id_ = #{studentId},
 			</if>
 			<if test="result != null">
-				result_ = #{result},
+				result_ = #{result,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
 			</if>
 			<if test="memo != null">
 				memo_ = #{memo},
@@ -81,4 +79,63 @@
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM student_exam_result
 	</select>
+
+	<sql id="queryStudentExamResultCondition">
+		<where>
+			er.organ_id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
+			<if test="examId!=null">
+				er.examination_basic_id_ = #{examId}
+			</if>
+		</where>
+	</sql>
+
+	<select id="queryStudentExamResult" resultMap="StudentExamResult" parameterType="map">
+		SELECT
+			er.card_no_,
+			er.student_id_,
+			er.organ_id_,
+			er.subject_id_,
+			er.level_,
+			CASE WHEN ser.id_>0 THEN 1 ELSE 0 END,
+			ser.confirm_status_
+		FROM
+			exam_registration er
+			LEFT JOIN student_exam_result ser ON er.examination_basic_id_ = ser.examination_basic_id_
+			AND er.student_id_ = ser.student_id_
+		<include refid="queryStudentExamResultCondition"/>
+		ORDER BY id_ <include refid="global.limit"/>
+	</select>
+
+	<select id="countStudentExamResult" resultType="int">
+		SELECT
+			COUNT(er.id_)
+		FROM
+			exam_registration er
+			LEFT JOIN student_exam_result ser ON er.examination_basic_id_ = ser.examination_basic_id_
+			AND er.student_id_ = ser.student_id_
+		<include refid="queryStudentExamResultCondition"/>
+	</select>
+
+	<select id="getStudentExamResultStatisticsInfo" resultType="com.keao.edu.user.dto.StudentExamResultStatisticsDto">
+		SELECT
+			COUNT( er.id_ ) totalRegistrationStudentNum,
+			SUM( CASE WHEN ser.id_ > 0 THEN 0 ELSE 1 END ) notExamStudentNum,
+			SUM( CASE WHEN ser.result_ = 'FAIL' THEN 1 ELSE 0 END ) examFailStudentNum,
+			SUM( CASE WHEN ser.id_ > 0 THEN 1 ELSE 0 END ) examStudentNum
+		FROM
+			exam_registration er
+			LEFT JOIN student_exam_result ser ON er.examination_basic_id_ = ser.examination_basic_id_
+			AND er.student_id_ = ser.student_id_
+		WHERE
+			er.examination_basic_id_ = #{examId}
+			AND er.organ_id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
+		GROUP BY
+			er.examination_basic_id_
+	</select>
 </mapper>