ClientController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. package com.qmth.distributed.print.api;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.qmth.boot.api.annotation.Aac;
  6. import com.qmth.boot.api.annotation.BOOL;
  7. import com.qmth.boot.api.constant.ApiConstant;
  8. import com.qmth.distributed.print.business.bean.dto.*;
  9. import com.qmth.distributed.print.business.bean.params.ClientLoginParam;
  10. import com.qmth.distributed.print.business.service.ClientService;
  11. import com.qmth.teachcloud.common.bean.result.LoginResult;
  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 + "/${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. clientService.checkPrivilege(sysUser.getId());
  73. return ResultUtil.ok(teachcloudCommonService.login(login.getPassword(), sysUser, AppSourceEnum.SYSTEM));
  74. }
  75. /**
  76. * 试卷打样-列表
  77. *
  78. * @param machineCode 机器唯一码
  79. * @param orgId 机构ID
  80. * @param printPlanId 印刷计划ID
  81. * @param courseCode 课程代码
  82. * @param paperNumber 试卷编号
  83. * @param isTry 是否打样
  84. * @param isPass 是否合格
  85. * @param pageNumber 分页参数
  86. * @param pageSize 分页参数
  87. */
  88. @ApiOperation(value = "试卷打样-列表")
  89. @PostMapping("/paper_try/list")
  90. public Result paperTryList(@RequestParam("machineCode") String machineCode,
  91. @RequestParam("orgId") Long orgId,
  92. @RequestParam(value = "printPlanId", required = false) Long printPlanId,
  93. @RequestParam(value = "courseCode", required = false) String courseCode,
  94. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  95. @RequestParam(value = "isTry", required = false) Boolean isTry,
  96. @RequestParam(value = "isPass", required = false) Boolean isPass,
  97. @RequestParam Integer pageNumber,
  98. @RequestParam Integer pageSize) {
  99. IPage<ClientExamTaskDto> examTasks = clientService.listTryTask(machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass, pageNumber, pageSize);
  100. return ResultUtil.ok(examTasks);
  101. }
  102. /**
  103. * 试卷打样-查看/试印/重印
  104. *
  105. * @param examTaskId 命题任务ID
  106. */
  107. @ApiOperation(value = "试卷打样-查看/试印/重印")
  108. @PostMapping("/paper_try/print")
  109. public Result paperTryPrint(@RequestParam("printPlanId") Long printPlanId,
  110. @RequestParam("examTaskId") Long examTaskId) {
  111. List<Map<String, String>> list = clientService.getPaperUrl(printPlanId, examTaskId);
  112. return ResultUtil.ok(list);
  113. }
  114. /**
  115. * 试卷打样-批量试印
  116. *
  117. * @param machineCode 机器码
  118. * @param orgId 机构ID
  119. * @param printPlanId 印刷计划ID
  120. * @param courseCode 课程代码
  121. * @param paperNumber 试卷编号
  122. * @param isTry 是否打样
  123. * @param isPass 是否通过
  124. */
  125. @ApiOperation(value = "试卷打样-批量试印")
  126. @PostMapping("/paper_try/print_batch")
  127. public Result printBatch(@RequestParam("machineCode") String machineCode,
  128. @RequestParam("orgId") Long orgId,
  129. @RequestParam(value = "printPlanId", required = false) Long printPlanId,
  130. @RequestParam(value = "courseCode", required = false) String courseCode,
  131. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  132. @RequestParam(value = "isTry", required = false) Boolean isTry,
  133. @RequestParam(value = "isPass", required = false) Boolean isPass) {
  134. List<Map<String, Object>> urls = clientService.getBatchUrl(machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass);
  135. return ResultUtil.ok(urls);
  136. }
  137. /**
  138. * 试卷打样-标记合格状态
  139. *
  140. * @param machineCode 机器码
  141. * @param isPass 是否通过
  142. * @param userId 用户Id
  143. */
  144. @ApiOperation(value = "试卷打样-标记合格状态")
  145. @PostMapping("/paper_try/tag_pass")
  146. public Result paperTryTagPass(@RequestParam("printPlanId") Long printPlanId,
  147. @RequestParam("courseCode") String courseCode,
  148. @RequestParam("courseName") String courseName,
  149. @RequestParam("paperNumber") String paperNumber,
  150. @RequestParam("machineCode") String machineCode,
  151. @RequestParam("isPass") Boolean isPass,
  152. @RequestParam("userId") Long userId) {
  153. Boolean isSuccess = clientService.tagPass(printPlanId, courseCode, courseName, paperNumber, machineCode, isPass, userId);
  154. return ResultUtil.ok(isSuccess);
  155. }
  156. /**
  157. * 印刷管理-查询列表
  158. *
  159. * @param machineCode 机器码
  160. * @param orgId 机构ID
  161. * @param printPlanId 印刷计划ID
  162. * @param status 状态
  163. * @param courseCode 课程代码
  164. * @param paperNumber 试卷编号
  165. * @param examPlace 考点
  166. * @param examRoom 考场
  167. * @param examStartTime 考试时间(开始)
  168. * @param examEndTime 考试时间(结束)
  169. * @param isDownload 是否缓存
  170. * @param validate 是否校验
  171. * @param pageNumber 分页参数
  172. * @param pageSize 分页参数
  173. */
  174. @ApiOperation(value = "印刷管理-查询列表")
  175. @PostMapping("/print/task_list")
  176. public Result printTaskList(@RequestParam("machineCode") String machineCode,
  177. @RequestParam("orgId") Long orgId,
  178. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  179. @RequestParam(value = "status", required = false) String status,
  180. @RequestParam(value = "courseCode", required = false) String courseCode,
  181. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  182. @RequestParam(value = "examPlace", required = false) String examPlace,
  183. @RequestParam(value = "examRoom", required = false) String examRoom,
  184. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  185. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  186. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  187. @RequestParam(value = "validate", required = false) Boolean validate,
  188. @RequestParam Integer pageNumber,
  189. @RequestParam Integer pageSize) {
  190. IPage<ClientPrintTaskDto> printTaskDtoIPage = clientService.listClientPrintTask(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, pageNumber, pageSize);
  191. return ResultUtil.ok(printTaskDtoIPage);
  192. }
  193. /**
  194. * 印刷管理-导出
  195. *
  196. * @param response response
  197. * @param machineCode 机器码
  198. * @param orgId 机构ID
  199. * @param printPlanId 印刷计划ID
  200. * @param status 状态
  201. * @param courseCode 课程代码
  202. * @param paperNumber 试卷编号
  203. * @param examPlace 考点
  204. * @param examRoom 考场
  205. * @param examStartTime 考试时间(开始)
  206. * @param examEndTime 考试时间(结束)
  207. * @param isDownload 是否缓存
  208. * @param validate 是否核验
  209. */
  210. @ApiOperation(value = "印刷管理-导出")
  211. @PostMapping("/print/task_list_export")
  212. public void printTaskListExport(HttpServletResponse response,
  213. @RequestParam("machineCode") String machineCode,
  214. @RequestParam("orgId") Long orgId,
  215. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  216. @RequestParam(value = "status", required = false) String status,
  217. @RequestParam(value = "courseCode", required = false) String courseCode,
  218. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  219. @RequestParam(value = "examPlace", required = false) String examPlace,
  220. @RequestParam(value = "examRoom", required = false) String examRoom,
  221. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  222. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  223. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  224. @RequestParam(value = "validate", required = false) Boolean validate) throws Exception {
  225. clientService.exportClientPrintTask(response, machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
  226. }
  227. /**
  228. * 印刷管理-汇总数据查询
  229. *
  230. * @param machineCode 机器码
  231. * @param orgId 机构ID
  232. * @param printPlanId 印刷计划ID
  233. * @param status 状态
  234. * @param courseCode 课程代码
  235. * @param paperNumber 试卷编号
  236. * @param examPlace 考点
  237. * @param examRoom 考场
  238. * @param examStartTime 考试时间(开始)
  239. * @param examEndTime 考试时间(结束)
  240. * @param isDownload 是否缓存
  241. * @param validate 是否校验
  242. */
  243. @ApiOperation(value = "印刷管理-汇总数据查询")
  244. @PostMapping("/print/task_total_data")
  245. public Result printTaskTotalData(@RequestParam("machineCode") String machineCode,
  246. @RequestParam("orgId") Long orgId,
  247. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  248. @RequestParam(value = "status", required = false) String status,
  249. @RequestParam(value = "courseCode", required = false) String courseCode,
  250. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  251. @RequestParam(value = "examPlace", required = false) String examPlace,
  252. @RequestParam(value = "examRoom", required = false) String examRoom,
  253. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  254. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  255. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  256. @RequestParam(value = "validate", required = false) Boolean validate) {
  257. ClientPrintTaskTotalDto clientPrintTaskTotalDto = clientService.taskTotalData(printPlanId, orgId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, machineCode);
  258. return ResultUtil.ok(clientPrintTaskTotalDto);
  259. }
  260. /**
  261. * 印刷管理-查看
  262. *
  263. * @param examDetailId 命题任务ID
  264. */
  265. @ApiOperation(value = "印刷管理-查看")
  266. @PostMapping("/print/preview")
  267. public Result printPreview(@RequestParam("examDetailId") Long examDetailId) {
  268. Map<String, Object> map = clientService.getUrlByExamDetailId(examDetailId);
  269. return ResultUtil.ok(map);
  270. }
  271. /**
  272. * 印刷管理-印刷/缓存数据
  273. *
  274. * @param examDetailId 考场ID
  275. * @param machineCode 机器码
  276. * @param printUser 打印员
  277. */
  278. @ApiOperation(value = "印刷管理-印刷/缓存数据")
  279. @PostMapping("/print/get_print_data")
  280. public Result printGetPrintData(@RequestParam("examDetailId") Long examDetailId,
  281. @RequestParam("machineCode") String machineCode,
  282. @RequestParam("isPrint") Boolean isPrint,
  283. @RequestParam(value = "printUser", required = false) String printUser) {
  284. Map<String, Object> map = clientService.getPrintData(examDetailId, machineCode, isPrint, printUser);
  285. return ResultUtil.ok(map);
  286. }
  287. /**
  288. * 印刷管理-批量缓存数据
  289. *
  290. * @param orgId 机构ID
  291. * @param machineCode 机器码
  292. */
  293. @ApiOperation(value = "印刷管理-批量缓存数据")
  294. @PostMapping("/print/get_print_data_batch")
  295. public Result printGetPrintDataBatch(@RequestParam("machineCode") String machineCode,
  296. @RequestParam("orgId") Long orgId,
  297. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  298. @RequestParam(value = "status", required = false) String status,
  299. @RequestParam(value = "courseCode", required = false) String courseCode,
  300. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  301. @RequestParam(value = "examPlace", required = false) String examPlace,
  302. @RequestParam(value = "examRoom", required = false) String examRoom,
  303. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  304. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  305. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  306. @RequestParam(value = "validate", required = false) Boolean validate) {
  307. List<Map<String, Object>> list = clientService.getPrintDataBatch(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
  308. return ResultUtil.ok(list);
  309. }
  310. /**
  311. * @param examDetailId 考场ID
  312. * @param machineCode 机器码
  313. * @param isDownload 是否缓存
  314. */
  315. @ApiOperation(value = "印刷管理-缓存后更新状态")
  316. @PostMapping("/print/update_download")
  317. public Result updateDownload(@RequestParam("examDetailId") Long examDetailId,
  318. @RequestParam("machineCode") String machineCode,
  319. @RequestParam("isDownload") Boolean isDownload) {
  320. Boolean isSuccess = clientService.updateDownload(examDetailId, machineCode, isDownload);
  321. return ResultUtil.ok(isSuccess);
  322. }
  323. /**
  324. * 印刷管理-校验
  325. *
  326. * @param examDetailId 考场ID
  327. * @param packageCode 机器码
  328. * @param lastCode 校验条码号
  329. */
  330. @ApiOperation(value = "印刷管理-校验")
  331. @PostMapping("/print/validate_data")
  332. public Result dataCheck(@RequestParam("examDetailId") Long examDetailId,
  333. @RequestParam("packageCode") String packageCode,
  334. @RequestParam("lastCode") String lastCode) {
  335. Boolean isSuccess = clientService.validateData(examDetailId, packageCode, lastCode);
  336. return ResultUtil.ok(isSuccess);
  337. }
  338. /**
  339. * 印刷管理-更新打印进度
  340. *
  341. * @param examDetailId 考场ID
  342. * @param machineCode 机器码
  343. * @param printProgress 打印进度
  344. */
  345. @ApiOperation(value = "印刷管理-更新打印进度")
  346. @PostMapping("/print/update_progress")
  347. public Result updateProgress(@RequestParam("examDetailId") Long examDetailId,
  348. @RequestParam("machineCode") String machineCode,
  349. @RequestParam("printProgress") Integer printProgress,
  350. @RequestParam(value = "isPrint", required = false) Boolean isPrint) {
  351. Boolean isSuccess = clientService.updatePrintProgress(examDetailId, machineCode, printProgress, isPrint);
  352. return ResultUtil.ok(isSuccess);
  353. }
  354. /**
  355. * 重打-查询考生列表
  356. *
  357. * @param examDetailId 考场ID
  358. * @param ticketNumber 准考证号
  359. * @param studentName 学号
  360. * @param courseCode 课程代码
  361. */
  362. @ApiOperation(value = "重打-查询考生列表")
  363. @PostMapping("/print/list_student")
  364. public Result listStudent(@RequestParam("examDetailId") Long examDetailId,
  365. @RequestParam(value = "ticketNumber", required = false) String ticketNumber,
  366. @RequestParam(value = "studentName", required = false) String studentName,
  367. @RequestParam(value = "courseCode", required = false) String courseCode,
  368. @RequestParam Integer pageNumber,
  369. @RequestParam Integer pageSize) {
  370. IPage<ClientExamStudentDto> examStudentDtoIPage = clientService.listStudent(examDetailId, ticketNumber, studentName, courseCode, pageNumber, pageSize);
  371. return ResultUtil.ok(examStudentDtoIPage);
  372. }
  373. /**
  374. * 重打-内容查询
  375. *
  376. * @param examDetailId 考场ID
  377. * @param ticketNumber 准考证号
  378. * @param type 类型
  379. */
  380. @ApiOperation(value = "重打-内容查询")
  381. @PostMapping("/print/get_reprint_data")
  382. public Result getReprintData(@RequestParam("examDetailId") Long examDetailId,
  383. @RequestParam("ticketNumber") String ticketNumber,
  384. @RequestParam("type") String type) {
  385. Map<String, Object> map = clientService.getReprintData(examDetailId, ticketNumber, type);
  386. return ResultUtil.ok(map);
  387. }
  388. /**
  389. * 统计查询-查询列表
  390. *
  391. * @param orgId 机构ID
  392. * @param printPlanId 印刷计划ID
  393. * @param examPlace 考点
  394. * @param examStartTime 考试时间(开始)
  395. * @param examEndTime 考试时间(结束)
  396. * @param courseCode 课程代码
  397. * @param paperNumber 试卷编号
  398. * @param pageNumber 分页参数
  399. * @param pageSize 分页参数
  400. */
  401. @ApiOperation(value = "统计查询-查询列表")
  402. @PostMapping("/print/statistics_list")
  403. public Result printStatisticsList(@RequestParam("orgId") Long orgId,
  404. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  405. @RequestParam(value = "examPlace", required = false) String examPlace,
  406. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  407. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  408. @RequestParam(value = "courseCode", required = false) String courseCode,
  409. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  410. @RequestParam Integer pageNumber,
  411. @RequestParam Integer pageSize) {
  412. IPage<ClientPrintStatisticsDto> statisticsDtoIPage = clientService.listClientPrintStatistics(orgId, printPlanId, examPlace, examStartTime, examEndTime, courseCode, paperNumber, pageNumber, pageSize);
  413. return ResultUtil.ok(statisticsDtoIPage);
  414. }
  415. /**
  416. * 统计查询-汇总数据查询
  417. *
  418. * @param orgId 机构ID
  419. * @param printPlanId 印刷计划Id
  420. * @param examPlace 考点
  421. * @param examStartTime 考试时间(开始)
  422. * @param examEndTime 考试时间(结束)
  423. * @param courseCode 课程代码
  424. * @param paperNumber 试卷编号
  425. */
  426. @ApiOperation(value = "统计查询-汇总数据查询")
  427. @PostMapping("/print/statistics_total_data")
  428. public Result printStatisticsTotalData(@RequestParam("orgId") Long orgId,
  429. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  430. @RequestParam(value = "examPlace", required = false) String examPlace,
  431. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  432. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  433. @RequestParam(value = "courseCode", required = false) String courseCode,
  434. @RequestParam(value = "paperNumber", required = false) String paperNumber) {
  435. ClientPrintStatisticsTotalDto statisticsTotalDto = clientService.clientStatisticsTotalData(orgId, printPlanId, examPlace, examStartTime, examEndTime, courseCode, paperNumber);
  436. return ResultUtil.ok(statisticsTotalDto);
  437. }
  438. }