|
@@ -32,6 +32,7 @@ import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
|
|
import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
|
|
import cn.com.qmth.stmms.biz.exam.query.ExamStudentSearchQuery;
|
|
import cn.com.qmth.stmms.biz.exam.query.ExamStudentSearchQuery;
|
|
import cn.com.qmth.stmms.biz.exam.service.CheckStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.CheckStudentService;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
@@ -45,387 +46,430 @@ import cn.com.qmth.stmms.common.enums.MarkStatus;
|
|
@Service("examSubjectService")
|
|
@Service("examSubjectService")
|
|
public class ExamSubjectServiceImpl extends BaseQueryService<ExamSubject> implements ExamSubjectService {
|
|
public class ExamSubjectServiceImpl extends BaseQueryService<ExamSubject> implements ExamSubjectService {
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private ExamSubjectDao subjectDao;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamStudentDao examStudentDao;
|
|
|
|
-
|
|
|
|
- @PersistenceContext
|
|
|
|
- private EntityManager entityManager;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private MarkGroupService groupService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamStudentService studentService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private CheckStudentService checkStudentService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private MarkGroupService markGroupService;
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- // @CachePut(value = "exam_subject_cache", key =
|
|
|
|
- // "T(String).valueOf(#subject.examId)+'-'+#subject.code", condition =
|
|
|
|
- // "#subject!=null && #subject.examId!=null && #subject.code!=null")
|
|
|
|
- public ExamSubject save(ExamSubject subject) {
|
|
|
|
- return subjectDao.save(subject);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- // @Cacheable(value = "exam_subject_cache", key =
|
|
|
|
- // "T(String).valueOf(#examId)+'-'+#code", condition =
|
|
|
|
- // "#examId>0 && #code!=null")
|
|
|
|
- public ExamSubject find(int examId, String code) {
|
|
|
|
- return subjectDao.findByExamIdAndCode(examId, code);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<ExamSubject> list(int examId) {
|
|
|
|
- return subjectDao.findByExamId(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<ExamSubject> list(int examId, Set<String> codes) {
|
|
|
|
- return subjectDao.findByExamIdAndSubjectCodeIn(examId, codes);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<String> listLevel(int examId) {
|
|
|
|
- return subjectDao.findDistinctLevel(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<String> listCategory(int examId) {
|
|
|
|
- return subjectDao.findDistinctCategory(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<ExamSubject> list(int examId, int uploadCountGt) {
|
|
|
|
- return subjectDao.findByExamIdAndUploadCountGt(examId, uploadCountGt);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public long count(int examId) {
|
|
|
|
- return subjectDao.countByExamId(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public ExamSubjectSearchQuery findByQuery(ExamSubjectSearchQuery query) {
|
|
|
|
- checkQuery(query);
|
|
|
|
- Page<ExamSubject> result = subjectDao.findAll(buildSpecification(query), query);
|
|
|
|
- fillResult(result, query);
|
|
|
|
- return query;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public long countByQuery(ExamSubjectSearchQuery query) {
|
|
|
|
- return subjectDao.count(buildSpecification(query));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
- // allEntries = true)
|
|
|
|
- public void delete(ExamSubject markSubject) {
|
|
|
|
- subjectDao.delete(markSubject);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
- // allEntries = true)
|
|
|
|
- public void deleteByExamId(int examId) {
|
|
|
|
- subjectDao.deleteByExamId(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
- // allEntries = true)
|
|
|
|
- public void updateTotalScore(int examId) {
|
|
|
|
- subjectDao.updateTotalScoreByExamId(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
- // allEntries = true)
|
|
|
|
- public void updateScore(int examId, String code, boolean objective, double score) {
|
|
|
|
- if (objective) {
|
|
|
|
- subjectDao.updateObjectiveScore(examId, code, score);
|
|
|
|
- } else {
|
|
|
|
- subjectDao.updateSubjectiveScore(examId, code, score);
|
|
|
|
- }
|
|
|
|
- subjectDao.updateTotalScoreByExamIdAndCode(examId, code);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private Specification<ExamSubject> buildSpecification(final ExamSubjectSearchQuery query) {
|
|
|
|
- return new Specification<ExamSubject>() {
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Predicate toPredicate(Root<ExamSubject> root, CriteriaQuery<?> cQuery, CriteriaBuilder cb) {
|
|
|
|
- List<Predicate> predicates = new LinkedList<Predicate>();
|
|
|
|
- if (query.getExamId() > 0) {
|
|
|
|
- predicates.add(cb.equal(root.get("pk").get("examId"), query.getExamId()));
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotEmpty(query.getCode())) {
|
|
|
|
- predicates.add(cb.equal(root.get("pk").get("code"), query.getCode()));
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(query.getLevel())) {
|
|
|
|
- predicates.add(cb.equal(root.get("level"), query.getLevel()));
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(query.getCategory())) {
|
|
|
|
- predicates.add(cb.equal(root.get("category"), query.getCategory()));
|
|
|
|
- }
|
|
|
|
- if (query.getTotalScore() != null) {
|
|
|
|
- predicates.add(cb.equal(root.get("totalScore"), query.getTotalScore()));
|
|
|
|
- }
|
|
|
|
- if (query.getTotalScoreNotEqual() != null) {
|
|
|
|
- predicates.add(cb.notEqual(root.get("totalScore"), query.getTotalScoreNotEqual()));
|
|
|
|
- }
|
|
|
|
- if (query.getSubjectiveScoreNotEqual() != null) {
|
|
|
|
- predicates.add(cb.notEqual(root.get("subjectiveScore"), query.getSubjectiveScoreNotEqual()));
|
|
|
|
- }
|
|
|
|
- if (query.getUploadCountGt() != null) {
|
|
|
|
- predicates.add(cb.gt(root.get("uploadCount").as(Integer.class), query.getUploadCountGt()));
|
|
|
|
- }
|
|
|
|
- if (query.getUploadCountEqual() != null) {
|
|
|
|
- predicates.add(cb.equal(root.get("uploadCount").as(Integer.class), query.getUploadCountEqual()));
|
|
|
|
- }
|
|
|
|
- if (query.getSelective() != null) {
|
|
|
|
- predicates.add(cb.equal(root.get("selective"), query.getSelective()));
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(query.getCodeIn())) {
|
|
|
|
- String[] list = query.getCodeIn().split(",");
|
|
|
|
- if (list.length > 0) {
|
|
|
|
- Predicate[] sub = new Predicate[list.length];
|
|
|
|
- for (int i = 0; i < list.length; i++) {
|
|
|
|
- sub[i] = cb.equal(root.get("pk").get("code"), list[i]);
|
|
|
|
- }
|
|
|
|
- predicates.add(cb.or(sub));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(query.getCodeNotIn())) {
|
|
|
|
- String[] list = query.getCodeNotIn().split(",");
|
|
|
|
- if (list.length > 0) {
|
|
|
|
- Predicate[] sub = new Predicate[list.length];
|
|
|
|
- for (int i = 0; i < list.length; i++) {
|
|
|
|
- sub[i] = cb.notEqual(root.get("pk").get("code"), list[i]);
|
|
|
|
- }
|
|
|
|
- predicates.add(cb.and(sub));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return predicates.isEmpty() ? cb.conjunction()
|
|
|
|
- : cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @Transactional
|
|
|
|
- public void updateUploadCount(Integer examId, String subjectCode, int count) {
|
|
|
|
- subjectDao.updateUploadCount(examId, subjectCode, count);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<ExamSubject> listSubjectiveScore(int examId, double subjectiveScore) {
|
|
|
|
- return subjectDao.listSubjectiveScore(examId, subjectiveScore);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @Transactional
|
|
|
|
- public void updateSliceConfig(Integer examId, String subjectCode, List<PictureConfigItem> configList) {
|
|
|
|
- subjectDao.updateSliceConfig(examId, subjectCode,
|
|
|
|
- configList != null ? StringUtils.join(configList, PictureConfigItem.DB_ITEM_JOINER) : "");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public void updateTrialCount(int examId, String subjectCode, int trialCount) {
|
|
|
|
- subjectDao.updateTrialCount(examId, subjectCode, trialCount);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public int findMaxInspectRound(int examId, Set<String> subjectCodes) {
|
|
|
|
- StringBuilder sql = new StringBuilder("select max(s.inspect_round) from eb_exam_subject s ");
|
|
|
|
- sql.append(" where s.exam_id=" + examId + " and s.code in ('" + StringUtils.join(subjectCodes, "','") + "')");
|
|
|
|
- Query countQuery = entityManager.createNativeQuery(sql.toString());
|
|
|
|
- Object singleResult = countQuery.getResultList().get(0);
|
|
|
|
- Integer count = singleResult == null ? 0 : Integer.valueOf(singleResult.toString());
|
|
|
|
- return count;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public void nextInspectRound(int examId, String subjectCode) {
|
|
|
|
- subjectDao.nextInspectRound(examId, subjectCode);
|
|
|
|
- examStudentDao.cancelInspect(examId, subjectCode, false, true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public void updateSelective(int examId, String subjectCode, boolean selective) {
|
|
|
|
- subjectDao.updateSelective(examId, subjectCode, selective);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public String enableExport(Exam exam, String subjectCode) {
|
|
|
|
- ExamSubject subject = find(exam.getId(), subjectCode);
|
|
|
|
- if (subject == null) {
|
|
|
|
- return subjectCode + "该科目不存在";
|
|
|
|
- }
|
|
|
|
- List<MarkGroup> groups = groupService.findByExamAndSubjectAndStatus(exam.getId(), subjectCode,
|
|
|
|
- MarkStatus.FORMAL, MarkStatus.TRIAL);
|
|
|
|
- if (groups != null && !groups.isEmpty()) {
|
|
|
|
- return subjectCode + "评卷未完成";
|
|
|
|
- }
|
|
|
|
- if (ExamType.MULTI_MEDIA.equals(exam.getType())) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- if (DoubleUtil.sum(subject.getObjectiveScore(), subject.getSubjectiveScore()) == 0) {
|
|
|
|
- return subjectCode + "科目总分为0";
|
|
|
|
- }
|
|
|
|
- long groupCount = groupService.countByExamAndSubject(exam.getId(), subjectCode);
|
|
|
|
- if (subject.getSubjectiveScore() != null && subject.getSubjectiveScore() > 0 && groupCount == 0) {
|
|
|
|
- return subjectCode + "未设置评卷分组";
|
|
|
|
- }
|
|
|
|
- if (checkStudentService.countByExamIdAndSubjectCodeAndChecked(exam.getId(), subjectCode, false) > 0) {
|
|
|
|
- return subjectCode + "人工确认未完成";
|
|
|
|
- }
|
|
|
|
- ExamStudentSearchQuery query = new ExamStudentSearchQuery();
|
|
|
|
- query.setExamId(exam.getId());
|
|
|
|
- query.setUpload(false);
|
|
|
|
- query.setManualAbsent(false);
|
|
|
|
- query.setSubjectCode(subjectCode);
|
|
|
|
- if (studentService.countByQuery(query) > 0) {
|
|
|
|
- StringBuilder builder = new StringBuilder(subjectCode + "未上传考生必须人工指定缺考");
|
|
|
|
- query.setPageSize(Integer.MAX_VALUE);
|
|
|
|
- query = studentService.findByQuery(query);
|
|
|
|
- for (ExamStudent s : query.getResult()) {
|
|
|
|
- builder.append("," + s.getExamNumber());
|
|
|
|
- }
|
|
|
|
- return builder.toString();
|
|
|
|
- }
|
|
|
|
- query.setUpload(true);
|
|
|
|
- query.setManualAbsent(true);
|
|
|
|
- if (studentService.countByQuery(query) > 0) {
|
|
|
|
- StringBuilder builder = new StringBuilder(subjectCode + "已上传考生有人工指定缺考");
|
|
|
|
- query.setPageSize(Integer.MAX_VALUE);
|
|
|
|
- query = studentService.findByQuery(query);
|
|
|
|
- for (ExamStudent s : query.getResult()) {
|
|
|
|
- builder.append("," + s.getExamNumber());
|
|
|
|
- }
|
|
|
|
- return builder.toString();
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<Double> distinctTotalScore(int examId) {
|
|
|
|
- return subjectDao.distinctTotalScore(examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public void resetInspect(int examId, String subjectCode) {
|
|
|
|
- subjectDao.resetInspect(examId, subjectCode);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<ExamSubject> listObjectiveScore(Integer examId, double objectiveScoreGt) {
|
|
|
|
- return subjectDao.listObjectiveScore(examId, objectiveScoreGt);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamSubjectDao subjectDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamService examService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamStudentDao examStudentDao;
|
|
|
|
+
|
|
|
|
+ @PersistenceContext
|
|
|
|
+ private EntityManager entityManager;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MarkGroupService groupService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamStudentService studentService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CheckStudentService checkStudentService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private MarkGroupService markGroupService;
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ // @CachePut(value = "exam_subject_cache", key =
|
|
|
|
+ // "T(String).valueOf(#subject.examId)+'-'+#subject.code", condition =
|
|
|
|
+ // "#subject!=null && #subject.examId!=null && #subject.code!=null")
|
|
|
|
+ public ExamSubject save(ExamSubject subject) {
|
|
|
|
+ return subjectDao.save(subject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ // @Cacheable(value = "exam_subject_cache", key =
|
|
|
|
+ // "T(String).valueOf(#examId)+'-'+#code", condition =
|
|
|
|
+ // "#examId>0 && #code!=null")
|
|
|
|
+ public ExamSubject find(int examId, String code) {
|
|
|
|
+ return subjectDao.findByExamIdAndCode(examId, code);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ExamSubject> list(int examId) {
|
|
|
|
+ return subjectDao.findByExamId(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ExamSubject> list(int examId, Set<String> codes) {
|
|
|
|
+ return subjectDao.findByExamIdAndSubjectCodeIn(examId, codes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<String> listLevel(int examId) {
|
|
|
|
+ return subjectDao.findDistinctLevel(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<String> listCategory(int examId) {
|
|
|
|
+ return subjectDao.findDistinctCategory(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ExamSubject> list(int examId, int uploadCountGt) {
|
|
|
|
+ return subjectDao.findByExamIdAndUploadCountGt(examId, uploadCountGt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public long count(int examId) {
|
|
|
|
+ return subjectDao.countByExamId(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ExamSubjectSearchQuery findByQuery(ExamSubjectSearchQuery query) {
|
|
|
|
+ checkQuery(query);
|
|
|
|
+ Page<ExamSubject> result = subjectDao.findAll(buildSpecification(query), query);
|
|
|
|
+ fillResult(result, query);
|
|
|
|
+ return query;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public long countByQuery(ExamSubjectSearchQuery query) {
|
|
|
|
+ return subjectDao.count(buildSpecification(query));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
+ // allEntries = true)
|
|
|
|
+ public void delete(ExamSubject markSubject) {
|
|
|
|
+ subjectDao.delete(markSubject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
+ // allEntries = true)
|
|
|
|
+ public void deleteByExamId(int examId) {
|
|
|
|
+ subjectDao.deleteByExamId(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
+ // allEntries = true)
|
|
|
|
+ public void updateTotalScore(int examId) {
|
|
|
|
+ subjectDao.updateTotalScoreByExamId(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ // @CacheEvict(value = "exam_subject_cache", beforeInvocation = true,
|
|
|
|
+ // allEntries = true)
|
|
|
|
+ public void updateScore(int examId, String code, boolean objective, double score) {
|
|
|
|
+ if (objective) {
|
|
|
|
+ subjectDao.updateObjectiveScore(examId, code, score);
|
|
|
|
+ } else {
|
|
|
|
+ subjectDao.updateSubjectiveScore(examId, code, score);
|
|
|
|
+ }
|
|
|
|
+ subjectDao.updateTotalScoreByExamIdAndCode(examId, code);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Specification<ExamSubject> buildSpecification(final ExamSubjectSearchQuery query) {
|
|
|
|
+ return new Specification<ExamSubject>() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Predicate toPredicate(Root<ExamSubject> root, CriteriaQuery<?> cQuery, CriteriaBuilder cb) {
|
|
|
|
+ List<Predicate> predicates = new LinkedList<Predicate>();
|
|
|
|
+ if (query.getExamId() > 0) {
|
|
|
|
+ predicates.add(cb.equal(root.get("pk").get("examId"), query.getExamId()));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(query.getCode())) {
|
|
|
|
+ predicates.add(cb.equal(root.get("pk").get("code"), query.getCode()));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(query.getLevel())) {
|
|
|
|
+ predicates.add(cb.equal(root.get("level"), query.getLevel()));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(query.getCategory())) {
|
|
|
|
+ predicates.add(cb.equal(root.get("category"), query.getCategory()));
|
|
|
|
+ }
|
|
|
|
+ if (query.getTotalScore() != null) {
|
|
|
|
+ predicates.add(cb.equal(root.get("totalScore"), query.getTotalScore()));
|
|
|
|
+ }
|
|
|
|
+ if (query.getTotalScoreNotEqual() != null) {
|
|
|
|
+ predicates.add(cb.notEqual(root.get("totalScore"), query.getTotalScoreNotEqual()));
|
|
|
|
+ }
|
|
|
|
+ if (query.getSubjectiveScoreNotEqual() != null) {
|
|
|
|
+ predicates.add(cb.notEqual(root.get("subjectiveScore"), query.getSubjectiveScoreNotEqual()));
|
|
|
|
+ }
|
|
|
|
+ if (query.getUploadCountGt() != null) {
|
|
|
|
+ predicates.add(cb.gt(root.get("uploadCount").as(Integer.class), query.getUploadCountGt()));
|
|
|
|
+ }
|
|
|
|
+ if (query.getUploadCountEqual() != null) {
|
|
|
|
+ predicates.add(cb.equal(root.get("uploadCount").as(Integer.class), query.getUploadCountEqual()));
|
|
|
|
+ }
|
|
|
|
+ if (query.getSelective() != null) {
|
|
|
|
+ predicates.add(cb.equal(root.get("selective"), query.getSelective()));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(query.getCodeIn())) {
|
|
|
|
+ String[] list = query.getCodeIn().split(",");
|
|
|
|
+ if (list.length > 0) {
|
|
|
|
+ Predicate[] sub = new Predicate[list.length];
|
|
|
|
+ for (int i = 0; i < list.length; i++) {
|
|
|
|
+ sub[i] = cb.equal(root.get("pk").get("code"), list[i]);
|
|
|
|
+ }
|
|
|
|
+ predicates.add(cb.or(sub));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(query.getCodeNotIn())) {
|
|
|
|
+ String[] list = query.getCodeNotIn().split(",");
|
|
|
|
+ if (list.length > 0) {
|
|
|
|
+ Predicate[] sub = new Predicate[list.length];
|
|
|
|
+ for (int i = 0; i < list.length; i++) {
|
|
|
|
+ sub[i] = cb.notEqual(root.get("pk").get("code"), list[i]);
|
|
|
|
+ }
|
|
|
|
+ predicates.add(cb.and(sub));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return predicates.isEmpty() ? cb.conjunction()
|
|
|
|
+ : cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public void updateUploadCount(Integer examId, String subjectCode, int count) {
|
|
|
|
+ subjectDao.updateUploadCount(examId, subjectCode, count);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ExamSubject> listSubjectiveScore(int examId, double subjectiveScore) {
|
|
|
|
+ return subjectDao.listSubjectiveScore(examId, subjectiveScore);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public void updateSliceConfig(Integer examId, String subjectCode, List<PictureConfigItem> configList) {
|
|
|
|
+ subjectDao.updateSliceConfig(examId, subjectCode,
|
|
|
|
+ configList != null ? StringUtils.join(configList, PictureConfigItem.DB_ITEM_JOINER) : "");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public void updateTrialCount(int examId, String subjectCode, int trialCount) {
|
|
|
|
+ subjectDao.updateTrialCount(examId, subjectCode, trialCount);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int findMaxInspectRound(int examId, Set<String> subjectCodes) {
|
|
|
|
+ StringBuilder sql = new StringBuilder("select max(s.inspect_round) from eb_exam_subject s ");
|
|
|
|
+ sql.append(" where s.exam_id=" + examId + " and s.code in ('" + StringUtils.join(subjectCodes, "','") + "')");
|
|
|
|
+ Query countQuery = entityManager.createNativeQuery(sql.toString());
|
|
|
|
+ Object singleResult = countQuery.getResultList().get(0);
|
|
|
|
+ Integer count = singleResult == null ? 0 : Integer.valueOf(singleResult.toString());
|
|
|
|
+ return count;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public void nextInspectRound(int examId, String subjectCode) {
|
|
|
|
+ subjectDao.nextInspectRound(examId, subjectCode);
|
|
|
|
+ examStudentDao.cancelInspect(examId, subjectCode, false, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public void updateSelective(int examId, String subjectCode, boolean selective) {
|
|
|
|
+ subjectDao.updateSelective(examId, subjectCode, selective);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String enableExport(Exam exam, String subjectCode) {
|
|
|
|
+ ExamSubject subject = find(exam.getId(), subjectCode);
|
|
|
|
+ if (subject == null) {
|
|
|
|
+ return subjectCode + "该科目不存在";
|
|
|
|
+ }
|
|
|
|
+ List<MarkGroup> groups = groupService.findByExamAndSubjectAndStatus(exam.getId(), subjectCode,
|
|
|
|
+ MarkStatus.FORMAL, MarkStatus.TRIAL);
|
|
|
|
+ if (groups != null && !groups.isEmpty()) {
|
|
|
|
+ return subjectCode + "评卷未完成";
|
|
|
|
+ }
|
|
|
|
+ if (ExamType.MULTI_MEDIA.equals(exam.getType())) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ if (DoubleUtil.sum(subject.getObjectiveScore(), subject.getSubjectiveScore()) == 0) {
|
|
|
|
+ return subjectCode + "科目总分为0";
|
|
|
|
+ }
|
|
|
|
+ long groupCount = groupService.countByExamAndSubject(exam.getId(), subjectCode);
|
|
|
|
+ if (subject.getSubjectiveScore() != null && subject.getSubjectiveScore() > 0 && groupCount == 0) {
|
|
|
|
+ return subjectCode + "未设置评卷分组";
|
|
|
|
+ }
|
|
|
|
+ if (checkStudentService.countByExamIdAndSubjectCodeAndChecked(exam.getId(), subjectCode, false) > 0) {
|
|
|
|
+ return subjectCode + "人工确认未完成";
|
|
|
|
+ }
|
|
|
|
+ ExamStudentSearchQuery query = new ExamStudentSearchQuery();
|
|
|
|
+ query.setExamId(exam.getId());
|
|
|
|
+ query.setUpload(false);
|
|
|
|
+ query.setManualAbsent(false);
|
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
|
+ if (studentService.countByQuery(query) > 0) {
|
|
|
|
+ StringBuilder builder = new StringBuilder(subjectCode + "未上传考生必须人工指定缺考");
|
|
|
|
+ query.setPageSize(Integer.MAX_VALUE);
|
|
|
|
+ query = studentService.findByQuery(query);
|
|
|
|
+ for (ExamStudent s : query.getResult()) {
|
|
|
|
+ builder.append("," + s.getExamNumber());
|
|
|
|
+ }
|
|
|
|
+ return builder.toString();
|
|
|
|
+ }
|
|
|
|
+ query.setUpload(true);
|
|
|
|
+ query.setManualAbsent(true);
|
|
|
|
+ if (studentService.countByQuery(query) > 0) {
|
|
|
|
+ StringBuilder builder = new StringBuilder(subjectCode + "已上传考生有人工指定缺考");
|
|
|
|
+ query.setPageSize(Integer.MAX_VALUE);
|
|
|
|
+ query = studentService.findByQuery(query);
|
|
|
|
+ for (ExamStudent s : query.getResult()) {
|
|
|
|
+ builder.append("," + s.getExamNumber());
|
|
|
|
+ }
|
|
|
|
+ return builder.toString();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean checkSubjectAbsentForExport(Integer examId) {
|
|
|
|
+ ExamStudentSearchQuery query = new ExamStudentSearchQuery();
|
|
|
|
+ query.setExamId(examId);
|
|
|
|
+ query.setUpload(false);
|
|
|
|
+ query.setManualAbsent(false);
|
|
|
|
+ if (studentService.countByQuery(query) > 0) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ query.setUpload(true);
|
|
|
|
+ query.setManualAbsent(true);
|
|
|
|
+ if (studentService.countByQuery(query) > 0) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean checkSubjectForExport(Integer examId) {
|
|
|
|
+ Exam exam=examService.findById(examId);
|
|
|
|
+ if(exam==null) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ long groups = groupService.countByExamAndStatus(examId, MarkStatus.FORMAL, MarkStatus.TRIAL);
|
|
|
|
+ if (groups>0) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (ExamType.MULTI_MEDIA.equals(exam.getType())) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ if (subjectDao.getZeroScoreCount(examId)>0) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ long noGroupCount = subjectDao.getNoGroupCount(exam.getId());
|
|
|
|
+ if (noGroupCount>0) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<Double> distinctTotalScore(int examId) {
|
|
|
|
+ return subjectDao.distinctTotalScore(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public void resetInspect(int examId, String subjectCode) {
|
|
|
|
+ subjectDao.resetInspect(examId, subjectCode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<ExamSubject> listObjectiveScore(Integer examId, double objectiveScoreGt) {
|
|
|
|
+ return subjectDao.listObjectiveScore(examId, objectiveScoreGt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
@Override
|
|
@Override
|
|
public String split(Integer schoolId, Integer examId, List<SubjectSplit> list) {
|
|
public String split(Integer schoolId, Integer examId, List<SubjectSplit> list) {
|
|
- StringBuilder err=new StringBuilder();
|
|
|
|
- if(CollectionUtils.isEmpty(list)) {
|
|
|
|
- err.append("Excel中没有数据");
|
|
|
|
- return err.toString();
|
|
|
|
- }
|
|
|
|
- int index=0;
|
|
|
|
- for(SubjectSplit vo:list) {
|
|
|
|
- index++;
|
|
|
|
- StringBuilder line=new StringBuilder();
|
|
|
|
- if(StringUtils.isBlank(vo.getExamNumber())) {
|
|
|
|
- line.append(" 准考证号不能为空");
|
|
|
|
- }
|
|
|
|
- if(StringUtils.isBlank(vo.getSubjectCode())) {
|
|
|
|
- line.append(" 科目代码不能为空");
|
|
|
|
- }
|
|
|
|
- if(StringUtils.isBlank(vo.getSubjectName())) {
|
|
|
|
- line.append(" 科目名称不能为空");
|
|
|
|
- }
|
|
|
|
- if(StringUtils.isNotBlank(vo.getExamNumber())) {
|
|
|
|
- ExamStudent es=studentService.findByExamIdAndExamNumber(examId, vo.getExamNumber());
|
|
|
|
- if(es==null) {
|
|
|
|
- line.append(" 考生"+vo.getExamNumber()+"不存在");
|
|
|
|
- }else {
|
|
|
|
- vo.setStudent(es);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(line.length()>0) {
|
|
|
|
- err.append(" 第"+(index+2)+"行 "+line);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(err.length()>0) {
|
|
|
|
- return err.toString();
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
|
|
+ StringBuilder err = new StringBuilder();
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
+ err.append("Excel中没有数据");
|
|
|
|
+ return err.toString();
|
|
|
|
+ }
|
|
|
|
+ int index = 0;
|
|
|
|
+ for (SubjectSplit vo : list) {
|
|
|
|
+ index++;
|
|
|
|
+ StringBuilder line = new StringBuilder();
|
|
|
|
+ if (StringUtils.isBlank(vo.getExamNumber())) {
|
|
|
|
+ line.append(" 准考证号不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(vo.getSubjectCode())) {
|
|
|
|
+ line.append(" 科目代码不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(vo.getSubjectName())) {
|
|
|
|
+ line.append(" 科目名称不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(vo.getExamNumber())) {
|
|
|
|
+ ExamStudent es = studentService.findByExamIdAndExamNumber(examId, vo.getExamNumber());
|
|
|
|
+ if (es == null) {
|
|
|
|
+ line.append(" 考生" + vo.getExamNumber() + "不存在");
|
|
|
|
+ } else {
|
|
|
|
+ vo.setStudent(es);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (line.length() > 0) {
|
|
|
|
+ err.append(" 第" + (index + 2) + "行 " + line);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (err.length() > 0) {
|
|
|
|
+ return err.toString();
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
disposeSplit(schoolId, examId, list);
|
|
disposeSplit(schoolId, examId, list);
|
|
} catch (StatusException e) {
|
|
} catch (StatusException e) {
|
|
err.append(e.getDesc());
|
|
err.append(e.getDesc());
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- err.append("导入出错:"+e.getMessage());
|
|
|
|
|
|
+ err.append("导入出错:" + e.getMessage());
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
}
|
|
}
|
|
return err.toString();
|
|
return err.toString();
|
|
}
|
|
}
|
|
-
|
|
|
|
- private void disposeSplit(Integer schoolId, Integer examId, List<SubjectSplit> list) {
|
|
|
|
- int index=0;
|
|
|
|
- Set<String> validSubjects=new HashSet<>();
|
|
|
|
- for(SubjectSplit vo:list) {
|
|
|
|
- index++;
|
|
|
|
- long groupCount=markGroupService.countByExamAndSubject(examId, vo.getStudent().getSubjectCode());
|
|
|
|
- if(groupCount>0) {
|
|
|
|
- throw new StatusException(" 第"+(index+2)+"行 科目"+vo.getStudent().getSubjectCode()+"有分组,请先删除分组再执行");
|
|
|
|
- }
|
|
|
|
- validSubjects.add(vo.getStudent().getSubjectCode());
|
|
|
|
- if(!validSubjects.contains(vo.getSubjectCode())) {
|
|
|
|
- ExamSubject es=subjectDao.findByExamIdAndCode(index, vo.getSubjectCode());
|
|
|
|
- if(es==null) {
|
|
|
|
- es=new ExamSubject();
|
|
|
|
- es.setExamId(examId);
|
|
|
|
- es.setName(vo.getSubjectName());
|
|
|
|
- es.setCode(vo.getSubjectCode());
|
|
|
|
- es.setObjectiveScore(0.0);
|
|
|
|
- es.setSubjectiveScore(0.0);
|
|
|
|
- es.setTotalScore(0.0);
|
|
|
|
- es.setUploadCount(0);
|
|
|
|
- es.setDisplayQuestionName(true);
|
|
|
|
- es.setInspectRound(1);
|
|
|
|
- es.setSelective(false);
|
|
|
|
- subjectDao.save(es);
|
|
|
|
- }else {
|
|
|
|
- long count=markGroupService.countByExamAndSubject(examId, vo.getSubjectCode());
|
|
|
|
- if(count>0) {
|
|
|
|
- throw new StatusException(" 第"+(index+2)+"行 科目"+vo.getSubjectCode()+"有分组,请先删除分组再执行");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- validSubjects.add(vo.getSubjectCode());
|
|
|
|
- }
|
|
|
|
- vo.getStudent().setSubjectCode(vo.getSubjectCode());
|
|
|
|
- vo.getStudent().setSubjectName(vo.getSubjectName());
|
|
|
|
- examStudentDao.save(vo.getStudent());
|
|
|
|
- }
|
|
|
|
- subjectDao.updateUploadCountByExamId(examId);
|
|
|
|
- subjectDao.deleteNoStudentByExamId(examId);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ private void disposeSplit(Integer schoolId, Integer examId, List<SubjectSplit> list) {
|
|
|
|
+ int index = 0;
|
|
|
|
+ Set<String> validSubjects = new HashSet<>();
|
|
|
|
+ for (SubjectSplit vo : list) {
|
|
|
|
+ index++;
|
|
|
|
+ long groupCount = markGroupService.countByExamAndSubject(examId, vo.getStudent().getSubjectCode());
|
|
|
|
+ if (groupCount > 0) {
|
|
|
|
+ throw new StatusException(
|
|
|
|
+ " 第" + (index + 2) + "行 科目" + vo.getStudent().getSubjectCode() + "有分组,请先删除分组再执行");
|
|
|
|
+ }
|
|
|
|
+ validSubjects.add(vo.getStudent().getSubjectCode());
|
|
|
|
+ if (!validSubjects.contains(vo.getSubjectCode())) {
|
|
|
|
+ ExamSubject es = subjectDao.findByExamIdAndCode(index, vo.getSubjectCode());
|
|
|
|
+ if (es == null) {
|
|
|
|
+ es = new ExamSubject();
|
|
|
|
+ es.setExamId(examId);
|
|
|
|
+ es.setName(vo.getSubjectName());
|
|
|
|
+ es.setCode(vo.getSubjectCode());
|
|
|
|
+ es.setObjectiveScore(0.0);
|
|
|
|
+ es.setSubjectiveScore(0.0);
|
|
|
|
+ es.setTotalScore(0.0);
|
|
|
|
+ es.setUploadCount(0);
|
|
|
|
+ es.setDisplayQuestionName(true);
|
|
|
|
+ es.setInspectRound(1);
|
|
|
|
+ es.setSelective(false);
|
|
|
|
+ subjectDao.save(es);
|
|
|
|
+ } else {
|
|
|
|
+ long count = markGroupService.countByExamAndSubject(examId, vo.getSubjectCode());
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ throw new StatusException(" 第" + (index + 2) + "行 科目" + vo.getSubjectCode() + "有分组,请先删除分组再执行");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ validSubjects.add(vo.getSubjectCode());
|
|
|
|
+ }
|
|
|
|
+ vo.getStudent().setSubjectCode(vo.getSubjectCode());
|
|
|
|
+ vo.getStudent().setSubjectName(vo.getSubjectName());
|
|
|
|
+ examStudentDao.save(vo.getStudent());
|
|
|
|
+ }
|
|
|
|
+ subjectDao.updateUploadCountByExamId(examId);
|
|
|
|
+ subjectDao.deleteNoStudentByExamId(examId);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|