Browse Source

预警相关修改

wangliang 2 years ago
parent
commit
1b744c44ec

+ 29 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java

@@ -104,6 +104,9 @@ public class SysController {
     @Resource
     @Resource
     AuthInfoService authInfoService;
     AuthInfoService authInfoService;
 
 
+    @Resource
+    TIeInvigilateWarnInfoService tIeInvigilateWarnInfoService;
+
     @ApiOperation(value = "菜单查询接口")
     @ApiOperation(value = "菜单查询接口")
     @RequestMapping(value = "/getMenu", method = RequestMethod.POST)
     @RequestMapping(value = "/getMenu", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "菜单信息", response = TBPrivilege.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "菜单信息", response = TBPrivilege.class)})
@@ -285,9 +288,10 @@ public class SysController {
     @ApiOperation(value = "考试批次查询接口")
     @ApiOperation(value = "考试批次查询接口")
     @RequestMapping(value = "/exam/query", method = RequestMethod.POST)
     @RequestMapping(value = "/exam/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TEExamQueryDto.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TEExamQueryDto.class)})
-    public Result examQuery(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId,
-                            @ApiParam(value = "批次名称", required = false) @RequestParam(required = false) String name,
-                            @ApiParam(value = "类型(区分实时监考台和考务)", required = false) @RequestParam(required = false) String type) {
+    public Result examQuery(@ApiParam(value = "用户id") @RequestParam(required = false) Long userId,
+                            @ApiParam(value = "批次名称") @RequestParam(required = false) String name,
+                            @ApiParam(value = "类型(区分实时监考台和考务)") @RequestParam(required = false) String type,
+                            @ApiParam(value = "是否查询预警消息条数") @RequestParam(required = false) Boolean warnCount) {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         AuthDto authDto = cacheService.addAccountAuthCache(tbUser.getId());
         AuthDto authDto = cacheService.addAccountAuthCache(tbUser.getId());
         List<TEExam> teExamList = null;
         List<TEExam> teExamList = null;
@@ -318,10 +322,31 @@ public class SysController {
             }
             }
         }
         }
         List<TEExamQueryDto> teExamQueryDtoList = null;
         List<TEExamQueryDto> teExamQueryDtoList = null;
-        if (Objects.nonNull(teExamList) && teExamList.size() > 0) {
+        if (!CollectionUtils.isEmpty(teExamList)) {
             Gson gson = new Gson();
             Gson gson = new Gson();
             teExamQueryDtoList = gson.fromJson(gson.toJson(teExamList), new TypeToken<List<TEExamQueryDto>>() {
             teExamQueryDtoList = gson.fromJson(gson.toJson(teExamList), new TypeToken<List<TEExamQueryDto>>() {
             }.getType());
             }.getType());
+            if (Objects.nonNull(warnCount) && warnCount) {
+                List<Long> examIdList = new ArrayList<>(teExamQueryDtoList.size());
+                Map<Long, TEExamQueryDto> map = new HashMap<>(teExamQueryDtoList.size());
+                for (TEExamQueryDto t : teExamQueryDtoList) {
+                    examIdList.add(t.getId());
+                    map.computeIfAbsent(t.getId(), v -> t);
+                }
+                Long warnUserId = null, warnOrgId = null;
+                if (authDto.getRoleCodes().toString().contains(RoleEnum.INSPECTION.name()) || authDto.getRoleCodes().toString()
+                        .contains(RoleEnum.INVIGILATE.name())) {
+                    warnUserId = tbUser.getId();
+                    warnOrgId = tbUser.getOrgId();
+                }
+                List<TEExamQueryDto> warnCountList = tIeInvigilateWarnInfoService.warningCountByList(examIdList, warnUserId, warnOrgId);
+                if (!CollectionUtils.isEmpty(warnCountList)) {
+                    for (TEExamQueryDto t : warnCountList) {
+                        map.get(t.getId()).setWarnCount(t.getWarnCount());
+                    }
+                    teExamQueryDtoList = new ArrayList<>(map.values());
+                }
+            }
         }
         }
         return ResultUtil.ok(teExamQueryDtoList);
         return ResultUtil.ok(teExamQueryDtoList);
     }
     }

+ 11 - 2
themis-business/src/main/java/com/qmth/themis/business/dao/TIeInvigilateWarnInfoMapper.java

@@ -2,10 +2,9 @@ package com.qmth.themis.business.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.themis.business.bean.admin.WarningNotifyBean;
 import com.qmth.themis.business.bean.admin.WarningNotifyBean;
+import com.qmth.themis.business.dto.response.TEExamQueryDto;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
-import com.qmth.themis.business.enums.VerifyExceptionEnum;
-import com.qmth.themis.business.enums.WarningLevelEnum;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -37,6 +36,16 @@ public interface TIeInvigilateWarnInfoMapper extends BaseMapper<TIeInvigilateWar
                                 @Param("userId") Long userId,
                                 @Param("userId") Long userId,
                                 @Param("orgId") Long orgId);
                                 @Param("orgId") Long orgId);
 
 
