|
@@ -15,6 +15,7 @@ import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -25,6 +26,7 @@ import java.util.stream.Collectors;
|
|
|
import javax.persistence.EntityManager;
|
|
|
import javax.persistence.Query;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamListReq;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.hibernate.query.NativeQuery;
|
|
|
import org.hibernate.transform.Transformers;
|
|
@@ -341,6 +343,37 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
setPhone(examStudentInfoList, query.getRootOrgId());
|
|
|
return examStudentInfoList;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<OnHandExamInfo> queryOnlineExamEndList(Long studentId, ExamType examType) {
|
|
|
+ //只查没有禁用的考生
|
|
|
+ List<ExamStudentEntity> examStudents =
|
|
|
+ examStudentRepo.findByStudentIdAndEnable(studentId, true);
|
|
|
+
|
|
|
+ List<OnHandExamInfo> examStudentDtoList = new ArrayList<OnHandExamInfo>();
|
|
|
+ Date now = new Date();
|
|
|
+ for (ExamStudentEntity examStudent : examStudents) {
|
|
|
+ assemblingExamStudentDto(examStudent, now, examStudentDtoList, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ for(OnHandExamInfo info:examStudentDtoList) {
|
|
|
+ ExamPropertyCacheBean examCycleEnabledCache = CacheHelper.getExamProperty(info.getExamId(), ExamProperties.EXAM_CYCLE_ENABLED.name());
|
|
|
+ if(examCycleEnabledCache!=null&&StringUtil.isTrue(examCycleEnabledCache.getValue())) {
|
|
|
+ info.setExamCycleEnabled(true);
|
|
|
+
|
|
|
+ ExamPropertyCacheBean examCycleWeekCache = CacheHelper.getExamProperty(info.getExamId(), ExamProperties.EXAM_CYCLE_WEEK.name());
|
|
|
+
|
|
|
+ info.setExamCycleWeek(JSONObject.parseArray(examCycleWeekCache.getValue()));
|
|
|
+ ExamPropertyCacheBean examCycleTimeRangeCache = CacheHelper.getExamProperty(info.getExamId(), ExamProperties.EXAM_CYCLE_TIME_RANGE.name());
|
|
|
+ info.setExamCycleTimeRange(JSONObject.parseArray(examCycleTimeRangeCache.getValue()));
|
|
|
+ }else {
|
|
|
+ info.setExamCycleEnabled(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return examStudentDtoList;
|
|
|
+ }
|
|
|
+
|
|
|
private void setPhone(List<ExamStudentInfo> dataList,Long rootOrgId) {
|
|
|
GetStudentListByIdsReq req= new GetStudentListByIdsReq();
|
|
|
BatchSetDataUtil<ExamStudentInfo> tool = new BatchSetDataUtil<ExamStudentInfo>() {
|
|
@@ -1077,7 +1110,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
List<OnHandExamInfo> examStudentDtoList = new ArrayList<OnHandExamInfo>();
|
|
|
Date now = new Date();
|
|
|
for (ExamStudentEntity examStudent : examStudents) {
|
|
|
- assemblingExamStudentDto(examStudent, now, examStudentDtoList);
|
|
|
+ assemblingExamStudentDto(examStudent, now, examStudentDtoList, false);
|
|
|
}
|
|
|
|
|
|
for(OnHandExamInfo info:examStudentDtoList) {
|
|
@@ -1098,7 +1131,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
return examStudentDtoList;
|
|
|
}
|
|
|
|
|
|
- private void assemblingExamStudentDto(ExamStudentEntity examStudent, Date now, final List<OnHandExamInfo> resultList) {
|
|
|
+ private void assemblingExamStudentDto(ExamStudentEntity examStudent, Date now, final List<OnHandExamInfo> resultList, boolean end) {
|
|
|
Long examId = examStudent.getExamId();
|
|
|
Long studentId = examStudent.getStudentId();
|
|
|
Long examStageId = examStudent.getExamStageId();
|
|
@@ -1112,12 +1145,21 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
if (examStage.getHasValue() && !examStage.getEnable()) {
|
|
|
return;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //如果当前时间超过场次结束时间,不允许考试
|
|
|
+ if (end) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(examBean.getEndTime());
|
|
|
+ calendar.add(Calendar.DATE, 30);
|
|
|
+ Date leftTime = calendar.getTime();
|
|
|
+ //已结束且结束时间30天以内的
|
|
|
+ if(now.after(leftTime)||now.before(examBean.getEndTime())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
if (now.after(examBean.getEndTime())) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
OnHandExamInfo examStudentInfo = new OnHandExamInfo();
|