|
@@ -2,21 +2,12 @@ package com.qmth.themis.admin.api;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
-import com.qmth.themis.business.constant.SystemConstant;
|
|
|
-import com.qmth.themis.business.dto.MqDto;
|
|
|
-import com.qmth.themis.business.entity.TBTaskHistory;
|
|
|
-import com.qmth.themis.business.entity.TBUser;
|
|
|
-import com.qmth.themis.business.entity.TEExamCourse;
|
|
|
-import com.qmth.themis.business.enums.*;
|
|
|
-import com.qmth.themis.business.service.*;
|
|
|
-import com.qmth.themis.business.util.MqUtil;
|
|
|
-import com.qmth.themis.business.util.ServletUtil;
|
|
|
-import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.themis.business.bean.admin.OpenExamBean;
|
|
|
+import com.qmth.themis.business.bean.admin.OpenExamCourseBean;
|
|
|
+import com.qmth.themis.business.bean.mobile.MobileAuthorizationBean;
|
|
|
+import com.qmth.themis.business.service.TEOpenService;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
import com.qmth.themis.common.util.Result;
|
|
|
-import com.qmth.themis.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -28,8 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 开放接口
|
|
@@ -47,24 +36,9 @@ public class TEOpenController {
|
|
|
@Resource
|
|
|
private TEOpenService openService;
|
|
|
|
|
|
- @Resource
|
|
|
- TEExamService teExamService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- MqDtoService mqDtoService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- TEExamCourseService teExamCourseService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- TBTaskHistoryService taskHistoryService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- MqUtil mqUtil;
|
|
|
-
|
|
|
@ApiOperation(value = "获取考试详情")
|
|
|
@RequestMapping(value = "/exam/query", method = RequestMethod.POST)
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试详情信息", response = OpenExamBean.class)})
|
|
|
public Object examQueryPage(@ApiParam(value = "考试id", required = false) @RequestParam(required = false) Long id,
|
|
|
@ApiParam(value = "考试code", required = false) @RequestParam(required = false) String code,
|
|
|
@ApiParam(value = "分页页码", required = false) @RequestParam(required = false) Integer pageNumber,
|
|
@@ -80,7 +54,7 @@ public class TEOpenController {
|
|
|
|
|
|
@ApiOperation(value = "获取考试课程详情")
|
|
|
@RequestMapping(value = "/exam/course/query", method = RequestMethod.POST)
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试课程详情信息", response = OpenExamCourseBean.class)})
|
|
|
public Object examCourseQueryPage(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
|
@ApiParam(value = "课程code", required = false) @RequestParam(required = false) String courseCode,
|
|
|
@ApiParam(value = "是否有试卷", required = false) @RequestParam(required = false) Boolean hasPaper,
|
|
@@ -95,13 +69,12 @@ public class TEOpenController {
|
|
|
if (pageSize > 100) {
|
|
|
pageSize = 100;
|
|
|
}
|
|
|
- return openService
|
|
|
- .examCourseQueryPage(examId, StringUtils.trimToNull(courseCode), hasPaper, pageNumber, pageSize);
|
|
|
+ return openService.examCourseQueryPage(examId, StringUtils.trimToNull(courseCode), hasPaper, pageNumber, pageSize);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取考试试卷详情")
|
|
|
@RequestMapping(value = "/exam/paper/detail", method = RequestMethod.POST)
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "结果信息", response = Result.class)})
|
|
|
public JSONObject examPaperDetail(@ApiParam(value = "试卷id", required = true) @RequestParam Long id,
|
|
|
@ApiParam(value = "内容过滤", required = false) @RequestParam(required = false) String filter)
|
|
|
throws IOException {
|
|
@@ -114,7 +87,7 @@ public class TEOpenController {
|
|
|
|
|
|
@ApiOperation(value = "待评卷考试记录查询")
|
|
|
@RequestMapping(value = "/exam/record/need_mark", method = RequestMethod.POST)
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "结果信息", response = Result.class)})
|
|
|
public JSONArray examRecordNeedMark(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
|
@ApiParam(value = "课程代码", required = false) @RequestParam(required = false) String courseCode,
|
|
|
@ApiParam(value = "考生ID大于此参数", required = false) @RequestParam(required = false) Long examStudentIdGt,
|
|
@@ -127,74 +100,4 @@ public class TEOpenController {
|
|
|
}
|
|
|
return openService.examRecordNeedMark(examId, StringUtils.trimToNull(courseCode), examStudentIdGt, count);
|
|
|
}
|
|
|
-
|
|
|
- @ApiOperation(value = "成绩查询同步")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "成绩查询同步信息", response = Result.class)})
|
|
|
- @RequestMapping(value = "/score/sync", method = RequestMethod.POST)
|
|
|
- public Result scoreSync(@ApiParam(value = "考试ID", required = true) @RequestParam String examId,
|
|
|
- @ApiParam(value = "云阅卷考试id", required = true) @RequestParam String yunMarkExamId,
|
|
|
- @ApiParam(value = "accessKey", required = false) @RequestParam(required = false) String accessKey,
|
|
|
- @ApiParam(value = "accessSecret", required = false) @RequestParam(required = false) String accessSecret) {
|
|
|
- TBTaskHistory tbTaskHistory = null;
|
|
|
- try {
|
|
|
- ExamCacheBean examCacheBean = teExamService.getExamCacheBean(Long.parseLong(examId));
|
|
|
- Optional.ofNullable(examCacheBean).orElseThrow(() -> new BusinessException(ExceptionResultEnum.EXAM_NO));
|
|
|
- InvigilateMonitorStatusEnum invigilateMonitorStatusEnum = examCacheBean.getMonitorStatus();//监考状态
|
|
|
- if (Objects.nonNull(invigilateMonitorStatusEnum) && !Objects
|
|
|
- .equals(invigilateMonitorStatusEnum, InvigilateMonitorStatusEnum.FINISHED)) {
|
|
|
- throw new BusinessException("当前批次监考未结束,请在结束后操作");
|
|
|
- }
|
|
|
- ScoreStatusEnum scoreStatusEnum = examCacheBean.getScoreStatus();//算分状态
|
|
|
- if (Objects.nonNull(scoreStatusEnum) && (Objects.equals(scoreStatusEnum, ScoreStatusEnum.CALCULATING) || Objects
|
|
|
- .equals(scoreStatusEnum, ScoreStatusEnum.NEED_CALCULATE))) {
|
|
|
- throw new BusinessException("当前批次算分未结束,请在结束后操作");
|
|
|
- }
|
|
|
- QueryWrapper<TEExamCourse> teExamCourseQueryWrapper = new QueryWrapper<>();
|
|
|
- teExamCourseQueryWrapper.lambda().eq(TEExamCourse::getExamId, examId);
|
|
|
- List<TEExamCourse> teExamCourseList = teExamCourseService.list(teExamCourseQueryWrapper);
|
|
|
- Set answerList = null;
|
|
|
- if (Objects.nonNull(teExamCourseList) && teExamCourseList.size() > 0) {
|
|
|
- answerList = teExamCourseList.stream().filter(s -> {
|
|
|
- if (Objects.nonNull(s.getHasAnswer()) && s.getHasAnswer().intValue() == 0) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }).collect(Collectors.toSet());
|
|
|
- }
|
|
|
- if (Objects.nonNull(answerList) && answerList.size() > 0) {
|
|
|
- throw new BusinessException("当前批次标答未补齐,请补齐后操作");
|
|
|
- }
|
|
|
-
|
|
|
- Map transMap = new HashMap();
|
|
|
- TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
- //往任务表里插一条数据
|
|
|
- tbTaskHistory = new TBTaskHistory(TaskTypeEnum.SCORE_PUSH, TaskStatusEnum.INIT,
|
|
|
- SystemConstant.SCORE_PUSH_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
|
|
|
- tbTaskHistory.setExamId(Long.parseLong(examId));
|
|
|
- taskHistoryService.save(tbTaskHistory);
|
|
|
-
|
|
|
- transMap.put("tbTaskHistory", tbTaskHistory);
|
|
|
- transMap.put(SystemConstant.CREATE_ID, tbUser.getId());
|
|
|
- transMap.put(SystemConstant.ORG_ID, tbUser.getOrgId());
|
|
|
- transMap.put(SystemConstant.EXAM_ID, Long.parseLong(examId));
|
|
|
- transMap.put("yunMarkExamId", Long.parseLong(yunMarkExamId));
|
|
|
- transMap.put(SystemConstant.EXAM_CODE, examCacheBean.getCode());
|
|
|
- transMap.put(SystemConstant.ACCESS_KEY_ID, accessKey);
|
|
|
- transMap.put(SystemConstant.ACCESS_KEY_SECRET, accessSecret);
|
|
|
- //mq发送消息start
|
|
|
- MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.MARK_CLOUD_SCORE_PUSH.name(),
|
|
|
- transMap, MqTagEnum.MARK_CLOUD_SCORE_PUSH, String.valueOf(tbTaskHistory.getId()),
|
|
|
- tbUser.getName());
|
|
|
- mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(SystemConstant.LOG_ERROR, e);
|
|
|
- if (e instanceof BusinessException) {
|
|
|
- throw new BusinessException(e.getMessage());
|
|
|
- } else {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- }
|
|
|
- return ResultUtil.ok(Collections.singletonMap(SystemConstant.TASK_ID, tbTaskHistory.getId()));
|
|
|
- }
|
|
|
}
|