Explorar o código

监考端接口

wangliang %!s(int64=4) %!d(string=hai) anos
pai
achega
2376d9d611

+ 22 - 25
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamReexamController.java

@@ -1,11 +1,11 @@
 package com.qmth.themis.backend.api;
 
-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.ReexamListNotDongBean;
 import com.qmth.themis.business.bean.backend.ReexamListRequestBean;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
@@ -13,14 +13,11 @@ 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.TEExamReexamAuditing;
 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.service.*;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
@@ -61,6 +58,9 @@ public class TEExamReexamController {
     @Resource
     TBUserRoleService tbUserRoleService;
 
+    @Resource
+    TEExamReexamAuditingService teExamReexamAuditingService;
+
     @ApiOperation(value = "重考申请接口")
     @RequestMapping(value = "/apply", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
@@ -84,9 +84,9 @@ public class TEExamReexamController {
         }
         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;
+        List<TEExamReexamAuditing> teExamReexamAuditingList = new ArrayList<>();
         for (Long s : recordIdList) {
             //获取考试记录缓存
             Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(s));
@@ -111,24 +111,21 @@ public class TEExamReexamController {
             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());
+            teExamReexamService.save(teExamReexam);
             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());
+                    for (TBUser t : tbUserList) {
+                        TEExamReexamAuditing teExamReexamAuditing = new TEExamReexamAuditing(teExamReexam.getId(), t.getId());
+                        teExamReexamAuditingList.add(teExamReexamAuditing);
                     }
                 }
-                if (Objects.nonNull(jsonObject)) {
-                    teExamReexam.setAuditingId(JacksonUtil.parseJson(jsonObject));
-                }
             }
-            teExamReexamList.add(teExamReexam);
         }
-        teExamReexamService.saveBatch(teExamReexamList);
+        if (Objects.nonNull(teExamReexamAuditingList) && teExamReexamAuditingList.size() > 0) {
+            teExamReexamAuditingService.saveBatch(teExamReexamAuditingList);
+        }
         return ResultUtil.ok(SystemConstant.SUCCESS);
     }
 
@@ -156,9 +153,13 @@ public class TEExamReexamController {
             for (Long reexamId : reexamIdList) {
                 if (redisUtil.lock(SystemConstant.REDIS_LOCK_REEXAM_AUDITING + reexamId, SystemConstant.REDIS_LOCK_REEXAM_TIME_OUT)) {
                     TEExamReexam teExamReexam = teExamReexamService.getById(reexamId);
+                    if (Objects.isNull(teExamReexam)) {
+                        throw new BusinessException("重考id[" + reexamId + "]记录不存在");
+                    }
                     if (Objects.nonNull(teExamReexam.getStatus()) && teExamReexam.getStatus().intValue() == 2) {
                         throw new BusinessException("重考id[" + reexamId + "]已经审核");
                     } else {
+                        teExamReexam.setAuditingId(tbUser.getId());
                         teExamReexam.setAuditingStatus(auditingStatus);
                         teExamReexam.setAuditingTime(new Date());
                         teExamReexam.setAuditingSuggest(Objects.isNull(mapParameter.get("auditingSuggest")) ? null : String.valueOf(mapParameter.get("auditingSuggest")));
@@ -244,11 +245,9 @@ public class TEExamReexamController {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        IPage<ReexamListRequestBean> reexamListRequestBeanIPage = teExamReexamService.reexamPageRequestList(new Page<>(pageNumber, pageSize), examId, examActivityId, roomCode, courseCode, name, identity, tbUser.getId());
-        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);
+        IPage<ReexamListNotDongBean> reexamListNotDongBeanIPage = teExamReexamService.reexamPageNotDoneList(new Page<>(pageNumber, pageSize), examId, examActivityId, roomCode, courseCode, name, identity, reason, reasonStartTime, reasonEndTime, applyName, tbUser.getId());
+        BasePage basePage = new BasePage(reexamListNotDongBeanIPage.getRecords(), reexamListNotDongBeanIPage.getCurrent(), reexamListNotDongBeanIPage.getSize(), reexamListNotDongBeanIPage.getTotal());
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.RECORDS, basePage));
     }
 
     @ApiOperation(value = "重考已审列表接口")
@@ -274,8 +273,6 @@ public class TEExamReexamController {
         }
         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);
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.RECORDS, basePage));
     }
 }

+ 17 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamReexamAuditingMapper.java

@@ -0,0 +1,17 @@
+package com.qmth.themis.business.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.themis.business.entity.TEExamReexamAuditing;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Description: 考生重考审核人 Mapper 接口
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/6/25
+ */
+@Mapper
+public interface TEExamReexamAuditingMapper extends BaseMapper<TEExamReexamAuditing> {
+
+}

+ 4 - 4
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamReexam.java

