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