|
@@ -1,8 +1,38 @@
|
|
|
package com.qmth.themis.backend.api;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+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.base.BasePage;
|
|
|
+import com.qmth.themis.business.bean.backend.ReexamListRequestBean;
|
|
|
+import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
+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.entity.TBUser;
|
|
|
+import com.qmth.themis.business.entity.TEExamReexam;
|
|
|
+import com.qmth.themis.business.entity.TOeExamRecord;
|
|
|
+import com.qmth.themis.business.enums.ReexamReasonEnum;
|
|
|
+import com.qmth.themis.business.enums.RoleEnum;
|
|
|
+import com.qmth.themis.business.service.TBUserRoleService;
|
|
|
+import com.qmth.themis.business.service.TEExamReexamService;
|
|
|
+import com.qmth.themis.business.service.TEExamService;
|
|
|
+import com.qmth.themis.business.service.TOeExamRecordService;
|
|
|
+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.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: 考生重考处理 前端控制器
|
|
@@ -13,7 +43,233 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
*/
|
|
|
@Api(tags = "考生重考处理Controller")
|
|
|
@RestController
|
|
|
-@RequestMapping("/${prefix.url.admin}/examReexam")
|
|
|
+@RequestMapping("/${prefix.url.admin}/invigilate/reexam")
|
|
|
public class TEExamReexamController {
|
|
|
|
|
|
+ @Resource
|
|
|
+ TEExamReexamService teExamReexamService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ RedisUtil redisUtil;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TEExamService teExamService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TBUserRoleService tbUserRoleService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "重考申请接口")
|
|
|
+ @RequestMapping(value = "/apply", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ @Transactional
|
|
|
+ public Result apply(@ApiJsonObject(name = "reexamApply", value = {
|
|
|
+ @ApiJsonProperty(key = "examRecordId", type = "long", example = "1", description = "考试记录id", required = true),
|
|
|
+ @ApiJsonProperty(key = "model", type = "int", example = "1", description = "重考方式", required = true),
|
|
|
+ @ApiJsonProperty(key = "reason", description = "重考原因", required = true),
|
|
|
+ @ApiJsonProperty(key = "remark", 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("model")) || Objects.equals(mapParameter.get("model"), "")) {
|
|
|
+ throw new BusinessException("重考方式不能为空");
|
|
|
+ }
|
|
|
+ Integer model = Integer.parseInt(String.valueOf(mapParameter.get("model")));
|
|
|
+ if (Objects.isNull(mapParameter.get("reason")) || Objects.equals(mapParameter.get("reason"), "")) {
|
|
|
+ throw new BusinessException("重考原因不能为空");
|
|
|
+ }
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ ReexamReasonEnum reason = ReexamReasonEnum.valueOf(String.valueOf(mapParameter.get("reason")));
|
|
|
+ List<TEExamReexam> teExamReexamList = new ArrayList<>();
|
|
|
+ Long examId = null, examStudentId = null, examActivityId = null;
|
|
|
+ Integer reexamAuditing = null, status;
|
|
|
+ for (Long s : recordIdList) {
|
|
|
+ //获取考试记录缓存
|
|
|
+ Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(s));
|
|
|
+ if (Objects.isNull(objectMap) || objectMap.size() == 0) {
|
|
|
+ TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(s);
|
|
|
+ if (Objects.isNull(tOeExamRecord)) {
|
|
|
+ throw new BusinessException("考试记录[" + s + "]不存在");
|
|
|
+ }
|
|
|
+ examId = tOeExamRecord.getExamId();
|
|
|
+ examStudentId = tOeExamRecord.getExamStudentId();
|
|
|
+ examActivityId = tOeExamRecord.getExamActivityId();
|
|
|
+ } else {
|
|
|
+ examId = Long.parseLong(String.valueOf(objectMap.get("examId")));
|
|
|
+ examStudentId = Long.parseLong(String.valueOf(objectMap.get("examStudentId")));
|
|
|
+ examActivityId = Long.parseLong(String.valueOf(objectMap.get("examActivityId")));
|
|
|
+ }
|
|
|
+ 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, s, examStudentId, model, reason, status, Objects.isNull(mapParameter.get("remark")) ? null : String.valueOf(mapParameter.get("remark")));
|
|
|
+ teExamReexam.setCreateId(tbUser.getId());
|
|
|
+ if (Objects.nonNull(status) && status.intValue() == 1) {
|
|
|
+ //这里查询该机构下所有为管理员角色的账号
|
|
|
+ List<TBUser> tbUserList = tbUserRoleService.userQueryByRole(tbUser.getOrgId(), RoleEnum.ADMIN.name());
|
|
|
+ JSONObject jsonObject = null;
|
|
|
+ if (Objects.nonNull(tbUserList) && tbUserList.size() > 0) {
|
|
|
+ jsonObject = new JSONObject();
|
|
|
+ for (int i = 0; i < tbUserList.size(); i++) {
|
|
|
+ TBUser t = tbUserList.get(i);
|
|
|
+ jsonObject.put(String.valueOf(t.getId()), t.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(jsonObject)) {
|
|
|
+ teExamReexam.setAuditingId(JacksonUtil.parseJson(jsonObject));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ teExamReexamList.add(teExamReexam);
|
|
|
+ }
|
|
|
+ teExamReexamService.saveBatch(teExamReexamList);
|
|
|
+ return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重考审核接口")
|
|
|
+ @RequestMapping(value = "/auditing", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ @Transactional
|
|
|
+ public Result auditing(@ApiJsonObject(name = "reexamAuditing", value = {
|
|
|
+ @ApiJsonProperty(key = "reexamId", type = "long", example = "1", description = "重考id", required = true),
|
|
|
+ @ApiJsonProperty(key = "auditingSuggest", description = "审批意见"),
|
|
|
+ @ApiJsonProperty(key = "auditingStatus", type = "long", example = "1", description = "审批状态", required = true)
|
|
|
+ }) @ApiParam(value = "重考信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
+ if (Objects.isNull(mapParameter.get("reexamId")) || Objects.equals(mapParameter.get("reexamId"), "")) {
|
|
|
+ throw new BusinessException("重考id不能为空");
|
|
|
+ }
|
|
|
+ Long reexamId = null;
|
|
|
+ try {
|
|
|
+ reexamId = Long.parseLong(String.valueOf(mapParameter.get("reexamId")));
|
|
|
+ if (Objects.isNull(mapParameter.get("auditingStatus")) || Objects.equals(mapParameter.get("auditingStatus"), "")) {
|
|
|
+ throw new BusinessException("审批状态不能为空");
|
|
|
+ }
|
|
|
+ Integer auditingStatus = Integer.parseInt(String.valueOf(mapParameter.get("auditingStatus")));
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ if (redisUtil.lock(SystemConstant.REDIS_LOCK_REEXAM_AUDITING + reexamId, SystemConstant.REDIS_LOCK_REEXAM_TIME_OUT)) {
|
|
|
+ TEExamReexam teExamReexam = teExamReexamService.getById(reexamId);
|
|
|
+ if (Objects.isNull(teExamReexam.getUpdateId())) {
|
|
|
+ teExamReexam.setAuditingStatus(auditingStatus);
|
|
|
+ teExamReexam.setAuditingTime(new Date());
|
|
|
+ teExamReexam.setAuditingSuggest(Objects.isNull(mapParameter.get("auditingSuggest")) ? null : String.valueOf(mapParameter.get("auditingSuggest")));
|
|
|
+ teExamReexam.setUpdateId(tbUser.getId());
|
|
|
+ teExamReexamService.updateById(teExamReexam);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("重考id[" + reexamId + "]已经审核");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (e instanceof BusinessException) {
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (Objects.nonNull(reexamId)) {
|
|
|
+ redisUtil.releaseLock(SystemConstant.REDIS_LOCK_REEXAM_AUDITING + reexamId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重考审核明细接口")
|
|
|
+ @RequestMapping(value = "/detail", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = TEExamReexam.class)})
|
|
|
+ public Result detail(@ApiParam(value = "重考id") @RequestParam Long reexamId) {
|
|
|
+ if (Objects.isNull(reexamId) || Objects.equals(reexamId, "")) {
|
|
|
+ throw new BusinessException("重考id不能为空");
|
|
|
+ }
|
|
|
+ return ResultUtil.ok(teExamReexamService.getById(reexamId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重考申请列表接口")
|
|
|
+ @RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = ReexamListRequestBean.class)})
|
|
|
+ public Result list(@ApiParam(value = "考试批次id") @RequestParam Long examId,
|
|
|
+ @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long examActivityId,
|
|
|
+ @ApiParam(value = "虚拟考场代码", required = false) @RequestParam(required = false) String roomCode,
|
|
|
+ @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
|
|
|
+ @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
|
|
|
+ @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
|
|
|
+ @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
|
|
|
+ @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
|
|
|
+ if (Objects.isNull(examId) || Objects.equals(examId, "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
|
|
|
+ //如果有监考员角色,只能查看自己所监考的考场,巡考员和管理员则可以查看全部考场
|
|
|
+ Long userId = null;
|
|
|
+ if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name())) {
|
|
|
+ userId = tbUser.getId();
|
|
|
+ }
|
|
|
+ IPage<ReexamListRequestBean> reexamListRequestBeanIPage = teExamReexamService.reexamPageRequestList(new Page<>(pageNumber, pageSize), examId, examActivityId, roomCode, courseCode, name, identity, userId);
|
|
|
+ BasePage basePage = new BasePage(reexamListRequestBeanIPage.getRecords(), reexamListRequestBeanIPage.getCurrent(), reexamListRequestBeanIPage.getSize(), reexamListRequestBeanIPage.getTotal());
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put(SystemConstant.RECORDS, basePage);
|
|
|
+ return ResultUtil.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重考待审列表接口")
|
|
|
+ @RequestMapping(value = "/list_not_done", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = ReexamListRequestBean.class)})
|
|
|
+ public Result listNotDone(@ApiParam(value = "考试批次id") @RequestParam Long examId,
|
|
|
+ @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long examActivityId,
|
|
|
+ @ApiParam(value = "虚拟考场代码", required = false) @RequestParam(required = false) String roomCode,
|
|
|
+ @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
|
|
|
+ @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
|
|
|
+ @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
|
|
|
+ @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
|
|
|
+ @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
|
|
|
+ if (Objects.isNull(examId) || Objects.equals(examId, "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
|
|
|
+ //如果有监考员角色,只能查看自己所监考的考场,巡考员和管理员则可以查看全部考场
|
|
|
+ Long userId = null;
|
|
|
+ if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name())) {
|
|
|
+ userId = tbUser.getId();
|
|
|
+ }
|
|
|
+ IPage<ReexamListRequestBean> reexamListRequestBeanIPage = teExamReexamService.reexamPageRequestList(new Page<>(pageNumber, pageSize), examId, examActivityId, roomCode, courseCode, name, identity, userId);
|
|
|
+ BasePage basePage = new BasePage(reexamListRequestBeanIPage.getRecords(), reexamListRequestBeanIPage.getCurrent(), reexamListRequestBeanIPage.getSize(), reexamListRequestBeanIPage.getTotal());
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put(SystemConstant.RECORDS, basePage);
|
|
|
+ return ResultUtil.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重考已审列表接口")
|
|
|
+ @RequestMapping(value = "/list_done", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = ReexamListRequestBean.class)})
|
|
|
+ public Result listDone(@ApiParam(value = "考试批次id") @RequestParam Long examId,
|
|
|
+ @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long examActivityId,
|
|
|
+ @ApiParam(value = "虚拟考场代码", required = false) @RequestParam(required = false) String roomCode,
|
|
|
+ @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
|
|
|
+ @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
|
|
|
+ @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
|
|
|
+ @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
|
|
|
+ @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
|
|
|
+ if (Objects.isNull(examId) || Objects.equals(examId, "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
|
|
|
+ //如果有监考员角色,只能查看自己所监考的考场,巡考员和管理员则可以查看全部考场
|
|
|
+ Long userId = null;
|
|
|
+ if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name())) {
|
|
|
+ userId = tbUser.getId();
|
|
|
+ }
|
|
|
+ IPage<ReexamListRequestBean> reexamListRequestBeanIPage = teExamReexamService.reexamPageRequestList(new Page<>(pageNumber, pageSize), examId, examActivityId, roomCode, courseCode, name, identity, userId);
|
|
|
+ BasePage basePage = new BasePage(reexamListRequestBeanIPage.getRecords(), reexamListRequestBeanIPage.getCurrent(), reexamListRequestBeanIPage.getSize(), reexamListRequestBeanIPage.getTotal());
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put(SystemConstant.RECORDS, basePage);
|
|
|
+ return ResultUtil.ok(map);
|
|
|
+ }
|
|
|
}
|