|
@@ -2,10 +2,25 @@ package com.qmth.themis.admin.api;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.qmth.themis.business.service.TEOpenService;
|
|
|
|
|
|
+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.common.exception.BusinessException;
|
|
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 io.swagger.annotations.*;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -13,6 +28,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 开放接口
|
|
* 开放接口
|
|
@@ -25,13 +42,29 @@ import java.io.IOException;
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/${prefix.url.open}")
|
|
@RequestMapping("/${prefix.url.open}")
|
|
public class TEOpenController {
|
|
public class TEOpenController {
|
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(TEOpenController.class);
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private TEOpenService openService;
|
|
private TEOpenService openService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TEExamService teExamService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ MqDtoService mqDtoService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TEExamCourseService teExamCourseService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TBTaskHistoryService taskHistoryService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ MqUtil mqUtil;
|
|
|
|
+
|
|
@ApiOperation(value = "获取考试详情")
|
|
@ApiOperation(value = "获取考试详情")
|
|
@RequestMapping(value = "/exam/query", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/exam/query", method = RequestMethod.POST)
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "结果信息") })
|
|
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
public Object examQueryPage(@ApiParam(value = "考试id", required = false) @RequestParam(required = false) Long id,
|
|
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 = "考试code", required = false) @RequestParam(required = false) String code,
|
|
@ApiParam(value = "分页页码", required = false) @RequestParam(required = false) Integer pageNumber,
|
|
@ApiParam(value = "分页页码", required = false) @RequestParam(required = false) Integer pageNumber,
|
|
@@ -47,7 +80,7 @@ public class TEOpenController {
|
|
|
|
|
|
@ApiOperation(value = "获取考试课程详情")
|
|
@ApiOperation(value = "获取考试课程详情")
|
|
@RequestMapping(value = "/exam/course/query", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/exam/course/query", method = RequestMethod.POST)
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "结果信息") })
|
|
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
public Object examCourseQueryPage(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
public Object examCourseQueryPage(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
@ApiParam(value = "课程code", required = false) @RequestParam(required = false) String courseCode,
|
|
@ApiParam(value = "课程code", required = false) @RequestParam(required = false) String courseCode,
|
|
@ApiParam(value = "是否有试卷", required = false) @RequestParam(required = false) Boolean hasPaper,
|
|
@ApiParam(value = "是否有试卷", required = false) @RequestParam(required = false) Boolean hasPaper,
|
|
@@ -68,7 +101,7 @@ public class TEOpenController {
|
|
|
|
|
|
@ApiOperation(value = "获取考试试卷详情")
|
|
@ApiOperation(value = "获取考试试卷详情")
|
|
@RequestMapping(value = "/exam/paper/detail", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/exam/paper/detail", method = RequestMethod.POST)
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "结果信息") })
|
|
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
public JSONObject examPaperDetail(@ApiParam(value = "试卷id", required = true) @RequestParam Long id,
|
|
public JSONObject examPaperDetail(@ApiParam(value = "试卷id", required = true) @RequestParam Long id,
|
|
@ApiParam(value = "内容过滤", required = false) @RequestParam(required = false) String filter)
|
|
@ApiParam(value = "内容过滤", required = false) @RequestParam(required = false) String filter)
|
|
throws IOException {
|
|
throws IOException {
|
|
@@ -81,7 +114,7 @@ public class TEOpenController {
|
|
|
|
|
|
@ApiOperation(value = "待评卷考试记录查询")
|
|
@ApiOperation(value = "待评卷考试记录查询")
|
|
@RequestMapping(value = "/exam/record/need_mark", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/exam/record/need_mark", method = RequestMethod.POST)
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "结果信息") })
|
|
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
public JSONArray examRecordNeedMark(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
public JSONArray examRecordNeedMark(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
@ApiParam(value = "课程代码", required = false) @RequestParam(required = false) String courseCode,
|
|
@ApiParam(value = "课程代码", required = false) @RequestParam(required = false) String courseCode,
|
|
@ApiParam(value = "考生ID大于此参数", required = false) @RequestParam(required = false) Long examStudentIdGt,
|
|
@ApiParam(value = "考生ID大于此参数", required = false) @RequestParam(required = false) Long examStudentIdGt,
|
|
@@ -94,4 +127,69 @@ public class TEOpenController {
|
|
}
|
|
}
|
|
return openService.examRecordNeedMark(examId, StringUtils.trimToNull(courseCode), examStudentIdGt, count);
|
|
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 = "课程编码", required = false) @RequestParam(required = false) String courseCode) {
|
|
|
|
+ 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(SystemConstant.EXAM_CODE, examCacheBean.getCode());
|
|
|
|
+ //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()));
|
|
|
|
+ }
|
|
}
|
|
}
|