GradePaperStructController.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.qmth.distributed.print.api;
  2. import com.qmth.boot.api.constant.ApiConstant;
  3. import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructParam;
  4. import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult;
  5. import com.qmth.distributed.print.business.service.GradePaperStructService;
  6. import com.qmth.teachcloud.common.annotation.OperationLogDetail;
  7. import com.qmth.teachcloud.common.contant.SystemConstant;
  8. import com.qmth.teachcloud.common.entity.MarkQuestion;
  9. import com.qmth.teachcloud.common.entity.SysUser;
  10. import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
  11. import com.qmth.teachcloud.common.enums.log.OperationTypeEnum;
  12. import com.qmth.teachcloud.common.util.Result;
  13. import com.qmth.teachcloud.common.util.ResultUtil;
  14. import com.qmth.teachcloud.common.util.ServletUtil;
  15. import com.qmth.teachcloud.mark.service.MarkQuestionService;
  16. import io.swagger.annotations.*;
  17. import org.springframework.validation.BindingResult;
  18. import org.springframework.validation.annotation.Validated;
  19. import org.springframework.web.bind.annotation.*;
  20. import org.springframework.web.multipart.MultipartFile;
  21. import javax.annotation.Resource;
  22. import javax.validation.Valid;
  23. import java.io.IOException;
  24. import java.util.List;
  25. /**
  26. * <p>
  27. * 分析-试卷结构(蓝图)表 前端控制器
  28. * </p>
  29. *
  30. * @author wangliang
  31. * @since 2022-05-20
  32. */
  33. @Api(tags = "分析课程试卷结构管理Controller")
  34. @RestController
  35. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_GRADE + "/paper/struct")
  36. @Validated
  37. //@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
  38. public class GradePaperStructController {
  39. @Resource
  40. private GradePaperStructService gradePaperStructService;
  41. @Resource
  42. private MarkQuestionService markQuestionService;
  43. @ApiOperation(value = "成绩分析试卷结构-查询")
  44. @RequestMapping(value = "/list", method = RequestMethod.POST)
  45. @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = GradePaperStructResult.class)})
  46. public Result findGradePaperStructList(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
  47. @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
  48. @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) {
  49. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  50. if (SystemConstant.isOneNull(paperNumber, paperType)) {
  51. throw ExceptionResultEnum.ERROR.exception("试卷参数不完整");
  52. }
  53. List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null);
  54. return ResultUtil.ok(gradePaperStructService.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser, markQuestionList));
  55. }
  56. @ApiOperation(value = "成绩分析试卷结构-新建试卷结构")
  57. @RequestMapping(value = "/save", method = RequestMethod.POST)
  58. @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
  59. @OperationLogDetail(operationType = OperationTypeEnum.ADD)
  60. public Result saveGradePaperStructBatch(@Valid @RequestBody GradePaperStructParam gradePaperStructParam, BindingResult bindingResult) {
  61. if (bindingResult.hasErrors()) {
  62. return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
  63. }
  64. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  65. gradePaperStructService.saveGradePaperStructBatch(gradePaperStructParam, requestUser);
  66. return ResultUtil.ok();
  67. }
  68. @ApiOperation(value = "成绩分析试卷结构-导入")
  69. @RequestMapping(value = "/import", method = RequestMethod.POST)
  70. @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
  71. @OperationLogDetail(operationType = OperationTypeEnum.IMPORT)
  72. public Result gradePaperStructImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
  73. @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
  74. @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType,
  75. @ApiParam(value = "试卷名称", required = true) @RequestParam String paperName) throws IOException, NoSuchFieldException {
  76. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  77. if (SystemConstant.isOneNull(file, paperNumber, paperType, paperName)) {
  78. throw ExceptionResultEnum.ERROR.exception("参数不完整");
  79. }
  80. gradePaperStructService.importGradePaperStruct(file, paperNumber, paperType, paperName, requestUser);
  81. return ResultUtil.ok();
  82. }
  83. @ApiOperation(value = "成绩分析试卷结构-模板导出")
  84. @RequestMapping(value = "/export", method = RequestMethod.POST)
  85. @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
  86. @OperationLogDetail(operationType = OperationTypeEnum.EXPORT)
  87. public Result gradePaperStructExport(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
  88. @ApiParam(value = "课程编号", required = true) @RequestParam String paperNumber,
  89. @ApiParam(value = "课程名称", required = true) @RequestParam String paperType) throws Exception {
  90. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  91. if (SystemConstant.isOneNull(examId, paperNumber, paperType)) {
  92. throw ExceptionResultEnum.ERROR.exception("参数不完整");
  93. }
  94. List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null);
  95. gradePaperStructService.exportGradePaperStructTemplate(examId, paperNumber, paperType, requestUser, markQuestionList);
  96. return ResultUtil.ok();
  97. }
  98. @ApiOperation(value = "成绩分析试卷结构-更新试卷机构")
  99. @RequestMapping(value = "/change_paper_structure", method = RequestMethod.POST)
  100. @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
  101. @OperationLogDetail(operationType = OperationTypeEnum.UPDATE)
  102. public Result updateExamCloudPaperStruct(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId,
  103. @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
  104. @ApiParam(value = "试卷类型") @RequestParam(required = false) String paperType) {
  105. if (SystemConstant.isOneNull(paperNumber)) {
  106. throw ExceptionResultEnum.ERROR.exception("缺少试卷编号");
  107. }
  108. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  109. List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null);
  110. gradePaperStructService.updateExamCloudPaperStruct(requestUser.getSchoolId(), paperNumber, paperType, markQuestionList);
  111. return ResultUtil.ok();
  112. }
  113. }