|
@@ -1,42 +1,37 @@
|
|
|
package com.qmth.themis.backend.api;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.themis.business.annotation.ApiJsonObject;
|
|
|
import com.qmth.themis.business.annotation.ApiJsonProperty;
|
|
|
import com.qmth.themis.business.bean.backend.InvigilateListQueryBean;
|
|
|
+import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
|
import com.qmth.themis.business.entity.TBUser;
|
|
|
-import com.qmth.themis.business.enums.FinishTypeEnum;
|
|
|
-import com.qmth.themis.business.enums.MqEnum;
|
|
|
-import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
-import com.qmth.themis.business.enums.MqTopicEnum;
|
|
|
+import com.qmth.themis.business.entity.TEExamBreachLog;
|
|
|
+import com.qmth.themis.business.enums.*;
|
|
|
import com.qmth.themis.business.service.MqDtoService;
|
|
|
+import com.qmth.themis.business.service.TEExamBreachLogService;
|
|
|
import com.qmth.themis.business.util.JacksonUtil;
|
|
|
+import com.qmth.themis.business.util.RedisUtil;
|
|
|
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.util.Result;
|
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
-import io.swagger.annotations.ApiResponse;
|
|
|
-import io.swagger.annotations.ApiResponses;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* @Description: 监考信息 前端控制器
|
|
@@ -54,6 +49,12 @@ public class TIeInvigilateController {
|
|
|
@Resource
|
|
|
MqDtoService mqDtoService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TEExamBreachLogService teExamBreachLogService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ RedisUtil redisUtil;
|
|
|
+
|
|
|
@ApiOperation(value = "实时监控台列表接口")
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
public Result list(@RequestBody InvigilateListQueryBean param) {
|
|
@@ -72,21 +73,76 @@ public class TIeInvigilateController {
|
|
|
@RequestMapping(value = "/finish", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
public Result finish(@ApiJsonObject(name = "invigilateFinish", value = {
|
|
|
- @ApiJsonProperty(key = "examRecordId", description = "考试记录id"),
|
|
|
+ @ApiJsonProperty(key = "examRecordId", type = "long", example = "1", description = "考试记录id"),
|
|
|
@ApiJsonProperty(key = "type", description = "收卷类型,手动/强制")
|
|
|
}) @ApiParam(value = "考试记录信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
- if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
|
|
|
+ if (Objects.isNull(mapParameter.get("examRecordId")) || Objects.equals(mapParameter.get("examRecordId"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
|
|
|
}
|
|
|
- List<Long> recordIdList = (List<Long>) mapParameter.get("recordId");
|
|
|
+ List<Long> recordIdList = (List<Long>) mapParameter.get("examRecordId");
|
|
|
if (Objects.isNull(mapParameter.get("type")) || Objects.equals(mapParameter.get("type"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.FINISH_TYPE_IS_NULL);
|
|
|
}
|
|
|
FinishTypeEnum type = FinishTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
|
|
|
TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
- //发送mq给客户端强制收卷
|
|
|
+ //发送mq给客户端强制收卷start
|
|
|
MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.oe.name(), JacksonUtil.parseJson(recordIdList), type.ordinal() == FinishTypeEnum.INTERRUPT.ordinal() ? MqEnum.WEBSOCKET_MONITOR_FINISH_LOG : MqEnum.WEBSOCKET_HAND_FINISH_LOG, String.valueOf(tbUser.getId()), mapParameter, tbUser.getName());
|
|
|
mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
+ //发送mq给客户端强制收卷end
|
|
|
+ return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "违纪处理接口")
|
|
|
+ @RequestMapping(value = "/breach", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result breach(@ApiJsonObject(name = "invigilateBreach", value = {
|
|
|
+ @ApiJsonProperty(key = "examRecordId", type = "long", example = "1", description = "考试记录id"),
|
|
|
+ @ApiJsonProperty(key = "type", description = "违规类型"),
|
|
|
+ @ApiJsonProperty(key = "description", description = "描述"),
|
|
|
+ @ApiJsonProperty(key = "status", type = "int", example = "1", description = "新建/撤销")
|
|
|
+ }) @ApiParam(value = "考试记录信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
+ if (Objects.isNull(mapParameter.get("examRecordId")) || Objects.equals(mapParameter.get("examRecordId"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ List<Long> recordIdList = (List<Long>) mapParameter.get("examRecordId");
|
|
|
+ if (Objects.isNull(mapParameter.get("type")) || Objects.equals(mapParameter.get("type"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.BREACH_TYPE_IS_NULL);
|
|
|
+ }
|
|
|
+ BreachTypeEnum type = BreachTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
|
|
|
+ if (Objects.isNull(mapParameter.get("description")) || Objects.equals(mapParameter.get("description"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.BREACH_DESC_IS_NULL);
|
|
|
+ }
|
|
|
+ String description = String.valueOf(mapParameter.get("description"));
|
|
|
+ if (Objects.isNull(mapParameter.get("status")) || Objects.equals(mapParameter.get("status"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.BREACH_STATUS_IS_NULL);
|
|
|
+ }
|
|
|
+ Integer status = Integer.parseInt(String.valueOf(mapParameter.get("status")));
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ List<TEExamBreachLog> teExamBreachLogList = new ArrayList<>();
|
|
|
+ if (status == 1) {//新建违纪
|
|
|
+ List<TEExamBreachLog> finalTeExamBreachLogList = teExamBreachLogList;
|
|
|
+ recordIdList.forEach(s -> {
|
|
|
+ Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(s));
|
|
|
+ Long examId = Long.parseLong(String.valueOf(objectMap.get("examId")));
|
|
|
+ Long examStudentId = Long.parseLong(String.valueOf(objectMap.get("examStudentId")));
|
|
|
+ Long examActivityId = Long.parseLong(String.valueOf(objectMap.get("examActivityId")));
|
|
|
+ TEExamBreachLog teExamBreachLog = new TEExamBreachLog(examId, examActivityId, s, examStudentId, type, description, status);
|
|
|
+ teExamBreachLog.setCreateId(tbUser.getId());
|
|
|
+ finalTeExamBreachLogList.add(teExamBreachLog);
|
|
|
+ });
|
|
|
+ } else {//撤销违纪
|
|
|
+ QueryWrapper<TEExamBreachLog> teExamBreachLogQueryWrapper = new QueryWrapper<>();
|
|
|
+ teExamBreachLogQueryWrapper.lambda().in(TEExamBreachLog::getExamRecordId, recordIdList);
|
|
|
+ teExamBreachLogList = teExamBreachLogService.list(teExamBreachLogQueryWrapper);
|
|
|
+ teExamBreachLogList.forEach(s -> {
|
|
|
+ s.setType(type);
|
|
|
+ s.setDescription(description);
|
|
|
+ s.setStatus(status);
|
|
|
+ s.setUpdateId(tbUser.getId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ teExamBreachLogService.saveOrUpdateBatch(teExamBreachLogList);
|
|
|
+ //todo 这里是否需要收卷处理
|
|
|
return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
}
|
|
|
|
|
@@ -94,16 +150,22 @@ public class TIeInvigilateController {
|
|
|
@RequestMapping(value = "/notice", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
public Result notice(@ApiJsonObject(name = "invigilateNotice", value = {
|
|
|
- @ApiJsonProperty(key = "recordId", description = "考试记录id"),
|
|
|
- @ApiJsonProperty(key = "type", description = "消息类型,text/audio")
|
|
|
+ @ApiJsonProperty(key = "examRecordId", type = "long", example = "1", description = "考试记录id"),
|
|
|
+ @ApiJsonProperty(key = "type", description = "消息类型,text/audio"),
|
|
|
+ @ApiJsonProperty(key = "content", description = "消息内容")
|
|
|
}) @ApiParam(value = "考试记录信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
- if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
|
|
|
+ if (Objects.isNull(mapParameter.get("examRecordId")) || Objects.equals(mapParameter.get("examRecordId"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
|
|
|
}
|
|
|
- Long recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
|
|
|
+ Long recordId = Long.parseLong(String.valueOf(mapParameter.get("examRecordId")));
|
|
|
if (Objects.isNull(mapParameter.get("type")) || Objects.equals(mapParameter.get("type"), "")) {
|
|
|
- throw new BusinessException(ExceptionResultEnum.FINISH_TYPE_IS_NULL);
|
|
|
+ throw new BusinessException(ExceptionResultEnum.MESSAGE_TYPE_IS_NULL);
|
|
|
}
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ //发送mq给客户端监考消息start
|
|
|
+ MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.oe.name(), recordId, MqEnum.WEBSOCKET_IM_CLUSTERING_LOG, String.valueOf(tbUser.getId()), mapParameter, tbUser.getName());
|
|
|
+ mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
+ //发送mq给客户端监考消息end
|
|
|
return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
}
|
|
|
}
|