|
@@ -1,17 +1,16 @@
|
|
package com.qmth.themis.backend.api;
|
|
package com.qmth.themis.backend.api;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.qmth.themis.business.annotation.ApiJsonObject;
|
|
import com.qmth.themis.business.annotation.ApiJsonObject;
|
|
import com.qmth.themis.business.annotation.ApiJsonProperty;
|
|
import com.qmth.themis.business.annotation.ApiJsonProperty;
|
|
import com.qmth.themis.business.bean.backend.ReexamListRequestBean;
|
|
import com.qmth.themis.business.bean.backend.ReexamListRequestBean;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
|
+import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
-import com.qmth.themis.business.entity.TBUser;
|
|
|
|
-import com.qmth.themis.business.entity.TEExamReexam;
|
|
|
|
-import com.qmth.themis.business.entity.TEExamReexamAuditing;
|
|
|
|
-import com.qmth.themis.business.entity.TOeExamRecord;
|
|
|
|
|
|
+import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.enums.ReexamReasonEnum;
|
|
import com.qmth.themis.business.enums.ReexamReasonEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
@@ -61,6 +60,9 @@ public class TEExamReexamController {
|
|
@Resource
|
|
@Resource
|
|
TEExamReexamAuditingService teExamReexamAuditingService;
|
|
TEExamReexamAuditingService teExamReexamAuditingService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TEExamStudentService teExamStudentService;
|
|
|
|
+
|
|
@ApiOperation(value = "重考申请接口")
|
|
@ApiOperation(value = "重考申请接口")
|
|
@RequestMapping(value = "/apply", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/apply", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
@@ -88,6 +90,7 @@ public class TEExamReexamController {
|
|
Long examId = null, examStudentId = null, examActivityId = null;
|
|
Long examId = null, examStudentId = null, examActivityId = null;
|
|
Integer reexamAuditing = null, status;
|
|
Integer reexamAuditing = null, status;
|
|
List<TEExamReexamAuditing> teExamReexamAuditingList = new ArrayList<>();
|
|
List<TEExamReexamAuditing> teExamReexamAuditingList = new ArrayList<>();
|
|
|
|
+ Set<Long> examStudentIdList = new HashSet<>();
|
|
for (String s : recordIdList) {
|
|
for (String s : recordIdList) {
|
|
//获取考试记录缓存
|
|
//获取考试记录缓存
|
|
Long recordId = Long.parseLong(s);
|
|
Long recordId = Long.parseLong(s);
|
|
@@ -102,29 +105,49 @@ public class TEExamReexamController {
|
|
examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
}
|
|
}
|
|
- ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);//考试缓存
|
|
|
|
- if (Objects.isNull(examCacheBean)) {
|
|
|
|
- throw new BusinessException("考试批次[" + examCacheBean + "]不存在");
|
|
|
|
- }
|
|
|
|
- reexamAuditing = examCacheBean.getReexamAuditing();
|
|
|
|
- status = Objects.isNull(reexamAuditing) || reexamAuditing.intValue() == 0 ? 0 : 1;
|
|
|
|
- TEExamReexam teExamReexam = new TEExamReexam(examId, examActivityId, Long.parseLong(s), examStudentId, model, reason, status, Objects.isNull(mapParameter.get("remark")) ? null : String.valueOf(mapParameter.get("remark")));
|
|
|
|
- teExamReexam.setCreateId(tbUser.getId());
|
|
|
|
- teExamReexamService.save(teExamReexam);
|
|
|
|
- if (Objects.nonNull(status) && status.intValue() == 1) {
|
|
|
|
- //这里查询该机构下所有为管理员角色的账号
|
|
|
|
- List<TBUser> tbUserList = tbUserRoleService.userQueryByRole(tbUser.getOrgId(), RoleEnum.ADMIN.name());
|
|
|
|
- if (Objects.nonNull(tbUserList) && tbUserList.size() > 0) {
|
|
|
|
- for (TBUser t : tbUserList) {
|
|
|
|
- TEExamReexamAuditing teExamReexamAuditing = new TEExamReexamAuditing(teExamReexam.getId(), t.getId());
|
|
|
|
- teExamReexamAuditingList.add(teExamReexamAuditing);
|
|
|
|
|
|
+ if (redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_STUDENT_PREFIX + examStudentId, SystemConstant.REDIS_LOCK_REEXAM_EXAM_STUDENT_TIME_OUT)) {
|
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);//考试缓存
|
|
|
|
+ if (Objects.isNull(examCacheBean)) {
|
|
|
|
+ throw new BusinessException("考试批次[" + examCacheBean + "]不存在");
|
|
|
|
+ }
|
|
|
|
+ reexamAuditing = examCacheBean.getReexamAuditing();
|
|
|
|
+ status = Objects.isNull(reexamAuditing) || reexamAuditing.intValue() == 0 ? 0 : 1;
|
|
|
|
+ TEExamReexam teExamReexam = new TEExamReexam(examId, examActivityId, Long.parseLong(s), examStudentId, model, reason, status, Objects.isNull(mapParameter.get("remark")) ? null : String.valueOf(mapParameter.get("remark")));
|
|
|
|
+ teExamReexam.setCreateId(tbUser.getId());
|
|
|
|
+ teExamReexamService.save(teExamReexam);
|
|
|
|
+ if (Objects.nonNull(status) && status.intValue() == 1) {
|
|
|
|
+ //这里查询该机构下所有为管理员角色的账号
|
|
|
|
+ List<TBUser> tbUserList = tbUserRoleService.userQueryByRole(tbUser.getOrgId(), RoleEnum.ADMIN.name());
|
|
|
|
+ if (Objects.nonNull(tbUserList) && tbUserList.size() > 0) {
|
|
|
|
+ for (TBUser t : tbUserList) {
|
|
|
|
+ TEExamReexamAuditing teExamReexamAuditing = new TEExamReexamAuditing(teExamReexam.getId(), t.getId());
|
|
|
|
+ teExamReexamAuditingList.add(teExamReexamAuditing);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else if (Objects.nonNull(status) && status.intValue() == 0) {//无需审核时考生已考次数-1
|
|
|
|
+ examStudentIdList.add(examStudentId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (Objects.nonNull(teExamReexamAuditingList) && teExamReexamAuditingList.size() > 0) {
|
|
if (Objects.nonNull(teExamReexamAuditingList) && teExamReexamAuditingList.size() > 0) {
|
|
teExamReexamAuditingService.saveBatch(teExamReexamAuditingList);
|
|
teExamReexamAuditingService.saveBatch(teExamReexamAuditingList);
|
|
}
|
|
}
|
|
|
|
+ if (Objects.nonNull(examStudentIdList) && examStudentIdList.size() > 0) {
|
|
|
|
+ examStudentIdList.forEach(s -> {
|
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(s);
|
|
|
|
+ if (Objects.nonNull(examStudentCacheBean)) {
|
|
|
|
+ Integer alreadyExamCount = Objects.nonNull(examStudentCacheBean.getAlreadyExamCount()) ? examStudentCacheBean.getAlreadyExamCount() : 0;
|
|
|
|
+ if (alreadyExamCount > 0) {
|
|
|
|
+ alreadyExamCount = alreadyExamCount - 1;
|
|
|
|
+ UpdateWrapper<TEExamStudent> teExamStudentUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getAlreadyExamCount, alreadyExamCount)
|
|
|
|
+ .eq(TEExamStudent::getId, s);
|
|
|
|
+ teExamStudentService.update(teExamStudentUpdateWrapper);
|
|
|
|
+ teExamStudentService.updateExamStudentCacheBean(s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
}
|
|
}
|
|
@@ -167,7 +190,18 @@ public class TEExamReexamController {
|
|
teExamReexam.setStatus(2);
|
|
teExamReexam.setStatus(2);
|
|
teExamReexam.setUpdateId(tbUser.getId());
|
|
teExamReexam.setUpdateId(tbUser.getId());
|
|
teExamReexamUpdateList.add(teExamReexam);
|
|
teExamReexamUpdateList.add(teExamReexam);
|
|
- teExamReexamService.updateById(teExamReexam);
|
|
|
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(teExamReexam.getExamStudentId());
|
|
|
|
+ if (Objects.nonNull(examStudentCacheBean)) {
|
|
|
|
+ Integer alreadyExamCount = Objects.nonNull(examStudentCacheBean.getAlreadyExamCount()) ? examStudentCacheBean.getAlreadyExamCount() : 0;
|
|
|
|
+ if (alreadyExamCount > 0) {
|
|
|
|
+ alreadyExamCount = alreadyExamCount - 1;
|
|
|
|
+ UpdateWrapper<TEExamStudent> teExamStudentUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getAlreadyExamCount, alreadyExamCount)
|
|
|
|
+ .eq(TEExamStudent::getId, teExamReexam.getExamStudentId());
|
|
|
|
+ teExamStudentService.update(teExamStudentUpdateWrapper);
|
|
|
|
+ teExamStudentService.updateExamStudentCacheBean(teExamReexam.getExamStudentId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|