ClientController.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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.auth.AuthBean;
  8. import com.qmth.distributed.print.business.bean.dto.ClientExamStudentDto;
  9. import com.qmth.distributed.print.business.bean.dto.ClientExamTaskDto;
  10. import com.qmth.distributed.print.business.bean.dto.ClientPrintTaskDto;
  11. import com.qmth.distributed.print.business.bean.dto.ClientPrintTaskTotalDto;
  12. import com.qmth.distributed.print.business.bean.params.ClientLoginParam;
  13. import com.qmth.distributed.print.business.bean.result.LoginResult;
  14. import com.qmth.distributed.print.business.entity.SysUser;
  15. import com.qmth.distributed.print.business.enums.RoleTypeEnum;
  16. import com.qmth.distributed.print.business.service.ClientService;
  17. import com.qmth.distributed.print.business.service.CommonService;
  18. import com.qmth.distributed.print.business.service.SysUserService;
  19. import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
  20. import com.qmth.distributed.print.common.util.Result;
  21. import com.qmth.distributed.print.common.util.ResultUtil;
  22. import io.swagger.annotations.*;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.validation.BindingResult;
  25. import org.springframework.web.bind.annotation.*;
  26. import javax.annotation.Resource;
  27. import javax.servlet.http.HttpServletResponse;
  28. import javax.validation.Valid;
  29. import java.security.NoSuchAlgorithmException;
  30. import java.util.List;
  31. import java.util.Map;
  32. import java.util.Objects;
  33. import java.util.Set;
  34. import java.util.stream.Collectors;
  35. /**
  36. * @Date: 2021/4/19.
  37. */
  38. @Api(tags = "客户端Controller")
  39. @RestController
  40. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.client}")
  41. public class ClientController {
  42. @Autowired
  43. private ClientService clientService;
  44. @Resource
  45. SysUserService sysUserService;
  46. @Resource
  47. CommonService commonService;
  48. /**
  49. * 登录
  50. *
  51. * @param login
  52. * @return
  53. */
  54. @ApiOperation(value = "登录")
  55. @RequestMapping(value = "/user/login", method = RequestMethod.POST)
  56. @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = LoginResult.class)})
  57. @Aac(auth = BOOL.FALSE)
  58. public Result login(@ApiParam(value = "用户信息", required = true) @Valid @RequestBody ClientLoginParam login, BindingResult bindingResult) throws NoSuchAlgorithmException {
  59. if (bindingResult.hasErrors()) {
  60. return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
  61. }
  62. QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
  63. wrapper.lambda().eq(SysUser::getLoginName, login.getLoginName());
  64. SysUser sysUser = sysUserService.getOne(wrapper);
  65. //用户不存在
  66. if (Objects.isNull(sysUser)) {
  67. throw ExceptionResultEnum.USER_NO_DATA.exception();
  68. }
  69. AuthBean authBean = commonService.getUserAuth(sysUser.getId());
  70. if (Objects.nonNull(authBean) && Objects.nonNull(authBean.getRoleList()) && authBean.getRoleList().size() > 0) {
  71. Set<RoleTypeEnum> roleType = authBean.getRoleList().stream().map(s -> s.getType()).collect(Collectors.toSet());
  72. if (!roleType.contains(RoleTypeEnum.PRINTER)) {
  73. throw ExceptionResultEnum.ERROR.exception("客户端只允许" + RoleTypeEnum.PRINTER.getDesc() + "登录");
  74. }
  75. }
  76. return ResultUtil.ok(commonService.login(login.getPassword(), sysUser));
  77. }
  78. /**
  79. * 试卷打样-列表
  80. *
  81. * @param machineCode 机器唯一码
  82. * @param orgId 机构ID
  83. * @param printPlanId 印刷计划ID
  84. * @param courseCode 课程代码
  85. * @param paperNumber 试卷编号
  86. * @param isTry 是否打样
  87. * @param isPass 是否合格
  88. * @param pageNumber
  89. * @param pageSize
  90. * @return
  91. */
  92. @ApiOperation(value = "试卷打样-列表")
  93. @RequestMapping(value = "/paper_try/list", method = RequestMethod.POST)
  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("pageNumber") Integer pageNumber,
  102. @RequestParam("pageSize") 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
  110. * @return
  111. */
  112. @ApiOperation(value = "试卷打样-查看/试印/重印")
  113. @RequestMapping(value = "/paper_try/print", method = RequestMethod.POST)
  114. public Result paperTryPrint(@RequestParam("examTaskId") Long examTaskId) {
  115. Map<String, String> map = clientService.getUrl(examTaskId);
  116. return ResultUtil.ok(map);
  117. }
  118. /**
  119. * 试卷打样-批量试印
  120. *
  121. * @param machineCode
  122. * @param orgId
  123. * @param printPlanId
  124. * @param courseCode
  125. * @param paperNumber
  126. * @param isTry
  127. * @param isPass
  128. * @return
  129. */
  130. @ApiOperation(value = "试卷打样-批量试印")
  131. @RequestMapping(value = "/paper_try/print_batch", method = RequestMethod.POST)
  132. public Result printBatch(@RequestParam("machineCode") String machineCode,
  133. @RequestParam("orgId") Long orgId,
  134. @RequestParam(value = "printPlanId", required = false) Long printPlanId,
  135. @RequestParam(value = "courseCode", required = false) String courseCode,
  136. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  137. @RequestParam(value = "isTry", required = false) Boolean isTry,
  138. @RequestParam(value = "isPass", required = false) Boolean isPass) {
  139. List<Map<String, String>> urls = clientService.getBatchUrl(machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass);
  140. return ResultUtil.ok(urls);
  141. }
  142. /**
  143. * 试卷打样-标记合格状态
  144. *
  145. * @param machineCode
  146. * @param isPass
  147. * @param userId
  148. * @return
  149. */
  150. @ApiOperation(value = "试卷打样-标记合格状态")
  151. @RequestMapping(value = "/paper_try/tag_pass", method = RequestMethod.POST)
  152. public Result paperTryTagPass(@RequestParam("courseCode") String courseCode,
  153. @RequestParam("courseName") String courseName,
  154. @RequestParam("paperNumber") String paperNumber,
  155. @RequestParam("machineCode") String machineCode,
  156. @RequestParam("isPass") Boolean isPass,
  157. @RequestParam("userId") Long userId) {
  158. Boolean isSuccess = clientService.tagPass(courseCode, courseName, paperNumber, machineCode, isPass, userId);
  159. return ResultUtil.ok(isSuccess);
  160. }
  161. /**
  162. * 印刷管理-查询列表
  163. *
  164. * @param machineCode
  165. * @param orgId
  166. * @param printPlanId
  167. * @param status
  168. * @param courseCode
  169. * @param paperNumber
  170. * @param examPlace
  171. * @param examRoom
  172. * @param examStartTime
  173. * @param examEndTime
  174. * @param isDownload
  175. * @param validate
  176. * @param pageNumber
  177. * @param pageSize
  178. * @return
  179. */
  180. @ApiOperation(value = "印刷管理-查询列表")
  181. @RequestMapping(value = "/print/task_list", method = RequestMethod.POST)
  182. public Result printTaskList(@RequestParam("machineCode") Long machineCode,
  183. @RequestParam("orgId") String orgId,
  184. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  185. @RequestParam(value = "status", required = false) String status,
  186. @RequestParam(value = "courseCode", required = false) String courseCode,
  187. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  188. @RequestParam(value = "examPlace", required = false) String examPlace,
  189. @RequestParam(value = "examRoom", required = false) String examRoom,
  190. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  191. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  192. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  193. @RequestParam(value = "validate", required = false) Boolean validate,
  194. @RequestParam("pageNumber") Integer pageNumber,
  195. @RequestParam("pageSize") Integer pageSize) {
  196. IPage<ClientPrintTaskDto> printTaskDtoIPage = clientService.listClientPrintTask(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, pageNumber, pageSize);
  197. return ResultUtil.ok(printTaskDtoIPage);
  198. }
  199. /**
  200. * 印刷管理-导出
  201. *
  202. * @param response
  203. * @param machineCode
  204. * @param orgId
  205. * @param printPlanId
  206. * @param status
  207. * @param courseCode
  208. * @param paperNumber
  209. * @param examPlace
  210. * @param examRoom
  211. * @param examStartTime
  212. * @param examEndTime
  213. * @param isDownload
  214. * @param validate
  215. * @return
  216. */
  217. @ApiOperation(value = "印刷管理-导出")
  218. @RequestMapping(value = "/print/task_list_export", method = RequestMethod.POST)
  219. public void printTaskListExport(HttpServletResponse response,
  220. @RequestParam("machineCode") Long machineCode,
  221. @RequestParam("orgId") String orgId,
  222. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  223. @RequestParam(value = "status", required = false) String status,
  224. @RequestParam(value = "courseCode", required = false) String courseCode,
  225. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  226. @RequestParam(value = "examPlace", required = false) String examPlace,
  227. @RequestParam(value = "examRoom", required = false) String examRoom,
  228. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  229. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  230. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  231. @RequestParam(value = "validate", required = false) Boolean validate) throws Exception {
  232. clientService.exportClientPrintTask(response, machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
  233. }
  234. /**
  235. * 印刷管理-汇总数据查询
  236. *
  237. * @param machineCode
  238. * @param orgId
  239. * @param printPlanId
  240. * @param status
  241. * @param courseCode
  242. * @param paperNumber
  243. * @param examPlace
  244. * @param examRoom
  245. * @param examStartTime
  246. * @param examEndTime
  247. * @param isDownload
  248. * @param validate
  249. * @return
  250. */
  251. @ApiOperation(value = "印刷管理-汇总数据查询")
  252. @RequestMapping(value = "/print/task_total_data", method = RequestMethod.POST)
  253. public Result printTaskTotalData(@RequestParam("machineCode") Long machineCode,
  254. @RequestParam("orgId") String orgId,
  255. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  256. @RequestParam(value = "status", required = false) String status,
  257. @RequestParam(value = "courseCode", required = false) String courseCode,
  258. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  259. @RequestParam(value = "examPlace", required = false) String examPlace,
  260. @RequestParam(value = "examRoom", required = false) String examRoom,
  261. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  262. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  263. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  264. @RequestParam(value = "validate", required = false) Boolean validate) {
  265. ClientPrintTaskTotalDto clientPrintTaskTotalDto = clientService.taskTotalData(printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, machineCode);
  266. return ResultUtil.ok(clientPrintTaskTotalDto);
  267. }
  268. /**
  269. * 印刷管理-查看
  270. *
  271. * @param examDetailId
  272. * @return
  273. */
  274. @ApiOperation(value = "印刷管理-查看")
  275. @RequestMapping(value = "/print/preview", method = RequestMethod.POST)
  276. public Result printPreview(@RequestParam("examDetailId") Long examDetailId) {
  277. Map<String, String> map = clientService.getUrlByExamDetailId(examDetailId);
  278. return ResultUtil.ok(map);
  279. }
  280. /**
  281. * 印刷管理-印刷/缓存数据
  282. *
  283. * @param examDetailId
  284. * @param machineCode
  285. * @param printUser
  286. * @return
  287. */
  288. @ApiOperation(value = "印刷管理-印刷/缓存数据")
  289. @RequestMapping(value = "/print/get_print_data", method = RequestMethod.POST)
  290. public Result printGetPrintData(@RequestParam("examDetailId") Long examDetailId,
  291. @RequestParam("machineCode") String machineCode,
  292. @RequestParam("isPrint") Boolean isPrint,
  293. @RequestParam(value = "printUser", required = false) String printUser) {
  294. Map<String, Object> map = clientService.getPrintData(examDetailId, machineCode, isPrint, printUser);
  295. return ResultUtil.ok(map);
  296. }
  297. /**
  298. * 印刷管理-批量缓存数据
  299. *
  300. * @param orgId
  301. * @param machineCode
  302. * @return
  303. */
  304. @ApiOperation(value = "印刷管理-批量缓存数据")
  305. @RequestMapping(value = "/print/get_print_data_batch", method = RequestMethod.POST)
  306. public Result printGetPrintDataBatch(@RequestParam("machineCode") Long machineCode,
  307. @RequestParam("orgId") String orgId,
  308. @RequestParam(value = "printPlanId", required = false) String printPlanId,
  309. @RequestParam(value = "status", required = false) String status,
  310. @RequestParam(value = "courseCode", required = false) String courseCode,
  311. @RequestParam(value = "paperNumber", required = false) String paperNumber,
  312. @RequestParam(value = "examPlace", required = false) String examPlace,
  313. @RequestParam(value = "examRoom", required = false) String examRoom,
  314. @RequestParam(value = "examStartTime", required = false) Long examStartTime,
  315. @RequestParam(value = "examEndTime", required = false) Long examEndTime,
  316. @RequestParam(value = "isDownload", required = false) Boolean isDownload,
  317. @RequestParam(value = "validate", required = false) Boolean validate) {
  318. List<Map<String, Object>> list = clientService.getPrintDataBatch(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
  319. return ResultUtil.ok(list);
  320. }
  321. /**
  322. * @param examDetailId
  323. * @param machineCode
  324. * @param isDownload
  325. * @return
  326. */
  327. @ApiOperation(value = "印刷管理-缓存后更新状态")
  328. @RequestMapping(value = "/print/update_download", method = RequestMethod.POST)
  329. public Result updateDownload(@RequestParam("examDetailId") Long examDetailId,
  330. @RequestParam("machineCode") String machineCode,
  331. @RequestParam("isDownload") Boolean isDownload) {
  332. Boolean isSuccess = clientService.updateDownload(examDetailId, machineCode, isDownload);
  333. return ResultUtil.ok(isSuccess);
  334. }
  335. /**
  336. * 印刷管理-校验
  337. *
  338. * @param examDetailId
  339. * @param packageCode
  340. * @param lastCode
  341. * @return
  342. */
  343. @ApiOperation(value = "印刷管理-校验")
  344. @RequestMapping(value = "/print/validate_data", method = RequestMethod.POST)
  345. public Result dataCheck(@RequestParam("examDetailId") Long examDetailId,
  346. @RequestParam("packageCode") String packageCode,
  347. @RequestParam("lastCode") String lastCode) {
  348. Boolean isSuccess = clientService.validateData(examDetailId, packageCode, lastCode);
  349. return ResultUtil.ok(isSuccess);
  350. }
  351. /**
  352. * 印刷管理-更新打印进度
  353. *
  354. * @param examDetailId
  355. * @param machineCode
  356. * @param printProgress
  357. * @return
  358. */
  359. @ApiOperation(value = "印刷管理-更新打印进度")
  360. @RequestMapping(value = "/print/update_progress", method = RequestMethod.POST)
  361. public Result updateProgress(@RequestParam("examDetailId") Long examDetailId,
  362. @RequestParam("machineCode") String machineCode,
  363. @RequestParam("printProgress") Integer printProgress) {
  364. Boolean isSuccess = clientService.updatePrintProgress(examDetailId, machineCode, printProgress);
  365. return ResultUtil.ok(isSuccess);
  366. }
  367. /**
  368. * 重打-查询考生列表
  369. *
  370. * @param examDetailId
  371. * @param ticketNumber
  372. * @param studentName
  373. * @param courseCode
  374. * @return
  375. */
  376. @ApiOperation(value = "重打-查询考生列表")
  377. @RequestMapping(value = "/print/list_student", method = RequestMethod.POST)
  378. public Result listStudent(@RequestParam("examDetailId") Long examDetailId,
  379. @RequestParam(value = "ticketNumber", required = false) String ticketNumber,
  380. @RequestParam(value = "studentName", required = false) String studentName,
  381. @RequestParam(value = "courseCode", required = false) String courseCode,
  382. @RequestParam("pageNumber") Integer pageNumber,
  383. @RequestParam("pageSize") Integer pageSize) {
  384. IPage<ClientExamStudentDto> examStudentDtoIPage = clientService.listStudent(examDetailId, ticketNumber, studentName, courseCode, pageNumber, pageSize);
  385. return ResultUtil.ok(examStudentDtoIPage);
  386. }
  387. /**
  388. * 重打-内容查询
  389. *
  390. * @param examDetailId
  391. * @param ticketNumber
  392. * @param type
  393. * @return
  394. */
  395. @ApiOperation(value = "重打-内容查询")
  396. @RequestMapping(value = "/print/get_reprint_data", method = RequestMethod.POST)
  397. public Result getReprintData(@RequestParam("examDetailId") Long examDetailId,
  398. @RequestParam("ticketNumber") String ticketNumber,
  399. @RequestParam("type") String type) {
  400. Map<String, Object> map = clientService.getReprintData(examDetailId, ticketNumber, type);
  401. return ResultUtil.ok(map);
  402. }
  403. }