|
@@ -22,12 +22,24 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.LocalCacheService;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.*;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.cache.ExamStudentCache;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.others.ExamCacheTransferHelper;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.bean.ExamSpecialSettingsBean;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetOngoingExamListReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetOngoingExamListResp;
|
|
|
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamBoss;
|
|
|
+import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
|
|
|
+import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
|
|
|
+import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.hibernate.query.NativeQuery;
|
|
|
import org.hibernate.transform.Transformers;
|
|
@@ -50,6 +62,8 @@ import java.math.BigDecimal;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import static cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentMapper.statisticFinishedColumns;
|
|
|
import static cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentMapper.statisticOrgColumns;
|
|
@@ -81,7 +95,11 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
private LocalCacheService localCacheService;
|
|
|
@Autowired
|
|
|
private ExamStudentCache examStudentCache;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ExamCloudService examCloudService;
|
|
|
+ @Autowired
|
|
|
+ private RedisClient redisClient;
|
|
|
+
|
|
|
@Override
|
|
|
public void syncExamStudentAllData(List<ExamStudentInfo> examStudents) {
|
|
|
Check.isEmpty(examStudents, "考生信息不能为空!");
|
|
@@ -658,4 +676,112 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据学生id获取考试列表
|
|
|
+ *
|
|
|
+ * @param studentId 学生id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<OnHandExamInfo> queryOnlineExamList(Long studentId) {
|
|
|
+ StudentCacheBean studentBean = CacheHelper.getStudent(studentId);
|
|
|
+
|
|
|
+ //获取可以考的和即将考的考试Id
|
|
|
+ GetOngoingExamListReq getOngoingExamListReq = new GetOngoingExamListReq();
|
|
|
+ getOngoingExamListReq.setExamType(ExamType.ONLINE.name());
|
|
|
+ getOngoingExamListReq.setRootOrgId(studentBean.getRootOrgId());
|
|
|
+ getOngoingExamListReq.setOrgId(studentBean.getOrgId());
|
|
|
+ getOngoingExamListReq.setStudentId(studentId);
|
|
|
+ GetOngoingExamListResp getOngoingExamListResp = examCloudService.getOngoingExamList(getOngoingExamListReq);
|
|
|
+
|
|
|
+ //获取学生所在组织机构的所有考试列表集合(虽然名字起的特殊考试设置,事实上取的就是实际的可考的考试列表,可能是考试中心特殊设置的考试时间,也可能不是)
|
|
|
+ List<ExamSpecialSettingsBean> examSpecialSettingsBeanList = getOngoingExamListResp.getExamSpecialSettingsList();
|
|
|
+ if (examSpecialSettingsBeanList == null || examSpecialSettingsBeanList.size() == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<Long> examIds = examSpecialSettingsBeanList.stream().map(ExamSpecialSettingsBean::getExamId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //只查没有禁用的考生
|
|
|
+ List<ExamStudentEntity> examStudents = examStudentRepo.findByStudentIdAndEnableAndExamIdIn(studentId, true, examIds);
|
|
|
+ List<OnHandExamInfo> examStudentDtoList = new ArrayList<OnHandExamInfo>();
|
|
|
+ for (ExamStudentEntity examStudent : examStudents) {
|
|
|
+ Stream<ExamSpecialSettingsBean> examSpecialSettingsBeanStream = examSpecialSettingsBeanList.stream().filter(examSpecialSettingsBean -> {
|
|
|
+ return examSpecialSettingsBean.getExamId().longValue() == examStudent.getExamId().longValue();
|
|
|
+ });
|
|
|
+ if (examSpecialSettingsBeanStream != null) {
|
|
|
+ ExamSpecialSettingsBean examSpecialSettingsBean = examSpecialSettingsBeanStream.findFirst().get();
|
|
|
+ examStudentDtoList.add(assemblingExamStudentDto(examStudent, examSpecialSettingsBean));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return examStudentDtoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private OnHandExamInfo assemblingExamStudentDto(ExamStudentEntity examStudent, ExamSpecialSettingsBean examSpecialSettingsBean) {
|
|
|
+ OnHandExamInfo examStudentInfo = new OnHandExamInfo();
|
|
|
+ examStudentInfo.setExamStudentId(examStudent.getExamStudentId());
|
|
|
+ examStudentInfo.setStudentCode(examStudent.getStudentCode());
|
|
|
+ examStudentInfo.setStudentName(examStudent.getStudentName());
|
|
|
+ Long rootOrgId = examStudent.getRootOrgId();
|
|
|
+ examStudentInfo.setRootOrgId(rootOrgId);
|
|
|
+ examStudentInfo.setIdentityNumber(examStudent.getIdentityNumber());
|
|
|
+
|
|
|
+ CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
|
|
|
+ examStudentInfo.setCourseName(courseBean.getName());
|
|
|
+ examStudentInfo.setCourseCode(courseBean.getCode());
|
|
|
+ examStudentInfo.setCourseLevel(CourseLevel.getCourseLevel(courseBean.getLevel()).getTitle());
|
|
|
+ examStudentInfo.setCourseId(examStudent.getCourseId());
|
|
|
+ examStudentInfo.setSpecialtyName(examStudent.getSpecialtyName());
|
|
|
+ Long orgId = examStudent.getOrgId();
|
|
|
+ examStudentInfo.setOrgId(orgId);
|
|
|
+
|
|
|
+ OrgCacheBean orgBean = gainBaseDataService.getOrgBean(orgId);
|
|
|
+ Long studentId = examStudent.getStudentId();
|
|
|
+ ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
|
|
|
+ studentId);
|
|
|
+
|
|
|
+ examStudentInfo.setOrgName(orgBean.getName());
|
|
|
+ Long examId = examBean.getId();
|
|
|
+ examStudentInfo.setExamId(examId);
|
|
|
+ examStudentInfo.setExamName(examBean.getName());
|
|
|
+ examStudentInfo.setStartTime(examSpecialSettingsBean.getBeginTime());//考试开始时间设置
|
|
|
+ examStudentInfo.setEndTime(examSpecialSettingsBean.getEndTime());//考试结束时间设置
|
|
|
+ examStudentInfo.setAllowExamCount(countExamTimes(examStudent, examBean));
|
|
|
+ examStudentInfo.setPaperMins(examBean.getDuration());
|
|
|
+ //是否启用人脸识别
|
|
|
+ examStudentInfo.setFaceEnable(FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId));
|
|
|
+ //进入考试是否验证人脸识别(强制、非强制)
|
|
|
+ examStudentInfo.setFaceCheck(FaceBiopsyHelper.isFaceCheck(examId, studentId));
|
|
|
+ //是否显示客观分
|
|
|
+ String isObjScoreView = ExamCacheTransferHelper.getCachedExamProperty(examId,
|
|
|
+ studentId, ExamProperties.IS_OBJ_SCORE_VIEW.name()).getValue();
|
|
|
+ if (StringUtils.isBlank(isObjScoreView)) {
|
|
|
+ examStudentInfo.setIsObjScoreView(false);
|
|
|
+ } else {
|
|
|
+ examStudentInfo.setIsObjScoreView(Boolean.valueOf(isObjScoreView));
|
|
|
+ }
|
|
|
+ return examStudentInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer countExamTimes(ExamStudentEntity examStudentInfo, ExamBean examBean) {
|
|
|
+ if (ExamType.OFFLINE.name().equals(examBean.getExamType())) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ //考试批次中设置的考试次数
|
|
|
+ int canExamTimes = examBean.getExamTimes().intValue();
|
|
|
+ //可补考次数
|
|
|
+ int extraNum = (examStudentInfo.getExtraNum()==null?0:examStudentInfo.getExtraNum());
|
|
|
+ //考生已考次数
|
|
|
+ int usedNum = (examStudentInfo.getUsedNum()==null?0:examStudentInfo.getUsedNum());
|
|
|
+ //缓存中开考次数
|
|
|
+ int startCount=0;
|
|
|
+ //缓存中考试完结次数
|
|
|
+ int endCount=0;
|
|
|
+ String key = RedisKeyHelper.getBuilder().examBossKey(examBean.getId());
|
|
|
+ ExamBoss eb=redisClient.get(key, ExamBoss.class);
|
|
|
+ if(eb!=null) {
|
|
|
+ startCount=eb.getStartCount();
|
|
|
+ endCount=eb.getEndCount();
|
|
|
+ }
|
|
|
+ return canExamTimes+extraNum-(usedNum+startCount-endCount);
|
|
|
+ }
|
|
|
+
|
|
|
}
|