|
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnum;
|
|
@@ -32,16 +33,16 @@ import cn.com.qmth.examcloud.commons.web.enums.DataExecutionStatus;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamCourseRelationRepo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.ExamSpecialSettingsRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamPaperTypeRelationRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamSpecialSettingsRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamCourseRelationEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamSpecialSettingsEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPaperTypeRelationEntity;
|
|
|
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.dao.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
|
|
@@ -261,6 +262,7 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
|
|
|
Long rootOrgId = req.getRootOrgId();
|
|
|
String examType = req.getExamType();
|
|
|
+ Long orgId = req.getOrgId();
|
|
|
|
|
|
ExamType et = null;
|
|
|
if (StringUtils.isNotBlank(examType)) {
|
|
@@ -273,10 +275,9 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
|
|
|
final ExamType type = et;
|
|
|
|
|
|
- Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
|
+ Specification<ExamSpecialSettingsEntity> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
- // predicates.add(cb.lessThan(root.get("beginTime"), new Date()));
|
|
|
predicates.add(cb.greaterThan(root.get("endTime"), new Date()));
|
|
|
if (null != type) {
|
|
|
predicates.add(cb.equal(root.get("examType"), type));
|
|
@@ -286,24 +287,44 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
if (null == enable) {
|
|
|
enable = true;
|
|
|
}
|
|
|
- predicates.add(cb.equal(root.get("enable"), enable));
|
|
|
+ predicates.add(cb.equal(root.get("examEnable"), enable));
|
|
|
+ predicates.add(cb.isNull(root.get("courseId")));
|
|
|
+
|
|
|
+ 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 = new PageRequest(0, 100, new Sort(Direction.ASC, "beginTime"));
|
|
|
+ PageRequest pageRequest = new PageRequest(0, 10000, new Sort(Direction.ASC, "beginTime"));
|
|
|
|
|
|
- Page<ExamEntity> page = examRepo.findAll(specification, pageRequest);
|
|
|
+ List<ExamSpecialSettingsEntity> entityList = examSpecialSettingsRepo
|
|
|
+ .findAll(specification, pageRequest).getContent();
|
|
|
|
|
|
- Iterator<ExamEntity> iterator = page.iterator();
|
|
|
+ List<ExamSpecialSettingsEntity> resultList = Lists.newArrayList();
|
|
|
+ Map<String, ExamSpecialSettingsEntity> examMap = Maps.newHashMap();
|
|
|
+ for (ExamSpecialSettingsEntity cur : entityList) {
|
|
|
+ resultList.add(cur);
|
|
|
+ if (null == cur.getOrgId() || null == cur.getCourseId()) {
|
|
|
+ examMap.put(String.valueOf(cur.getExamId()), 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<ExamBean> list = Lists.newArrayList();
|
|
|
-
|
|
|
- while (iterator.hasNext()) {
|
|
|
- ExamEntity exam = iterator.next();
|
|
|
+ for (ExamSpecialSettingsEntity cur : entityList) {
|
|
|
ExamBean bean = new ExamBean();
|
|
|
list.add(bean);
|
|
|
-
|
|
|
+ ExamEntity exam = examRepo.findOne(cur.getExamId());
|
|
|
bean.setId(exam.getId());
|
|
|
bean.setBeginTime(exam.getBeginTime());
|
|
|
bean.setDuration(exam.getDuration());
|
|
@@ -315,6 +336,7 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
bean.setRemark(exam.getRemark());
|
|
|
bean.setRootOrgId(exam.getRootOrgId());
|
|
|
}
|
|
|
+
|
|
|
GetOngoingExamListResp resp = new GetOngoingExamListResp();
|
|
|
resp.setExamList(list);
|
|
|
return resp;
|