ExamServiceImpl.java 23 KB

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