GradeBatchController.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.GradeBatchParam;
  4. import com.qmth.distributed.print.business.bean.result.EditResult;
  5. import com.qmth.distributed.print.business.bean.result.analyze.GradeBatchResult;
  6. import com.qmth.distributed.print.business.entity.GradeBatch;
  7. import com.qmth.distributed.print.business.service.GradeBatchService;
  8. import com.qmth.distributed.print.business.templete.execute.AsyncTeachCloudReportService;
  9. import com.qmth.teachcloud.common.annotation.OperationLogDetail;
  10. import com.qmth.teachcloud.common.contant.SystemConstant;
  11. import com.qmth.teachcloud.common.entity.SysUser;
  12. import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
  13. import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
  14. import com.qmth.teachcloud.common.util.Result;
  15. import com.qmth.teachcloud.common.util.ResultUtil;
  16. import com.qmth.teachcloud.common.util.ServletUtil;
  17. import io.swagger.annotations.*;
  18. import org.springframework.validation.BindingResult;
  19. import org.springframework.validation.annotation.Validated;
  20. import org.springframework.web.bind.annotation.*;
  21. import org.springframework.web.multipart.MultipartFile;
  22. import javax.annotation.Resource;
  23. import javax.validation.Valid;
  24. import javax.validation.constraints.Max;
  25. import javax.validation.constraints.Min;
  26. import java.io.IOException;
  27. /**
  28. * <p>
  29. * 分析-批次表 前端控制器
  30. * </p>
  31. *
  32. * @author wangliang
  33. * @since 2022-05-20
  34. */
  35. @Api(tags = "分析批次管理Controller")
  36. @RestController
  37. @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_GRADE + "/batch")
  38. @Validated
  39. //@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
  40. public class GradeBatchController {
  41. @Resource
  42. private GradeBatchService gradeBatchService;
  43. @Resource
  44. private AsyncTeachCloudReportService asyncTeachCloudReportService;
  45. @ApiOperation(value = "成绩分析批次-查询")
  46. @RequestMapping(value = "/page", method = RequestMethod.POST)
  47. @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = GradeBatchResult.class)})
  48. public Result findGradeBatchPage(@ApiParam(value = "分析批次名称") @RequestParam(required = false) String gradeBatchName,
  49. @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
  50. @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
  51. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  52. return ResultUtil.ok(gradeBatchService.gradeBatchPage(gradeBatchName, pageNumber, pageSize, requestUser));
  53. }
  54. @ApiOperation(value = "成绩分析批次-新建")
  55. @RequestMapping(value = "/save", method = RequestMethod.POST)
  56. @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
  57. @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EDIT)
  58. public Result saveGradeBatch(@Valid @RequestBody GradeBatchParam gradeBatchParam, BindingResult bindingResult) {
  59. if (bindingResult.hasErrors()) {
  60. return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
  61. }
  62. SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
  63. return ResultUtil.ok(gradeBatchService.editGradeBatch(gradeBatchParam, requestUser));
  64. }
  65. @ApiOperation(value = "成绩分析批次-删除")
  66. @RequestMapping(value = "/delete", method = RequestMethod.POST)
  67. @ApiResponses({@ApiResponse(code = 200, message = SystemConstant.PUSH_OPERATE_NOTICE, response = EditResult.class)})
  68. @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.DELETE)
  69. public Result deleteGradeBatch(@ApiParam(value = "选择的要删除的成绩分析批次id", required = true) @RequestParam String id) {
  70. GradeBatch gradeBatch = gradeBatchService.getById(SystemConstant.convertIdToLong(id));
  71. if(gradeBatch == null){
  72. throw ExceptionResultEnum.ERROR.exception("没有批次信息");
  73. }
  74. asyncTeachCloudReportService.deleteGradeBatch(gradeBatch);
  75. return ResultUtil.ok();
  76. }
  77. /**
  78. * 按批次下载考务数据
  79. *
  80. * @param batchId 批次ID
  81. */
  82. @ApiOperation(value = "成绩分析批次课程-考务数据下载")
  83. @RequestMapping(value = "/download", method = RequestMethod.POST)
  84. @ApiResponses({@ApiResponse(code = 200, message = "下载成功", response = EditResult.class)})
  85. public void downloadFile(@RequestParam Long batchId) throws IOException {
  86. gradeBatchService.downloadFile(batchId, ServletUtil.getResponse());
  87. }
  88. /**
  89. * 导入考务数据-包含任课老师信息
  90. *
  91. * @param batchId 批次ID
  92. * @param file 上传文件
  93. * @return
  94. */
  95. @ApiOperation(value = "成绩分析批次课程-考务数据导入")
  96. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  97. @ApiResponses({@ApiResponse(code = 200, message = "上传成功", response = EditResult.class)})
  98. @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.IMPORT)
  99. public Result upload(@RequestParam Long batchId,
  100. @RequestParam MultipartFile file) throws IOException, NoSuchFieldException {
  101. gradeBatchService.uploadFile(batchId, file);
  102. return ResultUtil.success(true);
  103. }
  104. /**
  105. * 导入考务数据-包含任课老师信息
  106. *
  107. * @param batchId 批次ID
  108. */
  109. @ApiOperation(value = "成绩分析批次课程-批次同步")
  110. @RequestMapping(value = "/push", method = RequestMethod.POST)
  111. @ApiResponses({@ApiResponse(code = 200, message = "同步成功", response = EditResult.class)})
  112. @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.IMPORT)
  113. public Result batchSync(@RequestParam Long batchId) {
  114. GradeBatch gradeBatch = gradeBatchService.getById(batchId);
  115. if(gradeBatch == null){
  116. throw ExceptionResultEnum.ERROR.exception("没有批次信息");
  117. }
  118. asyncTeachCloudReportService.syncGradeBatch(gradeBatch);
  119. return ResultUtil.success(true);
  120. }
  121. /**
  122. * 成绩分析批次课程-开始计算
  123. *
  124. * @param batchId 批次ID
  125. */
  126. @ApiOperation(value = "成绩分析批次课程-开始计算")
  127. @RequestMapping(value = "/start_calc", method = RequestMethod.POST)
  128. @ApiResponses({@ApiResponse(code = 200, message = "同步成功", response = EditResult.class)})
  129. @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.UN_KNOW)
  130. public Result startCalc(@RequestParam Long batchId) {
  131. GradeBatch gradeBatch = gradeBatchService.getById(batchId);
  132. if(gradeBatch == null){
  133. throw ExceptionResultEnum.ERROR.exception("没有批次信息");
  134. }
  135. asyncTeachCloudReportService.startCalc(gradeBatch);
  136. return ResultUtil.success(true);
  137. }
  138. }