@@ -52,9 +52,9 @@ public class TEExamReexam extends BaseEntity {
     @TableField(value = "status")
     private Integer status;
 
-    @ApiModelProperty(value = "审核人id")
+    @ApiModelProperty(value = "审核人id")
     @TableField(value = "auditing_id")
-    private String auditingId;
+    private Long auditingId;
 
     @ApiModelProperty(value = "审核状态,0:通过,1:不通过")
     @TableField(value = "auditing_status")
@@ -148,11 +148,11 @@ public class TEExamReexam extends BaseEntity {
         this.status = status;
     }
 
-    public String getAuditingId() {
+    public Long getAuditingId() {
         return auditingId;
     }
 
-    public void setAuditingId(String auditingId) {
+    public void setAuditingId(Long auditingId) {
         this.auditingId = auditingId;
     }
 

+ 72 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamReexamAuditing.java

@@ -0,0 +1,72 @@
+package com.qmth.themis.business.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.qmth.themis.common.contanst.Constants;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 考生重考审核人
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/6/25
+ */
+@ApiModel(value = "t_e_exam_reexam_auditing", description = "考生重考审核人")
+public class TEExamReexamAuditing implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键")
+    @TableId(value = "id")
+    private Long id;
+
+    @ApiModelProperty(value = "重考id")
+    @TableField(value = "reexam_id")
+    private Long reexamId;
+
+    @ApiModelProperty(value = "审核人id")
+    @TableField(value = "auditing_id")
+    private Long auditingId;
+
+    public TEExamReexamAuditing() {
+
+    }
+
+    public TEExamReexamAuditing(Long reexamId, Long auditingId) {
+        this.id = Constants.idGen.next();
+        this.reexamId = reexamId;
+        this.auditingId = auditingId;
+    }
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getReexamId() {
+        return reexamId;
+    }
+
+    public void setReexamId(Long reexamId) {
+        this.reexamId = reexamId;
+    }
+
+    public Long getAuditingId() {
+        return auditingId;
+    }
+
+    public void setAuditingId(Long auditingId) {
+        this.auditingId = auditingId;
+    }
+}

+ 21 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamReexamAuditingService.java

@@ -0,0 +1,21 @@
+package com.qmth.themis.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.themis.business.bean.backend.ReexamListNotDongBean;
+import com.qmth.themis.business.bean.backend.ReexamListRequestBean;
+import com.qmth.themis.business.entity.TEExamReexam;
+import com.qmth.themis.business.entity.TEExamReexamAuditing;
+
+import java.util.Map;
+
+/**
+ * @Description: 考生重考审核人 服务类
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/6/25
+ */
+public interface TEExamReexamAuditingService extends IService<TEExamReexamAuditing> {
+
+}

+ 19 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamReexamAuditingServiceImpl.java

@@ -0,0 +1,19 @@
+package com.qmth.themis.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.themis.business.dao.TEExamReexamAuditingMapper;
+import com.qmth.themis.business.entity.TEExamReexamAuditing;
+import com.qmth.themis.business.service.TEExamReexamAuditingService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 考生重考审核人 服务实现类
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/6/25
+ */
+@Service
+public class TEExamReexamAuditingServiceImpl extends ServiceImpl<TEExamReexamAuditingMapper, TEExamReexamAuditing> implements TEExamReexamAuditingService {
+
+}

+ 11 - 0
themis-business/src/main/resources/db/init.sql

@@ -1040,6 +1040,17 @@ CREATE TABLE `t_e_exam_reexam` (
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考生重考处理';
 
+-- ----------------------------
+-- Table structure for t_e_exam_reexam_auditing
+-- ----------------------------
+DROP TABLE IF EXISTS `t_e_exam_reexam_auditing`;
+CREATE TABLE `t_e_exam_reexam_auditing` (
+  `id` bigint NOT NULL COMMENT '主键',
+  `reexam_id` bigint DEFAULT NULL COMMENT '重考id',
+  `auditing_id` bigint DEFAULT NULL COMMENT '待审核人id',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='重考审核人表';
+
 -- ----------------------------
 -- Table structure for t_e_exam_student
 -- ----------------------------

+ 5 - 0
themis-business/src/main/resources/mapper/TEExamReexamAuditingMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.themis.business.dao.TEExamReexamAuditingMapper">
+
+</mapper>

+ 11 - 10
themis-business/src/main/resources/mapper/TEExamReexamMapper.xml

@@ -48,7 +48,7 @@
     </select>
 
     <select id="reexamPageNotDoneList" resultType="com.qmth.themis.business.bean.backend.ReexamListNotDongBean">
-        select * from(select
+        select
             teer.id as reexamId,
             teer.exam_id as examId,
             teer.exam_activity_id as examActivityId,
@@ -62,7 +62,7 @@
             tees.name,
             teer.reason,
             teer.create_time as applyTime,
-            (select tbu.name from t_b_user tbu where tbu.id = teer.create_id) as applyName
+            tbu.name as applyName
         from
             t_e_exam_reexam teer
         left join t_e_exam_student tees on
@@ -71,9 +71,13 @@
             tee.id = teer.exam_id
         left join t_e_exam_activity teea on
             teea.id = teer.exam_activity_id
+        left join t_b_user tbu on
+            tbu.id = teer.create_id
+        left join t_e_exam_reexam_auditing teera on
+            teera.reexam_id = teer.id
          <where>
              <if test="userId != null and userId !=''">
-                 and CONVERT((teer.auditing_id->>CONCAT('$.",#{userId},"')) USING utf8) = #{userId}
+                 and teera.auditing_id = #{userId}
              </if>
              <if test="examId != null and examId != ''">
                  and tees.exam_id = #{examId}
@@ -102,17 +106,14 @@
              <if test="reasonEndTime != null and reasonEndTime != ''">
                  and teer.create_time &lt;= #{reasonEndTime}
              </if>
+             <if test="applyName != null and applyName !=''">
+                 and tbu.name like CONCAT(#{applyName},'%')
+             </if>
              and tee.enable = 1
              and teea.enable = 1
              and tees.enable = 1
              and teer.status = 1
          </where>
-        ) t
-        <where>
-            <if test="applyName != null and applyName !=''">
-                and t.applyName like CONCAT(#{applyName},'%')
-            </if>
-        </where>
-         order by t.roomCode
+         order by tees.room_code
     </select>
 </mapper>