123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- package com.qmth.distributed.print.api;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructParam;
- import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult;
- import com.qmth.distributed.print.business.service.GradePaperStructService;
- 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.OperationTypeEnum;
- import com.qmth.teachcloud.common.util.Result;
- import com.qmth.teachcloud.common.util.ResultUtil;
- import com.qmth.teachcloud.common.util.ServletUtil;
- import com.qmth.teachcloud.mark.dto.mark.MarkQuestionAnswerVo;
- import com.qmth.teachcloud.mark.service.MarkQuestionService;
- 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 java.io.IOException;
- import java.util.List;
- /**
- * <p>
- * 分析-试卷结构(蓝图)表 前端控制器
- * </p>
- *
- * @author wangliang
- * @since 2022-05-20
- */
- @Api(tags = "分析课程试卷结构管理Controller")
- @RestController
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_GRADE + "/paper/struct")
- @Validated
- //@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
- public class GradePaperStructController {
- @Resource
- private GradePaperStructService gradePaperStructService;
- @Resource
- private MarkQuestionService markQuestionService;
- @ApiOperation(value = "成绩分析试卷结构-查询")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = GradePaperStructResult.class)})
- public Result findGradePaperStructList(@ApiParam(value = "考试id", required = true) @RequestParam Long examId, @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
- @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) {
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
- if (SystemConstant.isOneNull(paperNumber, paperType)) {
- throw ExceptionResultEnum.ERROR.exception("试卷参数不完整");
- }
- // List<MarkQuestionResult> markQuestionList = markQuestionService.listDetailByExamIdAndPaperNumberAndPaperType(
- // examId, paperNumber, paperType, null);
- return ResultUtil.ok(
- gradePaperStructService.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser,
- markQuestionService.listQuestionAnswerByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null)));
- }
- @ApiOperation(value = "成绩分析试卷结构-新建试卷结构")
- @RequestMapping(value = "/save", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
- @OperationLogDetail(operationType = OperationTypeEnum.ADD)
- public Result saveGradePaperStructBatch(@Valid @RequestBody GradePaperStructParam gradePaperStructParam,
- BindingResult bindingResult) {
- if (bindingResult.hasErrors()) {
- return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
- }
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
- gradePaperStructService.saveGradePaperStructBatch(gradePaperStructParam, requestUser);
- return ResultUtil.ok();
- }
- @ApiOperation(value = "成绩分析试卷结构-导入")
- @RequestMapping(value = "/import", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
- @OperationLogDetail(operationType = OperationTypeEnum.IMPORT)
- public Result gradePaperStructImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @ApiParam(value = "考试id", required = true) @RequestParam Long examId,
- @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber, @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType,
- @ApiParam(value = "试卷名称", required = true) @RequestParam String paperName) throws IOException, NoSuchFieldException {
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
- if (SystemConstant.isOneNull(file, examId, paperNumber, paperType, paperName)) {
- throw ExceptionResultEnum.ERROR.exception("参数不完整");
- }
- gradePaperStructService.importGradePaperStruct(file, examId, paperNumber, paperType, paperName, requestUser);
- return ResultUtil.ok();
- }
- @ApiOperation(value = "成绩分析试卷结构-模板导出")
- @RequestMapping(value = "/export", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
- @OperationLogDetail(operationType = OperationTypeEnum.EXPORT)
- public Result gradePaperStructExport(@ApiParam(value = "考试id", required = true) @RequestParam Long examId, @ApiParam(value = "课程编号", required = true) @RequestParam String paperNumber,
- @ApiParam(value = "课程名称", required = true) @RequestParam String paperType) throws Exception {
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
- if (SystemConstant.isOneNull(examId, paperNumber, paperType)) {
- throw ExceptionResultEnum.ERROR.exception("参数不完整");
- }
- // List<MarkQuestionResult> markQuestionList = markQuestionService.listDetailByExamIdAndPaperNumberAndPaperType(
- // examId, paperNumber, paperType, null);
- gradePaperStructService.exportGradePaperStructTemplate(examId, paperNumber, paperType, requestUser,
- markQuestionService.listQuestionAnswerByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null));
- return ResultUtil.ok();
- }
- @ApiOperation(value = "成绩分析试卷结构-更新试卷机构")
- @RequestMapping(value = "/change_paper_structure", method = RequestMethod.POST)
- @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
- @OperationLogDetail(operationType = OperationTypeEnum.UPDATE)
- public Result updateExamCloudPaperStruct(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId, @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
- @ApiParam(value = "试卷类型") @RequestParam(required = false) String paperType) {
- if (SystemConstant.isOneNull(paperNumber)) {
- throw ExceptionResultEnum.ERROR.exception("缺少试卷编号");
- }
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
- List<MarkQuestionAnswerVo> markQuestionList = markQuestionService.listQuestionAnswerByExamIdAndPaperNumberAndPaperType(examId,
- paperNumber, paperType, null);
- gradePaperStructService.updateExamCloudPaperStruct(requestUser.getSchoolId(), paperNumber, paperType,
- markQuestionList);
- return ResultUtil.ok();
- }
- }
|