|
@@ -7,30 +7,31 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.JsonMapper;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.excel.ExportUtils;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreRepo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ExamScoreQuery;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examscore.ObjectiveScoreInfo;
|
|
|
+import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamBoss;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
+import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
|
|
|
+import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.web.support.Naked;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 考试分数相关接口
|
|
@@ -45,6 +46,12 @@ public class ExamScoreController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
private ExamScoreService examScoreService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisClient redisClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamScoreRepo examScoreRepo;
|
|
|
+
|
|
|
@PostMapping("/statistic/list")
|
|
|
@ApiOperation(value = "查询“成绩统计”列表(分页)")
|
|
|
public Page<ExamScoreInfo> getExamAuditList(@RequestBody ExamScoreQuery query) {
|
|
@@ -59,14 +66,76 @@ public class ExamScoreController extends ControllerSupport {
|
|
|
Check.isNull(newQuery, "请求参数不能为空!");
|
|
|
Check.isNull(newQuery.getExamId(), "请先选择考试批次!");
|
|
|
List<ExamScoreInfo> examScoreList = examScoreService.exportExamScoreList(newQuery);
|
|
|
- ExportUtils.exportEXCEL("成绩统计列表", ExamScoreInfo.class,examScoreList,response);
|
|
|
+ ExportUtils.exportEXCEL("成绩统计列表", ExamScoreInfo.class, examScoreList, response);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@ApiOperation(value = "根据examStudentId获取客观分信息")
|
|
|
@GetMapping("/queryObjectiveScoreList")
|
|
|
- public List<ObjectiveScoreInfo> queryObjectiveScoreList(@RequestParam Long examStudentId){
|
|
|
+ public List<ObjectiveScoreInfo> queryObjectiveScoreList(@RequestParam Long examStudentId) {
|
|
|
Check.isNull(examStudentId, "examStudentId 不能为空");
|
|
|
- return examScoreService.queryObjectiveScoreList(examStudentId);
|
|
|
+
|
|
|
+ List<ObjectiveScoreInfo> resultList = examScoreService.queryObjectiveScoreList(examStudentId);
|
|
|
+
|
|
|
+ //如果有未处理完成的考试记录,需要将未处理的考试记录数据添加到列表中
|
|
|
+ String examBossKey = RedisKeyHelper.getBuilder().examBossKey(examStudentId);
|
|
|
+ ExamBoss examBoss = redisClient.get(examBossKey, ExamBoss.class);
|
|
|
+ if (null != examBoss) {
|
|
|
+ //未完全同步的考试记录id
|
|
|
+ List<Long> unSyncedExamRecordDataIds = examBoss.getExamRecordDataIds();
|
|
|
+ if (null != unSyncedExamRecordDataIds && !unSyncedExamRecordDataIds.isEmpty()) {
|
|
|
+ //正序排列
|
|
|
+ unSyncedExamRecordDataIds.sort(Long::compareTo);
|
|
|
+
|
|
|
+ for (Long examRecordDataId : unSyncedExamRecordDataIds) {
|
|
|
+ resultList.add(0, getCachedObjectiveScoreInfo(examRecordDataId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ObjectiveScoreInfo getCachedObjectiveScoreInfo(Long examRecordDataId) {
|
|
|
+ ExamRecordData examRecordData =
|
|
|
+ redisClient.get(RedisKeyHelper.getBuilder().examRecordDataKey(examRecordDataId), ExamRecordData.class);
|
|
|
+ if (null == examRecordData) {
|
|
|
+ throw new StatusException("100001","考试记录的缓存数据有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ ObjectiveScoreInfo objectiveScoreInfo = new ObjectiveScoreInfo();
|
|
|
+
|
|
|
+ //如果考试没有结束,则只能返回部分数据
|
|
|
+ if (!isExamRecordEnded(examRecordData)) {
|
|
|
+ objectiveScoreInfo.setIsExamEnded(false);
|
|
|
+ return objectiveScoreInfo;
|
|
|
+ } else {
|
|
|
+ objectiveScoreInfo.setIsExamEnded(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (examRecordData.getIsIllegality() == null || !examRecordData.getIsIllegality()) {
|
|
|
+ if (examRecordData.getIsWarn() && !examRecordData.getIsAudit()) {
|
|
|
+ objectiveScoreInfo.setIsAuditing(true);
|
|
|
+ } else if (!examRecordData.getIsWarn() || (examRecordData.getIsWarn() && examRecordData.getIsAudit())) {
|
|
|
+ ExamScoreEntity examScore = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
|
|
|
+ objectiveScoreInfo.setIsAuditing(false);
|
|
|
+ objectiveScoreInfo.setObjectiveScore(examScore.getObjectiveScore());
|
|
|
+ }
|
|
|
+ objectiveScoreInfo.setIsIllegality(false);
|
|
|
+ } else {
|
|
|
+ objectiveScoreInfo.setIsIllegality(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ return objectiveScoreInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isExamRecordEnded(ExamRecordData examRecordData) {
|
|
|
+ //如果考试记录状态为已处理,则直接返回true.
|
|
|
+ if (examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_END ||
|
|
|
+ examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_OVERDUE ||
|
|
|
+ examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_INVALID) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
}
|