|
@@ -1,11 +1,44 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
|
|
|
|
+import static cn.com.qmth.examcloud.core.oe.admin.base.Constants.OE_CODE_400;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+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.jpa.domain.Specification;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.RowMapper;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordForMarkingCloudService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordDataBean;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordDataTotalScoreVo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordFileAnswerBean;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordForMarkingBean;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.api.request.*;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.FindExamRecordForMarkingInfoReq;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.GetSingleExamRecordDataReq;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.QueryValidExamRecordInfoPageReq;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.QueryValidExamRecordInfoReq;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.SaveExamRecordForMarkingReq;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.UpdateExamRecordForMarkingBatchNumReq;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.FindExamRecordForMarkingInfoResp;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetSingleExamRecordDataResp;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.QueryValidExamRecordInfoPageResp;
|
|
@@ -24,27 +57,8 @@ import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordQuestionsService;
|
|
|
import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-import com.mysql.cj.util.StringUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-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.jpa.domain.Specification;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import static cn.com.qmth.examcloud.core.oe.admin.base.Constants.OE_CODE_400;
|
|
|
|
|
|
/**
|
|
|
* @author chenken
|
|
@@ -55,289 +69,312 @@ import static cn.com.qmth.examcloud.core.oe.admin.base.Constants.OE_CODE_400;
|
|
|
@Api(tags = "阅卷获取信息相关接口")
|
|
|
@RestController
|
|
|
@RequestMapping("${$rmp.cloud.oe}/examRecordForMarking")
|
|
|
-public class ExamRecordForMarkingCloudServiceProvider extends ControllerSupport implements ExamRecordForMarkingCloudService {
|
|
|
-
|
|
|
- private static final long serialVersionUID = -8343697288418890873L;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordForMarkingService examRecordForMarkingService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamStudentRepo examStudentRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordDataRepo examRecordDataRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordForMarkingRepo examRecordForMarkingRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordQuestionsService examRecordQuestionsService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordFileAnswerRepo examRecordFileAnswerRepo;
|
|
|
-
|
|
|
- @Override
|
|
|
- @ApiOperation(value = "根据条件查询阅卷需要的信息")
|
|
|
- @PostMapping("/findExamRecordForMarkingInfo")
|
|
|
- public FindExamRecordForMarkingInfoResp findExamRecordForMarkingInfo(@RequestBody FindExamRecordForMarkingInfoReq req) {
|
|
|
- Long id = req.getId();
|
|
|
- Long examId = req.getExamId();
|
|
|
- FindExamRecordForMarkingInfoResp resp = new FindExamRecordForMarkingInfoResp();
|
|
|
- if (id == null && examId == null) {
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingList =
|
|
|
- examRecordForMarkingService.findExamRecordForMarkingInfo(id, examId, req.getCourseId(), req.getBatchNum());
|
|
|
- List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<>();
|
|
|
- for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
|
|
|
- ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
|
|
|
- examRecordForMarkingBean.setId(entity.getId());
|
|
|
- examRecordForMarkingBean.setExamId(entity.getExamId());
|
|
|
- examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
|
|
|
- examRecordForMarkingBean.setPaperType(entity.getPaperType());
|
|
|
- examRecordForMarkingBean.setCourseId(entity.getCourseId());
|
|
|
-
|
|
|
- if (entity.getExamRecordDataId() == null) {
|
|
|
- throw new StatusException("500101", "阅卷信息错误,考试记录ID存在空值!");
|
|
|
- }
|
|
|
-
|
|
|
- long examRecordDataId = entity.getExamRecordDataId();
|
|
|
- List<ExamRecordFileAnswerEntity> fileAnswerList = examRecordFileAnswerRepo.findByExamRecordDataId(examRecordDataId);
|
|
|
- if (fileAnswerList != null) {
|
|
|
- examRecordForMarkingBean.setOfflineFiles(getOfflineFilesFrom(fileAnswerList));
|
|
|
- }
|
|
|
-
|
|
|
- examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
|
|
|
- examRecordForMarkingBeanList.add(examRecordForMarkingBean);
|
|
|
- }
|
|
|
-
|
|
|
- resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- private List<ExamRecordFileAnswerBean> getOfflineFilesFrom(List<ExamRecordFileAnswerEntity> fileAnswerList) {
|
|
|
- List<ExamRecordFileAnswerBean> resultList = new ArrayList<>();
|
|
|
- for (ExamRecordFileAnswerEntity entity : fileAnswerList) {
|
|
|
- ExamRecordFileAnswerBean bean = new ExamRecordFileAnswerBean();
|
|
|
- bean.setId(entity.getId());
|
|
|
- bean.setExamRecordDataId(entity.getExamRecordDataId());
|
|
|
- bean.setOfflineFileUrl(FileStorageUtil.realPath(entity.getFileUrl()));
|
|
|
- bean.setOfflineFileName(entity.getFileName());
|
|
|
- bean.setOriginalFileName(entity.getOriginalFileName());
|
|
|
- bean.setFileType(entity.getFileType());
|
|
|
- bean.setSuffix(entity.getSuffix());
|
|
|
- bean.setProperties(entity.getProperties());
|
|
|
- resultList.add(bean);
|
|
|
- }
|
|
|
-
|
|
|
- return resultList;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @ApiOperation(value = "查询有效成绩")
|
|
|
- @PostMapping("/queryValidExamRecordInfo")
|
|
|
- public QueryValidExamRecordInfoResp queryValidExamRecordInfo(@RequestBody QueryValidExamRecordInfoReq req) {
|
|
|
- Check.isNull(req.getExamId(), "examId不能为空");
|
|
|
- Check.isNull(req.getCourseId(), "courseId不能为空");
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService.queryValidExamRecordList(req.getExamId(), req.getCourseId());
|
|
|
-
|
|
|
- QueryValidExamRecordInfoResp resp = new QueryValidExamRecordInfoResp();
|
|
|
- List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
|
|
|
- for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
|
|
|
- ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
|
|
|
- examRecordForMarkingBean.setId(entity.getId());
|
|
|
- examRecordForMarkingBean.setExamId(entity.getExamId());
|
|
|
- examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
|
|
|
- examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
|
|
|
- examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
|
|
|
- examRecordForMarkingBean.setPaperType(entity.getPaperType());
|
|
|
- examRecordForMarkingBean.setCourseId(entity.getCourseId());
|
|
|
- examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
|
|
|
- examRecordForMarkingBeanList.add(examRecordForMarkingBean);
|
|
|
- }
|
|
|
- resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @ApiOperation(value = "分页查询有效成绩")
|
|
|
- @PostMapping("/queryValidExamRecordInfoPage")
|
|
|
- public QueryValidExamRecordInfoPageResp queryValidExamRecordInfoPage(@RequestBody QueryValidExamRecordInfoPageReq req) {
|
|
|
- Check.isNull(req.getExamId(), "examId不能为空");
|
|
|
- Check.isNull(req.getCourseId(), "courseId不能为空");
|
|
|
- Check.isNull(req.getStart(), "start不能为空");
|
|
|
- Check.isNull(req.getSize(), "size不能为空");
|
|
|
- if (req.getStart().longValue() <= 0) {
|
|
|
- throw new StatusException(OE_CODE_400, "start必须大于0");
|
|
|
- }
|
|
|
- if (req.getSize().longValue() <= 0) {
|
|
|
- throw new StatusException(OE_CODE_400, "size必须大于0");
|
|
|
- }
|
|
|
- Long courseId = req.getCourseId();
|
|
|
- Long examId = req.getExamId();
|
|
|
- Long size = req.getSize();
|
|
|
- Long start = req.getStart();
|
|
|
- //分页获取考生id
|
|
|
- Pageable pageable = PageRequest.of(0, size.intValue(), Sort.Direction.ASC, "id");
|
|
|
-
|
|
|
- Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
- List<Predicate> predicates = new ArrayList<>();
|
|
|
- predicates.add(cb.equal(root.get("examId"), examId));
|
|
|
- predicates.add(cb.equal(root.get("courseId"), courseId));
|
|
|
- predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
- };
|
|
|
-
|
|
|
- Page<ExamStudentEntity> page = examStudentRepo.findAll(specification,
|
|
|
- pageable);
|
|
|
-
|
|
|
- Iterator<ExamStudentEntity> iterator = page.iterator();
|
|
|
-
|
|
|
- List<Long> stuIdList = Lists.newArrayList();
|
|
|
- Long next = start;
|
|
|
- while (iterator.hasNext()) {
|
|
|
- ExamStudentEntity e = iterator.next();
|
|
|
- next = e.getId();
|
|
|
- stuIdList.add(e.getExamStudentId());
|
|
|
- }
|
|
|
-
|
|
|
- QueryValidExamRecordInfoPageResp resp = new QueryValidExamRecordInfoPageResp();
|
|
|
- if (!next.equals(start)) {
|
|
|
- next++;
|
|
|
- }
|
|
|
- resp.setNext(next);
|
|
|
- //根据分页获取的考生id获取需要阅卷的试卷
|
|
|
- List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
|
|
|
- if (stuIdList.size() > 0) {
|
|
|
- List<ExamRecordForMarkingEntity> examRecordForMarkingList =
|
|
|
- examRecordForMarkingService.queryValidExamRecordInfoByStuIds(examId, courseId, stuIdList, req.getBatchNum());
|
|
|
-
|
|
|
- if (null == examRecordForMarkingList) {
|
|
|
- resp.setExamRecordForMarkingBeanList(null);
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
|
|
|
- ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
|
|
|
- examRecordForMarkingBean.setId(entity.getId());
|
|
|
- examRecordForMarkingBean.setExamId(entity.getExamId());
|
|
|
- examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
|
|
|
- examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
|
|
|
- examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
|
|
|
- examRecordForMarkingBean.setPaperType(entity.getPaperType());
|
|
|
- examRecordForMarkingBean.setCourseId(entity.getCourseId());
|
|
|
- examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
|
|
|
- examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
|
|
|
- examRecordForMarkingBeanList.add(examRecordForMarkingBean);
|
|
|
- }
|
|
|
- }
|
|
|
- resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取单个考试记录信息
|
|
|
- *
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- @PostMapping("/getSingleExamRecordData")
|
|
|
- public GetSingleExamRecordDataResp getSingleExamRecordData(@RequestBody GetSingleExamRecordDataReq req) {
|
|
|
- Check.isNull(req.getId(), "id不能为空");
|
|
|
- ExamRecordDataEntity entity = GlobalHelper.getEntity(examRecordDataRepo, req.getId(), ExamRecordDataEntity.class);
|
|
|
- if (entity == null) {
|
|
|
- return new GetSingleExamRecordDataResp();
|
|
|
- }
|
|
|
-
|
|
|
- return copyGetSingleExamRecordDataRespFrom(entity);
|
|
|
- }
|
|
|
-
|
|
|
- private GetSingleExamRecordDataResp copyGetSingleExamRecordDataRespFrom(ExamRecordDataEntity entity) {
|
|
|
- GetSingleExamRecordDataResp resp = new GetSingleExamRecordDataResp();
|
|
|
-
|
|
|
- ExamRecordDataBean data = new ExamRecordDataBean();
|
|
|
- data.setId(entity.getId());
|
|
|
- data.setExamId(entity.getExamId());
|
|
|
- data.setExamType(entity.getExamType() == null ? null : entity.getExamType().toString());
|
|
|
- data.setExamStudentId(entity.getExamStudentId());
|
|
|
- data.setStudentId(entity.getStudentId());
|
|
|
- data.setStudentCode(entity.getStudentCode());
|
|
|
- data.setStudentName(entity.getStudentName());
|
|
|
- data.setIdentityNumber(entity.getIdentityNumber());
|
|
|
- data.setCourseId(entity.getCourseId());
|
|
|
- data.setCourseLevel(entity.getCourseLevel());
|
|
|
- data.setOrgId(entity.getOrgId());
|
|
|
- data.setRootOrgId(entity.getRootOrgId());
|
|
|
- data.setBasePaperId(entity.getBasePaperId());
|
|
|
- data.setPaperType(entity.getPaperType());
|
|
|
- data.setPaperStructId(entity.getPaperStructId());
|
|
|
- data.setInfoCollector(entity.getInfoCollector());
|
|
|
- data.setExamRecordQuestionsId(entity.getExamRecordQuestionsId());
|
|
|
- data.setExamRecordStatus(entity.getExamRecordStatus() == null ? null : entity.getExamRecordStatus().toString());
|
|
|
- data.setStartTime(entity.getStartTime());
|
|
|
- data.setEndTime(entity.getEndTime());
|
|
|
- data.setCleanTime(entity.getCleanTime());
|
|
|
- data.setWarn(entity.getIsWarn());
|
|
|
- data.setAudit(entity.getIsAudit());
|
|
|
- data.setIllegality(entity.getIsIllegality());
|
|
|
- data.setUsedExamTime(entity.getUsedExamTime());
|
|
|
- data.setExamOrder(entity.getExamOrder());
|
|
|
- data.setReexamine(entity.getIsReexamine());
|
|
|
- data.setContinued(entity.getIsContinued());
|
|
|
- data.setAllObjectivePaper(entity.getIsAllObjectivePaper());
|
|
|
- data.setContinuedCount(entity.getContinuedCount());
|
|
|
- data.setExceed(entity.getIsExceed());
|
|
|
- data.setFaceSuccessCount(entity.getFaceSuccessCount());
|
|
|
- data.setFaceFailedCount(entity.getFaceFailedCount());
|
|
|
- data.setFaceStrangerCount(entity.getFaceStrangerCount());
|
|
|
- data.setFaceTotalCount(entity.getFaceTotalCount());
|
|
|
- data.setFaceSuccessPercent(entity.getFaceSuccessPercent());
|
|
|
- data.setFaceVerifyResult(entity.getFaceVerifyResult() == null ? null : entity.getFaceVerifyResult().toString());
|
|
|
- data.setBaiduFaceLivenessSuccessPercent(entity.getBaiduFaceLivenessSuccessPercent());
|
|
|
- data.setFaceLandmarkVal(entity.getFaceLandmarkVal());
|
|
|
- data.setRandomPaper(entity.getRandomPaper());
|
|
|
- data.setPaperScore(entity.getPaperScore());
|
|
|
-
|
|
|
- resp.setData(data);
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @PostMapping("/updateExamRecordForMarkingBatchNum")
|
|
|
- public void updateExamRecordForMarkingBatchNum(@RequestBody UpdateExamRecordForMarkingBatchNumReq req) {
|
|
|
- if (req.getIdList() == null || req.getIdList().isEmpty()) {
|
|
|
- throw new StatusException("222001", "阅卷原始数据表id不允许为空");
|
|
|
- }
|
|
|
- if (req.getIdList().size() > 100) {
|
|
|
- throw new StatusException("222002", "阅卷原始数据表id集合最大不得超过100条");
|
|
|
- }
|
|
|
- if (StringUtils.isNullOrEmpty(req.getBatchNum())) {
|
|
|
- throw new StatusException("222003", "批次号不允许为空");
|
|
|
- }
|
|
|
- examRecordForMarkingRepo.updateBatchNum(req.getIdList(), req.getBatchNum());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @PostMapping("/saveExamRecordForMarking")
|
|
|
- public void saveExamRecordForMarking(@RequestBody SaveExamRecordForMarkingReq req) {
|
|
|
- ExamRecordForMarkingEntity examRecordForMarkingExists = examRecordForMarkingRepo.findByExamRecordDataId(req.getExamRecordDataId());
|
|
|
- if (examRecordForMarkingExists != null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- ExamRecordForMarkingEntity examRecordForMarking = new ExamRecordForMarkingEntity();
|
|
|
- examRecordForMarking.setExamId(req.getExamId());
|
|
|
- examRecordForMarking.setExamRecordDataId(req.getExamRecordDataId());
|
|
|
- examRecordForMarking.setExamStudentId(req.getExamStudentId());
|
|
|
- examRecordForMarking.setBasePaperId(req.getBasePaperId());
|
|
|
- examRecordForMarking.setPaperType(req.getPaperType());
|
|
|
- examRecordForMarking.setCourseId(req.getCourseId());
|
|
|
- examRecordForMarking.setObjectiveScore(req.getObjectiveScore());
|
|
|
- int subjectiveAnswerLength = examRecordQuestionsService.calculationSubjectiveAnswerLength(req.getExamRecordDataId());
|
|
|
- examRecordForMarking.setSubjectiveAnswerLength(subjectiveAnswerLength);
|
|
|
- examRecordForMarkingRepo.save(examRecordForMarking);
|
|
|
- }
|
|
|
+public class ExamRecordForMarkingCloudServiceProvider extends ControllerSupport
|
|
|
+ implements ExamRecordForMarkingCloudService {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = -8343697288418890873L;
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordForMarkingService examRecordForMarkingService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamStudentRepo examStudentRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordDataRepo examRecordDataRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordForMarkingRepo examRecordForMarkingRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordQuestionsService examRecordQuestionsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordFileAnswerRepo examRecordFileAnswerRepo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @ApiOperation(value = "根据条件查询阅卷需要的信息")
|
|
|
+ @PostMapping("/findExamRecordForMarkingInfo")
|
|
|
+ public FindExamRecordForMarkingInfoResp findExamRecordForMarkingInfo(
|
|
|
+ @RequestBody FindExamRecordForMarkingInfoReq req) {
|
|
|
+ Long id = req.getId();
|
|
|
+ Long examId = req.getExamId();
|
|
|
+ FindExamRecordForMarkingInfoResp resp = new FindExamRecordForMarkingInfoResp();
|
|
|
+ if (id == null && examId == null) {
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
|
|
|
+ .findExamRecordForMarkingInfo(id, examId, req.getCourseId(), req.getBatchNum());
|
|
|
+ List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<>();
|
|
|
+ for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
|
|
|
+ ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
|
|
|
+ examRecordForMarkingBean.setId(entity.getId());
|
|
|
+ examRecordForMarkingBean.setExamId(entity.getExamId());
|
|
|
+ examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
|
|
|
+ examRecordForMarkingBean.setPaperType(entity.getPaperType());
|
|
|
+ examRecordForMarkingBean.setCourseId(entity.getCourseId());
|
|
|
+
|
|
|
+ if (entity.getExamRecordDataId() == null) {
|
|
|
+ throw new StatusException("500101", "阅卷信息错误,考试记录ID存在空值!");
|
|
|
+ }
|
|
|
+
|
|
|
+ long examRecordDataId = entity.getExamRecordDataId();
|
|
|
+ List<ExamRecordFileAnswerEntity> fileAnswerList = examRecordFileAnswerRepo
|
|
|
+ .findByExamRecordDataId(examRecordDataId);
|
|
|
+ if (fileAnswerList != null) {
|
|
|
+ examRecordForMarkingBean.setOfflineFiles(getOfflineFilesFrom(fileAnswerList));
|
|
|
+ }
|
|
|
+
|
|
|
+ examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
|
|
|
+ examRecordForMarkingBeanList.add(examRecordForMarkingBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamRecordFileAnswerBean> getOfflineFilesFrom(List<ExamRecordFileAnswerEntity> fileAnswerList) {
|
|
|
+ List<ExamRecordFileAnswerBean> resultList = new ArrayList<>();
|
|
|
+ for (ExamRecordFileAnswerEntity entity : fileAnswerList) {
|
|
|
+ ExamRecordFileAnswerBean bean = new ExamRecordFileAnswerBean();
|
|
|
+ bean.setId(entity.getId());
|
|
|
+ bean.setExamRecordDataId(entity.getExamRecordDataId());
|
|
|
+ bean.setOfflineFileUrl(FileStorageUtil.realPath(entity.getFileUrl()));
|
|
|
+ bean.setOfflineFileName(entity.getFileName());
|
|
|
+ bean.setOriginalFileName(entity.getOriginalFileName());
|
|
|
+ bean.setFileType(entity.getFileType());
|
|
|
+ bean.setSuffix(entity.getSuffix());
|
|
|
+ bean.setProperties(entity.getProperties());
|
|
|
+ resultList.add(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @ApiOperation(value = "查询有效成绩")
|
|
|
+ @PostMapping("/queryValidExamRecordInfo")
|
|
|
+ public QueryValidExamRecordInfoResp queryValidExamRecordInfo(@RequestBody QueryValidExamRecordInfoReq req) {
|
|
|
+ Check.isNull(req.getExamId(), "examId不能为空");
|
|
|
+ Check.isNull(req.getCourseId(), "courseId不能为空");
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
|
|
|
+ .queryValidExamRecordList(req.getExamId(), req.getCourseId());
|
|
|
+
|
|
|
+ QueryValidExamRecordInfoResp resp = new QueryValidExamRecordInfoResp();
|
|
|
+ List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
|
|
|
+ for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
|
|
|
+ ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
|
|
|
+ examRecordForMarkingBean.setId(entity.getId());
|
|
|
+ examRecordForMarkingBean.setExamId(entity.getExamId());
|
|
|
+ examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
|
|
|
+ examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
|
|
|
+ examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
|
|
|
+ examRecordForMarkingBean.setPaperType(entity.getPaperType());
|
|
|
+ examRecordForMarkingBean.setCourseId(entity.getCourseId());
|
|
|
+ examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
|
|
|
+ examRecordForMarkingBeanList.add(examRecordForMarkingBean);
|
|
|
+ }
|
|
|
+ resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @ApiOperation(value = "分页查询有效成绩")
|
|
|
+ @PostMapping("/queryValidExamRecordInfoPage")
|
|
|
+ public QueryValidExamRecordInfoPageResp queryValidExamRecordInfoPage(
|
|
|
+ @RequestBody QueryValidExamRecordInfoPageReq req) {
|
|
|
+ Check.isNull(req.getExamId(), "examId不能为空");
|
|
|
+ Check.isNull(req.getCourseId(), "courseId不能为空");
|
|
|
+ Check.isNull(req.getStart(), "start不能为空");
|
|
|
+ Check.isNull(req.getSize(), "size不能为空");
|
|
|
+ if (req.getStart().longValue() <= 0) {
|
|
|
+ throw new StatusException(OE_CODE_400, "start必须大于0");
|
|
|
+ }
|
|
|
+ if (req.getSize().longValue() <= 0) {
|
|
|
+ throw new StatusException(OE_CODE_400, "size必须大于0");
|
|
|
+ }
|
|
|
+ Long courseId = req.getCourseId();
|
|
|
+ Long examId = req.getExamId();
|
|
|
+ Long size = req.getSize();
|
|
|
+ Long start = req.getStart();
|
|
|
+ // 分页获取考生id
|
|
|
+ Pageable pageable = PageRequest.of(0, size.intValue(), Sort.Direction.ASC, "id");
|
|
|
+
|
|
|
+ Specification<ExamStudentEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("examId"), examId));
|
|
|
+ predicates.add(cb.equal(root.get("courseId"), courseId));
|
|
|
+ predicates.add(cb.greaterThanOrEqualTo(root.get("id"), start));
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ Page<ExamStudentEntity> page = examStudentRepo.findAll(specification, pageable);
|
|
|
+
|
|
|
+ Iterator<ExamStudentEntity> iterator = page.iterator();
|
|
|
+
|
|
|
+ List<Long> stuIdList = Lists.newArrayList();
|
|
|
+ Long next = start;
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ ExamStudentEntity e = iterator.next();
|
|
|
+ next = e.getId();
|
|
|
+ stuIdList.add(e.getExamStudentId());
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryValidExamRecordInfoPageResp resp = new QueryValidExamRecordInfoPageResp();
|
|
|
+ if (!next.equals(start)) {
|
|
|
+ next++;
|
|
|
+ }
|
|
|
+ resp.setNext(next);
|
|
|
+ // 根据分页获取的考生id获取需要阅卷的试卷
|
|
|
+ List<ExamRecordForMarkingBean> examRecordForMarkingBeanList = new ArrayList<ExamRecordForMarkingBean>();
|
|
|
+ if (stuIdList.size() > 0) {
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingService
|
|
|
+ .queryValidExamRecordInfoByStuIds(examId, courseId, stuIdList, req.getBatchNum());
|
|
|
+
|
|
|
+ if (null == examRecordForMarkingList) {
|
|
|
+ resp.setExamRecordForMarkingBeanList(null);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ExamRecordForMarkingEntity entity : examRecordForMarkingList) {
|
|
|
+ ExamRecordForMarkingBean examRecordForMarkingBean = new ExamRecordForMarkingBean();
|
|
|
+ examRecordForMarkingBean.setId(entity.getId());
|
|
|
+ examRecordForMarkingBean.setExamId(entity.getExamId());
|
|
|
+ examRecordForMarkingBean.setExamRecordDataId(entity.getExamRecordDataId());
|
|
|
+ examRecordForMarkingBean.setExamStudentId(entity.getExamStudentId());
|
|
|
+ examRecordForMarkingBean.setBasePaperId(entity.getBasePaperId());
|
|
|
+ examRecordForMarkingBean.setPaperType(entity.getPaperType());
|
|
|
+ examRecordForMarkingBean.setCourseId(entity.getCourseId());
|
|
|
+ examRecordForMarkingBean.setObjectiveScore(entity.getObjectiveScore());
|
|
|
+ examRecordForMarkingBean.setBatchNum(entity.getBatchNum());
|
|
|
+ examRecordForMarkingBeanList.add(examRecordForMarkingBean);
|
|
|
+ }
|
|
|
+ fillTatolScore(examRecordForMarkingBeanList);
|
|
|
+ }
|
|
|
+ resp.setExamRecordForMarkingBeanList(examRecordForMarkingBeanList);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillTatolScore(List<ExamRecordForMarkingBean> list) {
|
|
|
+ RowMapper<ExamRecordDataTotalScoreVo> rowMapper = new BeanPropertyRowMapper<>(ExamRecordDataTotalScoreVo.class);
|
|
|
+ StringBuilder sb = new StringBuilder(
|
|
|
+ "select t.id,t.paper_score totalScore from ec_oe_exam_record_data t where t.id in (");
|
|
|
+ List<Long> ids = list.stream().map(e -> e.getExamRecordDataId()).collect(Collectors.toList());
|
|
|
+ sb.append(StringUtils.join(ids, ","));
|
|
|
+ sb.append(")");
|
|
|
+ List<ExamRecordDataTotalScoreVo> dtos = jdbcTemplate.query(sb.toString(), rowMapper);
|
|
|
+ Map<Long, Double> totalScores = dtos.stream().collect(Collectors.toMap(e -> e.getId(), e -> e.getTotalScore()));
|
|
|
+ for(ExamRecordForMarkingBean b:list) {
|
|
|
+ b.setTotalScore(totalScores.get(b.getExamRecordDataId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取单个考试记录信息
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @PostMapping("/getSingleExamRecordData")
|
|
|
+ public GetSingleExamRecordDataResp getSingleExamRecordData(@RequestBody GetSingleExamRecordDataReq req) {
|
|
|
+ Check.isNull(req.getId(), "id不能为空");
|
|
|
+ ExamRecordDataEntity entity = GlobalHelper.getEntity(examRecordDataRepo, req.getId(),
|
|
|
+ ExamRecordDataEntity.class);
|
|
|
+ if (entity == null) {
|
|
|
+ return new GetSingleExamRecordDataResp();
|
|
|
+ }
|
|
|
+
|
|
|
+ return copyGetSingleExamRecordDataRespFrom(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ private GetSingleExamRecordDataResp copyGetSingleExamRecordDataRespFrom(ExamRecordDataEntity entity) {
|
|
|
+ GetSingleExamRecordDataResp resp = new GetSingleExamRecordDataResp();
|
|
|
+
|
|
|
+ ExamRecordDataBean data = new ExamRecordDataBean();
|
|
|
+ data.setId(entity.getId());
|
|
|
+ data.setExamId(entity.getExamId());
|
|
|
+ data.setExamType(entity.getExamType() == null ? null : entity.getExamType().toString());
|
|
|
+ data.setExamStudentId(entity.getExamStudentId());
|
|
|
+ data.setStudentId(entity.getStudentId());
|
|
|
+ data.setStudentCode(entity.getStudentCode());
|
|
|
+ data.setStudentName(entity.getStudentName());
|
|
|
+ data.setIdentityNumber(entity.getIdentityNumber());
|
|
|
+ data.setCourseId(entity.getCourseId());
|
|
|
+ data.setCourseLevel(entity.getCourseLevel());
|
|
|
+ data.setOrgId(entity.getOrgId());
|
|
|
+ data.setRootOrgId(entity.getRootOrgId());
|
|
|
+ data.setBasePaperId(entity.getBasePaperId());
|
|
|
+ data.setPaperType(entity.getPaperType());
|
|
|
+ data.setPaperStructId(entity.getPaperStructId());
|
|
|
+ data.setInfoCollector(entity.getInfoCollector());
|
|
|
+ data.setExamRecordQuestionsId(entity.getExamRecordQuestionsId());
|
|
|
+ data.setExamRecordStatus(entity.getExamRecordStatus() == null ? null : entity.getExamRecordStatus().toString());
|
|
|
+ data.setStartTime(entity.getStartTime());
|
|
|
+ data.setEndTime(entity.getEndTime());
|
|
|
+ data.setCleanTime(entity.getCleanTime());
|
|
|
+ data.setWarn(entity.getIsWarn());
|
|
|
+ data.setAudit(entity.getIsAudit());
|
|
|
+ data.setIllegality(entity.getIsIllegality());
|
|
|
+ data.setUsedExamTime(entity.getUsedExamTime());
|
|
|
+ data.setExamOrder(entity.getExamOrder());
|
|
|
+ data.setReexamine(entity.getIsReexamine());
|
|
|
+ data.setContinued(entity.getIsContinued());
|
|
|
+ data.setAllObjectivePaper(entity.getIsAllObjectivePaper());
|
|
|
+ data.setContinuedCount(entity.getContinuedCount());
|
|
|
+ data.setExceed(entity.getIsExceed());
|
|
|
+ data.setFaceSuccessCount(entity.getFaceSuccessCount());
|
|
|
+ data.setFaceFailedCount(entity.getFaceFailedCount());
|
|
|
+ data.setFaceStrangerCount(entity.getFaceStrangerCount());
|
|
|
+ data.setFaceTotalCount(entity.getFaceTotalCount());
|
|
|
+ data.setFaceSuccessPercent(entity.getFaceSuccessPercent());
|
|
|
+ data.setFaceVerifyResult(entity.getFaceVerifyResult() == null ? null : entity.getFaceVerifyResult().toString());
|
|
|
+ data.setBaiduFaceLivenessSuccessPercent(entity.getBaiduFaceLivenessSuccessPercent());
|
|
|
+ data.setFaceLandmarkVal(entity.getFaceLandmarkVal());
|
|
|
+ data.setRandomPaper(entity.getRandomPaper());
|
|
|
+ data.setPaperScore(entity.getPaperScore());
|
|
|
+
|
|
|
+ resp.setData(data);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @PostMapping("/updateExamRecordForMarkingBatchNum")
|
|
|
+ public void updateExamRecordForMarkingBatchNum(@RequestBody UpdateExamRecordForMarkingBatchNumReq req) {
|
|
|
+ if (req.getIdList() == null || req.getIdList().isEmpty()) {
|
|
|
+ throw new StatusException("222001", "阅卷原始数据表id不允许为空");
|
|
|
+ }
|
|
|
+ if (req.getIdList().size() > 100) {
|
|
|
+ throw new StatusException("222002", "阅卷原始数据表id集合最大不得超过100条");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(req.getBatchNum())) {
|
|
|
+ throw new StatusException("222003", "批次号不允许为空");
|
|
|
+ }
|
|
|
+ examRecordForMarkingRepo.updateBatchNum(req.getIdList(), req.getBatchNum());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @PostMapping("/saveExamRecordForMarking")
|
|
|
+ public void saveExamRecordForMarking(@RequestBody SaveExamRecordForMarkingReq req) {
|
|
|
+ ExamRecordForMarkingEntity examRecordForMarkingExists = examRecordForMarkingRepo
|
|
|
+ .findByExamRecordDataId(req.getExamRecordDataId());
|
|
|
+ if (examRecordForMarkingExists != null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ExamRecordForMarkingEntity examRecordForMarking = new ExamRecordForMarkingEntity();
|
|
|
+ examRecordForMarking.setExamId(req.getExamId());
|
|
|
+ examRecordForMarking.setExamRecordDataId(req.getExamRecordDataId());
|
|
|
+ examRecordForMarking.setExamStudentId(req.getExamStudentId());
|
|
|
+ examRecordForMarking.setBasePaperId(req.getBasePaperId());
|
|
|
+ examRecordForMarking.setPaperType(req.getPaperType());
|
|
|
+ examRecordForMarking.setCourseId(req.getCourseId());
|
|
|
+ examRecordForMarking.setObjectiveScore(req.getObjectiveScore());
|
|
|
+ int subjectiveAnswerLength = examRecordQuestionsService
|
|
|
+ .calculationSubjectiveAnswerLength(req.getExamRecordDataId());
|
|
|
+ examRecordForMarking.setSubjectiveAnswerLength(subjectiveAnswerLength);
|
|
|
+ examRecordForMarkingRepo.save(examRecordForMarking);
|
|
|
+ }
|
|
|
|
|
|
}
|