ExamServiceImpl.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. package cn.com.qmth.scancentral.service.impl;
  2. import java.util.List;
  3. import org.apache.commons.lang3.StringUtils;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import org.springframework.transaction.annotation.Transactional;
  9. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  10. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  11. import com.baomidou.mybatisplus.core.metadata.IPage;
  12. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  13. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  14. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  15. import com.qmth.boot.core.collection.PageResult;
  16. import com.qmth.boot.core.exception.ParameterException;
  17. import com.qmth.boot.core.security.exception.AuthorizationException;
  18. import cn.com.qmth.scancentral.bean.ImportExamDomain;
  19. import cn.com.qmth.scancentral.bean.User;
  20. import cn.com.qmth.scancentral.dao.ExamDao;
  21. import cn.com.qmth.scancentral.entity.ExamEntity;
  22. import cn.com.qmth.scancentral.entity.ExamSummaryEntity;
  23. import cn.com.qmth.scancentral.entity.SubjectEntity;
  24. import cn.com.qmth.scancentral.enums.CheckStatus;
  25. import cn.com.qmth.scancentral.enums.ExamMode;
  26. import cn.com.qmth.scancentral.enums.ExamStatus;
  27. import cn.com.qmth.scancentral.enums.ImageTransferMode;
  28. import cn.com.qmth.scancentral.enums.OP;
  29. import cn.com.qmth.scancentral.enums.Role;
  30. import cn.com.qmth.scancentral.enums.TaskStatus;
  31. import cn.com.qmth.scancentral.exception.ParameterExceptions;
  32. import cn.com.qmth.scancentral.service.AnswerCardService;
  33. import cn.com.qmth.scancentral.service.BatchService;
  34. import cn.com.qmth.scancentral.service.ExamService;
  35. import cn.com.qmth.scancentral.service.ExamSummaryService;
  36. import cn.com.qmth.scancentral.service.OmrGroupService;
  37. import cn.com.qmth.scancentral.service.OmrTaskService;
  38. import cn.com.qmth.scancentral.service.PackageCardService;
  39. import cn.com.qmth.scancentral.service.PackageTaskService;
  40. import cn.com.qmth.scancentral.service.StudentService;
  41. import cn.com.qmth.scancentral.service.SubjectService;
  42. import cn.com.qmth.scancentral.util.JsonMapper;
  43. import cn.com.qmth.scancentral.util.MathUtil;
  44. import cn.com.qmth.scancentral.util.PageUtil;
  45. import cn.com.qmth.scancentral.vo.ExamConfigVo;
  46. import cn.com.qmth.scancentral.vo.ExamVo;
  47. import cn.com.qmth.scancentral.vo.auditor.AuditorOverview;
  48. import cn.com.qmth.scancentral.vo.checkimage.RatioVo;
  49. import cn.com.qmth.scancentral.vo.examinfo.ExamEdit;
  50. import cn.com.qmth.scancentral.vo.examinfo.ExamOverview;
  51. import cn.com.qmth.scancentral.vo.examinfo.ExamQuery;
  52. import cn.com.qmth.scancentral.vo.omr.OmrTaskOverview;
  53. import cn.com.qmth.scancentral.vo.scanexaminfo.ScanExamInfoVo;
  54. import cn.com.qmth.scancentral.vo.scanexamlist.ScanExamListQuery;
  55. import cn.com.qmth.scancentral.vo.scanexamlist.ScanExamListVo;
  56. import cn.com.qmth.scancentral.vo.studentimport.StudentImportConfigVo;
  57. @Service
  58. public class ExamServiceImpl extends ServiceImpl<ExamDao, ExamEntity> implements ExamService {
  59. private static final Logger log = LoggerFactory.getLogger(ExamServiceImpl.class);
  60. @Autowired
  61. private AnswerCardService answerCardService;
  62. @Autowired
  63. private PackageCardService packageCardService;
  64. @Autowired
  65. private OmrTaskService omrTaskService;
  66. @Autowired
  67. private PackageTaskService packageTaskService;
  68. @Autowired
  69. private StudentService studentService;
  70. @Autowired
  71. private SubjectService subjectService;
  72. @Autowired
  73. private BatchService batchService;
  74. @Autowired
  75. private OmrGroupService omrGroupService;
  76. @Autowired
  77. private ExamSummaryService examSummaryService;
  78. @Override
  79. public PageResult<ExamVo> pageQuery(ExamQuery query, User user) {
  80. query.setEnable(true);
  81. IPage<ExamVo> iPage = this.baseMapper.pageExam(new Page<>(query.getPageNumber(), query.getPageSize()), query);
  82. return PageUtil.of(iPage);
  83. }
  84. @Override
  85. public List<ExamEntity> listEnable() {
  86. return list(new LambdaQueryWrapper<ExamEntity>().eq(ExamEntity::getEnable, true));
  87. }
  88. @Transactional
  89. @Override
  90. public Long save(ExamEdit exam) {
  91. if (StringUtils.isBlank(exam.getName())) {
  92. throw new ParameterException("考试名称不能为空");
  93. }
  94. if (StringUtils.length(exam.getName()) > 100) {
  95. throw new ParameterException("考试名称限制100字以内");
  96. }
  97. boolean isCreate = false;
  98. if (exam.getId() != null) {
  99. // 修改考试
  100. ExamEntity examEntity = this.getById(exam.getId());
  101. if (examEntity == null) {
  102. throw ParameterExceptions.EXAM_NOT_FOUND;
  103. }
  104. LambdaUpdateWrapper<ExamEntity> updateWrapper = new LambdaUpdateWrapper<>();
  105. updateWrapper.set(ExamEntity::getUpdateTime, System.currentTimeMillis());
  106. updateWrapper.set(ExamEntity::getUpdaterId, exam.getOperateUserId());
  107. updateWrapper.set(ExamEntity::getName, exam.getName());
  108. updateWrapper.eq(ExamEntity::getId, exam.getId());
  109. this.update(updateWrapper);
  110. return exam.getId();
  111. } else {
  112. isCreate = true;
  113. }
  114. // 新增考试
  115. ExamEntity examEntity = new ExamEntity();
  116. examEntity.setName(exam.getName());
  117. examEntity.setEnable(true);
  118. examEntity.setCreatorId(exam.getOperateUserId());
  119. examEntity.setUpdaterId(exam.getOperateUserId());
  120. examEntity.setCreateTime(System.currentTimeMillis());
  121. examEntity.setUpdateTime(System.currentTimeMillis());
  122. examEntity.setMode(ExamMode.CET);
  123. examEntity.setScanByPackage(true);
  124. examEntity.setAllowUnexistPaper(false);
  125. examEntity.setAnswerFrontCardType(1);
  126. examEntity.setEnableSinglePageAnswer(false);
  127. examEntity.setEnableUpload(false);
  128. examEntity.setEnableSyncVerify(true);
  129. examEntity.setImageTransferMode(ImageTransferMode.CET);
  130. examEntity.setImageCheckRatio(1d);
  131. // examEntity.setImageCheckOrder(null);
  132. // examEntity.setScannerAssignedMaxCount(null);
  133. // examEntity.setScannerAssignedVerifyPassword(null);
  134. // examEntity.setPaperTypeBarcodeContent(null);
  135. // examEntity.setAbsentBarcodeContent(null);
  136. // examEntity.setDataSyncTime(null);
  137. // examEntity.setCardSyncTime(null);
  138. // examEntity.setExamNumberFillCount(null);
  139. this.save(examEntity);
  140. if (isCreate) {
  141. subjectService.initSubject(examEntity.getId());
  142. }
  143. log.warn("新增考试成功! examId:{}", examEntity.getId());
  144. return examEntity.getId();
  145. }
  146. @Override
  147. public ExamOverview getExamOverview(Long examId, User accessUser) {
  148. ExamEntity exam = this.getById(examId);
  149. if (exam == null) {
  150. throw ParameterExceptions.EXAM_NOT_FOUND;
  151. }
  152. ExamOverview vo = new ExamOverview();
  153. vo.setId(examId);
  154. vo.setName(exam.getName());
  155. ExamSummaryEntity summary = examSummaryService.find(examId);
  156. vo.getBasic().setStudentCount(summary.getStudentCount());
  157. vo.getBasic().setSubjectCount(summary.getSubjectCount());
  158. vo.getBasic().setCardCount(answerCardService.getCountByExam(examId));
  159. int scannedTotalCount = summary.getAnswerScannedCount() + summary.getAnswerUnexistCount();
  160. double scannedRate = MathUtil.percentage(summary.getAnswerScannedCount(), scannedTotalCount);
  161. vo.getScan().setScannedRate(scannedRate);
  162. vo.getScan().setScannedCount(summary.getAnswerScannedCount());
  163. vo.getScan().setUnexistCount(summary.getAnswerUnexistCount());
  164. int imageCheckCount = batchService.getCheckCountByExamId(examId, CheckStatus.FINISH, accessUser);
  165. int imageCheckTodoCount = batchService.getCheckCountByExamId(examId, CheckStatus.WAITING, accessUser);
  166. int imageCheckTotalCount = imageCheckCount + imageCheckTodoCount;
  167. double imageCheckRate = MathUtil.percentage(imageCheckCount, imageCheckTotalCount);
  168. vo.getScan().setImageCheckRate(imageCheckRate);
  169. vo.getScan().setImageCheckCount(imageCheckCount);
  170. vo.getScan().setImageCheckTodoCount(imageCheckTodoCount);
  171. int auditorTodoCount = studentService.getCountByExamAndAssignedCheckCount(examId, null, 0, OP.EQ);
  172. int auditorFinishCount = studentService.getCountByExamAndAssignedCheckCount(examId, null, 0, OP.GT);
  173. int adminTodoCount = studentService.getCountByExamAndAssignedCheckCount(examId, null, 1, OP.EQ);
  174. int adminFinishCount = studentService.getCountByExamAndAssignedCheckCount(examId, null, 2, OP.GE);
  175. int auditorTotalCount = auditorTodoCount + auditorFinishCount;
  176. double auditorFinishRate = MathUtil.percentage(auditorFinishCount, auditorTotalCount);
  177. int adminTotalCount = adminTodoCount + adminFinishCount;
  178. double adminFinishRate = MathUtil.percentage(adminFinishCount, adminTotalCount);
  179. vo.getAssignedCheck().setAuditorTodoCount(auditorTodoCount);
  180. vo.getAssignedCheck().setAuditorFinishCount(auditorFinishCount);
  181. vo.getAssignedCheck().setAuditorFinishRate(auditorFinishRate);
  182. vo.getAssignedCheck().setAdminTodoCount(adminTodoCount);
  183. vo.getAssignedCheck().setAdminFinishCount(adminFinishCount);
  184. vo.getAssignedCheck().setAdminFinishRate(adminFinishRate);
  185. OmrTaskOverview suspectOverview = omrTaskService.countByExamIdAndFixed(examId, true);
  186. OmrTaskOverview customizeOverview = omrTaskService.countByExamIdAndFixed(examId, false);
  187. int suspectFinishCount = suspectOverview.getProcessedCount() + suspectOverview.getArbitrateCount();
  188. int suspectTodoCount = suspectOverview.getWaitingCount() + suspectOverview.getWaitArbitrateCount();
  189. double suspectFinishRate = MathUtil.percentage(suspectFinishCount, suspectOverview.getTotalCount());
  190. int customizeFinishCount = customizeOverview.getProcessedCount() + customizeOverview.getArbitrateCount();
  191. int customizeTodoCount = customizeOverview.getWaitingCount() + customizeOverview.getWaitArbitrateCount();
  192. double customizeFinishRate = MathUtil.percentage(customizeFinishCount, customizeOverview.getTotalCount());
  193. vo.getOmr().setSuspectFinishCount(suspectFinishCount);
  194. vo.getOmr().setSuspectTodoCount(suspectTodoCount);
  195. vo.getOmr().setSuspectFinishRate(suspectFinishRate);
  196. vo.getOmr().setCustomizeFinishCount(customizeFinishCount);
  197. vo.getOmr().setCustomizeTodoCount(customizeTodoCount);
  198. vo.getOmr().setCustomizeFinishRate(customizeFinishRate);
  199. int absentCount = studentService.countByExamIdAndExamStatus(examId, ExamStatus.ABSENT);
  200. int okCount = studentService.countByExamIdAndExamStatus(examId, ExamStatus.OK);
  201. int todoCount = studentService.countByExamIdAndExamStatus(examId, ExamStatus.UNCHECK);
  202. vo.getAbsentCheck().setAbsentCount(absentCount);
  203. vo.getAbsentCheck().setOkCount(okCount);
  204. vo.getAbsentCheck().setTodoCount(todoCount);
  205. return vo;
  206. }
  207. @Override
  208. public ScanExamInfoVo getScanExamInfo(Long id, User accessUser) {
  209. ExamEntity exam = this.getById(id);
  210. if (exam == null || (exam.getEnable() != null && !exam.getEnable())) {
  211. throw ParameterExceptions.EXAM_NOT_FOUND;
  212. }
  213. ExamSummaryEntity es = examSummaryService.find(exam.getId());
  214. ScanExamInfoVo vo = new ScanExamInfoVo();
  215. vo.setId(id);
  216. vo.setName(exam.getName());
  217. vo.getExamConfig().setAllowUnexistPaper(exam.getAllowUnexistPaper());
  218. vo.getExamConfig().setAnswerFrontCardType(exam.getAnswerFrontCardType());
  219. vo.getExamConfig().setImageTransferMode(exam.getImageTransferMode());
  220. vo.getExamConfig().setEnableSinglePageAnswer(exam.getEnableSinglePageAnswer());
  221. vo.getExamConfig().setMode(exam.getMode());
  222. vo.getExamConfig().setScanByPackage(exam.getScanByPackage());
  223. vo.getExamConfig().setEnableSyncVerify(exam.getEnableSyncVerify());
  224. vo.getExamConfig().setAbsentBarcodeContent(exam.getAbsentBarcodeContent());
  225. vo.getExamConfig().setPaperTypeBarcodeContent(exam.getPaperTypeBarcodeContent());
  226. vo.getExamConfig().setScannerAssignedMaxCount(exam.getScannerAssignedMaxCount());
  227. vo.getAnswerScan().setCardCount(answerCardService.getCountByExam(id));
  228. vo.getAnswerScan().setTotalCount(es.getStudentCount());
  229. vo.getAnswerScan().setScannedCount(es.getAnswerScannedCount());
  230. vo.getPackageScan().setCardCount(packageCardService.getCountByExam(id));
  231. vo.getPackageScan().setTotalCount(es.getPackageTotalCount());
  232. vo.getPackageScan().setScannedCount(es.getPackageScannedCount());
  233. vo.getOmrTask().setTodoCount(omrTaskService.getCountByExamAndStatus(id, TaskStatus.WAITING));
  234. vo.getOmrTask().setFinishCount(omrTaskService.getCountByExamAndStatus(id, TaskStatus.PROCESSED));
  235. vo.getPackageTask().setTodoCount(packageTaskService.getCountByExamAndStatus(id, TaskStatus.WAITING));
  236. vo.getPackageTask().setFinishCount(packageTaskService.getCountByExamAndStatus(id, TaskStatus.PROCESSED));
  237. vo.setSubjectConfig(subjectService.listConfigByExamId(id));
  238. return vo;
  239. }
  240. @Override
  241. public List<ScanExamListVo> getScanExamList() {
  242. ScanExamListQuery query = new ScanExamListQuery();
  243. query.setEnable(true);
  244. return this.baseMapper.getExamList(query);
  245. }
  246. @Override
  247. public ExamConfigVo getConfigInfo(Long examId) {
  248. ExamEntity exam = this.getById(examId);
  249. if (exam == null) {
  250. throw ParameterExceptions.EXAM_NOT_FOUND;
  251. }
  252. ExamConfigVo vo = new ExamConfigVo();
  253. vo.setExamId(exam.getId());
  254. vo.setPaperTypeBarcodeContent(exam.getPaperTypeBarcodeContent());
  255. vo.setImageCheckRatio(exam.getImageCheckRatio());
  256. vo.setImageCheckOrder(exam.getImageCheckOrder());
  257. vo.setEnableSyncVerify(exam.getEnableSyncVerify());
  258. vo.setScannerAssignedMaxCount(exam.getScannerAssignedMaxCount());
  259. vo.setScannerAssignedVerifyPassword(exam.getScannerAssignedVerifyPassword());
  260. return vo;
  261. }
  262. @Transactional
  263. @Override
  264. public void saveConfig(ExamConfigVo config, User user) {
  265. if (!Role.SCHOOL_ADMIN.equals(user.getRole())) {
  266. throw AuthorizationException.NO_PERMISSION;
  267. }
  268. ExamEntity exam = this.getById(config.getExamId());
  269. if (exam == null) {
  270. throw ParameterExceptions.EXAM_NOT_FOUND;
  271. }
  272. LambdaUpdateWrapper<ExamEntity> updateWrapper = Wrappers.lambdaUpdate(ExamEntity.class);
  273. if (config.getPaperTypeBarcodeContent() != null) {
  274. updateWrapper.setSql("paper_type_barcode_content = '"
  275. + new JsonMapper().toJson(config.getPaperTypeBarcodeContent()) + "'");
  276. }
  277. if (config.getImageCheckRatio() != null) {
  278. updateWrapper.set(ExamEntity::getImageCheckRatio, config.getImageCheckRatio());
  279. }
  280. if (StringUtils.isNotBlank(config.getImageCheckOrder())) {
  281. updateWrapper.set(ExamEntity::getImageCheckOrder, config.getImageCheckOrder());
  282. }
  283. if (config.getEnableSyncVerify() != null) {
  284. updateWrapper.set(ExamEntity::getEnableSyncVerify, config.getEnableSyncVerify());
  285. }
  286. if (config.getScannerAssignedMaxCount() != null) {
  287. updateWrapper.set(ExamEntity::getScannerAssignedMaxCount, config.getScannerAssignedMaxCount());
  288. }
  289. if (StringUtils.isNotBlank(config.getScannerAssignedVerifyPassword())) {
  290. updateWrapper.set(ExamEntity::getScannerAssignedVerifyPassword, config.getScannerAssignedVerifyPassword());
  291. }
  292. updateWrapper.set(ExamEntity::getUpdateTime, System.currentTimeMillis());
  293. updateWrapper.set(ExamEntity::getUpdaterId, user.getId());
  294. updateWrapper.eq(ExamEntity::getId, config.getExamId());
  295. this.update(updateWrapper);
  296. if (config.getEnableSyncVerify() != null && !config.getEnableSyncVerify()) {
  297. // batchService.batchVerifyCancel(user, config.getExamId());
  298. }
  299. }
  300. @Override
  301. public StudentImportConfigVo getStudentImportConfig(Long examId) {
  302. if (examId == null) {
  303. throw new ParameterException("examId不能为空");
  304. }
  305. ExamEntity exam = this.getById(examId);
  306. if (exam == null) {
  307. throw ParameterExceptions.EXAM_NOT_FOUND;
  308. }
  309. StudentImportConfigVo config = new StudentImportConfigVo();
  310. config.setExamId(examId);
  311. config.setYear(exam.getYear());
  312. config.setYearHalf(exam.getYearHalf());
  313. return config;
  314. }
  315. @Override
  316. public void saveStudentImportConfig(StudentImportConfigVo config) {
  317. if (config.getExamId() == null) {
  318. throw new ParameterException("examId不能为空");
  319. }
  320. if (config.getYear() == null) {
  321. throw new ParameterException("考试年度不能为空");
  322. }
  323. if (config.getYearHalf() == null) {
  324. throw new ParameterException("考次不能为空");
  325. }
  326. ExamEntity exam = this.getById(config.getExamId());
  327. if (exam == null) {
  328. throw ParameterExceptions.EXAM_NOT_FOUND;
  329. }
  330. LambdaUpdateWrapper<ExamEntity> updateWrapper = new LambdaUpdateWrapper<>();
  331. updateWrapper.set(ExamEntity::getYear, config.getYear());
  332. updateWrapper.set(ExamEntity::getYearHalf, config.getYearHalf());
  333. updateWrapper.set(ExamEntity::getUpdateTime, System.currentTimeMillis());
  334. updateWrapper.eq(ExamEntity::getId, exam.getId());
  335. this.update(updateWrapper);
  336. }
  337. @Transactional
  338. @Override
  339. public ExamEntity save(ImportExamDomain domain) {
  340. // if (SystemMode.MARKINGCLOUD.equals(SystemMode.current())) {
  341. // throw new ParameterException("非本地模式不支持此功能");
  342. // }
  343. if (domain.getAllowUnexistPaper() == null) {
  344. throw new ParameterException("AllowUnexistPaper 不能为空");
  345. }
  346. if (domain.getEnableSinglePageAnswer() == null) {
  347. throw new ParameterException("EnableSinglePageAnswer 不能为空");
  348. }
  349. if (domain.getEnableSyncVerify() == null) {
  350. throw new ParameterException("EnableSyncVerify 不能为空");
  351. }
  352. if (domain.getScanByPackage() == null) {
  353. throw new ParameterException("ScanByPackage 不能为空");
  354. }
  355. if (domain.getAbsentBarcodeContent() == null) {
  356. throw new ParameterException("AbsentBarcodeContent 不能为空");
  357. }
  358. if (domain.getAnswerFrontCardType() == null) {
  359. throw new ParameterException("AnswerFrontCardType 不能为空");
  360. }
  361. if (domain.getImageTransferMode() == null) {
  362. domain.setImageTransferMode(ImageTransferMode.OFF);
  363. // throw new ParameterException("ImageTransferMode 不能为空");
  364. }
  365. if (domain.getMode() == null) {
  366. throw new ParameterException("ExamMode 不能为空");
  367. }
  368. if (domain.getPaperTypeBarcodeContent() == null) {
  369. throw new ParameterException("PaperTypeBarcodeContent 不能为空");
  370. }
  371. if (domain.getExamNumberFillCount() == null) {
  372. throw new ParameterException("ExamNumberFillCount 不能为空");
  373. }
  374. ExamEntity exam = new ExamEntity();
  375. exam.setId(domain.getId());
  376. exam.setName(domain.getName());
  377. exam.setEnable(true);
  378. exam.setEnableUpload(false);
  379. exam.setImageCheckRatio(0d);
  380. exam.setAllowUnexistPaper(domain.getAllowUnexistPaper());
  381. exam.setEnableSinglePageAnswer(domain.getEnableSinglePageAnswer());
  382. exam.setEnableSyncVerify(domain.getEnableSyncVerify());
  383. exam.setScanByPackage(domain.getScanByPackage());
  384. exam.setAbsentBarcodeContent(domain.getAbsentBarcodeContent());
  385. exam.setAnswerFrontCardType(domain.getAnswerFrontCardType());
  386. exam.setImageTransferMode(domain.getImageTransferMode());
  387. exam.setMode(domain.getMode());
  388. exam.setPaperTypeBarcodeContent(domain.getPaperTypeBarcodeContent());
  389. if (getById(domain.getId()) == null) {
  390. List<SubjectEntity> subjects = subjectService.listByExamId(exam.getId());
  391. for (SubjectEntity subject : subjects) {
  392. omrGroupService.addFixOmrCondition(1L, exam.getId(), subject.getCode());
  393. }
  394. }
  395. exam.setExamNumberFillCount(domain.getExamNumberFillCount());
  396. this.saveOrUpdate(exam);
  397. return exam;
  398. }
  399. @Override
  400. public RatioVo updateRatio(Long examId, Double ratio) {
  401. if (ratio == null || ratio < 0 || ratio > 1) {
  402. throw new ParameterException("ratio 不符合");
  403. }
  404. ExamEntity exam = this.getById(examId);
  405. if (exam == null) {
  406. throw new ParameterException("Exam 不能为空");
  407. }
  408. exam.setImageCheckRatio(ratio);
  409. this.updateById(exam);
  410. return new RatioVo(ratio);
  411. }
  412. @Transactional
  413. @Override
  414. public void updateDataSyncTime(Long examId) {
  415. ExamEntity exam = this.getById(examId);
  416. if (exam == null) {
  417. throw new ParameterException("Exam 不能为空");
  418. }
  419. exam.setDataSyncTime(System.currentTimeMillis());
  420. this.updateById(exam);
  421. }
  422. @Transactional
  423. @Override
  424. public void updateCardSyncTime(Long examId) {
  425. ExamEntity exam = this.getById(examId);
  426. if (exam == null) {
  427. throw new ParameterException("Exam 不能为空");
  428. }
  429. exam.setCardSyncTime(System.currentTimeMillis());
  430. this.updateById(exam);
  431. }
  432. @Override
  433. public void updateExamNumberFillCount(Long examId, Integer examNumberFillCount) {
  434. ExamEntity exam = this.getById(examId);
  435. if (exam == null) {
  436. throw new ParameterException("Exam 不能为空");
  437. }
  438. exam.setExamNumberFillCount(examNumberFillCount);
  439. this.updateById(exam);
  440. }
  441. @Override
  442. @Transactional
  443. public ExamEntity updateEnableSyncVerify(User user, Long examId, Boolean enableSyncVerify) {
  444. ExamEntity exam = this.getById(examId);
  445. if (exam == null) {
  446. throw ParameterExceptions.EXAM_NOT_FOUND;
  447. }
  448. if (enableSyncVerify == false) {
  449. batchService.batchVerifyCancel(user, examId);
  450. }
  451. exam.setEnableSyncVerify(enableSyncVerify);
  452. this.saveOrUpdate(exam);
  453. return exam;
  454. }
  455. @Override
  456. public AuditorOverview getAuditorOverview(Long examId, User user) {
  457. if (!user.getRole().equals(Role.AUDITOR)) {
  458. throw new ParameterException("user 不是审核员");
  459. }
  460. ExamEntity exam = this.getById(examId);
  461. if (exam == null) {
  462. throw ParameterExceptions.EXAM_NOT_FOUND;
  463. }
  464. AuditorOverview vo = new AuditorOverview();
  465. vo.setId(examId);
  466. vo.setName(exam.getName());
  467. vo.getVerifyTask().setTodoCount(batchService.getVerifyCount(examId));
  468. vo.getImageCheckTask().setCheckRatio(exam.getImageCheckRatio());
  469. vo.getImageCheckTask().setFinishCount(batchService.getCheckCountByExamId(examId, CheckStatus.FINISH, user));
  470. vo.getImageCheckTask().setTodoCount(batchService.getCheckCountByExamId(examId, CheckStatus.WAITING, user));
  471. vo.getAssignedCheck().setTodoCount(studentService.getCountByExamAndAssignedCheckCount(examId, null, 0, OP.EQ));
  472. return vo;
  473. }
  474. @Transactional
  475. @Override
  476. public void scanSiteSave(Long examId, String scanStie) {
  477. LambdaUpdateWrapper<ExamEntity> updateWrapper = new LambdaUpdateWrapper<>();
  478. updateWrapper.set(ExamEntity::getScanSite, scanStie);
  479. updateWrapper.eq(ExamEntity::getId, examId);
  480. this.update(updateWrapper);
  481. }
  482. @Override
  483. public String getScanSite(Long examId) {
  484. return this.getById(examId).getScanSite();
  485. }
  486. }