ClientController.java 23 KB

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