123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- package com.qmth.distributed.print.api;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.qmth.boot.api.annotation.Aac;
- import com.qmth.boot.api.annotation.BOOL;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.distributed.print.business.bean.dto.*;
- import com.qmth.distributed.print.business.bean.params.ClientLoginParam;
- import com.qmth.distributed.print.business.service.ClientService;
- import com.qmth.teachcloud.common.bean.auth.AuthBean;
- import com.qmth.teachcloud.common.bean.result.LoginResult;
- import com.qmth.teachcloud.common.contant.SystemConstant;
- import com.qmth.teachcloud.common.entity.BasicSchool;
- import com.qmth.teachcloud.common.entity.SysUser;
- import com.qmth.teachcloud.common.enums.AppSourceEnum;
- import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
- import com.qmth.teachcloud.common.service.CommonCacheService;
- import com.qmth.teachcloud.common.service.SysUserService;
- import com.qmth.teachcloud.common.service.TeachcloudCommonService;
- import com.qmth.teachcloud.common.util.Result;
- import com.qmth.teachcloud.common.util.ResultUtil;
- import io.swagger.annotations.*;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.validation.BindingResult;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import javax.validation.Valid;
- import javax.validation.constraints.Max;
- import javax.validation.constraints.Min;
- import java.security.NoSuchAlgorithmException;
- import java.util.List;
- import java.util.Map;
- import java.util.Objects;
- import java.util.Set;
- import java.util.stream.Collectors;
- /**
- * @Date: 2021/4/19.
- */
- @Api(tags = "客户端Controller")
- @RestController
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.client}")
- @Validated
- public class ClientController {
- @Autowired
- private ClientService clientService;
- @Resource
- SysUserService sysUserService;
- @Resource
- CommonCacheService commonCacheService;
- @Resource
- TeachcloudCommonService teachcloudCommonService;
- /**
- * 登录
- *
- * @param login
- * @return
- */
- @ApiOperation(value = "登录")
- @RequestMapping(value = "/user/login", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = LoginResult.class)})
- @Aac(auth = BOOL.FALSE)
- public Result login(@ApiParam(value = "用户信息", required = true) @Valid @RequestBody ClientLoginParam login, BindingResult bindingResult) throws NoSuchAlgorithmException {
- if (bindingResult.hasErrors()) {
- return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
- }
- BasicSchool basicSchool = commonCacheService.schoolCache(login.getSchoolCode());
- if (Objects.isNull(basicSchool)) {
- throw ExceptionResultEnum.SCHOOL_NO_DATA.exception();
- }
- QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
- wrapper.lambda().eq(SysUser::getSchoolId, basicSchool.getId()).eq(SysUser::getLoginName, login.getLoginName());
- SysUser sysUser = sysUserService.getOne(wrapper);
- //用户不存在
- if (Objects.isNull(sysUser)) {
- throw ExceptionResultEnum.USER_NO_DATA.exception();
- }
- // 是否有客户端权限
- clientService.checkPrivilege(sysUser.getId());
- return ResultUtil.ok(teachcloudCommonService.login(login.getPassword(), sysUser, AppSourceEnum.SYSTEM));
- }
- /**
- * 试卷打样-列表
- *
- * @param machineCode 机器唯一码
- * @param orgId 机构ID
- * @param printPlanId 印刷计划ID
- * @param courseCode 课程代码
- * @param paperNumber 试卷编号
- * @param isTry 是否打样
- * @param isPass 是否合格
- * @param pageNumber
- * @param pageSize
- * @return
- */
- @ApiOperation(value = "试卷打样-列表")
- @RequestMapping(value = "/paper_try/list", method = RequestMethod.POST)
- public Result paperTryList(@RequestParam("machineCode") String machineCode,
- @RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) Long printPlanId,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber,
- @RequestParam(value = "isTry", required = false) Boolean isTry,
- @RequestParam(value = "isPass", required = false) Boolean isPass,
- @RequestParam Integer pageNumber,
- @RequestParam Integer pageSize) {
- IPage<ClientExamTaskDto> examTasks = clientService.listTryTask(machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass, pageNumber, pageSize);
- return ResultUtil.ok(examTasks);
- }
- /**
- * 试卷打样-查看/试印/重印
- *
- * @param examTaskId
- * @return
- */
- @ApiOperation(value = "试卷打样-查看/试印/重印")
- @RequestMapping(value = "/paper_try/print", method = RequestMethod.POST)
- public Result paperTryPrint(@RequestParam("printPlanId") Long printPlanId,
- @RequestParam("examTaskId") Long examTaskId) {
- Map<String, String> map = clientService.getUrl(printPlanId, examTaskId);
- return ResultUtil.ok(map);
- }
- /**
- * 试卷打样-批量试印
- *
- * @param machineCode
- * @param orgId
- * @param printPlanId
- * @param courseCode
- * @param paperNumber
- * @param isTry
- * @param isPass
- * @return
- */
- @ApiOperation(value = "试卷打样-批量试印")
- @RequestMapping(value = "/paper_try/print_batch", method = RequestMethod.POST)
- public Result printBatch(@RequestParam("machineCode") String machineCode,
- @RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) Long printPlanId,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber,
- @RequestParam(value = "isTry", required = false) Boolean isTry,
- @RequestParam(value = "isPass", required = false) Boolean isPass) {
- List<Map<String, String>> urls = clientService.getBatchUrl(machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass);
- return ResultUtil.ok(urls);
- }
- /**
- * 试卷打样-标记合格状态
- *
- * @param machineCode
- * @param isPass
- * @param userId
- * @return
- */
- @ApiOperation(value = "试卷打样-标记合格状态")
- @RequestMapping(value = "/paper_try/tag_pass", method = RequestMethod.POST)
- public Result paperTryTagPass(@RequestParam("printPlanId") Long printPlanId,
- @RequestParam("courseCode") String courseCode,
- @RequestParam("courseName") String courseName,
- @RequestParam("paperNumber") String paperNumber,
- @RequestParam("machineCode") String machineCode,
- @RequestParam("isPass") Boolean isPass,
- @RequestParam("userId") Long userId) {
- Boolean isSuccess = clientService.tagPass(printPlanId, courseCode, courseName, paperNumber, machineCode, isPass, userId);
- return ResultUtil.ok(isSuccess);
- }
- /**
- * 印刷管理-查询列表
- *
- * @param machineCode
- * @param orgId
- * @param printPlanId
- * @param status
- * @param courseCode
- * @param paperNumber
- * @param examPlace
- * @param examRoom
- * @param examStartTime
- * @param examEndTime
- * @param isDownload
- * @param validate
- * @param pageNumber
- * @param pageSize
- * @return
- */
- @ApiOperation(value = "印刷管理-查询列表")
- @RequestMapping(value = "/print/task_list", method = RequestMethod.POST)
- public Result printTaskList(@RequestParam("machineCode") String machineCode,
- @RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) String printPlanId,
- @RequestParam(value = "status", required = false) String status,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber,
- @RequestParam(value = "examPlace", required = false) String examPlace,
- @RequestParam(value = "examRoom", required = false) String examRoom,
- @RequestParam(value = "examStartTime", required = false) Long examStartTime,
- @RequestParam(value = "examEndTime", required = false) Long examEndTime,
- @RequestParam(value = "isDownload", required = false) Boolean isDownload,
- @RequestParam(value = "validate", required = false) Boolean validate,
- @RequestParam Integer pageNumber,
- @RequestParam Integer pageSize) {
- IPage<ClientPrintTaskDto> printTaskDtoIPage = clientService.listClientPrintTask(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, pageNumber, pageSize);
- return ResultUtil.ok(printTaskDtoIPage);
- }
- /**
- * 印刷管理-导出
- *
- * @param response
- * @param machineCode
- * @param orgId
- * @param printPlanId
- * @param status
- * @param courseCode
- * @param paperNumber
- * @param examPlace
- * @param examRoom
- * @param examStartTime
- * @param examEndTime
- * @param isDownload
- * @param validate
- * @return
- */
- @ApiOperation(value = "印刷管理-导出")
- @RequestMapping(value = "/print/task_list_export", method = RequestMethod.POST)
- public void printTaskListExport(HttpServletResponse response,
- @RequestParam("machineCode") String machineCode,
- @RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) String printPlanId,
- @RequestParam(value = "status", required = false) String status,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber,
- @RequestParam(value = "examPlace", required = false) String examPlace,
- @RequestParam(value = "examRoom", required = false) String examRoom,
- @RequestParam(value = "examStartTime", required = false) Long examStartTime,
- @RequestParam(value = "examEndTime", required = false) Long examEndTime,
- @RequestParam(value = "isDownload", required = false) Boolean isDownload,
- @RequestParam(value = "validate", required = false) Boolean validate) throws Exception {
- clientService.exportClientPrintTask(response, machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
- }
- /**
- * 印刷管理-汇总数据查询
- *
- * @param machineCode
- * @param orgId
- * @param printPlanId
- * @param status
- * @param courseCode
- * @param paperNumber
- * @param examPlace
- * @param examRoom
- * @param examStartTime
- * @param examEndTime
- * @param isDownload
- * @param validate
- * @return
- */
- @ApiOperation(value = "印刷管理-汇总数据查询")
- @RequestMapping(value = "/print/task_total_data", method = RequestMethod.POST)
- public Result printTaskTotalData(@RequestParam("machineCode") String machineCode,
- @RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) String printPlanId,
- @RequestParam(value = "status", required = false) String status,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber,
- @RequestParam(value = "examPlace", required = false) String examPlace,
- @RequestParam(value = "examRoom", required = false) String examRoom,
- @RequestParam(value = "examStartTime", required = false) Long examStartTime,
- @RequestParam(value = "examEndTime", required = false) Long examEndTime,
- @RequestParam(value = "isDownload", required = false) Boolean isDownload,
- @RequestParam(value = "validate", required = false) Boolean validate) {
- ClientPrintTaskTotalDto clientPrintTaskTotalDto = clientService.taskTotalData(printPlanId, orgId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, machineCode);
- return ResultUtil.ok(clientPrintTaskTotalDto);
- }
- /**
- * 印刷管理-查看
- *
- * @param examDetailId
- * @return
- */
- @ApiOperation(value = "印刷管理-查看")
- @RequestMapping(value = "/print/preview", method = RequestMethod.POST)
- public Result printPreview(@RequestParam("examDetailId") Long examDetailId) {
- Map<String, Object> map = clientService.getUrlByExamDetailId(examDetailId);
- return ResultUtil.ok(map);
- }
- /**
- * 印刷管理-印刷/缓存数据
- *
- * @param examDetailId
- * @param machineCode
- * @param printUser
- * @return
- */
- @ApiOperation(value = "印刷管理-印刷/缓存数据")
- @RequestMapping(value = "/print/get_print_data", method = RequestMethod.POST)
- public Result printGetPrintData(@RequestParam("examDetailId") Long examDetailId,
- @RequestParam("machineCode") String machineCode,
- @RequestParam("isPrint") Boolean isPrint,
- @RequestParam(value = "printUser", required = false) String printUser) {
- Map<String, Object> map = clientService.getPrintData(examDetailId, machineCode, isPrint, printUser);
- return ResultUtil.ok(map);
- }
- /**
- * 印刷管理-批量缓存数据
- *
- * @param orgId
- * @param machineCode
- * @return
- */
- @ApiOperation(value = "印刷管理-批量缓存数据")
- @RequestMapping(value = "/print/get_print_data_batch", method = RequestMethod.POST)
- public Result printGetPrintDataBatch(@RequestParam("machineCode") String machineCode,
- @RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) String printPlanId,
- @RequestParam(value = "status", required = false) String status,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber,
- @RequestParam(value = "examPlace", required = false) String examPlace,
- @RequestParam(value = "examRoom", required = false) String examRoom,
- @RequestParam(value = "examStartTime", required = false) Long examStartTime,
- @RequestParam(value = "examEndTime", required = false) Long examEndTime,
- @RequestParam(value = "isDownload", required = false) Boolean isDownload,
- @RequestParam(value = "validate", required = false) Boolean validate) {
- List<Map<String, Object>> list = clientService.getPrintDataBatch(machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
- return ResultUtil.ok(list);
- }
- /**
- * @param examDetailId
- * @param machineCode
- * @param isDownload
- * @return
- */
- @ApiOperation(value = "印刷管理-缓存后更新状态")
- @RequestMapping(value = "/print/update_download", method = RequestMethod.POST)
- public Result updateDownload(@RequestParam("examDetailId") Long examDetailId,
- @RequestParam("machineCode") String machineCode,
- @RequestParam("isDownload") Boolean isDownload) {
- Boolean isSuccess = clientService.updateDownload(examDetailId, machineCode, isDownload);
- return ResultUtil.ok(isSuccess);
- }
- /**
- * 印刷管理-校验
- *
- * @param examDetailId
- * @param packageCode
- * @param lastCode
- * @return
- */
- @ApiOperation(value = "印刷管理-校验")
- @RequestMapping(value = "/print/validate_data", method = RequestMethod.POST)
- public Result dataCheck(@RequestParam("examDetailId") Long examDetailId,
- @RequestParam("packageCode") String packageCode,
- @RequestParam("lastCode") String lastCode) {
- Boolean isSuccess = clientService.validateData(examDetailId, packageCode, lastCode);
- return ResultUtil.ok(isSuccess);
- }
- /**
- * 印刷管理-更新打印进度
- *
- * @param examDetailId
- * @param machineCode
- * @param printProgress
- * @return
- */
- @ApiOperation(value = "印刷管理-更新打印进度")
- @RequestMapping(value = "/print/update_progress", method = RequestMethod.POST)
- public Result updateProgress(@RequestParam("examDetailId") Long examDetailId,
- @RequestParam("machineCode") String machineCode,
- @RequestParam("printProgress") Integer printProgress,
- @RequestParam(value = "isPrint", required = false) Boolean isPrint) {
- Boolean isSuccess = clientService.updatePrintProgress(examDetailId, machineCode, printProgress, isPrint);
- return ResultUtil.ok(isSuccess);
- }
- /**
- * 重打-查询考生列表
- *
- * @param examDetailId
- * @param ticketNumber
- * @param studentName
- * @param courseCode
- * @return
- */
- @ApiOperation(value = "重打-查询考生列表")
- @RequestMapping(value = "/print/list_student", method = RequestMethod.POST)
- public Result listStudent(@RequestParam("examDetailId") Long examDetailId,
- @RequestParam(value = "ticketNumber", required = false) String ticketNumber,
- @RequestParam(value = "studentName", required = false) String studentName,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam Integer pageNumber,
- @RequestParam Integer pageSize) {
- IPage<ClientExamStudentDto> examStudentDtoIPage = clientService.listStudent(examDetailId, ticketNumber, studentName, courseCode, pageNumber, pageSize);
- return ResultUtil.ok(examStudentDtoIPage);
- }
- /**
- * 重打-内容查询
- *
- * @param examDetailId
- * @param ticketNumber
- * @param type
- * @return
- */
- @ApiOperation(value = "重打-内容查询")
- @RequestMapping(value = "/print/get_reprint_data", method = RequestMethod.POST)
- public Result getReprintData(@RequestParam("examDetailId") Long examDetailId,
- @RequestParam("ticketNumber") String ticketNumber,
- @RequestParam("type") String type) {
- Map<String, Object> map = clientService.getReprintData(examDetailId, ticketNumber, type);
- return ResultUtil.ok(map);
- }
- /**
- * 统计查询-查询列表
- *
- * @param orgId
- * @param printPlanId
- * @param examPlace
- * @param examStartTime
- * @param examEndTime
- * @param courseCode
- * @param paperNumber
- * @param pageNumber
- * @param pageSize
- * @return
- */
- @ApiOperation(value = "统计查询-查询列表")
- @RequestMapping(value = "/print/statistics_list", method = RequestMethod.POST)
- public Result printStatisticsList(@RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) String printPlanId,
- @RequestParam(value = "examPlace", required = false) String examPlace,
- @RequestParam(value = "examStartTime", required = false) Long examStartTime,
- @RequestParam(value = "examEndTime", required = false) Long examEndTime,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber,
- @RequestParam Integer pageNumber,
- @RequestParam Integer pageSize) {
- IPage<ClientPrintStatisticsDto> statisticsDtoIPage = clientService.listClientPrintStatistics(orgId, printPlanId, examPlace, examStartTime, examEndTime, courseCode, paperNumber, pageNumber, pageSize);
- return ResultUtil.ok(statisticsDtoIPage);
- }
- /**
- * 统计查询-汇总数据查询
- *
- * @param orgId
- * @param printPlanId
- * @param examPlace
- * @param examStartTime
- * @param examEndTime
- * @param courseCode
- * @param paperNumber
- * @return
- */
- @ApiOperation(value = "统计查询-汇总数据查询")
- @RequestMapping(value = "/print/statistics_total_data", method = RequestMethod.POST)
- public Result printStatisticsTotalData(@RequestParam("orgId") Long orgId,
- @RequestParam(value = "printPlanId", required = false) String printPlanId,
- @RequestParam(value = "examPlace", required = false) String examPlace,
- @RequestParam(value = "examStartTime", required = false) Long examStartTime,
- @RequestParam(value = "examEndTime", required = false) Long examEndTime,
- @RequestParam(value = "courseCode", required = false) String courseCode,
- @RequestParam(value = "paperNumber", required = false) String paperNumber) {
- ClientPrintStatisticsTotalDto statisticsTotalDto = clientService.clientStatisticsTotalData(orgId, printPlanId, examPlace, examStartTime, examEndTime, courseCode, paperNumber);
- return ResultUtil.ok(statisticsTotalDto);
- }
- }
|