ExamServiceImpl.java 22 KB

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