|
@@ -1,13 +1,10 @@
|
|
|
-package com.qmth.themis.backend.api;
|
|
|
+package com.qmth.themis.admin.api;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.qmth.themis.business.annotation.ApiJsonObject;
|
|
|
import com.qmth.themis.business.annotation.ApiJsonProperty;
|
|
|
-import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
|
-import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
|
import com.qmth.themis.business.dto.ExamPropCountDto;
|
|
@@ -16,10 +13,7 @@ import com.qmth.themis.business.dto.request.TEExamDto;
|
|
|
import com.qmth.themis.business.entity.*;
|
|
|
import com.qmth.themis.business.enums.*;
|
|
|
import com.qmth.themis.business.service.*;
|
|
|
-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.business.util.UidUtil;
|
|
|
+import com.qmth.themis.business.util.*;
|
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
import com.qmth.themis.common.util.Result;
|
|
@@ -72,13 +66,25 @@ public class TEExamController {
|
|
|
@Resource
|
|
|
UidUtil uidUtil;
|
|
|
|
|
|
+ @Resource
|
|
|
+ MqUtil mqUtil;
|
|
|
+
|
|
|
@Resource
|
|
|
TBTaskHistoryService taskHistoryService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TEExamPaperService examPaperService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CacheService cacheService;
|
|
|
+
|
|
|
@ApiOperation(value = "考试批次修改/新增接口")
|
|
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
@Transactional
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
public Result save(@ApiParam(value = "考试批次信息", required = true) @RequestBody TEExamDto teExamDto) {
|
|
|
if (Objects.isNull(teExamDto) || Objects.equals(teExamDto, "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_INFO_IS_NULL);
|
|
@@ -98,31 +104,44 @@ public class TEExamController {
|
|
|
try {
|
|
|
TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
|
|
|
- if (Objects.nonNull(tbOrg)) {
|
|
|
- if (Objects.isNull(tbOrg.getId())) {
|
|
|
- throw new BusinessException("考试的机构id不允许为空");
|
|
|
- }
|
|
|
- teExamDto.setOrgId(tbOrg.getId());
|
|
|
+ if (Objects.nonNull(tbOrg) && Objects.isNull(tbOrg.getId())) {
|
|
|
+ throw new BusinessException("考试的机构id不允许为空");
|
|
|
}
|
|
|
+ teExamDto.setOrgId(tbOrg.getId());
|
|
|
oldId = teExamDto.getId();
|
|
|
TEExam oldTeExam = null;
|
|
|
if (Objects.nonNull(oldId)) {
|
|
|
teExamDto.setUpdateId(tbUser.getId());
|
|
|
- oldTeExam = teExamService.getById(oldId);
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(oldId);
|
|
|
+ oldTeExam = teExamService.cacheConvert(examCacheBean);
|
|
|
+ if (Objects.equals(oldTeExam.getMonitorStatus(), InvigilateMonitorStatusEnum.FINISHED)) {
|
|
|
+ throw new BusinessException("监考结束的考试批次不可以修改");
|
|
|
+ }
|
|
|
+ boolean recordUpdate = true;
|
|
|
+ if ((Objects.nonNull(oldTeExam.getRecordSelectStrategy()) && Objects.nonNull(teExamDto.getRecordSelectStrategy()) && !Objects.equals(oldTeExam.getRecordSelectStrategy(), teExamDto.getRecordSelectStrategy()))) {
|
|
|
+ recordUpdate = false;
|
|
|
+ }
|
|
|
+ boolean objectiveUpdate = true;
|
|
|
+ if ((Objects.nonNull(oldTeExam.getObjectiveScorePolicy()) && Objects.nonNull(teExamDto.getObjectiveScorePolicy()) && !Objects.equals(oldTeExam.getObjectiveScorePolicy(), teExamDto.getObjectiveScorePolicy()))) {
|
|
|
+ objectiveUpdate = false;
|
|
|
+ }
|
|
|
+ QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
|
|
|
+ tOeExamRecordQueryWrapper.lambda().eq(TOeExamRecord::getExamId, oldId);
|
|
|
+ int count = tOeExamRecordService.count(tOeExamRecordQueryWrapper);
|
|
|
+ if (count > 0) {
|
|
|
+ if (!recordUpdate) {
|
|
|
+ throw new BusinessException("已有考试记录,取分策略不允许修改");
|
|
|
+ }
|
|
|
+ if (!objectiveUpdate) {
|
|
|
+ throw new BusinessException("已有考试记录,客观题判分策略不允许修改");
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
teExamDto.setId(uidUtil.getId());
|
|
|
teExamDto.setCreateId(tbUser.getId());
|
|
|
}
|
|
|
+ teExamDto.setMonitorStatus(Objects.nonNull(oldTeExam) ? oldTeExam.getMonitorStatus() : InvigilateMonitorStatusEnum.NOT_START);
|
|
|
teExam = new TEExam(teExamDto);
|
|
|
- if (oldTeExam != null) {
|
|
|
- teExam.setMonitorStatus(oldTeExam.getMonitorStatus());
|
|
|
- } else {
|
|
|
- teExam.setMonitorStatus(InvigilateMonitorStatusEnum.NOT_START);
|
|
|
- }
|
|
|
- if (Objects.nonNull(teExam.getMonitorStatus()) && Objects
|
|
|
- .equals(teExam.getMonitorStatus(), InvigilateMonitorStatusEnum.FINISHED)) {
|
|
|
- throw new BusinessException("监考结束的考试批次不可以修改");
|
|
|
- }
|
|
|
teExamService.saveOrUpdate(teExam);
|
|
|
if (Objects.nonNull(oldTeExam) && !Objects
|
|
|
.equals(oldTeExam.getMode().name(), teExamDto.getMode().name())) {//如果模式改变,则删除之前模式的全部quartz
|
|
@@ -134,10 +153,10 @@ public class TEExamController {
|
|
|
Map<String, Object> prop = new HashMap<>();
|
|
|
prop.put("oper", "delete");
|
|
|
if (Objects.nonNull(teExamActivityList.get(0)) && teExamActivityList.get(0).getEnable() == 1) {
|
|
|
- MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_ACTIVITY.name(),
|
|
|
+ MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.EXAM_ACTIVITY.name(),
|
|
|
JacksonUtil.parseJson(teExamActivityList), MqTagEnum.EXAM_ACTIVITY,
|
|
|
String.valueOf(teExam.getId()), prop, tbUser.getName());
|
|
|
- mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
+ mqDtoService.assembleSendOneOrderMsg(mqDto);
|
|
|
}
|
|
|
//删除quartz任务,发送mq消息end
|
|
|
//删除数据
|
|
@@ -169,10 +188,10 @@ public class TEExamController {
|
|
|
Map<String, Object> prop = new HashMap<>();
|
|
|
prop.put("oper", "insert");
|
|
|
prop.put("exam", teExam);
|
|
|
- MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_ACTIVITY.name(),
|
|
|
+ MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.EXAM_ACTIVITY.name(),
|
|
|
JacksonUtil.parseJson(teExamActivityList), MqTagEnum.EXAM_ACTIVITY,
|
|
|
String.valueOf(teExam.getId()), prop, tbUser.getName());
|
|
|
- mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
+ mqDtoService.assembleSendOneOrderMsg(mqDto);
|
|
|
//新增quartz任务,发送mq消息end
|
|
|
}
|
|
|
} else {
|
|
@@ -191,10 +210,10 @@ public class TEExamController {
|
|
|
Map<String, Object> prop = new HashMap<>();
|
|
|
prop.put("oper", "insert");
|
|
|
prop.put("exam", teExam);
|
|
|
- MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_ACTIVITY.name(),
|
|
|
+ MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.EXAM_ACTIVITY.name(),
|
|
|
JacksonUtil.parseJson(Arrays.asList(teExamActivity)), MqTagEnum.EXAM_ACTIVITY,
|
|
|
String.valueOf(teExam.getId()), prop, tbUser.getName());
|
|
|
- mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
+ mqDtoService.assembleSendOneOrderMsg(mqDto);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -216,15 +235,16 @@ public class TEExamController {
|
|
|
}
|
|
|
}
|
|
|
teExamService.updateExamCacheBean(teExam.getId());
|
|
|
- return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ examPaperService.disposeObjectiveAnswer(teExam.getId());
|
|
|
+ return ResultUtil.ok(true);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "考试批次统计接口")
|
|
|
@RequestMapping(value = "/count", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "{\"count\":1}", response = Result.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"count\":1}", response = Result.class)})
|
|
|
public Result count(@ApiParam(value = "考试批次编码", required = false) @RequestParam(required = false) String code,
|
|
|
- @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
|
|
|
- @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) Integer mode) {
|
|
|
+ @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
|
|
|
+ @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) Integer mode) {
|
|
|
QueryWrapper<TEExam> teExamQueryWrapper = new QueryWrapper<>();
|
|
|
if (Objects.nonNull(code)) {
|
|
|
teExamQueryWrapper.lambda().eq(TEExam::getCode, code);
|
|
@@ -241,18 +261,18 @@ public class TEExamController {
|
|
|
|
|
|
@ApiOperation(value = "考试批次查询接口")
|
|
|
@RequestMapping(value = "/query", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class)})
|
|
|
public Result query(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId,
|
|
|
- @ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long id,
|
|
|
- @ApiParam(value = "考试批次编码", required = false) @RequestParam(required = false) String code,
|
|
|
- @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
|
|
|
- @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) String mode,
|
|
|
- @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
|
|
|
- @ApiParam(value = "类型(区分实时监考台和考务)", required = false) @RequestParam(required = false) String type,
|
|
|
- @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
|
|
|
- @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
|
|
|
+ @ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long id,
|
|
|
+ @ApiParam(value = "考试批次编码", required = false) @RequestParam(required = false) String code,
|
|
|
+ @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
|
|
|
+ @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) String mode,
|
|
|
+ @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
|
|
|
+ @ApiParam(value = "类型(区分实时监考台和考务)", required = false) @RequestParam(required = false) String type,
|
|
|
+ @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
|
|
|
+ @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
|
|
|
TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
- AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
|
|
|
+ AuthDto authDto = cacheService.addAccountAuthCache(tbUser.getId());
|
|
|
if (authDto.getRoleCodes().toString().contains(RoleEnum.INSPECTION.name())) {
|
|
|
userId = null;
|
|
|
}
|
|
@@ -263,11 +283,11 @@ public class TEExamController {
|
|
|
|
|
|
@ApiOperation(value = "考试批次停用/启用接口")
|
|
|
@RequestMapping(value = "/toggle", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
@Transactional
|
|
|
public Result examToggle(@ApiJsonObject(name = "examToggle", value = {
|
|
|
@ApiJsonProperty(key = "id", type = "long", example = "1", description = "考试批次ID"),
|
|
|
- @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用") }) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
+ @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")}) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
if (Objects.isNull(mapParameter.get("id")) || Objects.equals(mapParameter.get("id"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
}
|
|
@@ -276,40 +296,41 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.ENABLE_IS_NULL);
|
|
|
}
|
|
|
Integer enable = Integer.parseInt(String.valueOf(mapParameter.get("enable")));
|
|
|
- TEExam teExam = teExamService.getById(examId);
|
|
|
- if (Objects.isNull(teExam)) {
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
|
+ if (Objects.isNull(examCacheBean)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_NO);
|
|
|
}
|
|
|
+ TEExam teExam = teExamService.cacheConvert(examCacheBean);
|
|
|
TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
teExam.setEnable(enable);
|
|
|
teExam.setUpdateId(tbUser.getId());
|
|
|
teExamService.updateById(teExam);
|
|
|
teExamService.updateExamCacheBean(teExam.getId());
|
|
|
- return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ return ResultUtil.ok(true);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "考试批次详情接口")
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class)})
|
|
|
public Result detail(@ApiParam(value = "考试批次id", required = true) @RequestParam Long id) {
|
|
|
if (Objects.isNull(id) || Objects.equals(id, "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
}
|
|
|
- TEExam teExam = teExamService.getById(id);
|
|
|
- if (Objects.isNull(teExam)) {
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(id);
|
|
|
+ if (Objects.isNull(examCacheBean)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_NO);
|
|
|
}
|
|
|
- return ResultUtil.ok(new TEExamDto(teExam));
|
|
|
+ return ResultUtil.ok(new TEExamDto(teExamService.cacheConvert(examCacheBean)));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "考试批次复制接口")
|
|
|
@RequestMapping(value = "/copy", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
@Transactional
|
|
|
public Result copy(@ApiJsonObject(name = "examCopy", value = {
|
|
|
@ApiJsonProperty(key = "sourceId", type = "long", example = "1", description = "来源批次ID"),
|
|
|
@ApiJsonProperty(key = "code", description = "代码"),
|
|
|
- @ApiJsonProperty(key = "name", description = "名称") }) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
+ @ApiJsonProperty(key = "name", description = "名称")}) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
if (Objects.isNull(mapParameter.get("sourceId")) || Objects.equals(mapParameter.get("sourceId"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
}
|
|
@@ -322,10 +343,11 @@ public class TEExamController {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_NAME_IS_NULL);
|
|
|
}
|
|
|
String name = String.valueOf(mapParameter.get("name"));
|
|
|
- TEExam teExam = teExamService.getById(examId);
|
|
|
- if (Objects.isNull(teExam)) {
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
|
+ if (Objects.isNull(examCacheBean)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_NO);
|
|
|
}
|
|
|
+ TEExam teExam = teExamService.cacheConvert(examCacheBean);
|
|
|
List<TEExamActivity> teExamActivityList = null;
|
|
|
try {
|
|
|
teExam.setId(null);
|
|
@@ -374,12 +396,12 @@ public class TEExamController {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
- return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
|
+ return ResultUtil.ok(true);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "监考端获取考试批次提醒接口")
|
|
|
@RequestMapping(value = "/list/count", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = Result.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = Result.class)})
|
|
|
public Result listCount(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId) {
|
|
|
TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
return ResultUtil.ok(teExamService.examList(userId, tbUser.getOrgId()));
|
|
@@ -387,7 +409,7 @@ public class TEExamController {
|
|
|
|
|
|
@ApiOperation(value = "考试属性统计接口")
|
|
|
@RequestMapping(value = "/prop/count", method = RequestMethod.POST)
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "考试属性信息", response = ExamPropCountDto.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试属性信息", response = ExamPropCountDto.class)})
|
|
|
public Result propCount(@ApiParam(value = "考试id", required = true) @RequestParam Long examId) {
|
|
|
if (Objects.isNull(examId) || Objects.equals(examId, "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
@@ -399,7 +421,7 @@ public class TEExamController {
|
|
|
}
|
|
|
//首先查询当前用户所要监控的roomCode
|
|
|
QueryWrapper<TBExamInvigilateUser> examInvigilateUserQueryWrapper = new QueryWrapper<>();
|
|
|
- AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
|
|
|
+ AuthDto authDto = cacheService.addAccountAuthCache(tbUser.getId());
|
|
|
//如果有监考员角色,只能查看自己所监考的考场,巡考员和管理员则可以查看全部考场
|
|
|
examInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getOrgId, tbUser.getOrgId())
|
|
|
.eq(TBExamInvigilateUser::getExamId, examId);
|
|
@@ -448,66 +470,60 @@ public class TEExamController {
|
|
|
alreadyComplete = new HashSet<>();
|
|
|
//获取已待考、考试中、已完成学生
|
|
|
Set<Long> finalAlreadyComplete = alreadyComplete;
|
|
|
- examActivityIdSet.forEach(s -> {
|
|
|
- Map<String, Object> objectMap = redisUtil
|
|
|
- .getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(s));
|
|
|
- if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
- objectMap.forEach((k, v) -> {
|
|
|
- Long recordId = Long.parseLong(k);
|
|
|
- ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCacheBean.getStatus();
|
|
|
- ExamStudentCacheBean examStudentCacheBean = teExamStudentService
|
|
|
- .getExamStudentCacheBean(examActivityRecordCacheBean.getExamStudentId());
|
|
|
- if (Objects.nonNull(examStudentCacheBean)
|
|
|
- && examStudentCacheBean.getEnable().intValue() == 1 && Objects
|
|
|
- .nonNull(examRecordStatusEnum) && !Objects
|
|
|
- .equals(examRecordStatusEnum, ExamRecordStatusEnum.PERSISTED) && !Objects
|
|
|
- .equals(examRecordStatusEnum, ExamRecordStatusEnum.FINISHED)) {
|
|
|
- //客户端通讯状态
|
|
|
- WebsocketStatusEnum clientStatus = Objects
|
|
|
- .isNull(ExamRecordCacheUtil.getClientWebsocketStatus(recordId)) ?
|
|
|
- null :
|
|
|
- ExamRecordCacheUtil.getClientWebsocketStatus(recordId);
|
|
|
- if (Objects.nonNull(clientStatus) && Objects
|
|
|
- .equals(clientStatus, WebsocketStatusEnum.OFF_LINE)) {
|
|
|
- clientWebsocketStatusCount.getAndSet(clientWebsocketStatusCount.get() + 1);
|
|
|
- }
|
|
|
- //监控端通讯状态
|
|
|
- MonitorVideoSourceEnum source = null;
|
|
|
- if (Objects.nonNull(ExamRecordCacheUtil.getMonitorLiveUrlClientCamera(recordId))) {
|
|
|
- source = MonitorVideoSourceEnum.CLIENT_CAMERA;
|
|
|
- } else if (Objects
|
|
|
- .nonNull(ExamRecordCacheUtil.getMonitorLiveUrlClientScreen(recordId))) {
|
|
|
- source = MonitorVideoSourceEnum.CLIENT_SCREEN;
|
|
|
- } else if (Objects
|
|
|
- .nonNull(ExamRecordCacheUtil.getMonitorLiveUrlMobileFirst(recordId))) {
|
|
|
- source = MonitorVideoSourceEnum.MOBILE_FIRST;
|
|
|
- } else if (Objects
|
|
|
- .nonNull(ExamRecordCacheUtil.getMonitorLiveUrlMobileSecond(recordId))) {
|
|
|
- source = MonitorVideoSourceEnum.MOBILE_SECOND;
|
|
|
- }
|
|
|
- MonitorStatusSourceEnum status = Objects.isNull(source) ?
|
|
|
- null :
|
|
|
- ExamRecordCacheUtil.getMonitorStatus(recordId, source);
|
|
|
- if (Objects.nonNull(status) && Objects.equals(status, MonitorStatusSourceEnum.STOP)) {
|
|
|
- monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- //已待考
|
|
|
- if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FIRST_PREPARE)) {
|
|
|
- prepareCount.getAndSet(prepareCount.get() + 1);
|
|
|
- }
|
|
|
- //考试中
|
|
|
- else if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.ANSWERING)) {
|
|
|
- examCount.getAndSet(examCount.get() + 1);
|
|
|
- }
|
|
|
- //已完成
|
|
|
- else if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FINISHED) || Objects
|
|
|
- .equals(examRecordStatusEnum, ExamRecordStatusEnum.PERSISTED)) {
|
|
|
- finalAlreadyComplete.add(examActivityRecordCacheBean.getExamStudentId());
|
|
|
- }
|
|
|
- });
|
|
|
+ QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
|
|
|
+ tOeExamRecordQueryWrapper.lambda().in(TOeExamRecord::getExamActivityId, examActivityIdSet);
|
|
|
+ List<TOeExamRecord> examRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
|
|
|
+ examRecordList.forEach(s -> {
|
|
|
+// Map<String, Object> objectMap = redisUtil
|
|
|
+// .getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(s));
|
|
|
+// if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
+// objectMap.forEach((k, v) -> {
|
|
|
+// Long recordId = Long.parseLong(k);
|
|
|
+// ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
|
|
|
+ ExamRecordStatusEnum examRecordStatusEnum = s.getStatus();
|
|
|
+// ExamStudentCacheBean examStudentCacheBean = teExamStudentService
|
|
|
+// .getExamStudentCacheBean(examActivityRecordCacheBean.getExamStudentId());
|
|
|
+// if (Objects.nonNull(examStudentCacheBean)
|
|
|
+// && examStudentCacheBean.getEnable().intValue() == 1) {
|
|
|
+ //客户端通讯状态
|
|
|
+ WebsocketStatusEnum clientStatus = Objects.isNull(s.getClientWebsocketStatus()) ? null : s.getClientWebsocketStatus();
|
|
|
+ if (Objects
|
|
|
+ .nonNull(examRecordStatusEnum) && !Objects
|
|
|
+ .equals(examRecordStatusEnum, ExamRecordStatusEnum.PERSISTED) && !Objects
|
|
|
+ .equals(examRecordStatusEnum, ExamRecordStatusEnum.FINISHED)) {
|
|
|
+ if (Objects.nonNull(clientStatus) && Objects
|
|
|
+ .equals(clientStatus, WebsocketStatusEnum.OFF_LINE)) {
|
|
|
+ clientWebsocketStatusCount.getAndSet(clientWebsocketStatusCount.get() + 1);
|
|
|
+ }
|
|
|
+ //监控端通讯状态
|
|
|
+ if (Objects.nonNull(s.getCameraMonitorStatus()) && Objects.equals(s.getCameraMonitorStatus(), MonitorStatusSourceEnum.STOP)) {
|
|
|
+ monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
|
|
|
+ } else if (Objects.nonNull(s.getScreenMonitorStatus()) && Objects.equals(s.getScreenMonitorStatus(), MonitorStatusSourceEnum.STOP)) {
|
|
|
+ monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
|
|
|
+ } else if (Objects.nonNull(s.getMobileFirstMonitorStatus()) && Objects.equals(s.getMobileFirstMonitorStatus(), MonitorStatusSourceEnum.STOP)) {
|
|
|
+ monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
|
|
|
+ } else if (Objects.nonNull(s.getMobileSecondMonitorStatus()) && Objects.equals(s.getMobileSecondMonitorStatus(), MonitorStatusSourceEnum.STOP)) {
|
|
|
+ monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //已待考
|
|
|
+ if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FIRST_PREPARE) && Objects.nonNull(clientStatus) && Objects
|
|
|
+ .equals(clientStatus, WebsocketStatusEnum.ON_LINE)) {
|
|
|
+ prepareCount.getAndSet(prepareCount.get() + 1);
|
|
|
+ }
|
|
|
+ //考试中
|
|
|
+ else if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.ANSWERING) && Objects.nonNull(clientStatus) && Objects
|
|
|
+ .equals(clientStatus, WebsocketStatusEnum.ON_LINE)) {
|
|
|
+ examCount.getAndSet(examCount.get() + 1);
|
|
|
+ }
|
|
|
+ //已完成
|
|
|
+ else if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FINISHED) || Objects
|
|
|
+ .equals(examRecordStatusEnum, ExamRecordStatusEnum.PERSISTED)) {
|
|
|
+ finalAlreadyComplete.add(s.getExamStudentId());
|
|
|
}
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
});
|
|
|
}
|
|
|
notComplete = allCount - alreadyComplete.size();
|
|
@@ -526,10 +542,11 @@ public class TEExamController {
|
|
|
@ApiOperation(value = "考试重新算分")
|
|
|
@RequestMapping(value = "/score/calculate", method = RequestMethod.POST)
|
|
|
@Transactional
|
|
|
- @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
|
|
|
public Result scoreCalculate(@ApiParam(value = "批次ID", required = true) @RequestParam Long id) {
|
|
|
//先查询考试相关信息
|
|
|
- TEExam teExam = teExamService.getById(id);
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(id);
|
|
|
+ TEExam teExam = teExamService.cacheConvert(examCacheBean);
|
|
|
if (Objects.isNull(teExam)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_NO);
|
|
|
}
|
|
@@ -547,7 +564,7 @@ public class TEExamController {
|
|
|
transMap.put("orgId", tbUser.getOrgId());
|
|
|
transMap.put(SystemConstant.TASK_ID, tbTaskHistory.getId());
|
|
|
//mq发送消息start
|
|
|
- MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_SCORE_CALCULATE.name(), transMap,
|
|
|
+ MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.EXAM_SCORE_CALCULATE.name(), transMap,
|
|
|
MqTagEnum.EXAM_SCORE_CALCULATE, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
|
|
|
mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
//mq发送消息end
|