ExamServiceImpl.java 22 KB

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