|
@@ -1,24 +1,5 @@
|
|
package cn.com.qmth.stmms.biz.exam.service.impl;
|
|
package cn.com.qmth.stmms.biz.exam.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.LinkedHashSet;
|
|
|
|
-import java.util.LinkedList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Set;
|
|
|
|
-
|
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
|
-
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
|
-import org.springframework.data.domain.Sort.Direction;
|
|
|
|
-import org.springframework.data.jpa.domain.Specification;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-
|
|
|
|
import cn.com.qmth.stmms.biz.common.BaseQueryService;
|
|
import cn.com.qmth.stmms.biz.common.BaseQueryService;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamQuestionDao;
|
|
import cn.com.qmth.stmms.biz.exam.dao.ExamQuestionDao;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
@@ -27,6 +8,19 @@ import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.query.ExamQuestionSearchQuery;
|
|
import cn.com.qmth.stmms.biz.exam.service.query.ExamQuestionSearchQuery;
|
|
import cn.com.qmth.stmms.common.enums.ObjectivePolicy;
|
|
import cn.com.qmth.stmms.common.enums.ObjectivePolicy;
|
|
import cn.com.qmth.stmms.common.enums.ObjectiveStatus;
|
|
import cn.com.qmth.stmms.common.enums.ObjectiveStatus;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> implements ExamQuestionService {
|
|
public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> implements ExamQuestionService {
|
|
@@ -74,23 +68,29 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
|
|
return questionDao.findByExamIdAndSubjectCodeAndObjective(examId, subjectCode, objective);
|
|
return questionDao.findByExamIdAndSubjectCodeAndObjective(examId, subjectCode, objective);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<ExamQuestion> findByExamAndSubjectAndObjectiveGroupByNumber(Integer examId, String subjectCode,
|
|
|
|
+ boolean objective) {
|
|
|
|
+ return questionDao.findByExamIdAndSubjectCodeAndObjectiveGroupByNumber(examId, subjectCode, objective);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndPaperType(Integer examId, String subjectCode,
|
|
public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndPaperType(Integer examId, String subjectCode,
|
|
boolean objective, String paperType) {
|
|
boolean objective, String paperType) {
|
|
- return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndPaperType(examId, subjectCode, objective,
|
|
|
|
- paperType, new Sort(Direction.ASC, "mainNumber", "subNumber"));
|
|
|
|
|
|
+ return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndPaperType(examId, subjectCode, objective, paperType,
|
|
|
|
+ new Sort(Direction.ASC, "mainNumber", "subNumber"));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndGroupNumber(Integer examId, String subjectCode,
|
|
public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndGroupNumber(Integer examId, String subjectCode,
|
|
boolean objective, Integer groupNumber) {
|
|
boolean objective, Integer groupNumber) {
|
|
- return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndGroupNumber(examId, subjectCode, objective,
|
|
|
|
- groupNumber);
|
|
|
|
|
|
+ return questionDao
|
|
|
|
+ .findByExamIdAndSubjectCodeAndObjectiveAndGroupNumber(examId, subjectCode, objective, groupNumber);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndGroupNumberNotEqual(Integer examId,
|
|
|
|
- String subjectCode, boolean objective, Integer groupNumber) {
|
|
|
|
|
|
+ public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndGroupNumberNotEqual(Integer examId, String subjectCode,
|
|
|
|
+ boolean objective, Integer groupNumber) {
|
|
return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndGroupNumberNotEqual(examId, subjectCode, objective,
|
|
return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndGroupNumberNotEqual(examId, subjectCode, objective,
|
|
groupNumber);
|
|
groupNumber);
|
|
}
|
|
}
|
|
@@ -98,8 +98,8 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
|
|
@Override
|
|
@Override
|
|
public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndMainNumber(Integer examId, String subjectCode,
|
|
public List<ExamQuestion> findByExamAndSubjectAndObjectiveAndMainNumber(Integer examId, String subjectCode,
|
|
boolean objective, Integer mainNumber) {
|
|
boolean objective, Integer mainNumber) {
|
|
- return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndMainNumber(examId, subjectCode, objective,
|
|
|
|
- mainNumber);
|
|
|
|
|
|
+ return questionDao
|
|
|
|
+ .findByExamIdAndSubjectCodeAndObjectiveAndMainNumber(examId, subjectCode, objective, mainNumber);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -118,8 +118,8 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
|
|
@Override
|
|
@Override
|
|
public long countByExamAndSubjectAndObjectiveAndMainNumber(Integer examId, String subjectCode, boolean objective,
|
|
public long countByExamAndSubjectAndObjectiveAndMainNumber(Integer examId, String subjectCode, boolean objective,
|
|
Integer mainNumber) {
|
|
Integer mainNumber) {
|
|
- return questionDao.countByExamIdAndSubjectCodeAndObjectiveAndMainNumber(examId, subjectCode, objective,
|
|
|
|
- mainNumber);
|
|
|
|
|
|
+ return questionDao
|
|
|
|
+ .countByExamIdAndSubjectCodeAndObjectiveAndMainNumber(examId, subjectCode, objective, mainNumber);
|
|
}
|
|
}
|
|
|
|
|
|
private Specification<ExamQuestion> buildSpecification(final ExamQuestionSearchQuery query) {
|
|
private Specification<ExamQuestion> buildSpecification(final ExamQuestionSearchQuery query) {
|
|
@@ -154,8 +154,9 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
|
|
if (query.getMainNumber() != null) {
|
|
if (query.getMainNumber() != null) {
|
|
predicates.add(cb.equal(root.get("mainNumber"), query.getMainNumber()));
|
|
predicates.add(cb.equal(root.get("mainNumber"), query.getMainNumber()));
|
|
}
|
|
}
|
|
- return predicates.isEmpty() ? cb.conjunction() : cb.and(predicates.toArray(new Predicate[predicates
|
|
|
|
- .size()]));
|
|
|
|
|
|
+ return predicates.isEmpty() ?
|
|
|
|
+ cb.conjunction() :
|
|
|
|
+ cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
}
|
|
}
|
|
};
|
|
};
|
|
}
|
|
}
|
|
@@ -174,15 +175,17 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
|
|
@Override
|
|
@Override
|
|
public long countByExamAndSubjectAndObjectiveAndMainNumberAndPaperType(Integer examId, String subjectCode,
|
|
public long countByExamAndSubjectAndObjectiveAndMainNumberAndPaperType(Integer examId, String subjectCode,
|
|
boolean objective, Integer mainNumber, String paperType) {
|
|
boolean objective, Integer mainNumber, String paperType) {
|
|
- return questionDao.countByExamIdAndSubjectCodeAndObjectiveAndMainNumber(examId, subjectCode, objective,
|
|
|
|
- mainNumber, paperType);
|
|
|
|
|
|
+ return questionDao
|
|
|
|
+ .countByExamIdAndSubjectCodeAndObjectiveAndMainNumber(examId, subjectCode, objective, mainNumber,
|
|
|
|
+ paperType);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public long countByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(Integer examId, String subjectCode,
|
|
public long countByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(Integer examId, String subjectCode,
|
|
boolean objective, Integer mainNumber, Integer subNumber) {
|
|
boolean objective, Integer mainNumber, Integer subNumber) {
|
|
- return questionDao.countByExamIdAndSubjectCodeAndObjectiveAndMainNumberAndSubNumber(examId, subjectCode,
|
|
|
|
- objective, mainNumber, subNumber);
|
|
|
|
|
|
+ return questionDao
|
|
|
|
+ .countByExamIdAndSubjectCodeAndObjectiveAndMainNumberAndSubNumber(examId, subjectCode, objective,
|
|
|
|
+ mainNumber, subNumber);
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@@ -203,12 +206,14 @@ public class ExamQuestionServiceImpl extends BaseQueryService<ExamQuestion> impl
|
|
@Override
|
|
@Override
|
|
public ExamQuestion findByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(Integer examId, String subjectCode,
|
|
public ExamQuestion findByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(Integer examId, String subjectCode,
|
|
boolean objective, Integer mainNumber, Integer subNumber) {
|
|
boolean objective, Integer mainNumber, Integer subNumber) {
|
|
- return questionDao.findByExamIdAndSubjectCodeAndObjectiveAndMainNumberAndSubNumber(examId, subjectCode,
|
|
|
|
- objective, mainNumber, subNumber);
|
|
|
|
|
|
+ return questionDao
|
|
|
|
+ .findByExamIdAndSubjectCodeAndObjectiveAndMainNumberAndSubNumber(examId, subjectCode, objective,
|
|
|
|
+ mainNumber, subNumber);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<ExamQuestion> findMainByExamAndSubjectAndObjective(Integer examId, String subjectCode, boolean objective) {
|
|
|
|
|
|
+ public List<ExamQuestion> findMainByExamAndSubjectAndObjective(Integer examId, String subjectCode,
|
|
|
|
+ boolean objective) {
|
|
List<ExamQuestion> list = new ArrayList<ExamQuestion>();
|
|
List<ExamQuestion> list = new ArrayList<ExamQuestion>();
|
|
Set<Integer> mainNumbers = new LinkedHashSet<>();
|
|
Set<Integer> mainNumbers = new LinkedHashSet<>();
|
|
List<ExamQuestion> all = questionDao.findByExamIdAndSubjectCodeAndObjective(examId, subjectCode, objective);
|
|
List<ExamQuestion> all = questionDao.findByExamIdAndSubjectCodeAndObjective(examId, subjectCode, objective);
|