ExamPaperStructureController.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package com.qmth.distributed.print.api;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.qmth.boot.api.constant.ApiConstant;
  5. import com.qmth.distributed.print.business.bean.result.EditResult;
  6. import com.qmth.distributed.print.business.entity.ExamPaperStructure;
  7. import com.qmth.distributed.print.business.service.ExamPaperStructureService;
  8. import com.qmth.distributed.print.business.templete.execute.AsyncCloudMarkingTaskService;
  9. import com.qmth.teachcloud.common.contant.SystemConstant;
  10. import com.qmth.teachcloud.common.entity.SysUser;
  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 io.swagger.annotations.*;
  15. import org.springframework.web.bind.annotation.*;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import javax.annotation.Resource;
  18. import javax.validation.constraints.Max;
  19. import javax.validation.constraints.Min;
  20. import java.util.List;
  21. import java.util.Map;
  22. /**
  23. * <p>
  24. * 试卷结构 前端控制器
  25. * </p>
  26. *
  27. * @author xf
  28. */
  29. @Api(tags = "试卷结构Controller")
  30. @RestController
  31. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.exam}/structure")
  32. public class ExamPaperStructureController {
  33. @Resource
  34. private ExamPaperStructureService examPaperStructureService;
  35. @Resource
  36. private AsyncCloudMarkingTaskService asyncCloudMarkingTaskService;
  37. /**
  38. * 查询
  39. *
  40. * @return
  41. */
  42. @ApiOperation(value = "查询")
  43. @RequestMapping(value = "/list", method = RequestMethod.POST)
  44. public Result list(@ApiParam(value = "学期ID", required = false) @RequestParam(required = false) Long semesterId,
  45. @ApiParam(value = "考试ID", required = false) @RequestParam(required = false) Long examId,
  46. @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
  47. @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
  48. IPage<ExamPaperStructure> examPaperStructureIPage = examPaperStructureService.listByPropositionTeacherId(semesterId, examId, pageNumber, pageSize, null, false);
  49. return ResultUtil.ok(examPaperStructureIPage);
  50. }
  51. /**
  52. * 上传
  53. *
  54. * @param md5 文件md5
  55. * @param files 文件数组
  56. * @return Result
  57. */
  58. @ApiOperation(value = "上传试卷结构、标答")
  59. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  60. public Result upload(@RequestParam("examPaperStructure") String examPaperStructure,
  61. @RequestParam("md5") String md5,
  62. @RequestParam("keys") String keys,
  63. @RequestParam("files") MultipartFile[] files) {
  64. ExamPaperStructure examPaper = examPaperStructureService.upload(examPaperStructure, md5, keys, files);
  65. return ResultUtil.ok(String.valueOf(examPaper.getId()), null);
  66. }
  67. @ApiOperation(value = "评卷参数-提交")
  68. @RequestMapping(value = "/submit", method = RequestMethod.POST)
  69. @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = EditResult.class)})
  70. public Result submitExamPaperParams(@RequestBody String evaluationParameters) {
  71. SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
  72. ExamPaperStructure examPaperStructure = examPaperStructureService.submitExamPaperParams(evaluationParameters, sysUser);
  73. // 异步同步到云阅卷
  74. asyncCloudMarkingTaskService.syncPaperStructureAndGroup(examPaperStructure);
  75. return ResultUtil.ok();
  76. }
  77. /**
  78. * 上传标答文件
  79. *
  80. * @param md5 文件md5
  81. * @param file 文件数组
  82. * @return Result
  83. */
  84. @ApiOperation(value = "上传试卷标答文件")
  85. @RequestMapping(value = "/upload_answer", method = RequestMethod.POST)
  86. public Result uploadAnswer(@RequestParam("id") String id,
  87. @RequestParam("md5") String md5,
  88. @RequestParam("file") MultipartFile file) {
  89. ExamPaperStructure examPaperStructure = examPaperStructureService.uploadAnswer(id, md5, file);
  90. // 异步同步到云阅卷
  91. asyncCloudMarkingTaskService.syncPaperAndAnswer(examPaperStructure);
  92. return ResultUtil.ok(true);
  93. }
  94. /**
  95. * 设置科组长
  96. *
  97. * @param data data
  98. * @return Result
  99. */
  100. @ApiOperation(value = "设置科组长")
  101. @RequestMapping(value = "/bind_mark_leader", method = RequestMethod.POST)
  102. public Result bindMarkLeader(@RequestBody String data) {
  103. ExamPaperStructure examPaperStructure = examPaperStructureService.bindMarkLeader(data);
  104. // 异步同步到云阅卷
  105. asyncCloudMarkingTaskService.syncMarkLeader(examPaperStructure);
  106. return ResultUtil.ok(true);
  107. }
  108. /**
  109. * 保存客观题答案
  110. *
  111. * @param body body
  112. */
  113. @ApiOperation(value = "更新客观题答案")
  114. @RequestMapping(value = "/update_objective_answer", method = RequestMethod.POST)
  115. public Result updateObjectiveAnswer(@RequestBody String body) {
  116. JSONObject object = JSONObject.parseObject(body, JSONObject.class);
  117. Long id = object.getLong("id");
  118. String objectiveStructure = object.getString("objectiveStructure");
  119. ExamPaperStructure examPaperStructure = examPaperStructureService.updateObjectiveAnswer(id, objectiveStructure);
  120. // 异步同步到云阅卷
  121. asyncCloudMarkingTaskService.syncObjectiveStructure(examPaperStructure);
  122. return ResultUtil.ok(true);
  123. }
  124. /**
  125. * 试卷结构预览
  126. *
  127. * @param id id
  128. */
  129. @ApiOperation(value = "试卷结构预览")
  130. @RequestMapping(value = "/preview_structure", method = RequestMethod.POST)
  131. public Result preStructure(@RequestParam("id") Long id) {
  132. List<Map> list = examPaperStructureService.preStructure(id);
  133. return ResultUtil.ok(list);
  134. }
  135. @ApiOperation(value = "评卷参数设置-获取题卡图片")
  136. @RequestMapping(value = "/find_jpg_file", method = RequestMethod.POST)
  137. @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
  138. public Result findCardJpgFileByPaperNumber(@ApiParam(value = "考试id", required = true) @RequestParam String examId,
  139. @ApiParam(value = "课程代码", required = true) @RequestParam String courseCode,
  140. @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
  141. @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) {
  142. return ResultUtil.ok(examPaperStructureService.findCardJpgFileByPaperNumber(SystemConstant.convertIdToLong(examId), courseCode, paperNumber, paperType));
  143. }
  144. }