+    /**
+     * 预警提醒
+     *
+     * @param examIdList
+     * @param userId
+     * @param orgId
+     * @return
+     */
+    public List<TEExamQueryDto> warningCountByList(@Param("examIdList") List<Long> examIdList, @Param("userId") Long userId, @Param("orgId") Long orgId);
+
     /**
     /**
      * 预警通知
      * 预警通知
      *
      *

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamQueryDto.java

@@ -74,6 +74,17 @@ public class TEExamQueryDto implements Serializable {
     @ApiModelProperty(name = "监考状态,NOT_START:未开始,START:监考中,FINISHED:已结束")
     @ApiModelProperty(name = "监考状态,NOT_START:未开始,START:监考中,FINISHED:已结束")
     private String monitorStatus;
     private String monitorStatus;
 
 
+    @ApiModelProperty(value = "预警条数")
+    private Integer warnCount;
+
+    public Integer getWarnCount() {
+        return warnCount;
+    }
+
+    public void setWarnCount(Integer warnCount) {
+        this.warnCount = warnCount;
+    }
+
     public String getMonitorRecord() {
     public String getMonitorRecord() {
         return monitorRecord;
         return monitorRecord;
     }
     }

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TIeInvigilateWarnInfoService.java

@@ -1,6 +1,7 @@
 package com.qmth.themis.business.service;
 package com.qmth.themis.business.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.themis.business.dto.response.TEExamQueryDto;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.enums.VerifyExceptionEnum;
 import com.qmth.themis.business.enums.VerifyExceptionEnum;
@@ -33,6 +34,16 @@ public interface TIeInvigilateWarnInfoService extends IService<TIeInvigilateWarn
                                 Long userId,
                                 Long userId,
                                 Long orgId);
                                 Long orgId);
 
 
+    /**
+     * 预警提醒
+     *
+     * @param examIdList
+     * @param userId
+     * @param orgId
+     * @return
+     */
+    public List<TEExamQueryDto> warningCountByList(List<Long> examIdList, Long userId, Long orgId);
+
     /**
     /**
      * 预警通知
      * 预警通知
      *
      *

+ 14 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TIeInvigilateWarnInfoServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.service.impl;
 
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.dao.TIeInvigilateWarnInfoMapper;
 import com.qmth.themis.business.dao.TIeInvigilateWarnInfoMapper;
+import com.qmth.themis.business.dto.response.TEExamQueryDto;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.enums.VerifyExceptionEnum;
 import com.qmth.themis.business.enums.VerifyExceptionEnum;
@@ -41,6 +42,19 @@ public class TIeInvigilateWarnInfoServiceImpl extends ServiceImpl<TIeInvigilateW
         return tIeInvigilateWarnInfoMapper.warningCount(examId, examActivityId, roomCode, userId, orgId);
         return tIeInvigilateWarnInfoMapper.warningCount(examId, examActivityId, roomCode, userId, orgId);
     }
     }
 
 
+    /**
+     * 预警提醒
+     *
+     * @param examIdList
+     * @param userId
+     * @param orgId
+     * @return
+     */
+    @Override
+    public List<TEExamQueryDto> warningCountByList(List<Long> examIdList, Long userId, Long orgId) {
+        return tIeInvigilateWarnInfoMapper.warningCountByList(examIdList, userId, orgId);
+    }
+
     /**
     /**
      * 预警通知
      * 预警通知
      *
      *

+ 30 - 1
themis-business/src/main/resources/mapper/TIeInvigilateWarnInfoMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.qmth.themis.business.dao.TIeInvigilateWarnInfoMapper">
 <mapper namespace="com.qmth.themis.business.dao.TIeInvigilateWarnInfoMapper">
 
 
     <select id="warningCount" resultType="java.lang.Integer">
     <select id="warningCount" resultType="java.lang.Integer">
-        select count(1) as count
+        select count(distinct tiiwi.exam_record_id) as count
         from t_ie_invigilate_warn_info tiiwi
         from t_ie_invigilate_warn_info tiiwi
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
         left join t_e_exam tee on tee.id = tees.exam_id
         left join t_e_exam tee on tee.id = tees.exam_id
@@ -31,6 +31,35 @@
         </where>
         </where>
     </select>
     </select>
 
 
+    <select id="warningCountByList" resultType="com.qmth.themis.business.dto.response.TEExamQueryDto">
+        select
+           tiiwi.exam_id as id,
+           count(distinct tiiwi.exam_record_id) as warnCount
+        from t_ie_invigilate_warn_info tiiwi
+        left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
+        left join t_e_exam tee on tee.id = tees.exam_id
+        <where> 1 = 1
+            and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
+            <if test="examIdList != null and examIdList != '' and examIdList.size > 0">
+                and tiiwi.exam_id in
+                <foreach collection="examIdList" item="examId" index="index" open="(" close=")" separator=",">
+                    #{examId}
+                </foreach>
+            </if>
+            <if test="userId != null and userId != ''">
+                and exists (select tbeiu.exam_id from t_b_exam_invigilate_user tbeiu
+                where tbeiu.user_id = #{userId}
+                and tbeiu.exam_id = tees.exam_id and tbeiu.room_code = tees.room_code)
+            </if>
+            <if test="orgId != null and orgId != ''">
+                and tee.org_id = #{orgId}
+            </if>
+            and tiiwi.approve_status = 0
+            and tiiwi.remind_status = 1
+            group by tiiwi.exam_id
+        </where>
+    </select>
+
     <select id="warningMessage" resultType="com.qmth.themis.business.dto.response.TIeWarningNotifyDto">
     <select id="warningMessage" resultType="com.qmth.themis.business.dto.response.TIeWarningNotifyDto">
         select
         select
         tees.id as examStudentId,
         tees.id as examStudentId,

+ 1 - 1
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -422,7 +422,7 @@
 
 
     <select id="invigilatePageWarningList" resultType="com.qmth.themis.business.bean.admin.InvigilateListWarningBean">
     <select id="invigilatePageWarningList" resultType="com.qmth.themis.business.bean.admin.InvigilateListWarningBean">
         select (@i := @i + 1) as seq,t.* from(select
         select (@i := @i + 1) as seq,t.* from(select
-        tiiwi.id as warningId,
+        distinct
         tee.id as examId,
         tee.id as examId,
         tee.name as examName,
         tee.name as examName,
         teea.id as examActivityId,
         teea.id as examActivityId,