GradePaperStructController.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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.SysUser;
  9. import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
  10. import com.qmth.teachcloud.common.enums.log.OperationTypeEnum;
  11. import com.qmth.teachcloud.common.util.Result;
  12. import com.qmth.teachcloud.common.util.ResultUtil;
  13. import com.qmth.teachcloud.common.util.ServletUtil;
  14. import com.qmth.teachcloud.mark.dto.mark.MarkQuestionAnswerVo;
  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, @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
  47. @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) {
  48. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  49. if (SystemConstant.isOneNull(paperNumber, paperType)) {
  50. throw ExceptionResultEnum.ERROR.exception("试卷参数不完整");
  51. }
  52. // List<MarkQuestionResult> markQuestionList = markQuestionService.listDetailByExamIdAndPaperNumberAndPaperType(
  53. // examId, paperNumber, paperType, null);
  54. return ResultUtil.ok(
  55. gradePaperStructService.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser,
  56. markQuestionService.listQuestionAnswerByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null)));
  57. }
  58. @ApiOperation(value = "成绩分析试卷结构-新建试卷结构")
  59. @RequestMapping(value = "/save", method = RequestMethod.POST)
  60. @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
  61. @OperationLogDetail(operationType = OperationTypeEnum.ADD)
  62. public Result saveGradePaperStructBatch(@Valid @RequestBody GradePaperStructParam gradePaperStructParam,
  63. BindingResult bindingResult) {
  64. if (bindingResult.hasErrors()) {
  65. return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
  66. }
  67. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  68. gradePaperStructService.saveGradePaperStructBatch(gradePaperStructParam, requestUser);
  69. return ResultUtil.ok();
  70. }
  71. @ApiOperation(value = "成绩分析试卷结构-导入")
  72. @RequestMapping(value = "/import", method = RequestMethod.POST)
  73. @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
  74. @OperationLogDetail(operationType = OperationTypeEnum.IMPORT)
  75. public Result gradePaperStructImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @ApiParam(value = "考试id", required = true) @RequestParam Long examId,
  76. @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber, @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType,
  77. @ApiParam(value = "试卷名称", required = true) @RequestParam String paperName) throws IOException, NoSuchFieldException {
  78. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  79. if (SystemConstant.isOneNull(file, examId, paperNumber, paperType, paperName)) {
  80. throw ExceptionResultEnum.ERROR.exception("参数不完整");
  81. }
  82. gradePaperStructService.importGradePaperStruct(file, examId, paperNumber, paperType, paperName, requestUser);
  83. return ResultUtil.ok();
  84. }
  85. @ApiOperation(value = "成绩分析试卷结构-模板导出")
  86. @RequestMapping(value = "/export", method = RequestMethod.POST)
  87. @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
  88. @OperationLogDetail(operationType = OperationTypeEnum.EXPORT)
  89. public Result gradePaperStructExport(@ApiParam(value = "考试id", required = true) @RequestParam Long examId, @ApiParam(value = "课程编号", required = true) @RequestParam String paperNumber,
  90. @ApiParam(value = "课程名称", required = true) @RequestParam String paperType) throws Exception {
  91. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  92. if (SystemConstant.isOneNull(examId, paperNumber, paperType)) {
  93. throw ExceptionResultEnum.ERROR.exception("参数不完整");
  94. }
  95. // List<MarkQuestionResult> markQuestionList = markQuestionService.listDetailByExamIdAndPaperNumberAndPaperType(
  96. // examId, paperNumber, paperType, null);
  97. gradePaperStructService.exportGradePaperStructTemplate(examId, paperNumber, paperType, requestUser,
  98. markQuestionService.listQuestionAnswerByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null));
  99. return ResultUtil.ok();
  100. }
  101. @ApiOperation(value = "成绩分析试卷结构-更新试卷机构")
  102. @RequestMapping(value = "/change_paper_structure", method = RequestMethod.POST)
  103. @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
  104. @OperationLogDetail(operationType = OperationTypeEnum.UPDATE)
  105. public Result updateExamCloudPaperStruct(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId, @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
  106. @ApiParam(value = "试卷类型") @RequestParam(required = false) String paperType) {
  107. if (SystemConstant.isOneNull(paperNumber)) {
  108. throw ExceptionResultEnum.ERROR.exception("缺少试卷编号");
  109. }
  110. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  111. List<MarkQuestionAnswerVo> markQuestionList = markQuestionService.listQuestionAnswerByExamIdAndPaperNumberAndPaperType(examId,
  112. paperNumber, paperType, null);
  113. gradePaperStructService.updateExamCloudPaperStruct(requestUser.getSchoolId(), paperNumber, paperType,
  114. markQuestionList);
  115. return ResultUtil.ok();
  116. }
  117. }