|
@@ -1,51 +1,39 @@
|
|
package cn.com.qmth.scancentral.service.impl;
|
|
package cn.com.qmth.scancentral.service.impl;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.boot.core.collection.PageResult;
|
|
|
|
+import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
|
+import com.qmth.boot.core.exception.ParameterException;
|
|
|
|
+import com.qmth.boot.core.security.exception.AuthorizationException;
|
|
|
|
+
|
|
import cn.com.qmth.scancentral.bean.ExamConfigDomain;
|
|
import cn.com.qmth.scancentral.bean.ExamConfigDomain;
|
|
import cn.com.qmth.scancentral.bean.ImportExamDomain;
|
|
import cn.com.qmth.scancentral.bean.ImportExamDomain;
|
|
import cn.com.qmth.scancentral.bean.User;
|
|
import cn.com.qmth.scancentral.bean.User;
|
|
-import cn.com.qmth.scancentral.client.MarkingcloudApiClient;
|
|
|
|
import cn.com.qmth.scancentral.dao.ExamDao;
|
|
import cn.com.qmth.scancentral.dao.ExamDao;
|
|
-import cn.com.qmth.scancentral.entity.*;
|
|
|
|
|
|
+import cn.com.qmth.scancentral.entity.ExamEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.ExamSummaryEntity;
|
|
|
|
+import cn.com.qmth.scancentral.entity.SystemConfigEntity;
|
|
import cn.com.qmth.scancentral.enums.*;
|
|
import cn.com.qmth.scancentral.enums.*;
|
|
import cn.com.qmth.scancentral.exception.ParameterExceptions;
|
|
import cn.com.qmth.scancentral.exception.ParameterExceptions;
|
|
-import cn.com.qmth.scancentral.model.ExamInfoDto;
|
|
|
|
-import cn.com.qmth.scancentral.model.StudentInfo;
|
|
|
|
import cn.com.qmth.scancentral.service.*;
|
|
import cn.com.qmth.scancentral.service.*;
|
|
import cn.com.qmth.scancentral.util.PageUtil;
|
|
import cn.com.qmth.scancentral.util.PageUtil;
|
|
import cn.com.qmth.scancentral.vo.ExamConfigVo;
|
|
import cn.com.qmth.scancentral.vo.ExamConfigVo;
|
|
-import cn.com.qmth.scancentral.vo.ExamInitVo;
|
|
|
|
-import cn.com.qmth.scancentral.vo.ExamRemoteVo;
|
|
|
|
import cn.com.qmth.scancentral.vo.ExamVo;
|
|
import cn.com.qmth.scancentral.vo.ExamVo;
|
|
import cn.com.qmth.scancentral.vo.checkimage.RatioVo;
|
|
import cn.com.qmth.scancentral.vo.checkimage.RatioVo;
|
|
-import cn.com.qmth.scancentral.vo.examinfo.ExamConfig;
|
|
|
|
import cn.com.qmth.scancentral.vo.examinfo.ExamInfoVo;
|
|
import cn.com.qmth.scancentral.vo.examinfo.ExamInfoVo;
|
|
import cn.com.qmth.scancentral.vo.examinfo.ExamQuery;
|
|
import cn.com.qmth.scancentral.vo.examinfo.ExamQuery;
|
|
import cn.com.qmth.scancentral.vo.scanexaminfo.ScanExamInfoVo;
|
|
import cn.com.qmth.scancentral.vo.scanexaminfo.ScanExamInfoVo;
|
|
import cn.com.qmth.scancentral.vo.scanexamlist.ScanExamListQuery;
|
|
import cn.com.qmth.scancentral.vo.scanexamlist.ScanExamListQuery;
|
|
import cn.com.qmth.scancentral.vo.scanexamlist.ScanExamListVo;
|
|
import cn.com.qmth.scancentral.vo.scanexamlist.ScanExamListVo;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
-import com.qmth.boot.core.collection.PageResult;
|
|
|
|
-import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
|
-import com.qmth.boot.core.exception.ParameterException;
|
|
|
|
-import com.qmth.boot.core.exception.StatusException;
|
|
|
|
-import com.qmth.boot.core.retrofit.exception.RetrofitResponseError;
|
|
|
|
-import com.qmth.boot.core.retrofit.utils.SignatureInfo;
|
|
|
|
-import com.qmth.boot.core.security.exception.AuthorizationException;
|
|
|
|
-import com.qmth.boot.mybatis.query.BaseQuery;
|
|
|
|
-import com.qmth.boot.tools.signature.SignatureType;
|
|
|
|
-import net.sf.json.JSONObject;
|
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
-
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamEntity> implements ExamService {
|
|
public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamEntity> implements ExamService {
|
|
@@ -80,9 +68,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamEntity> implements
|
|
@Autowired
|
|
@Autowired
|
|
private ConcurrentService concurrentService;
|
|
private ConcurrentService concurrentService;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private MarkingcloudApiClient apiClient;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private OmrGroupService omrGroupService;
|
|
private OmrGroupService omrGroupService;
|
|
|
|
|
|
@@ -258,61 +243,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamEntity> implements
|
|
return this.baseMapper.getExamList(query);
|
|
return this.baseMapper.getExamList(query);
|
|
}
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public PageResult<ExamRemoteVo> listRemote(BaseQuery<?> query, User user) {
|
|
|
|
- if (SystemMode.STANDALONE.equals(SystemMode.current())) {
|
|
|
|
- return PageUtil.emptyPage();
|
|
|
|
- }
|
|
|
|
- SignatureInfo signatureInfo = new SignatureInfo(SignatureType.TOKEN, user.getAccount(),
|
|
|
|
- user.getMarkingCloudToken());
|
|
|
|
- int pageNumber = 1;
|
|
|
|
- int pageSize = 20;
|
|
|
|
- List<ExamInfoDto> yunList = new ArrayList<>();
|
|
|
|
- try {
|
|
|
|
- List<ExamInfoDto> list = apiClient.examQuery(signatureInfo, pageNumber, pageSize);
|
|
|
|
- yunList.addAll(list);
|
|
|
|
- while (list.size() != 0) {
|
|
|
|
- pageNumber++;
|
|
|
|
- list = apiClient.examQuery(signatureInfo, pageNumber, pageSize);
|
|
|
|
- yunList.addAll(list);
|
|
|
|
- }
|
|
|
|
- } catch (RetrofitResponseError e) {
|
|
|
|
- if (e.getCode() == 401) {
|
|
|
|
- sessionService.removeSchoolSession(user.getSchoolId());
|
|
|
|
- }
|
|
|
|
- log.error("list remote exam error, account=" + user.getAccount() + ", schoolId=" + user.getSchoolId()
|
|
|
|
- + ", token=" + user.getMarkingCloudToken(), e);
|
|
|
|
- throw e;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("list remote exam error, account=" + user.getAccount() + ", schoolId=" + user.getSchoolId()
|
|
|
|
- + ", token=" + user.getMarkingCloudToken(), e);
|
|
|
|
- throw new StatusException("获取未开启的考试出错", e);
|
|
|
|
- }
|
|
|
|
- List<ExamInfoDto> remoteList = new ArrayList<>();
|
|
|
|
- for (ExamInfoDto infoDto : yunList) {
|
|
|
|
- if (this.getById(infoDto.getId()) == null) {
|
|
|
|
- remoteList.add(infoDto);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- List<ExamRemoteVo> vos = new ArrayList<>();
|
|
|
|
- for (ExamInfoDto examInfoDto : remoteList) {
|
|
|
|
- ExamRemoteVo vo = new ExamRemoteVo();
|
|
|
|
- vo.setExamTime(examInfoDto.getExamTime());
|
|
|
|
- vo.setId(examInfoDto.getId());
|
|
|
|
- vo.setName(examInfoDto.getName());
|
|
|
|
- vo.setScanConfig(examInfoDto.getConfig());
|
|
|
|
- vos.add(vo);
|
|
|
|
- }
|
|
|
|
- List<ExamRemoteVo> page = PageUtil.startPage(vos, (int) query.getPageNumber(), (int) query.getPageSize());
|
|
|
|
- PageResult<ExamRemoteVo> result = new PageResult<>();
|
|
|
|
- result.setPageNumber(query.getPageNumber());
|
|
|
|
- result.setPageSize(query.getPageSize());
|
|
|
|
- result.setResult(page);
|
|
|
|
- result.setTotalCount(vos.size());
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public ExamConfigVo config(User user, ExamConfigDomain domain) {
|
|
public ExamConfigVo config(User user, ExamConfigDomain domain) {
|
|
@@ -326,7 +256,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamEntity> implements
|
|
if (!exam.getSchoolId().equals(user.getSchoolId())) {
|
|
if (!exam.getSchoolId().equals(user.getSchoolId())) {
|
|
throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
}
|
|
}
|
|
- if (SystemMode.STANDALONE.equals(SystemMode.current())) {
|
|
|
|
if (domain.getAllowUnexistPaper() != null) {
|
|
if (domain.getAllowUnexistPaper() != null) {
|
|
exam.setAllowUnexistPaper(domain.getAllowUnexistPaper());
|
|
exam.setAllowUnexistPaper(domain.getAllowUnexistPaper());
|
|
}
|
|
}
|
|
@@ -354,281 +283,21 @@ public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamEntity> implements
|
|
if (domain.getPaperTypeBarcodeContent() != null) {
|
|
if (domain.getPaperTypeBarcodeContent() != null) {
|
|
exam.setPaperTypeBarcodeContent(domain.getPaperTypeBarcodeContent());
|
|
exam.setPaperTypeBarcodeContent(domain.getPaperTypeBarcodeContent());
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- if (domain.getAllowUnexistPaper() == null) {
|
|
|
|
- domain.setAllowUnexistPaper(exam.getAllowUnexistPaper());
|
|
|
|
- }
|
|
|
|
- if (domain.getEnableSinglePageAnswer() == null) {
|
|
|
|
- domain.setEnableSinglePageAnswer(exam.getEnableSinglePageAnswer());
|
|
|
|
- }
|
|
|
|
- if (domain.getEnableSyncVerify() == null) {
|
|
|
|
- domain.setEnableSyncVerify(exam.getEnableSyncVerify());
|
|
|
|
- }
|
|
|
|
- if (domain.getScanByPackage() == null) {
|
|
|
|
- domain.setScanByPackage(exam.getScanByPackage());
|
|
|
|
- }
|
|
|
|
- if (domain.getAbsentBarcodeContent() == null) {
|
|
|
|
- domain.setAbsentBarcodeContent(exam.getAbsentBarcodeContent());
|
|
|
|
- }
|
|
|
|
- if (domain.getAnswerFrontCardType() == null) {
|
|
|
|
- domain.setAnswerFrontCardType(exam.getAnswerFrontCardType());
|
|
|
|
- }
|
|
|
|
- if (domain.getImageTransferMode() == null) {
|
|
|
|
- domain.setImageTransferMode(exam.getImageTransferMode());
|
|
|
|
- }
|
|
|
|
- if (domain.getMode() == null) {
|
|
|
|
- domain.setMode(exam.getMode());
|
|
|
|
- }
|
|
|
|
- if (domain.getPaperTypeBarcodeContent() == null) {
|
|
|
|
- domain.setPaperTypeBarcodeContent(exam.getPaperTypeBarcodeContent());
|
|
|
|
- }
|
|
|
|
- SignatureInfo signatureInfo = new SignatureInfo(SignatureType.TOKEN, user.getAccount(),
|
|
|
|
- user.getMarkingCloudToken());
|
|
|
|
- JSONObject config = JSONObject.fromObject(domain);
|
|
|
|
- try {
|
|
|
|
- ExamInfoDto examInfo = apiClient
|
|
|
|
- .examConfig(signatureInfo, domain.getId(), config.toString());
|
|
|
|
- exam.setId(domain.getId());
|
|
|
|
- exam.setName(examInfo.getName());
|
|
|
|
- exam.setSchoolId(user.getSchoolId());
|
|
|
|
- exam.setSchoolName(examInfo.getSchoolName());
|
|
|
|
- exam.setAbsentBarcodeContent(examInfo.getConfig().getAbsentBarcodeContent());
|
|
|
|
- exam.setAllowUnexistPaper(examInfo.getConfig().getAllowUnexistPaper());
|
|
|
|
- exam.setAnswerFrontCardType(examInfo.getConfig().getAnswerFrontCardType());
|
|
|
|
- exam.setImageTransferMode(examInfo.getConfig().getImageTransferMode());
|
|
|
|
- exam.setEnableSyncVerify(examInfo.getConfig().getEnableSyncVerify());
|
|
|
|
- exam.setEnableSinglePageAnswer(examInfo.getConfig().getEnableSinglePageAnswer());
|
|
|
|
- exam.setMode(examInfo.getConfig().getMode());
|
|
|
|
- exam.setPaperTypeBarcodeContent(examInfo.getConfig().getPaperTypeBarcodeContent());
|
|
|
|
- exam.setScanByPackage(examInfo.getConfig().getScanByPackage());
|
|
|
|
- } catch (RetrofitResponseError e) {
|
|
|
|
- if (e.getCode() == 401) {
|
|
|
|
- sessionService.userLogout(user);
|
|
|
|
- throw AuthorizationException.SIGNATURE_INVALID;
|
|
|
|
- } else {
|
|
|
|
- throw e;
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- throw new StatusException("保存考试配置出错examId:" + exam.getId(), e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (exam.getEnableSyncVerify() == false) {
|
|
|
|
- batchService.batchVerifyCancel(user, exam.getId());
|
|
|
|
- }
|
|
|
|
- this.saveOrUpdate(exam);
|
|
|
|
- return new ExamConfigVo(exam);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Double syncProgress(User user, Long examId) {
|
|
|
|
- if (SystemMode.STANDALONE.equals(SystemMode.current())) {
|
|
|
|
- return 0d;
|
|
|
|
- }
|
|
|
|
- int studentCount = studentService.getCountByExam(examId);
|
|
|
|
- SignatureInfo signatureInfo = new SignatureInfo(SignatureType.TOKEN, user.getAccount(),
|
|
|
|
- user.getMarkingCloudToken());
|
|
|
|
- try {
|
|
|
|
- long totalCount = apiClient.studentCount(signatureInfo, examId);
|
|
|
|
- return (double) (studentCount * 100 / totalCount);
|
|
|
|
- } catch (RetrofitResponseError e) {
|
|
|
|
- if (e.getCode() == 401) {
|
|
|
|
- sessionService.userLogout(user);
|
|
|
|
- throw AuthorizationException.SIGNATURE_INVALID;
|
|
|
|
- } else {
|
|
|
|
- throw e;
|
|
|
|
- }
|
|
|
|
- } catch (StatusException e) {
|
|
|
|
- throw e;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.getStackTrace();
|
|
|
|
- throw new StatusException("获取同步进度出错examId:" + examId, e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public void sync(User user, Long examId) {
|
|
|
|
- if (SystemMode.STANDALONE.equals(SystemMode.current())) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- ExamEntity exam = this.getById(examId);
|
|
|
|
- if (exam == null) {
|
|
|
|
- throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
|
- }
|
|
|
|
- SignatureInfo signatureInfo = new SignatureInfo(SignatureType.TOKEN, user.getAccount(),
|
|
|
|
- user.getMarkingCloudToken());
|
|
|
|
- long now = System.currentTimeMillis();
|
|
|
|
- try {
|
|
|
|
- int pageNumber = 1;
|
|
|
|
- int pageSize = 100;
|
|
|
|
- List<StudentEntity> saveList = new ArrayList<>();
|
|
|
|
- List<SubjectEntity> subjectList = new ArrayList<>();
|
|
|
|
- Map<String, SubjectEntity> subjectMap = new HashMap<>();
|
|
|
|
- List<StudentInfo> students = apiClient.getStudents(signatureInfo, examId, pageNumber, pageSize);
|
|
|
|
- while (students.size() != 0) {
|
|
|
|
- List<Long> ids = new ArrayList<>();
|
|
|
|
- students.forEach((e) -> ids.add(e.getId()));
|
|
|
|
- List<StudentEntity> list = studentService.listByIds(ids);
|
|
|
|
- Map<Long, StudentEntity> map = new HashMap<>();
|
|
|
|
- list.forEach((e) -> map.put(e.getId(), e));
|
|
|
|
- for (StudentInfo studentInfo : students) {
|
|
|
|
- StudentEntity student = map.get(studentInfo.getId());
|
|
|
|
- if (student == null) {
|
|
|
|
- student = new StudentEntity();
|
|
|
|
- student.setId(studentInfo.getId());
|
|
|
|
- student.setExamId(examId);
|
|
|
|
- student.setPaperType(studentInfo.getPaperType());
|
|
|
|
- student.setAbsentSuspect(false);
|
|
|
|
- student.setAssigned(false);
|
|
|
|
- student.setIncomplete(false);
|
|
|
|
- student.setOmrAbsent(false);
|
|
|
|
- student.setQuestionFilled(false);
|
|
|
|
- student.setSubjectiveFilled(false);
|
|
|
|
- student.setStatus(ScanStatus.UNEXIST);
|
|
|
|
- student.setCheckMark(false);
|
|
|
|
- student.setAssignedSuspect(false);
|
|
|
|
- student.setAssignedCheckCount(0);
|
|
|
|
- } else {
|
|
|
|
- //考生已存在且未扫描状态下,才同步云端现有试卷类型
|
|
|
|
- //否则需要保留已扫描的试卷类型
|
|
|
|
- if (student.getStatus() == ScanStatus.UNEXIST) {
|
|
|
|
- student.setPaperType(studentInfo.getPaperType());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //更新必填属性
|
|
|
|
- student.setExamNumber(studentInfo.getExamNumber());
|
|
|
|
- student.setStudentCode(studentInfo.getStudentCode());
|
|
|
|
- student.setName(studentInfo.getName());
|
|
|
|
- student.setSubjectCode(studentInfo.getSubjectCode());
|
|
|
|
- //更新可选属性
|
|
|
|
- student.setExamRoom(studentInfo.getExamRoom() != null && studentInfo.getExamRoom().length() > 0 ?
|
|
|
|
- studentInfo.getExamRoom() :
|
|
|
|
- null);
|
|
|
|
- student.setExamSite(studentInfo.getExamSite() != null && studentInfo.getExamSite().length() > 0 ?
|
|
|
|
- studentInfo.getExamSite() :
|
|
|
|
- null);
|
|
|
|
- student.setPackageCode(
|
|
|
|
- studentInfo.getPackageCode() != null && studentInfo.getPackageCode().length() > 0 ?
|
|
|
|
- studentInfo.getPackageCode() :
|
|
|
|
- null);
|
|
|
|
- //更新时间属性
|
|
|
|
- student.setCreatorId(user.getId());
|
|
|
|
- student.setCreateTime(now);
|
|
|
|
- student.setUpdaterId(user.getId());
|
|
|
|
- student.setUpdateTime(now);
|
|
|
|
- saveList.add(student);
|
|
|
|
- SubjectEntity subject = subjectMap.get(studentInfo.getSubjectCode());
|
|
|
|
- if (subject == null) {
|
|
|
|
- subject = new SubjectEntity();
|
|
|
|
- subject.setExamId(examId);
|
|
|
|
- subject.setCode(studentInfo.getSubjectCode());
|
|
|
|
- subject.setName(studentInfo.getSubjectName());
|
|
|
|
- subject.setCreateTime(now);
|
|
|
|
- subject.setCreatorId(user.getId());
|
|
|
|
- subject.setUpdaterId(user.getId());
|
|
|
|
- subject.setUpdateTime(now);
|
|
|
|
- subjectList.add(subject);
|
|
|
|
- subjectMap.put(studentInfo.getSubjectCode(), subject);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (saveList.size() > 1000) {
|
|
|
|
- studentService.saveOrUpdateBatch(saveList);
|
|
|
|
- saveList = new ArrayList<>();
|
|
|
|
- }
|
|
|
|
- pageNumber++;
|
|
|
|
- students = apiClient.getStudents(signatureInfo, examId, pageNumber, pageSize);
|
|
|
|
- }
|
|
|
|
- for (String subjectCode : subjectMap.keySet()) {
|
|
|
|
- List<QuestionEntity> questions = apiClient.getQuestion(signatureInfo, examId, subjectCode);
|
|
|
|
- if (!questions.isEmpty()) {
|
|
|
|
- for (QuestionEntity question : questions) {
|
|
|
|
- question.setSubjectCode(subjectCode);
|
|
|
|
- question.setExamId(examId);
|
|
|
|
- }
|
|
|
|
- questionService.deleteByExamIdAndSubjectCode(examId, subjectCode);
|
|
|
|
- questionService.saveBatch(questions);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- studentService.saveOrUpdateBatch(saveList);
|
|
|
|
- subjectService.saveOrUpdateBatchByMultiId(subjectList);
|
|
|
|
- studentService.deletetByExamIdAndUnCreateTime(examId, now);
|
|
|
|
- this.updateDataSyncTime(examId);
|
|
|
|
- //一并同步卡格式
|
|
|
|
- answerCardService.sync(user, examId);
|
|
|
|
- } catch (RetrofitResponseError e) {
|
|
|
|
- if (e.getCode() == 401) {
|
|
|
|
- sessionService.userLogout(user);
|
|
|
|
- throw AuthorizationException.SIGNATURE_INVALID;
|
|
|
|
- } else {
|
|
|
|
- throw e;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public ExamInitVo init(User user, ExamConfigDomain domain) {
|
|
|
|
- if (SystemMode.STANDALONE.equals(SystemMode.current())) {
|
|
|
|
- throw new ParameterException("本地模式不支持此功能");
|
|
|
|
- }
|
|
|
|
- if (ExamMode.CET.equals(domain.getMode())) {
|
|
|
|
- throw new ParameterException("云阅卷模式下不支持CET考试");
|
|
|
|
- }
|
|
|
|
- if (!Role.SCHOOL_ADMIN.equals(user.getRole())) {
|
|
|
|
- throw AuthorizationException.NO_PERMISSION;
|
|
|
|
- }
|
|
|
|
- ExamEntity exam = this.getById(domain.getId());
|
|
|
|
- if (exam != null) {
|
|
|
|
- throw new ParameterException("考试已经存在");
|
|
|
|
- }
|
|
|
|
- // if (domain.getAbsentBarcodeContent() == null) {
|
|
|
|
- // throw new ParameterException("AbsentBarcodeContent 不能为空");
|
|
|
|
- // }
|
|
|
|
- // if (domain.getPaperTypeBarcodeContent().isEmpty()) {
|
|
|
|
- // throw new ParameterException("PaperTypeBarcodeContent 不能为空");
|
|
|
|
- // }
|
|
|
|
- exam = new ExamEntity();
|
|
|
|
- exam.setEnable(true);
|
|
|
|
- //独立模式默认不开启上传
|
|
|
|
- exam.setEnableUpload(!SystemMode.STANDALONE.equals(SystemMode.current()));
|
|
|
|
- //图片抽查比例默认为0
|
|
|
|
- exam.setImageCheckRatio(0d);
|
|
|
|
- exam.setMode(domain.getMode());
|
|
|
|
- exam.setAllowUnexistPaper(domain.getAllowUnexistPaper());
|
|
|
|
- exam.setEnableSinglePageAnswer(domain.getEnableSinglePageAnswer());
|
|
|
|
- exam.setEnableSyncVerify(domain.getEnableSyncVerify());
|
|
|
|
- exam.setScanByPackage(domain.getScanByPackage());
|
|
|
|
- exam.setAnswerFrontCardType(domain.getAnswerFrontCardType());
|
|
|
|
- exam.setImageTransferMode(domain.getImageTransferMode());
|
|
|
|
- exam.setAbsentBarcodeContent(StringUtils.trimToEmpty(domain.getAbsentBarcodeContent()));
|
|
|
|
- exam.setPaperTypeBarcodeContent(
|
|
|
|
- domain.getPaperTypeBarcodeContent() != null ? domain.getPaperTypeBarcodeContent() : new ArrayList<>());
|
|
|
|
- SignatureInfo signatureInfo = new SignatureInfo(SignatureType.TOKEN, user.getAccount(),
|
|
|
|
- user.getMarkingCloudToken());
|
|
|
|
- JSONObject config = JSONObject.fromObject(domain);
|
|
|
|
- try {
|
|
|
|
- ExamInfoDto examInfo = apiClient.examConfig(signatureInfo, domain.getId(), config.toString());
|
|
|
|
exam.setId(domain.getId());
|
|
exam.setId(domain.getId());
|
|
- exam.setName(examInfo.getName());
|
|
|
|
- exam.setSchoolId(user.getSchoolId());
|
|
|
|
- exam.setSchoolName(examInfo.getSchoolName());
|
|
|
|
- this.save(exam);
|
|
|
|
- omrGroupService.addFixOmrCondition(user.getId(), exam.getId());
|
|
|
|
- } catch (RetrofitResponseError e) {
|
|
|
|
- if (e.getCode() == 401) {
|
|
|
|
- sessionService.userLogout(user);
|
|
|
|
- throw AuthorizationException.SIGNATURE_INVALID;
|
|
|
|
- } else {
|
|
|
|
- throw e;
|
|
|
|
|
|
+ exam.setAbsentBarcodeContent(domain.getAbsentBarcodeContent());
|
|
|
|
+ exam.setAllowUnexistPaper(domain.getAllowUnexistPaper());
|
|
|
|
+ exam.setAnswerFrontCardType(domain.getAnswerFrontCardType());
|
|
|
|
+ exam.setImageTransferMode(domain.getImageTransferMode());
|
|
|
|
+ exam.setEnableSyncVerify(domain.getEnableSyncVerify());
|
|
|
|
+ exam.setEnableSinglePageAnswer(domain.getEnableSinglePageAnswer());
|
|
|
|
+ exam.setMode(domain.getMode());
|
|
|
|
+ exam.setPaperTypeBarcodeContent(domain.getPaperTypeBarcodeContent());
|
|
|
|
+ exam.setScanByPackage(domain.getScanByPackage());
|
|
|
|
+ if (exam.getEnableSyncVerify() == false) {
|
|
|
|
+ batchService.batchVerifyCancel(user, exam.getId());
|
|
}
|
|
}
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- throw new StatusException("保存考试配置出错examId:" + exam.getId(), e);
|
|
|
|
- }
|
|
|
|
- ExamInitVo vo = new ExamInitVo();
|
|
|
|
- vo.setExamConfig(new ExamConfig(exam));
|
|
|
|
- vo.setSubjectConfig(subjectService.listConfigByExamId(exam.getId()));
|
|
|
|
- return vo;
|
|
|
|
|
|
+ this.saveOrUpdate(exam);
|
|
|
|
+ return new ExamConfigVo(exam);
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|