|
@@ -1,69 +1,39 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.UUID;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.qmth.themis.business.bean.backend.InvigilateListBean;
|
|
|
-import com.qmth.themis.business.bean.backend.InvigilateListHistoryBean;
|
|
|
-import com.qmth.themis.business.bean.backend.InvigilateListPatrolBean;
|
|
|
-import com.qmth.themis.business.bean.backend.InvigilateListProgressBean;
|
|
|
-import com.qmth.themis.business.bean.backend.InvigilateListVideoBean;
|
|
|
-import com.qmth.themis.business.bean.backend.InvigilateListWarningBean;
|
|
|
+import com.qmth.themis.business.bean.backend.*;
|
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
|
import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamStudentAnswerCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamStudentPaperStructCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ObjectiveAnswerCacheBean;
|
|
|
+import com.qmth.themis.business.cache.bean.*;
|
|
|
import com.qmth.themis.business.config.SystemConfig;
|
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dao.TOeExamRecordMapper;
|
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
|
import com.qmth.themis.business.dto.response.TEExamUnFinishDto;
|
|
|
-import com.qmth.themis.business.entity.TEExamStudent;
|
|
|
import com.qmth.themis.business.entity.TOeExamAnswer;
|
|
|
import com.qmth.themis.business.entity.TOeExamRecord;
|
|
|
-import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
|
-import com.qmth.themis.business.enums.ExamTypeEnum;
|
|
|
-import com.qmth.themis.business.enums.LivenessTypeEnum;
|
|
|
-import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
-import com.qmth.themis.business.enums.MqTopicEnum;
|
|
|
-import com.qmth.themis.business.enums.ObjectiveScorePolicyEnum;
|
|
|
-import com.qmth.themis.business.enums.VerifyExceptionEnum;
|
|
|
-import com.qmth.themis.business.service.MqDtoService;
|
|
|
-import com.qmth.themis.business.service.TEExamActivityService;
|
|
|
-import com.qmth.themis.business.service.TEExamPaperService;
|
|
|
-import com.qmth.themis.business.service.TEExamService;
|
|
|
-import com.qmth.themis.business.service.TEExamStudentService;
|
|
|
-import com.qmth.themis.business.service.TOeExamAnswerService;
|
|
|
-import com.qmth.themis.business.service.TOeExamRecordService;
|
|
|
+import com.qmth.themis.business.enums.*;
|
|
|
+import com.qmth.themis.business.service.*;
|
|
|
import com.qmth.themis.business.util.OssUtil;
|
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
|
import com.qmth.themis.common.contanst.Constants;
|
|
|
import com.qmth.themis.common.util.FileUtil;
|
|
|
import com.qmth.themis.common.util.SimpleBeanUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: 考试记录 服务实现类
|
|
@@ -98,7 +68,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
|
|
|
|
|
|
@Resource
|
|
|
TEExamStudentService examStudentService;
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
TEExamActivityService examActivityService;
|
|
|
|
|
@@ -155,8 +125,8 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
|
|
|
@Override
|
|
|
public Long saveByPrepare(Long examId, Long examActivityId, Long examStudentId, Long paperId,
|
|
|
Integer serialNumber) {
|
|
|
- ExamActivityCacheBean ac=examActivityService.getExamActivityCacheBean(examActivityId);
|
|
|
- ExamCacheBean exam=examService.getExamCacheBean(examId);
|
|
|
+ ExamActivityCacheBean ac = examActivityService.getExamActivityCacheBean(examActivityId);
|
|
|
+ ExamCacheBean exam = examService.getExamCacheBean(examId);
|
|
|
TOeExamRecord er = new TOeExamRecord();
|
|
|
er.setId(Constants.idGen.next());
|
|
|
er.setExamId(examId);
|
|
@@ -361,11 +331,11 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
|
|
|
// examStudentService.saveOrUpdate(examStudent);
|
|
|
//上传个人试卷结构
|
|
|
ExamStudentPaperStructCacheBean struct = (ExamStudentPaperStructCacheBean) redisUtil.get(RedisKeyHelper.studentPaperStructKey(recordId));
|
|
|
- if(struct!=null) {
|
|
|
- File structFile = new File(dir + "struct.json");
|
|
|
- FileUtil.saveAsFile(structFile.getAbsolutePath(), struct.getContent());
|
|
|
- SystemConfig systemConfig = SpringContextHolder.getBean(SystemConfig.class);
|
|
|
- OssUtil.ossUpload(systemConfig.getOssEnv(3), structFilePath, structFile);
|
|
|
+ if (struct != null) {
|
|
|
+ File structFile = new File(dir + "struct.json");
|
|
|
+ FileUtil.saveAsFile(structFile.getAbsolutePath(), struct.getContent());
|
|
|
+ SystemConfig systemConfig = SpringContextHolder.getBean(SystemConfig.class);
|
|
|
+ OssUtil.ossUpload(systemConfig.getOssEnv(3), structFilePath, structFile);
|
|
|
}
|
|
|
} finally {
|
|
|
FileUtil.deleteFolder(dir);
|
|
@@ -515,6 +485,19 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
|
|
|
return tOeExamRecordMapper.invigilatePageListVideo(iPage, examId, examActivityId, roomCode, paperDownload, status, name, identity, minWarningCount, maxWarningCount, clientWebsocketStatus, monitorStatusSource, userId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 实时监控台视频随机列表
|
|
|
+ *
|
|
|
+ * @param examId
|
|
|
+ * @param userId
|
|
|
+ * @param randomNum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<InvigilateListVideoBean> invigilatePageListVideoRandom(Long examId, Long userId, Integer randomNum) {
|
|
|
+ return tOeExamRecordMapper.invigilatePageListVideoRandom(examId, userId, randomNum);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询在线巡考列表
|
|
|
*
|
|
@@ -585,6 +568,23 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
|
|
|
return tOeExamRecordMapper.invigilatePageProgressList(iPage, examId, examActivityId, roomCode, courseCode, name, identity, userId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 进度查询列表导出
|
|
|
+ *
|
|
|
+ * @param examId
|
|
|
+ * @param examActivityId
|
|
|
+ * @param roomCode
|
|
|
+ * @param courseCode
|
|
|
+ * @param name
|
|
|
+ * @param identity
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<InvigilateListProgressBean> invigilatePageProgressListExport(Long examId, Long examActivityId, String roomCode, String courseCode, String name, String identity, Long userId) {
|
|
|
+ return tOeExamRecordMapper.invigilatePageProgressListExport(examId, examActivityId, roomCode, courseCode, name, identity, userId);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 监考明细管理列表
|
|
|
*
|
|
@@ -613,49 +613,49 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
|
|
|
public IPage<InvigilateListHistoryBean> invigilatePageListHistory(IPage<Map> iPage, Long examId, Long examActivityId, String roomCode, String courseCode, String status, Integer breachStatus, String finishType, String name, String identity, Integer minMultipleFaceCount, Integer maxMultipleFaceCount, Integer minExceptionCount, Integer maxExceptionCount, Integer minWarningCount, Integer maxWarningCount, String clientWebsocketStatus, String monitorStatusSource, Long userId) {
|
|
|
return tOeExamRecordMapper.invigilatePageListHistory(iPage, examId, examActivityId, roomCode, courseCode, status, breachStatus, finishType, name, identity, minMultipleFaceCount, maxMultipleFaceCount, minExceptionCount, maxExceptionCount, minWarningCount, maxWarningCount, clientWebsocketStatus, monitorStatusSource, userId);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 重新算分
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void calculateScore(Long recordId) {
|
|
|
-
|
|
|
- TOeExamRecord rec=this.getById(recordId);
|
|
|
-
|
|
|
+
|
|
|
+ TOeExamRecord rec = this.getById(recordId);
|
|
|
+
|
|
|
Map<String, ObjectiveAnswerCacheBean> map = examPaperService.getObjectiveAnswerCacheBean(rec.getPaperId());
|
|
|
if (map == null || map.size() == 0) {
|
|
|
- log.debug("no ObjectiveAnswerCacheBean for calculateObjectiveScore recordId:"+recordId);
|
|
|
+ log.debug("no ObjectiveAnswerCacheBean for calculateObjectiveScore recordId:" + recordId);
|
|
|
return;
|
|
|
}
|
|
|
QueryWrapper<TOeExamAnswer> wp = new QueryWrapper<>();
|
|
|
- wp.lambda().eq(TOeExamAnswer::getExamRecordId, recordId);
|
|
|
- List<TOeExamAnswer> answers=examAnswerService.list(wp);
|
|
|
- if(answers==null||answers.size()==0) {
|
|
|
- log.debug("no ObjectiveAnswer for calculateObjectiveScore recordId:"+recordId);
|
|
|
- return;
|
|
|
- }
|
|
|
- BigDecimal tatolscore = new BigDecimal(0.0);
|
|
|
- for(TOeExamAnswer answer:answers) {
|
|
|
- Double score=calculateScoreForQuestion(answer, map);
|
|
|
- if(score!=null) {
|
|
|
- tatolscore=tatolscore.add(new BigDecimal(score));
|
|
|
- }
|
|
|
- }
|
|
|
+ wp.lambda().eq(TOeExamAnswer::getExamRecordId, recordId);
|
|
|
+ List<TOeExamAnswer> answers = examAnswerService.list(wp);
|
|
|
+ if (answers == null || answers.size() == 0) {
|
|
|
+ log.debug("no ObjectiveAnswer for calculateObjectiveScore recordId:" + recordId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BigDecimal tatolscore = new BigDecimal(0.0);
|
|
|
+ for (TOeExamAnswer answer : answers) {
|
|
|
+ Double score = calculateScoreForQuestion(answer, map);
|
|
|
+ if (score != null) {
|
|
|
+ tatolscore = tatolscore.add(new BigDecimal(score));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 设置客观分总分
|
|
|
- tOeExamRecordMapper.updateObjectiveScore(recordId, tatolscore.doubleValue());
|
|
|
+ tOeExamRecordMapper.updateObjectiveScore(recordId, tatolscore.doubleValue());
|
|
|
}
|
|
|
-
|
|
|
- private Double calculateScoreForQuestion(TOeExamAnswer answer,Map<String, ObjectiveAnswerCacheBean> map) {
|
|
|
- Long recordId=answer.getExamRecordId();
|
|
|
- Integer mainNumber=answer.getMainNumber();
|
|
|
- Integer subNumber=answer.getSubNumber();
|
|
|
- Integer subIndex=answer.getSubIndex();
|
|
|
- String key = RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex);
|
|
|
+
|
|
|
+ private Double calculateScoreForQuestion(TOeExamAnswer answer, Map<String, ObjectiveAnswerCacheBean> map) {
|
|
|
+ Long recordId = answer.getExamRecordId();
|
|
|
+ Integer mainNumber = answer.getMainNumber();
|
|
|
+ Integer subNumber = answer.getSubNumber();
|
|
|
+ Integer subIndex = answer.getSubIndex();
|
|
|
+ String key = RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex);
|
|
|
ObjectiveAnswerCacheBean cb = map.get(key);
|
|
|
if (cb == null) {
|
|
|
- log.debug("not a objective question recordId:"+answer.getExamRecordId()+" key:"+key);
|
|
|
+ log.debug("not a objective question recordId:" + answer.getExamRecordId() + " key:" + key);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -696,36 +696,40 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
|
|
|
}
|
|
|
|
|
|
examAnswerService.saveOrUpdate(answer);
|
|
|
-
|
|
|
+
|
|
|
return answer.getScore();
|
|
|
}
|
|
|
-
|
|
|
- /**获取考试记录数
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取考试记录数
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public Long getCountByExamId(Long examId) {
|
|
|
- return tOeExamRecordMapper.getCountByExamId(examId);
|
|
|
+ return tOeExamRecordMapper.getCountByExamId(examId);
|
|
|
}
|
|
|
-
|
|
|
- /**批量获取考试记录
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量获取考试记录
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param startId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<TOeExamRecord> getListByExamIdAndStartId(Long examId,Long startId) {
|
|
|
- return tOeExamRecordMapper.getListByExamIdAndStartId(examId, startId);
|
|
|
+ public List<TOeExamRecord> getListByExamIdAndStartId(Long examId, Long startId) {
|
|
|
+ return tOeExamRecordMapper.getListByExamIdAndStartId(examId, startId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TOeExamRecord findOneByPaperId(Long paperId) {
|
|
|
+ return tOeExamRecordMapper.findOneByPaperId(paperId);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public TOeExamRecord findOneByPaperId(Long paperId) {
|
|
|
- return tOeExamRecordMapper.findOneByPaperId(paperId);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public TOeExamRecord findOneByExamId(Long examId) {
|
|
|
- return tOeExamRecordMapper.findOneByExamId(examId);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public TOeExamRecord findOneByExamId(Long examId) {
|
|
|
+ return tOeExamRecordMapper.findOneByExamId(examId);
|
|
|
+ }
|
|
|
}
|