|
@@ -15,7 +15,6 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
-import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -45,6 +44,7 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamSpecialSettingsEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.ExamService;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.service.OnGoingExamService;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.bean.ExamSpecialSettingsInfo;
|
|
|
import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
@@ -129,6 +129,9 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
@Autowired
|
|
|
ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OnGoingExamService onGoingExamService;
|
|
|
+
|
|
|
@ApiOperation(value = "保存考试批次", notes = "保存")
|
|
|
@PostMapping("saveExam")
|
|
|
@Transactional
|
|
@@ -316,68 +319,10 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
Long rootOrgId = req.getRootOrgId();
|
|
|
String examType = req.getExamType();
|
|
|
Long orgId = req.getOrgId();
|
|
|
+ Long studentId = req.getStudentId();
|
|
|
|
|
|
- String key = "B_ON_GOING_EXAM:" + rootOrgId + "_" + examType + "_" + orgId;
|
|
|
- GetOngoingExamListResp resp = redisClient.get(key, GetOngoingExamListResp.class);
|
|
|
-
|
|
|
- if (null != resp) {
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- ExamType et = null;
|
|
|
- if (StringUtils.isNotBlank(examType)) {
|
|
|
- try {
|
|
|
- et = ExamType.valueOf(examType);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new StatusException("002005", "examType is wrong");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- final ExamType type = et;
|
|
|
-
|
|
|
- Specification<ExamSpecialSettingsEntity> specification = (root, query, cb) -> {
|
|
|
- List<Predicate> predicates = new ArrayList<>();
|
|
|
- predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
- predicates.add(cb.greaterThan(root.get("endTime"), new Date()));
|
|
|
- if (null != type) {
|
|
|
- predicates.add(cb.equal(root.get("examType"), type));
|
|
|
- }
|
|
|
-
|
|
|
- predicates.add(cb.equal(root.get("examEnable"), true));
|
|
|
- predicates.add(cb.isNull(root.get("courseId")));
|
|
|
-
|
|
|
- if (null != orgId) {
|
|
|
- Predicate pr1 = cb.isNull(root.get("orgId"));
|
|
|
- Predicate pr2 = cb.equal(root.get("orgId"), orgId);
|
|
|
- predicates.add(cb.or(pr1, pr2));
|
|
|
- }
|
|
|
-
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
- };
|
|
|
-
|
|
|
- PageRequest pageRequest = PageRequest.of(0, 10000, new Sort(Direction.ASC, "beginTime"));
|
|
|
-
|
|
|
- List<ExamSpecialSettingsEntity> entityList = examSpecialSettingsRepo
|
|
|
- .findAll(specification, pageRequest).getContent();
|
|
|
-
|
|
|
- List<ExamSpecialSettingsEntity> resultList = Lists.newArrayList();
|
|
|
- Map<String, ExamSpecialSettingsEntity> examMap = Maps.newHashMap();
|
|
|
- for (ExamSpecialSettingsEntity cur : entityList) {
|
|
|
- if (null == cur.getOrgId() && null == cur.getCourseId()) {
|
|
|
- examMap.put(String.valueOf(cur.getExamId()), cur);
|
|
|
- }
|
|
|
- if (null != cur.getBeginTime() && null != cur.getEndTime()) {
|
|
|
- resultList.add(cur);
|
|
|
- }
|
|
|
- }
|
|
|
- for (ExamSpecialSettingsEntity cur : entityList) {
|
|
|
- if ((null != cur.getOrgId() || null != cur.getCourseId()) && null != cur.getEndTime()) {
|
|
|
- ExamSpecialSettingsEntity tmp = examMap.get(String.valueOf(cur.getExamId()));
|
|
|
- if (null != tmp) {
|
|
|
- resultList.remove(tmp);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ List<ExamSpecialSettingsEntity> resultList = onGoingExamService
|
|
|
+ .getOngoingExamList(rootOrgId, examType, orgId, studentId);
|
|
|
|
|
|
List<ExamSpecialSettingsBean> list = Lists.newArrayList();
|
|
|
for (ExamSpecialSettingsEntity cur : resultList) {
|
|
@@ -396,11 +341,9 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
bean.setExamType(cur.getExamType().name());
|
|
|
}
|
|
|
|
|
|
- resp = new GetOngoingExamListResp();
|
|
|
+ GetOngoingExamListResp resp = new GetOngoingExamListResp();
|
|
|
resp.setExamSpecialSettingsList(list);
|
|
|
|
|
|
- redisClient.set(key, resp, 120);
|
|
|
-
|
|
|
return resp;
|
|
|
}
|
|
|
|