Selaa lähdekoodia

增加超管统计

wangliang 1 vuosi sitten
vanhempi
commit
f54612bea0

+ 3 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -208,6 +208,7 @@ public class SystemConstant {
     public static final Long AFTER_AUDIO_ATTACHMENT_ID = 2L;
     public static final Integer BEFORE_AUDIO_SECOND = 60;
     public static final Integer AFTER_AUDIO_SECOND = 900;
+    public static final long FINISH_DELAY_TIME = 1000 * 60 * 5;
     //    public static final String AUTH_INFO_CACHE = "auth:info:cache";
     public static final String EXAM_AUDIO_CACHE = "exam:audio:cache";
     public static final String ATTACHMENT_CACHE = "attachment:cache";
@@ -542,6 +543,8 @@ public class SystemConstant {
 
     public static final String examSummaryCache = "exam:summary:cache";
 
+    public static final String orgSummaryCache = "org:summary:cache";
+
     //    /**
     //     * ehcache配置
     //     */

+ 63 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEOrgSummaryMapper.java

@@ -2,6 +2,10 @@ package com.qmth.themis.business.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.themis.business.entity.TEOrgSummary;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -13,4 +17,63 @@ import com.qmth.themis.business.entity.TEOrgSummary;
  */
 public interface TEOrgSummaryMapper extends BaseMapper<TEOrgSummary> {
 
+    /**
+     * 机构统计考试次数和考试人数信息
+     *
+     * @param examIdSet
+     * @return
+     */
+    List<Integer> orgSummaryByFinishCountAndFinishStudentCount(@Param("examIdSet") List<Long> examIdSet);
+
+    /**
+     * 统计全局考试科次
+     *
+     * @param examIdSet
+     * @return
+     */
+    Integer orgSummaryByFinishCount(@Param("examIdSet") List<Long> examIdSet);
+
+    /**
+     * 统计全局考试科次
+     *
+     * @param examIdSet
+     * @return
+     */
+    Integer orgSummaryByOnlineCount(@Param("examIdSet") List<Long> examIdSet);
+
+    /**
+     * 统计全局考试科次
+     *
+     * @param examIdSet
+     * @return
+     */
+    Integer orgSummaryByExamCount(@Param("examIdSet") List<Long> examIdSet);
+
+
+    /**
+     * 保存机构统计信息
+     *
+     * @param fieldName
+     * @param fieldValue
+     * @return
+     */
+    Boolean saveOrgSummary(@Param("fieldName") String fieldName, @Param("fieldValue") String fieldValue);
+
+    /**
+     * 更新机构统计信息
+     *
+     * @param orgId
+     * @param fieldValue
+     * @return
+     */
+    Boolean updateOrgSummary(@Param("orgId") Long orgId, @Param("fieldValue") String fieldValue);
+
+    /**
+     * 查询机构统计信息count
+     *
+     * @param orgId
+     * @return
+     */
+    int selectOrgSummaryCount(@Param("orgId") Long orgId);
+
 }

+ 18 - 5
themis-business/src/main/java/com/qmth/themis/business/entity/TEOrgSummary.java

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * <p>
@@ -21,19 +22,31 @@ public class TEOrgSummary implements Serializable {
 
     @ApiModelProperty(value = "机构ID,全局为0")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long orgId;
+    private Long orgId = 0L;
 
     @ApiModelProperty(value = "在线人数")
-    private Integer onlineCount;
+    private Integer onlineCount = 0;
 
     @ApiModelProperty(value = "考试人数")
-    private Integer examCount;
+    private Integer examCount = 0;
 
     @ApiModelProperty(value = "完成考试次数")
-    private Integer finishCount;
+    private Integer finishCount = 0;
 
     @ApiModelProperty(value = "完成考试人数")
-    private Integer finishStudentCount;
+    private Integer finishStudentCount = 0;
+
+    public TEOrgSummary() {
+
+    }
+
+    public TEOrgSummary(Long orgId, Integer onlineCount, Integer examCount, Integer finishCount, Integer finishStudentCount) {
+        this.orgId = orgId;
+        this.onlineCount = Objects.isNull(onlineCount) ? 0 : onlineCount;
+        this.examCount = Objects.isNull(examCount) ? 0 : examCount;
+        this.finishCount = Objects.isNull(finishCount) ? 0 : finishCount;
+        this.finishStudentCount = Objects.isNull(finishStudentCount) ? 0 : finishStudentCount;
+    }
 
     public Long getOrgId() {
         return orgId;

+ 6 - 8
themis-business/src/main/java/com/qmth/themis/business/enums/ExamSummaryEnum.java

@@ -1,14 +1,12 @@
 package com.qmth.themis.business.enums;
 
-import java.util.Objects;
-
 /**
-* @Description: 考试信息统计表enum
-* @Param:
-* @return:
-* @Author: wangliang
-* @Date: 2023/10/28
-*/
+ * @Description: 考试信息统计表enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/10/28
+ */
 public enum ExamSummaryEnum {
 
     examId("exam_id"),

+ 35 - 0
themis-business/src/main/java/com/qmth/themis/business/enums/OrgSummaryEnum.java

@@ -0,0 +1,35 @@
+package com.qmth.themis.business.enums;
+
+/**
+ * @Description: 考试信息统计表enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/10/28
+ */
+public enum OrgSummaryEnum {
+
+    orgId("org_id"),
+
+    onlineCount("online_count"),
+
+    examCount("exam_count"),
+
+    finishCount("finish_count"),
+
+    finishStudentCount("finish_student_count");
+
+    OrgSummaryEnum(String code) {
+        this.code = code;
+    }
+
+    private String code;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+}

+ 16 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEOrgSummaryService.java

@@ -3,6 +3,8 @@ package com.qmth.themis.business.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.TEOrgSummary;
 
+import java.util.List;
+
 /**
  * <p>
  * 超管统计表 服务类
@@ -13,4 +15,18 @@ import com.qmth.themis.business.entity.TEOrgSummary;
  */
 public interface TEOrgSummaryService extends IService<TEOrgSummary> {
 
+    /**
+     * 保存机构统计信息
+     *
+     * @param orgId
+     * @param examIdSet
+     */
+    public void orgSummary(Long orgId, List<Long> examIdSet);
+
+    /**
+     * 保存机构统计信息
+     *
+     * @param teOrgSummary
+     */
+    public void saveOrgSummaryCommon(TEOrgSummary teOrgSummary);
 }

+ 23 - 0
themis-business/src/main/java/com/qmth/themis/business/service/ThemisCacheService.java

@@ -440,4 +440,27 @@ public interface ThemisCacheService {
      * @param roomCode
      */
     public void removeExamSummaryCache(Long examId, Long examActivityId, String roomCode);
+
+    /**
+     * 获取机构统计缓存
+     *
+     * @param orgId
+     * @return
+     */
+    public TEOrgSummary addOrgSummaryCache(Long orgId);
+
+    /**
+     * 更新机构统计缓存
+     *
+     * @param orgId
+     * @return
+     */
+    public TEOrgSummary updateOrgSummaryCache(Long orgId);
+
+    /**
+     * 删除机构统计缓存
+     *
+     * @param orgId
+     */
+    public void removeOrgSummaryCache(Long orgId);
 }

+ 1 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamSummaryServiceImpl.java

@@ -52,6 +52,7 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
     public void examSummary(Long examId, Long examActivityId, Set<String> roomCodeSet) {
         ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
         for (String s : roomCodeSet) {
+            //根据考试批次、场次、考场编码统计信息
             TEExamSummary teExamSummary = this.baseMapper.examSummary(examId, examActivityId, s);
             if (Objects.nonNull(teExamSummary)) {
                 teExamSummary.setExamId(examId);

+ 103 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEOrgSummaryServiceImpl.java

@@ -1,10 +1,24 @@
 package com.qmth.themis.business.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.dao.TEOrgSummaryMapper;
+import com.qmth.themis.business.entity.TBOrg;
+import com.qmth.themis.business.entity.TEExamSummary;
 import com.qmth.themis.business.entity.TEOrgSummary;
+import com.qmth.themis.business.enums.OrgSummaryEnum;
+import com.qmth.themis.business.service.TEExamService;
 import com.qmth.themis.business.service.TEOrgSummaryService;
+import com.qmth.themis.business.service.ThemisCacheService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.LinkedMultiValueMap;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Objects;
+import java.util.StringJoiner;
 
 /**
  * <p>
@@ -17,4 +31,92 @@ import org.springframework.stereotype.Service;
 @Service
 public class TEOrgSummaryServiceImpl extends ServiceImpl<TEOrgSummaryMapper, TEOrgSummary> implements TEOrgSummaryService {
 
-}
+    @Resource
+    ThemisCacheService themisCacheService;
+
+    @Resource
+    TEExamService teExamService;
+
+    @Resource
+    TEOrgSummaryService teOrgSummaryService;
+
+    /**
+     * 保存机构统计信息公用
+     *
+     * @param orgId
+     * @param examIdSet
+     */
+    @Override
+    @Transactional
+    public void orgSummary(Long orgId, List<Long> examIdSet) {
+        TEOrgSummary teOrgSummary = themisCacheService.addOrgSummaryCache(orgId);
+        if (Objects.isNull(teOrgSummary)) {//说明没有缓存
+            if (orgId.longValue() == 0) {//全局机构
+                Integer onlineCount = this.baseMapper.orgSummaryByOnlineCount(examIdSet);
+                Integer examCount = this.baseMapper.orgSummaryByExamCount(examIdSet);
+                List<Integer> finishCountList = this.baseMapper.orgSummaryByFinishCountAndFinishStudentCount(examIdSet);
+                teOrgSummary = new TEOrgSummary(orgId, onlineCount, examCount, finishCountList.get(0), finishCountList.get(1));
+                teOrgSummaryService.saveOrgSummaryCommon(teOrgSummary);
+            } else {
+                LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();
+                boolean reloadDb = false;
+                //先查询考试批次统计缓存
+                for (Long l : examIdSet) {
+                    List<TEExamSummary> teExamSummaryList = themisCacheService.addExamSummaryCache(l);
+                    if (!CollectionUtils.isEmpty(teExamSummaryList)) {//如果没有该批次的考试统计缓存信息,则自己从数据库取
+                        ExamCacheBean examCacheBean = teExamService.getExamCacheBean(l);
+                        TBOrg tbOrg = themisCacheService.addOrgCache(examCacheBean.getOrgId());
+                        orgExamIdMap.add(tbOrg.getId(), l);
+                    } else {
+                        reloadDb = true;
+                        break;
+                    }
+                }
+                if (reloadDb) {//没有该批次的考试统计缓存信息,则从数据库取数据
+                    Integer onlineCount = this.baseMapper.orgSummaryByOnlineCount(examIdSet);
+                    Integer examCount = this.baseMapper.orgSummaryByExamCount(examIdSet);
+                    List<Integer> finishCountList = this.baseMapper.orgSummaryByFinishCountAndFinishStudentCount(examIdSet);
+                    teOrgSummary = new TEOrgSummary(orgId, onlineCount, examCount, finishCountList.get(0), finishCountList.get(1));
+                    teOrgSummaryService.saveOrgSummaryCommon(teOrgSummary);
+                } else {
+                    orgExamIdMap.forEach((k, v) -> {//从考试批次缓存信息里拿取在线人数、考试人数、完成考生数
+                        Integer onlineCount = 0, examCount = 0, finishStudentCount = 0;
+                        for (Long l : v) {
+                            List<TEExamSummary> teExamSummaryList = themisCacheService.addExamSummaryCache(l);
+                            for (TEExamSummary t : teExamSummaryList) {
+                                onlineCount = onlineCount + t.getOnlineCount();
+                                examCount = examCount + t.getExamCount();
+                                finishStudentCount = finishStudentCount + t.getFinishCount();
+                            }
+                        }
+                        Integer finishCount = this.baseMapper.orgSummaryByFinishCount(v);
+                        TEOrgSummary teOrgSummaryNotZero = new TEOrgSummary(orgId, onlineCount, examCount, finishCount, finishStudentCount);
+                        teOrgSummaryService.saveOrgSummaryCommon(teOrgSummaryNotZero);
+                    });
+                }
+            }
+        }
+    }
+
+    /**
+     * 保存机构统计信息
+     *
+     * @param teOrgSummary
+     */
+    @Override
+    @Transactional
+    public void saveOrgSummaryCommon(TEOrgSummary teOrgSummary) {
+        StringJoiner stringJoinerFieldName = new StringJoiner(",");
+        StringJoiner stringJoinerFieldValue = new StringJoiner(",");
+        OrgSummaryEnum[] orgSummaryEnums = OrgSummaryEnum.values();
+        for (int i = 0; i < orgSummaryEnums.length; i++) {
+            stringJoinerFieldName.add(orgSummaryEnums[i].getCode());
+        }
+        stringJoinerFieldValue.add("'" + teOrgSummary.getOrgId() + "'")
+                .add(teOrgSummary.getOnlineCount() + "")
+                .add(teOrgSummary.getExamCount() + "")
+                .add(teOrgSummary.getFinishCount() + "")
+                .add(teOrgSummary.getFinishStudentCount() + "");
+        this.baseMapper.saveOrgSummary(stringJoinerFieldName.toString(), stringJoinerFieldValue.toString());
+    }
+}

+ 40 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/ThemisCacheServiceImpl.java

@@ -94,6 +94,9 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     @Resource
     TEExamService teExamService;
 
+    @Resource
+    TEOrgSummaryService teOrgSummaryService;
+
     /**
      * 添加机构缓存
      *
@@ -611,6 +614,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
             Long startTime = sdf2.parse(today + " 00:00:00").getTime();
             Long endTime = sdf2.parse(today + " 23:59:59").getTime();
             List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().ge(TEExamActivity::getStartTime, startTime).le(TEExamActivity::getStartTime, endTime).eq(TEExamActivity::getEnable, 1));
+            //统计当天00:00:00~23:59:59可以进行的考试批次、场次、考场编码信息
             if (!CollectionUtils.isEmpty(teExamActivityList)) {
                 LinkedMultiValueMap<Long, ExamActivityTodayBean> examActivityMap = new LinkedMultiValueMap<>();
                 for (TEExamActivity t : teExamActivityList) {
@@ -630,6 +634,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
                     }
                 });
             }
+            teOrgSummaryService.orgSummary(0L, null);//统计全局机构信息
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
         }
@@ -846,4 +851,39 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     public void removeExamSummaryCache(Long examId, Long examActivityId, String roomCode) {
 
     }
+
+    /**
+     * 获取机构统计缓存
+     *
+     * @param orgId
+     * @return
+     */
+    @Override
+    @Cacheable(value = SystemConstant.orgSummaryCache, key = "#p0", unless = "#result == null")
+    public TEOrgSummary addOrgSummaryCache(Long orgId) {
+        return teOrgSummaryService.getOne(new QueryWrapper<TEOrgSummary>().lambda().eq(TEOrgSummary::getOrgId, orgId));
+    }
+
+    /**
+     * 更新机构统计缓存
+     *
+     * @param orgId
+     * @return
+     */
+    @Override
+    @CachePut(value = SystemConstant.orgSummaryCache, key = "#p0", condition = "#result != null")
+    public TEOrgSummary updateOrgSummaryCache(Long orgId) {
+        return teOrgSummaryService.getOne(new QueryWrapper<TEOrgSummary>().lambda().eq(TEOrgSummary::getOrgId, orgId));
+    }
+
+    /**
+     * 删除机构统计缓存
+     *
+     * @param orgId
+     */
+    @Override
+    @CacheEvict(value = SystemConstant.orgSummaryCache, key = "#p0")
+    public void removeOrgSummaryCache(Long orgId) {
+
+    }
 }

+ 4 - 1
themis-business/src/main/resources/db/log/1.2.8.log

@@ -67,4 +67,7 @@ INSERT INTO t_b_role_privilege
 VALUES(149, 'INVIGILATE', 19);
 INSERT INTO t_b_role_privilege
 (id, role_code, privilege_id)
-VALUES(153, 'ADMIN', 19);
+VALUES(153, 'ADMIN', 19);
+
+delete t t_b_role_privilege t
+where t.id in (149,153);

+ 83 - 0
themis-business/src/main/resources/mapper/TEOrgSummaryMapper.xml

@@ -2,4 +2,87 @@
 <!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.TEOrgSummaryMapper">
 
+    <select id="orgSummaryByFinishCountAndFinishStudentCount" resultType="java.lang.Integer">
+        select count(1) as finishCount
+        from t_oe_exam_record toer
+        where toer.STATUS in ('FINISHED', 'PERSISTED')
+        <if test="examIdSet != null and examIdSet != '' and examIdSet.size > 0">
+            and toer.exam_id in
+            <foreach collection="examIdSet" item="examId" index="index" open="(" close=")" separator=",">
+                #{examId}
+            </foreach>
+        </if>
+        union all
+        select count(distinct tees.id) as finishStudentCount
+        from t_e_exam_student tees
+        left join t_oe_exam_record toer on toer.exam_student_id = tees.id
+        where toer.STATUS in ('FINISHED', 'PERSISTED')
+        <if test="examIdSet != null and examIdSet != '' and examIdSet.size > 0">
+            and toer.exam_id in
+            <foreach collection="examIdSet" item="examId" index="index" open="(" close=")" separator=",">
+                #{examId}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="orgSummaryByFinishCount" resultType="java.lang.Integer">
+        select count(1) as finishCount
+        from t_oe_exam_record toer
+        where toer.STATUS in ('FINISHED', 'PERSISTED')
+        <if test="examIdSet != null and examIdSet != '' and examIdSet.size > 0">
+            and toer.exam_id in
+            <foreach collection="examIdSet" item="examId" index="index" open="(" close=")" separator=",">
+                #{examId}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="orgSummaryByOnlineCount" resultType="java.lang.Integer">
+        select count(1) as onlineCount
+        from t_oe_exam_record toer
+        where toer.client_websocket_status = 'ON_LINE'
+        <if test="examIdSet != null and examIdSet != '' and examIdSet.size > 0">
+            and toer.exam_id in
+            <foreach collection="examIdSet" item="examId" index="index" open="(" close=")" separator=",">
+                #{examId}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="orgSummaryByExamCount" resultType="java.lang.Integer">
+        select count(1) as examCount
+        from t_oe_exam_record toer
+        where (toer.STATUS = 'ANSWERING' and toer.client_websocket_status = 'ON_LINE') or toer.status = 'RESUME_PREPARE' or toer.status = 'BREAK_OFF'
+        <if test="examIdSet != null and examIdSet != '' and examIdSet.size > 0">
+            and toer.exam_id in
+            <foreach collection="examIdSet" item="examId" index="index" open="(" close=")" separator=",">
+                #{examId}
+            </foreach>
+        </if>
+    </select>
+
+    <insert id="saveOrgSummary">
+        INSERT INTO t_e_org_summary
+            (${fieldName})
+        VALUES(${fieldValue})
+    </insert>
+
+    <update id="updateOrgSummary">
+        update t_e_org_summary
+        set ${fieldValue}
+        <where> 1 = 1
+            <if test="orgId != null and orgId != ''">
+                and org_id = #{orgId}
+            </if>
+        </where>
+    </update>
+
+    <select id="selectOrgSummaryCount" resultType="java.lang.Integer">
+        select count(1) from t_e_org_summary
+        <where> 1 = 1
+            <if test="orgId != null and orgId != ''">
+                and org_id = #{orgId}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 19 - 6
themis-task/src/main/java/com/qmth/themis/task/quartz/ExamSummaryJob.java

@@ -3,11 +3,9 @@ package com.qmth.themis.task.quartz;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.enums.ExamModeEnum;
-import com.qmth.themis.business.service.TEExamActivityService;
-import com.qmth.themis.business.service.TEExamService;
-import com.qmth.themis.business.service.TEExamSummaryService;
-import com.qmth.themis.business.service.ThemisCacheService;
+import com.qmth.themis.business.service.*;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.slf4j.Logger;
@@ -15,6 +13,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.scheduling.quartz.QuartzJobBean;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.LinkedMultiValueMap;
 
 import javax.annotation.Resource;
 import java.util.Map;
@@ -44,17 +43,26 @@ public class ExamSummaryJob extends QuartzJobBean {
     @Resource
     TEExamActivityService teExamActivityService;
 
+    @Resource
+    TEOrgSummaryService teOrgSummaryService;
+
     @Override
     protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
         log.info("ExamSummaryJob进来了,context:{}", context);
+        //获取当天考试列表
         Set<Long> examIdSet = themisCacheService.getTodayExamListCache();
         if (!CollectionUtils.isEmpty(examIdSet)) {
+            LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();
             for (Long l : examIdSet) {
                 ExamCacheBean examCacheBean = teExamService.getExamCacheBean(l);
+                //不在考试时间范围内或者禁用,则删除当前考试批次id,更新缓存
                 if (examCacheBean.getEnable().intValue() == 0 || examCacheBean.getEndTime().longValue() <= System.currentTimeMillis()) {
                     themisCacheService.removeTodayExamCache(l.toString());
                     themisCacheService.removeTodayExamListCache(l);
                 }
+                TBOrg tbOrg = themisCacheService.addOrgCache(examCacheBean.getOrgId());
+                orgExamIdMap.add(tbOrg.getId(), l);
+
                 Map<String, Set<String>> map = themisCacheService.getTodayExamCache(l.toString());
                 if (!CollectionUtils.isEmpty(map)) {
                     map.forEach((k, v) -> {
@@ -64,15 +72,16 @@ public class ExamSummaryJob extends QuartzJobBean {
                         if (ExamModeEnum.ANYTIME.equals(examCacheBean.getMode())) {
                             startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
                             endTime = ac.getFinishTime();
-                            endTime = endTime + (1000 * 60 * 5);//额外加5分钟,有可能后台交卷未完成
+                            endTime = endTime + SystemConstant.FINISH_DELAY_TIME;//额外加5分钟,有可能后台交卷未完成
                         } else {
                             startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
                             Integer openingSecondsTemp = ac.getOpeningSeconds();
                             openingSecondsTemp = Objects.nonNull(openingSecondsTemp) && openingSecondsTemp.intValue() == 0 ? SystemConstant.DEFAULT_OPENING_SECONDS : openingSecondsTemp;
                             endTime = ac.getStartTime() + (openingSecondsTemp * 1000);
-                            endTime = endTime + (1000 * 60 * 5);//额外加5分钟,有可能后台交卷未完成
+                            endTime = endTime + SystemConstant.FINISH_DELAY_TIME;//额外加5分钟,有可能后台交卷未完成
                         }
                         long timestamp = System.currentTimeMillis();
+                        //当考试场次开始时间和场次结束时间在范围内,则统计,否则删除考试批次缓存列表,考试批次统计缓存信息
                         if (ac.getEnable().intValue() == 1 && startTime <= timestamp && endTime >= timestamp) {
                             teExamSummaryService.examSummary(l, Long.parseLong(k), v);
                         } else {
@@ -84,6 +93,10 @@ public class ExamSummaryJob extends QuartzJobBean {
                     themisCacheService.removeTodayExamListCache(l);
                 }
             }
+            //统计机构信息
+            orgExamIdMap.forEach((k, v) -> {
+                teOrgSummaryService.orgSummary(k, v);
+            });
         }
     }
 }