ClientController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. package com.qmth.distributed.print.api;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.qmth.boot.api.annotation.Aac;
  5. import com.qmth.boot.api.annotation.BOOL;
  6. import com.qmth.boot.api.constant.ApiConstant;
  7. import com.qmth.distributed.print.business.bean.dto.*;
  8. import com.qmth.distributed.print.business.bean.params.ClientLoginParam;
  9. import com.qmth.distributed.print.business.service.ClientService;
  10. import com.qmth.teachcloud.common.bean.result.LoginResult;
  11. import com.qmth.teachcloud.common.contant.SystemConstant;
  12. import com.qmth.teachcloud.common.entity.BasicSchool;
  13. import com.qmth.teachcloud.common.entity.SysUser;
  14. import com.qmth.teachcloud.common.enums.AppSourceEnum;
  15. import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
  16. import com.qmth.teachcloud.common.service.CommonCacheService;
  17. import com.qmth.teachcloud.common.service.SysUserService;
  18. import com.qmth.teachcloud.common.service.TeachcloudCommonService;
  19. import com.qmth.teachcloud.common.util.Result;
  20. import com.qmth.teachcloud.common.util.ResultUtil;
  21. import io.swagger.annotations.*;
  22. import org.springframework.validation.BindingResult;
  23. import org.springframework.web.bind.annotation.*;
  24. import javax.annotation.Resource;
  25. import javax.servlet.http.HttpServletResponse;
  26. import javax.validation.Valid;
  27. import java.security.NoSuchAlgorithmException;
  28. import java.util.List;
  29. import java.util.Map;
  30. import java.util.Objects;
  31. /**
  32. * 客户端接口(打印端)
  33. */
  34. @Api(tags = "客户端Controller")
  35. @RestController
  36. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_CLIENT)
  37. //@Validated
  38. public class ClientController {
  39. @Resource
  40. ClientService clientService;
  41. @Resource
  42. SysUserService sysUserService;
  43. @Resource
  44. CommonCacheService commonCacheService;
  45. @Resource
  46. TeachcloudCommonService teachcloudCommonService;
  47. /**
  48. * 登录
  49. *
  50. * @param login 登录参数
  51. */
  52. @ApiOperation(value = "登录")
  53. @PostMapping("/user/login")
  54. @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = LoginResult.class)})
  55. @Aac(auth = BOOL.FALSE)
  56. public Result login(@ApiParam(value = "用户信息", required = true) @Valid @RequestBody ClientLoginParam login, BindingResult bindingResult) throws NoSuchAlgorithmException {
  57. if (bindingResult.hasErrors()) {
  58. return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
  59. }
  60. BasicSchool basicSchool = commonCacheService.schoolCache(login.getSchoolCode());
  61. if (Objects.isNull(basicSchool)) {
  62. throw ExceptionResultEnum.SCHOOL_NO_DATA.exception();
  63. }
  64. QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
  65. wrapper.lambda().eq(SysUser::getSchoolId, basicSchool.getId()).eq(SysUser::getLoginName, login.getLoginName());
  66. SysUser sysUser = sysUserService.getOne(wrapper);
  67. // 用户不存在
  68. if (Objects.isNull(sysUser)) {
  69. throw ExceptionResultEnum.USER_NO_DATA.exception();
  70. }
  71. // 校验密码
  72. if (!Objects.equals(sysUser.getPassword(), login.getPassword())) {
  73. throw ExceptionResultEnum.PASSWORD_ERROR.exception();
  74. }
  75. // 是否有客户端权限
  76. clientService.checkPrivilege(sysUser.getId());
  77. return ResultUtil.ok(teachcloudCommonService.login(login.getPassword(), sysUser, AppSourceEnum.SYSTEM));
  78. }
  79. /**
  80. * 试卷打样-列表
  81. *
  82. * @param machineCode 机器唯一码
  83. * @param orgId 机构ID
  84. * @param printPlanId 印刷计划ID
  85. * @param courseCode 课程代码
  86. * @param paperNumber 试卷编号
  87. * @param isTry 是否打样
  88. * @param isPass 是否合格
  89. * @param pageNumber 分页参数
  90. * @param pageSize 分页参数
  91. */
  92. @ApiOperation(value = "试卷打样-列表")
  93. @PostMapping("/paper_try/list")
  94. public Result paperTryList(@RequestParam("machineCode") String machineCode,
  95. @RequestParam("orgId") Long orgId,
  96. @RequestParam(value = "printPlanId", required = false) Long printPlanId,
  97. @RequestParam(value = "courseCode", required = false) String courseCode,
  98. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  99. @RequestParam(value = "isTry", required = false) Boolean isTry,
  100. @RequestParam(value = "isPass", required = false) Boolean isPass,
  101. @RequestParam Integer pageNumber,
  102. @RequestParam Integer pageSize) {
  103. IPage<ClientExamTaskDto> examTasks = clientService.listTryTask(machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass, pageNumber, pageSize);
  104. return ResultUtil.ok(examTasks);
  105. }
  106. /**
  107. * 试卷打样-查看/试印/重印
  108. *
  109. * @param examTaskId 命题任务ID
  110. */
  111. @ApiOperation(value = "试卷打样-查看/试印/重印")
  112. @PostMapping("/paper_try/print")
  113. public Result paperTryPrint(@RequestParam("printPlanId") Long printPlanId,
  114. @RequestParam("examTaskId") Long examTaskId) {
  115. List<Map<String, String>> list = clientService.getPaperUrl(printPlanId, examTaskId);
  116. return ResultUtil.ok(list);
  117. }
  118. /**
  119. * 试卷打样-批量试印
  120. *
  121. * @param machineCode 机器码
  122. * @param orgId 机构ID
  123. * @param printPlanId 印刷计划ID
  124. * @param courseCode 课程代码
  125. * @param paperNumber 试卷编号
  126. * @param isTry 是否打样
  127. * @param isPass 是否通过
  128. */
  129. @ApiOperation(value = "试卷打样-批量试印")
  130. @PostMapping("/paper_try/print_batch")
  131. public Result printBatch(@RequestParam("machineCode") String machineCode,
  132. @RequestParam("orgId") Long orgId,
  133. @RequestParam(value = "printPlanId", required = false) Long printPlanId,
  134. @RequestParam(value = "courseCode", required = false) String courseCode,
  135. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  136. @RequestParam(value = "isTry", required = false) Boolean isTry,
  137. @RequestParam(value = "isPass", required = false) Boolean isPass) {
  138. List<Map<String, Object>> urls = clientService.getBatchUrl(machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass);
  139. return ResultUtil.ok(urls);
  140. }
  141. /**
  142. * 试卷打样-标记合格状态
  143. *
  144. * @param machineCode 机器码
  145. * @param isPass 是否通过
  146. * @param userId 用户Id
  147. */
  148. @ApiOperation(value = "试卷打样-标记合格状态")
  149. @PostMapping("/paper_try/tag_pass")
  150. public Result paperTryTagPass(@RequestParam("printPlanId") Long printPlanId,
  151. @RequestParam("courseCode") String courseCode,
  152. @RequestParam("courseName") String courseName,
  153. @RequestParam("paperNumber") String paperNumber,
  154. @RequestParam("machineCode") String machineCode,
  155. @RequestParam("isPass") Boolean isPass,
  156. @RequestParam("userId") Long userId) {
  157. Boolean isSuccess = clientService.tagPass(printPlanId, courseCode, courseName, paperNumber, machineCode, isPass, userId);
  158. return ResultUtil.ok(isSuccess);
  159. }
  160. /**
  161. * 印刷管理-查询列表
  162. *
  163. * @param machineCode 机器码
  164. * @param orgId 机构ID
  165. * @param printPlanId 印刷计划ID
  166. * @param status 状态
  167. * @param courseCode 课程代码
  168. * @param paperNumber 试卷编号
  169. * @param examPlace 考点
  170. * @param examRoom 考场
  171. * @param examStartTime 考试时间(开始)
  172. * @param examEndTime 考试时间(结束)
  173. * @param isDownload 是否缓存
  174. * @param validate 是否校验
  175. * @param pageNumber 分页参数
  176. * @param pageSize 分页参数
  177. */
  178. @ApiOperation(value = "印刷管理-查询列表")
  179. @PostMapping("/print/task_list")
  180. public Result printTaskList(@RequestParam("machineCode") String machineCode,
  181. @RequestParam("orgId") Long orgId,
  182. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  183. @RequestParam(value = "status", required = false) String status,
  184. @RequestParam(value = "courseCode", required = false) String courseCode,
  185. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  186. @RequestParam(value = "examPlace", required = false) String examPlace,
  187. @RequestParam(value = "examRoom", required = false) String examRoom,
  188. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  189. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  190. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  191. @RequestParam(value = "validate", required = false) Boolean validate,
  192. @RequestParam Integer pageNumber,
  193. @RequestParam Integer pageSize) {
  194. IPage<ClientPrintTaskDto> printTaskDtoIPage = clientService.listClientPrintTask(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, pageNumber, pageSize);
  195. return ResultUtil.ok(printTaskDtoIPage);
  196. }
  197. /**
  198. * 印刷管理-导出
  199. *
  200. * @param response response
  201. * @param machineCode 机器码
  202. * @param orgId 机构ID
  203. * @param printPlanId 印刷计划ID
  204. * @param status 状态
  205. * @param courseCode 课程代码
  206. * @param paperNumber 试卷编号
  207. * @param examPlace 考点
  208. * @param examRoom 考场
  209. * @param examStartTime 考试时间(开始)
  210. * @param examEndTime 考试时间(结束)
  211. * @param isDownload 是否缓存
  212. * @param validate 是否核验
  213. */
  214. @ApiOperation(value = "印刷管理-导出")
  215. @PostMapping("/print/task_list_export")
  216. public void printTaskListExport(HttpServletResponse response,
  217. @RequestParam("machineCode") String machineCode,
  218. @RequestParam("orgId") Long orgId,
  219. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  220. @RequestParam(value = "status", required = false) String status,
  221. @RequestParam(value = "courseCode", required = false) String courseCode,
  222. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  223. @RequestParam(value = "examPlace", required = false) String examPlace,
  224. @RequestParam(value = "examRoom", required = false) String examRoom,
  225. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  226. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  227. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  228. @RequestParam(value = "validate", required = false) Boolean validate) throws Exception {
  229. clientService.exportClientPrintTask(response, machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
  230. }
  231. /**
  232. * 印刷管理-汇总数据查询
  233. *
  234. * @param machineCode 机器码
  235. * @param orgId 机构ID
  236. * @param printPlanId 印刷计划ID
  237. * @param status 状态
  238. * @param courseCode 课程代码
  239. * @param paperNumber 试卷编号
  240. * @param examPlace 考点
  241. * @param examRoom 考场
  242. * @param examStartTime 考试时间(开始)
  243. * @param examEndTime 考试时间(结束)
  244. * @param isDownload 是否缓存
  245. * @param validate 是否校验
  246. */
  247. @ApiOperation(value = "印刷管理-汇总数据查询")
  248. @PostMapping("/print/task_total_data")
  249. public Result printTaskTotalData(@RequestParam("machineCode") String machineCode,
  250. @RequestParam("orgId") Long orgId,
  251. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  252. @RequestParam(value = "status", required = false) String status,
  253. @RequestParam(value = "courseCode", required = false) String courseCode,
  254. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  255. @RequestParam(value = "examPlace", required = false) String examPlace,
  256. @RequestParam(value = "examRoom", required = false) String examRoom,
  257. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  258. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  259. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  260. @RequestParam(value = "validate", required = false) Boolean validate) {
  261. ClientPrintTaskTotalDto clientPrintTaskTotalDto = clientService.taskTotalData(printPlanId, orgId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, machineCode);
  262. return ResultUtil.ok(clientPrintTaskTotalDto);
  263. }
  264. /**
  265. * 印刷管理-查看
  266. *
  267. * @param examDetailId 命题任务ID
  268. */
  269. @ApiOperation(value = "印刷管理-查看")
  270. @PostMapping("/print/preview")
  271. public Result printPreview(@RequestParam("examDetailId") Long examDetailId) {
  272. Map<String, Object> map = clientService.getUrlByExamDetailId(examDetailId);
  273. return ResultUtil.ok(map);
  274. }
  275. /**
  276. * 印刷管理-印刷/缓存数据
  277. *
  278. * @param examDetailId 考场ID
  279. * @param machineCode 机器码
  280. * @param printUser 打印员
  281. */
  282. @ApiOperation(value = "印刷管理-印刷/缓存数据")
  283. @PostMapping("/print/get_print_data")
  284. public Result printGetPrintData(@RequestParam("examDetailId") Long examDetailId,
  285. @RequestParam("machineCode") String machineCode,
  286. @RequestParam("isPrint") Boolean isPrint,
  287. @RequestParam(value = "printUser", required = false) String printUser) {
  288. Map<String, Object> map = clientService.getPrintData(examDetailId, machineCode, isPrint, printUser);
  289. return ResultUtil.ok(map);
  290. }
  291. /**
  292. * 印刷管理-批量缓存数据
  293. *
  294. * @param orgId 机构ID
  295. * @param machineCode 机器码
  296. */
  297. @ApiOperation(value = "印刷管理-批量缓存数据")
  298. @PostMapping("/print/get_print_data_batch")
  299. public Result printGetPrintDataBatch(@RequestParam("machineCode") String machineCode,
  300. @RequestParam("orgId") Long orgId,
  301. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  302. @RequestParam(value = "status", required = false) String status,
  303. @RequestParam(value = "courseCode", required = false) String courseCode,
  304. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  305. @RequestParam(value = "examPlace", required = false) String examPlace,
  306. @RequestParam(value = "examRoom", required = false) String examRoom,
  307. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  308. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  309. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  310. @RequestParam(value = "validate", required = false) Boolean validate) {
  311. List<Map<String, Object>> list = clientService.getPrintDataBatch(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
  312. return ResultUtil.ok(list);
  313. }
  314. /**
  315. * @param examDetailId 考场ID
  316. * @param machineCode 机器码
  317. * @param isDownload 是否缓存
  318. */
  319. @ApiOperation(value = "印刷管理-缓存后更新状态")
  320. @PostMapping("/print/update_download")
  321. public Result updateDownload(@RequestParam("examDetailId") Long examDetailId,
  322. @RequestParam("machineCode") String machineCode,
  323. @RequestParam("isDownload") Boolean isDownload) {
  324. Boolean isSuccess = clientService.updateDownload(examDetailId, machineCode, isDownload);
  325. return ResultUtil.ok(isSuccess);
  326. }
  327. /**
  328. * 印刷管理-校验
  329. *
  330. * @param examDetailId 考场ID
  331. * @param packageCode 机器码
  332. * @param lastCode 校验条码号
  333. */
  334. @ApiOperation(value = "印刷管理-校验")
  335. @PostMapping("/print/validate_data")
  336. public Result dataCheck(@RequestParam("examDetailId") Long examDetailId,
  337. @RequestParam("packageCode") String packageCode,
  338. @RequestParam("lastCode") String lastCode) {
  339. Boolean isSuccess = clientService.validateData(examDetailId, packageCode, lastCode);
  340. return ResultUtil.ok(isSuccess);
  341. }
  342. /**
  343. * 印刷管理-更新打印进度
  344. *
  345. * @param examDetailId 考场ID
  346. * @param machineCode 机器码
  347. * @param printProgress 打印进度
  348. */
  349. @ApiOperation(value = "印刷管理-更新打印进度")
  350. @PostMapping("/print/update_progress")
  351. public Result updateProgress(@RequestParam("examDetailId") Long examDetailId,
  352. @RequestParam("machineCode") String machineCode,
  353. @RequestParam("printProgress") Integer printProgress,
  354. @RequestParam(value = "isPrint", required = false) Boolean isPrint) {
  355. Boolean isSuccess = clientService.updatePrintProgress(examDetailId, machineCode, printProgress, isPrint);
  356. return ResultUtil.ok(isSuccess);
  357. }
  358. /**
  359. * 重打-查询考生列表
  360. *
  361. * @param examDetailId 考场ID
  362. * @param ticketNumber 准考证号
  363. * @param studentName 学号
  364. * @param courseCode 课程代码
  365. */
  366. @ApiOperation(value = "重打-查询考生列表")
  367. @PostMapping("/print/list_student")
  368. public Result listStudent(@RequestParam("examDetailId") Long examDetailId,
  369. @RequestParam(value = "ticketNumber", required = false) String ticketNumber,
  370. @RequestParam(value = "studentName", required = false) String studentName,
  371. @RequestParam(value = "courseCode", required = false) String courseCode,
  372. @RequestParam Integer pageNumber,
  373. @RequestParam Integer pageSize) {
  374. IPage<ClientExamStudentDto> examStudentDtoIPage = clientService.listStudent(examDetailId, ticketNumber, studentName, courseCode, pageNumber, pageSize);
  375. return ResultUtil.ok(examStudentDtoIPage);
  376. }
  377. /**
  378. * 重打-内容查询
  379. *
  380. * @param examDetailId 考场ID
  381. * @param ticketNumber 准考证号
  382. * @param type 类型
  383. */
  384. @ApiOperation(value = "重打-内容查询")
  385. @PostMapping("/print/get_reprint_data")
  386. public Result getReprintData(@RequestParam("examDetailId") Long examDetailId,
  387. @RequestParam("ticketNumber") String ticketNumber,
  388. @RequestParam("type") String type) {
  389. Map<String, Object> map = clientService.getReprintData(examDetailId, ticketNumber, type);
  390. return ResultUtil.ok(map);
  391. }
  392. /**
  393. * 统计查询-查询列表
  394. *
  395. * @param orgId 机构ID
  396. * @param printPlanId 印刷计划ID
  397. * @param examPlace 考点
  398. * @param examStartTime 考试时间(开始)
  399. * @param examEndTime 考试时间(结束)
  400. * @param courseCode 课程代码
  401. * @param paperNumber 试卷编号
  402. * @param pageNumber 分页参数
  403. * @param pageSize 分页参数
  404. */
  405. @ApiOperation(value = "统计查询-查询列表")
  406. @PostMapping("/print/statistics_list")
  407. public Result printStatisticsList(@RequestParam("orgId") Long orgId,
  408. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  409. @RequestParam(value = "examPlace", required = false) String examPlace,
  410. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  411. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  412. @RequestParam(value = "courseCode", required = false) String courseCode,
  413. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  414. @RequestParam Integer pageNumber,
  415. @RequestParam Integer pageSize) {
  416. IPage<ClientPrintStatisticsDto> statisticsDtoIPage = clientService.listClientPrintStatistics(orgId, printPlanId, examPlace, examStartTime, examEndTime, courseCode, paperNumber, pageNumber, pageSize);
  417. return ResultUtil.ok(statisticsDtoIPage);
  418. }
  419. /**
  420. * 统计查询-汇总数据查询
  421. *
  422. * @param orgId 机构ID
  423. * @param printPlanId 印刷计划Id
  424. * @param examPlace 考点
  425. * @param examStartTime 考试时间(开始)
  426. * @param examEndTime 考试时间(结束)
  427. * @param courseCode 课程代码
  428. * @param paperNumber 试卷编号
  429. */
  430. @ApiOperation(value = "统计查询-汇总数据查询")
  431. @PostMapping("/print/statistics_total_data")
  432. public Result printStatisticsTotalData(@RequestParam("orgId") Long orgId,
  433. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  434. @RequestParam(value = "examPlace", required = false) String examPlace,
  435. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  436. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  437. @RequestParam(value = "courseCode", required = false) String courseCode,
  438. @RequestParam(value = "paperNumber", required = false) String paperNumber) {
  439. ClientPrintStatisticsTotalDto statisticsTotalDto = clientService.clientStatisticsTotalData(orgId, printPlanId, examPlace, examStartTime, examEndTime, courseCode, paperNumber);
  440. return ResultUtil.ok(statisticsTotalDto);
  441. }
  442. }