|
@@ -25,7 +25,14 @@ import java.util.stream.Stream;
|
|
|
import javax.persistence.EntityManager;
|
|
|
import javax.persistence.Query;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.DateUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.util.RegExpUtil;
|
|
|
+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.examwork.api.ExamStudentCloudService;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentResp;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.hibernate.query.NativeQuery;
|
|
|
import org.hibernate.transform.Transformers;
|
|
@@ -62,13 +69,6 @@ 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.CourseProgressInfo;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentEntityConvert;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentFinishedStatistic;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentInfo;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentOrgStatistic;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentPartInfo;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentQuery;
|
|
|
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;
|
|
@@ -84,6 +84,8 @@ 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 cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
|
|
|
+
|
|
|
/**
|
|
|
* 考生信息接口
|
|
|
*
|
|
@@ -116,11 +118,14 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
@Autowired
|
|
|
private ExamStudentCache examStudentCache;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ExamStudentCloudService examStudentCloudService;
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public List<Long> saveExamStudentList(List<ExamStudentInfo> examStudents) {
|
|
|
Check.isEmpty(examStudents, "考生信息不能为空!");
|
|
|
- List<Long> examStudentIdList = Lists.newArrayList();
|
|
|
+ List<Long> examStudentIdList = Lists.newArrayList();
|
|
|
//封装并校验数据
|
|
|
for (ExamStudentInfo cur : examStudents) {
|
|
|
Check.isNull(cur.getRootOrgId(), "顶级机构ID不能为空!");
|
|
@@ -160,7 +165,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
|
|
|
//保存考生
|
|
|
ExamStudentEntity examStudentEntity = examStudentRepo.save(entity);
|
|
|
-
|
|
|
+
|
|
|
examStudentIdList.add(examStudentEntity.getId());
|
|
|
//已完成 考试,更新考试记录表
|
|
|
if (examStudentEntity.getFinished() != null && examStudentEntity.getFinished()) {
|
|
@@ -171,7 +176,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
examRecordDataRepo.syncUpdateExamStudentInfo(examStudentId, studentName, studentCode, infoCollector);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return examStudentIdList;
|
|
|
}
|
|
|
|
|
@@ -730,9 +735,33 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
examStudentDtoList.add(assemblingExamStudentDto(examStudent, examSpecialSettingsBean));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //针对指定机构进行学生特殊设置进行校验,FIXME 临时代码
|
|
|
+ SysPropertyCacheBean specialStudentProperty = CacheHelper.getSysProperty("studentSpecialExamTime.enabledRootOrgIds");
|
|
|
+ if (specialStudentProperty.getHasValue()) {
|
|
|
+ List<String> orgIdList = RegExpUtil.findAll(specialStudentProperty.getValue().toString(), "\\d+");
|
|
|
+ if (orgIdList.contains(String.valueOf(studentBean.getRootOrgId()))) {
|
|
|
+ for (OnHandExamInfo info : examStudentDtoList) {
|
|
|
+ //如果考生特殊设置过开考时间,需要判断考生是否在考试时间内
|
|
|
+ ExamStudentBean remoteExamStudent = getRemoteExamStudent(studentBean.getRootOrgId(), info.getExamStudentId());
|
|
|
+ String strStartTime = remoteExamStudent.getExt4();
|
|
|
+ String strEndTime = remoteExamStudent.getExt5();
|
|
|
+
|
|
|
+ Date specialStartTime = StringUtils.isBlank(strStartTime) ? null :
|
|
|
+ DateUtil.parse(strStartTime, DateUtil.DatePatterns.CHINA_DEFAULT);
|
|
|
+ Date specialEndTime = StringUtils.isBlank(strEndTime) ? null :
|
|
|
+ DateUtil.parse(strEndTime, DateUtil.DatePatterns.CHINA_DEFAULT);
|
|
|
+ if (null != specialStartTime && null != specialEndTime) {
|
|
|
+ info.setStartTime(specialStartTime);
|
|
|
+ info.setEndTime(specialEndTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return examStudentDtoList;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private OnHandExamInfo assemblingExamStudentDto(ExamStudentEntity examStudent, ExamSpecialSettingsBean examSpecialSettingsBean) {
|
|
|
OnHandExamInfo examStudentInfo = new OnHandExamInfo();
|
|
|
examStudentInfo.setExamStudentId(examStudent.getExamStudentId());
|
|
@@ -754,7 +783,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
OrgCacheBean orgBean = gainBaseDataService.getOrgBean(orgId);
|
|
|
Long studentId = examStudent.getStudentId();
|
|
|
ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),
|
|
|
- studentId);
|
|
|
+ studentId);
|
|
|
|
|
|
examStudentInfo.setOrgName(orgBean.getName());
|
|
|
Long examId = examBean.getId();
|
|
@@ -765,7 +794,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
examStudentInfo.setAllowExamCount(countExamTimes(examStudent, examBean));
|
|
|
examStudentInfo.setPaperMins(examBean.getDuration());
|
|
|
//是否启用人脸识别
|
|
|
- examStudentInfo.setFaceEnable(FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId));
|
|
|
+ examStudentInfo.setFaceEnable(FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId));
|
|
|
//进入考试是否验证人脸识别(强制、非强制)
|
|
|
examStudentInfo.setFaceCheck(FaceBiopsyHelper.isFaceCheck(examId, studentId));
|
|
|
//是否显示客观分
|
|
@@ -778,7 +807,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
}
|
|
|
return examStudentInfo;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private Integer countExamTimes(ExamStudentEntity examStudentInfo, ExamBean examBean) {
|
|
|
if (ExamType.OFFLINE.name().equals(examBean.getExamType())) {
|
|
|
return 1;
|
|
@@ -786,24 +815,32 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
//考试批次中设置的考试次数
|
|
|
int canExamTimes = examBean.getExamTimes().intValue();
|
|
|
//可补考次数
|
|
|
- int extraNum = (examStudentInfo.getExtraNum()==null?0:examStudentInfo.getExtraNum());
|
|
|
+ int extraNum = (examStudentInfo.getExtraNum() == null ? 0 : examStudentInfo.getExtraNum());
|
|
|
//考生已考次数
|
|
|
- int usedNum = (examStudentInfo.getUsedNum()==null?0:examStudentInfo.getUsedNum());
|
|
|
+ int usedNum = (examStudentInfo.getUsedNum() == null ? 0 : examStudentInfo.getUsedNum());
|
|
|
//缓存中开考次数
|
|
|
- int startCount=0;
|
|
|
+ int startCount = 0;
|
|
|
//缓存中考试完结次数
|
|
|
- int endCount=0;
|
|
|
+ int endCount = 0;
|
|
|
String key = RedisKeyHelper.getBuilder().examBossKey(examStudentInfo.getExamStudentId());
|
|
|
- ExamBoss eb=redisClient.get(key, ExamBoss.class);
|
|
|
- if(eb!=null) {
|
|
|
- startCount=eb.getStartCount();
|
|
|
- endCount=eb.getEndCount();
|
|
|
+ ExamBoss eb = redisClient.get(key, ExamBoss.class);
|
|
|
+ if (eb != null) {
|
|
|
+ startCount = eb.getStartCount();
|
|
|
+ endCount = eb.getEndCount();
|
|
|
}
|
|
|
- Integer ret=canExamTimes+extraNum-(usedNum+startCount-endCount);
|
|
|
- if(ret<0) {
|
|
|
- ret=0;
|
|
|
+ Integer ret = canExamTimes + extraNum - (usedNum + startCount - endCount);
|
|
|
+ if (ret < 0) {
|
|
|
+ ret = 0;
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //获取考试的考生信息
|
|
|
+ private ExamStudentBean getRemoteExamStudent(Long rootOrgId, Long examStudentId) {
|
|
|
+ GetExamStudentReq req = new GetExamStudentReq();
|
|
|
+ req.setExamStudentId(examStudentId);
|
|
|
+ req.setRootOrgId(rootOrgId);
|
|
|
+ GetExamStudentResp resp = examStudentCloudService.getExamStudent(req);
|
|
|
+ return resp.getExamStudentBean();
|
|
|
+ }
|
|
|
}
|