123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package com.qmth.distributed.print.api;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.distributed.print.business.bean.params.analyze.GradeBatchParam;
- import com.qmth.distributed.print.business.bean.result.EditResult;
- import com.qmth.distributed.print.business.bean.result.analyze.GradeBatchResult;
- import com.qmth.distributed.print.business.entity.GradeBatch;
- import com.qmth.distributed.print.business.service.GradeBatchService;
- import com.qmth.distributed.print.business.templete.execute.AsyncTeachCloudReportService;
- import com.qmth.teachcloud.common.annotation.OperationLogDetail;
- import com.qmth.teachcloud.common.contant.SystemConstant;
- import com.qmth.teachcloud.common.entity.SysUser;
- import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
- import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
- import com.qmth.teachcloud.common.util.Result;
- import com.qmth.teachcloud.common.util.ResultUtil;
- import com.qmth.teachcloud.common.util.ServletUtil;
- import io.swagger.annotations.*;
- import org.springframework.validation.BindingResult;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import javax.validation.Valid;
- import javax.validation.constraints.Max;
- import javax.validation.constraints.Min;
- import java.io.IOException;
- /**
- * <p>
- * 分析-批次表 前端控制器
- * </p>
- *
- * @author wangliang
- * @since 2022-05-20
- */
- @Api(tags = "分析批次管理Controller")
- @RestController
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_GRADE + "/batch")
- @Validated
- //@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
- public class GradeBatchController {
- @Resource
- private GradeBatchService gradeBatchService;
- @Resource
- private AsyncTeachCloudReportService asyncTeachCloudReportService;
- @ApiOperation(value = "成绩分析批次-查询")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = GradeBatchResult.class)})
- public Result findGradeBatchPage(@ApiParam(value = "分析批次名称") @RequestParam(required = false) String gradeBatchName,
- @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
- @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
- return ResultUtil.ok(gradeBatchService.gradeBatchPage(gradeBatchName, pageNumber, pageSize, requestUser));
- }
- @ApiOperation(value = "成绩分析批次-新建")
- @RequestMapping(value = "/save", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EDIT)
- public Result saveGradeBatch(@Valid @RequestBody GradeBatchParam gradeBatchParam, BindingResult bindingResult) {
- if (bindingResult.hasErrors()) {
- return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
- }
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
- return ResultUtil.ok(gradeBatchService.editGradeBatch(gradeBatchParam, requestUser));
- }
- @ApiOperation(value = "成绩分析批次-删除")
- @RequestMapping(value = "/delete", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = SystemConstant.PUSH_OPERATE_NOTICE, response = EditResult.class)})
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.DELETE)
- public Result deleteGradeBatch(@ApiParam(value = "选择的要删除的成绩分析批次id", required = true) @RequestParam String id) {
- GradeBatch gradeBatch = gradeBatchService.getById(SystemConstant.convertIdToLong(id));
- if(gradeBatch == null){
- throw ExceptionResultEnum.ERROR.exception("没有批次信息");
- }
- asyncTeachCloudReportService.deleteGradeBatch(gradeBatch);
- return ResultUtil.ok();
- }
- /**
- * 按批次下载考务数据
- *
- * @param batchId 批次ID
- */
- @ApiOperation(value = "成绩分析批次课程-考务数据下载")
- @RequestMapping(value = "/download", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "下载成功", response = EditResult.class)})
- public void downloadFile(@RequestParam Long batchId) throws IOException {
- gradeBatchService.downloadFile(batchId, ServletUtil.getResponse());
- }
- /**
- * 导入考务数据-包含任课老师信息
- *
- * @param batchId 批次ID
- * @param file 上传文件
- * @return
- */
- @ApiOperation(value = "成绩分析批次课程-考务数据导入")
- @RequestMapping(value = "/upload", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "上传成功", response = EditResult.class)})
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.IMPORT)
- public Result upload(@RequestParam Long batchId,
- @RequestParam MultipartFile file) throws IOException, NoSuchFieldException {
- gradeBatchService.uploadFile(batchId, file);
- return ResultUtil.success(true);
- }
- /**
- * 导入考务数据-包含任课老师信息
- *
- * @param batchId 批次ID
- */
- @ApiOperation(value = "成绩分析批次课程-批次同步")
- @RequestMapping(value = "/push", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "同步成功", response = EditResult.class)})
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.IMPORT)
- public Result batchSync(@RequestParam Long batchId) {
- GradeBatch gradeBatch = gradeBatchService.getById(batchId);
- if(gradeBatch == null){
- throw ExceptionResultEnum.ERROR.exception("没有批次信息");
- }
- asyncTeachCloudReportService.syncGradeBatch(gradeBatch);
- return ResultUtil.success(true);
- }
- /**
- * 成绩分析批次课程-开始计算
- *
- * @param batchId 批次ID
- */
- @ApiOperation(value = "成绩分析批次课程-开始计算")
- @RequestMapping(value = "/start_calc", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "同步成功", response = EditResult.class)})
- @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.UN_KNOW)
- public Result startCalc(@RequestParam Long batchId) {
- GradeBatch gradeBatch = gradeBatchService.getById(batchId);
- if(gradeBatch == null){
- throw ExceptionResultEnum.ERROR.exception("没有批次信息");
- }
- asyncTeachCloudReportService.startCalc(gradeBatch);
- return ResultUtil.success(true);
- }
- }
|