|
@@ -1,52 +1,11 @@
|
|
|
package cn.com.qmth.stmms.biz.exam.service.impl;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.DecimalFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
-import javax.persistence.criteria.Expression;
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
-
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-import org.apache.commons.lang.math.RandomUtils;
|
|
|
-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.exam.dao.ExamStudentDao;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.ExamPackage;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
|
-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.*;
|
|
|
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.ExamPackageService;
|
|
|
-import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
|
-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.ExamSubjectService;
|
|
|
-import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
|
-import cn.com.qmth.stmms.biz.mark.model.MarkLibrary;
|
|
|
-import cn.com.qmth.stmms.biz.mark.model.MarkSpecialTag;
|
|
|
-import cn.com.qmth.stmms.biz.mark.model.MarkTrack;
|
|
|
-import cn.com.qmth.stmms.biz.mark.model.PictureConfigItem;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.*;
|
|
|
+import cn.com.qmth.stmms.biz.mark.model.*;
|
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkLibraryService;
|
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkSpecialTagService;
|
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkTrackService;
|
|
@@ -55,7 +14,20 @@ import cn.com.qmth.stmms.biz.utils.PictureConfigTransform;
|
|
|
import cn.com.qmth.stmms.biz.utils.PictureTag;
|
|
|
import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
|
import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
|
|
|
-import cn.com.qmth.stmms.common.utils.BigDecimalUtils;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.lang.math.RandomUtils;
|
|
|
+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.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implements ExamStudentService {
|
|
@@ -90,6 +62,9 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
@Autowired
|
|
|
private CheckStudentService checkStudentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AnswerCardService cardService;
|
|
|
+
|
|
|
public static final String LOGINNAME_SPLITE = "-";
|
|
|
|
|
|
public static final String USER_PASSWORD = "123456";
|
|
@@ -255,8 +230,14 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
|
|
|
public ExamStudentSearchQuery findByQuery(final ExamStudentSearchQuery query) {
|
|
|
checkQuery(query);
|
|
|
+ if (query.getSheetCount() != null) {
|
|
|
+ query.setSheetCount(query.getSheetCount() * 2);
|
|
|
+ }
|
|
|
Page<ExamStudent> result = studentDao.findAll(buildSpecification(query), query);
|
|
|
fillResult(result, query);
|
|
|
+ if (query.getSheetCount() != null) {
|
|
|
+ query.setSheetCount(query.getSheetCount() / 2);
|
|
|
+ }
|
|
|
return query;
|
|
|
}
|
|
|
|
|
@@ -402,7 +383,14 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
student.setUploadTime(new Date());
|
|
|
return studentDao.updateScanInfo(student.getId(), student.getSheetCount(), student.getSliceCount(),
|
|
|
student.getAnswers(), student.getBatchCode(), student.getPaperType(), student.isAbsent(),
|
|
|
- student.getUploadTime(), student.getObjectiveScore(), student.getObjectiveScoreList()) > 0;
|
|
|
+ student.getUploadTime(), student.getObjectiveScore(), student.getObjectiveScoreList(),
|
|
|
+ student.getCardNumber()) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public boolean resetScanInfo(ExamStudent student) {
|
|
|
+ return studentDao.resetScanInfo(student.getId(), student.getPaperType()) > 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -628,6 +616,16 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
predicates.add(cb.or(sub));
|
|
|
}
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(query.getExamSiteIn())) {
|
|
|
+ String[] list = query.getExamSiteIn().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("examSite"), list[i]);
|
|
|
+ }
|
|
|
+ predicates.add(cb.or(sub));
|
|
|
+ }
|
|
|
+ }
|
|
|
if (StringUtils.isNotBlank(query.getSubjectCodeNotIn())) {
|
|
|
String[] list = query.getSubjectCodeNotIn().split(",");
|
|
|
if (list.length > 0) {
|
|
@@ -648,6 +646,16 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
predicates.add(cb.and(sub));
|
|
|
}
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(query.getExamSiteNotIn())) {
|
|
|
+ String[] list = query.getExamSiteNotIn().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("examSite"), list[i]);
|
|
|
+ }
|
|
|
+ predicates.add(cb.and(sub));
|
|
|
+ }
|
|
|
+ }
|
|
|
if (StringUtils.isNotBlank(query.getPaperType())) {
|
|
|
predicates.add(cb.equal(root.get("paperType"), query.getPaperType()));
|
|
|
}
|
|
@@ -663,6 +671,15 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
if (query.getInspectorId() != null) {
|
|
|
predicates.add(cb.equal(root.get("inspectorId"), query.getInspectorId()));
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(query.getExamSite())) {
|
|
|
+ predicates.add(cb.equal(root.get("examSite"), query.getExamSite()));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(query.getExamRoom())) {
|
|
|
+ predicates.add(cb.equal(root.get("examRoom"), query.getExamRoom()));
|
|
|
+ }
|
|
|
+ if (query.getSheetCount() != null) {
|
|
|
+ predicates.add(cb.equal(root.get("sheetCount"), query.getSheetCount()));
|
|
|
+ }
|
|
|
return predicates.isEmpty() ? cb.conjunction() : cb.and(predicates.toArray(new Predicate[predicates
|
|
|
.size()]));
|
|
|
}
|
|
@@ -815,8 +832,8 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
sliceConfig = exam.getSliceConfigList();
|
|
|
}
|
|
|
if (!sliceConfig.isEmpty()) {
|
|
|
- List<PictureTag> tags = PictureConfigTransform.process(sliceConfig, getSliceTags(student, withGroupScore))
|
|
|
- .get(index);
|
|
|
+ List<PictureTag> tags = PictureConfigTransform.process(sliceConfig,
|
|
|
+ getSliceTags(student, withGroupScore, sliceConfig)).get(index);
|
|
|
if (tags != null) {
|
|
|
list.addAll(tags);
|
|
|
}
|
|
@@ -832,13 +849,22 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
Map<MarkGroup, List<OriginTag>> tagMap = new HashMap<MarkGroup, List<OriginTag>>();
|
|
|
Exam exam = examService.findById(student.getExamId());
|
|
|
ExamSubject subject = subjectService.find(student.getExamId(), student.getSubjectCode());
|
|
|
- List<PictureConfigItem> sliceConfig = subject.getSliceConfigList();
|
|
|
+ List<PictureConfigItem> sliceConfig = new ArrayList<PictureConfigItem>();
|
|
|
+ if (student.getCardNumber() != null) {
|
|
|
+ AnswerCard card = cardService.findByExamIdAndNumber(student.getExamId(), student.getCardNumber());
|
|
|
+ if (card != null) {
|
|
|
+ sliceConfig = card.getSliceConfigList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sliceConfig.isEmpty()) {
|
|
|
+ sliceConfig = subject.getSliceConfigList();
|
|
|
+ }
|
|
|
if (sliceConfig.isEmpty()) {
|
|
|
sliceConfig = exam.getSliceConfigList();
|
|
|
}
|
|
|
if (!sliceConfig.isEmpty()) {
|
|
|
// 有裁切图配置时才需要获取原始评卷标记信息
|
|
|
- tagMap = getSliceTags(student, withGroupScore);
|
|
|
+ tagMap = getSliceTags(student, withGroupScore, sliceConfig);
|
|
|
}
|
|
|
Map<Integer, List<PictureTag>> map = PictureConfigTransform.process(sliceConfig, tagMap);
|
|
|
// List<PictureTag> list = map.get(1);
|
|
@@ -854,14 +880,15 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
* 根据考生获取所有评卷分组的评卷标记内容
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<MarkGroup, List<OriginTag>> getSliceTags(ExamStudent student, boolean withGroupScore) {
|
|
|
+ public Map<MarkGroup, List<OriginTag>> getSliceTags(ExamStudent student, boolean withGroupScore,
|
|
|
+ List<PictureConfigItem> sliceConfig) {
|
|
|
Map<MarkGroup, List<OriginTag>> tagMap = new HashMap<MarkGroup, List<OriginTag>>();
|
|
|
List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(student.getExamId(),
|
|
|
student.getSubjectCode(), false);
|
|
|
List<ScoreItem> scoreList = student.getScoreList(false);
|
|
|
List<MarkGroup> markGroups = groupService.findByExamAndSubject(student.getExamId(), student.getSubjectCode());
|
|
|
for (MarkGroup group : markGroups) {
|
|
|
- tagMap.put(group, buildOriginTags(student, group, questions, scoreList, withGroupScore));
|
|
|
+ tagMap.put(group, buildOriginTags(student, group, questions, scoreList, withGroupScore, sliceConfig));
|
|
|
}
|
|
|
return tagMap;
|
|
|
}
|
|
@@ -934,7 +961,7 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
* @return
|
|
|
*/
|
|
|
private List<OriginTag> buildOriginTags(ExamStudent student, MarkGroup group, List<ExamQuestion> questions,
|
|
|
- List<ScoreItem> scoreList, boolean withGroupScore) {
|
|
|
+ List<ScoreItem> scoreList, boolean withGroupScore, List<PictureConfigItem> sliceConfig) {
|
|
|
if (scoreList.size() == 0) {
|
|
|
return new LinkedList<>();
|
|
|
}
|
|
@@ -955,14 +982,23 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
List<OriginTag> originTags = new LinkedList<>();
|
|
|
// 首先添加本大题总得分
|
|
|
if (withGroupScore) {
|
|
|
- List<PictureConfigItem> configList = group.getPictureConfigList();
|
|
|
+ List<MarkConfigItem> configList = group.getPictureConfigList();
|
|
|
if (configList.isEmpty()) {
|
|
|
// 未设置评卷区域,则自动取第一张裁切图的固定位置
|
|
|
originTags.add(new OriginTag(format.format(score), 1, 10, 10));
|
|
|
} else {
|
|
|
// 取第一个显示区域相对裁切图的位置
|
|
|
- PictureConfigItem config = configList.get(0);
|
|
|
- originTags.add(new OriginTag(format.format(score), config.getI(), config.getX(), config.getY()));
|
|
|
+ MarkConfigItem config = configList.get(0);
|
|
|
+ OriginTag tag = new OriginTag(format.format(score), config.getI(), config.getX(), config.getY());
|
|
|
+ // 兼容比例模式,且元素在裁切坐标内
|
|
|
+ if (config.getX() <= 1 && config.getY() <= 1 && config.getI() <= sliceConfig.size()
|
|
|
+ && sliceConfig.get(config.getI() - 1).getW() > 0
|
|
|
+ && sliceConfig.get(config.getI() - 1).getH() > 0) {
|
|
|
+ tag = new OriginTag(format.format(score), config.getI(), config.getX()
|
|
|
+ * sliceConfig.get(config.getI() - 1).getW(), config.getY()
|
|
|
+ * sliceConfig.get(config.getI() - 1).getH());
|
|
|
+ }
|
|
|
+ originTags.add(tag);
|
|
|
}
|
|
|
}
|
|
|
// 检测应该使用哪个评卷任务的轨迹记录
|
|
@@ -1066,4 +1102,43 @@ public class ExamStudentServiceImpl extends BaseQueryService<ExamStudent> implem
|
|
|
return list.get(RandomUtils.nextInt(list.size()));
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long countSheetCountByExamId(Integer examId) {
|
|
|
+ Long count = studentDao.sumSheetCountByExamId(examId);
|
|
|
+ return count == null ? 0 : count;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long countSheetCountByExamIdAndSubjectCode(int examId, String code) {
|
|
|
+ Long count = studentDao.sumSheetCountByExamIdAndSubjectCode(examId, code);
|
|
|
+ return count == null ? 0 : count;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Set<String> findSubjectUnInspectedByExamId(int examId) {
|
|
|
+ return studentDao.findSubjectUnInspectedByExamId(examId, SubjectiveStatus.MARKED);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> findDistinctCollege(int examId) {
|
|
|
+ return studentDao.findDistinctCollege(examId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> findDistinctSubjectCodeByCollege(int examId, String college) {
|
|
|
+ return studentDao.findDistinctSubjectCodeByCollege(examId, college);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int findMinInspectCountByExamIdAndSubjectCode(int examId, String subjectCode) {
|
|
|
+ Integer count = studentDao.findMinInspectCountByExamIdAndSubjectCode(examId, subjectCode);
|
|
|
+ return count == null ? 0 : count;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void updateInspectCount(Integer studentId, Integer inspectCount) {
|
|
|
+ studentDao.updateInspectCount(studentId, inspectCount);
|
|
|
+ }
|
|
|
}
|