Browse Source

增加超管机构统计

wangliang 1 year ago
parent
commit
0bdd528d79

+ 4 - 5
themis-business/src/main/java/com/qmth/themis/business/bean/admin/DataCountBean.java

@@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.List;
 import java.util.List;
-import java.util.Objects;
 
 
 /**
 /**
  * @Description: 数据统计
  * @Description: 数据统计
@@ -38,10 +37,10 @@ public class DataCountBean implements Serializable {
     }
     }
 
 
     public DataCountBean(List<Long> list, List<OrgDataCountBean> orgDataCountBeanList, List<MapDataCountBean> mapDataCountBeanList) {
     public DataCountBean(List<Long> list, List<OrgDataCountBean> orgDataCountBeanList, List<MapDataCountBean> mapDataCountBeanList) {
-        this.onlineCount = Objects.nonNull(list.get(0)) ? list.get(0) : 0L;
-        this.examCount = Objects.nonNull(list.get(1)) ? list.get(1) : 0L;
-        this.examRecordCount = Objects.nonNull(list.get(2)) ? list.get(2) : 0L;
-        this.examStudentCount = Objects.nonNull(list.get(3)) ? list.get(3) : 0L;
+        this.onlineCount = list.get(0);
+        this.examCount = list.get(1);
+        this.examRecordCount = list.get(2);
+        this.examStudentCount = list.get(3);
         this.orgDataCountBeanList = orgDataCountBeanList;
         this.orgDataCountBeanList = orgDataCountBeanList;
         this.mapDataCountBeanList = mapDataCountBeanList;
         this.mapDataCountBeanList = mapDataCountBeanList;
     }
     }

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/bean/admin/OrgDataCountBean.java

@@ -25,6 +25,17 @@ public class OrgDataCountBean implements Serializable {
     @ApiModelProperty(name = "考试人数")
     @ApiModelProperty(name = "考试人数")
     private Integer examCount = 0;
     private Integer examCount = 0;
 
 
+    public OrgDataCountBean() {
+
+    }
+
+    public OrgDataCountBean(String name, String code, Integer onlineCount, Integer examCount) {
+        this.name = name;
+        this.code = code;
+        this.onlineCount = onlineCount;
+        this.examCount = examCount;
+    }
+
     public Integer getOnlineCount() {
     public Integer getOnlineCount() {
         return onlineCount;
         return onlineCount;
     }
     }

+ 12 - 12
themis-business/src/main/java/com/qmth/themis/business/dao/TOeExamRecordMapper.java

@@ -566,19 +566,19 @@ public interface TOeExamRecordMapper extends BaseMapper<TOeExamRecord> {
     @SuppressWarnings("MybatisXMapperMethodInspection")
     @SuppressWarnings("MybatisXMapperMethodInspection")
     public List<Map> cleanExamFirstPrepareCache(@Param("examIds") Set<Long> examIds);
     public List<Map> cleanExamFirstPrepareCache(@Param("examIds") Set<Long> examIds);
 
 
-    /**
-     * 数据统计
-     *
-     * @return
-     */
-    List<Long> dataCount();
+//    /**
+//     * 数据统计
+//     *
+//     * @return
+//     */
+//    List<Long> dataCount();
 
 
-    /**
-     * 机构数据统计
-     *
-     * @return
-     */
-    List<OrgDataCountBean> orgDataCount();
+//    /**
+//     * 机构数据统计
+//     *
+//     * @return
+//     */
+//    List<OrgDataCountBean> orgDataCount();
 
 
     /**
     /**
      * 地图数据统计
      * 地图数据统计

+ 10 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TBOrgService.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.dto.response.TBOrgDto;
 import com.qmth.themis.business.dto.response.TBOrgDto;
 import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.entity.TBOrg;
+import org.springframework.util.LinkedMultiValueMap;
 
 
 import java.util.Map;
 import java.util.Map;
+import java.util.Set;
 
 
 /**
 /**
  * @Description: 机构 服务类
  * @Description: 机构 服务类
@@ -26,4 +28,12 @@ public interface TBOrgService extends IService<TBOrg> {
      * @return
      * @return
      */
      */
     public IPage<TBOrgDto> queryByPage(IPage<Map> iPage, String code, String name, Integer enable);
     public IPage<TBOrgDto> queryByPage(IPage<Map> iPage, String code, String name, Integer enable);
+
+    /**
+     * 根据考试批次id集合合并orgId
+     *
+     * @param examIdSet
+     * @return
+     */
+    LinkedMultiValueMap<Long, Long> mergeOrgId(Set<Long> examIdSet);
 }
 }

+ 28 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBOrgServiceImpl.java

@@ -2,14 +2,19 @@ package com.qmth.themis.business.service.impl;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.dao.TBOrgMapper;
 import com.qmth.themis.business.dao.TBOrgMapper;
 import com.qmth.themis.business.dto.response.TBOrgDto;
 import com.qmth.themis.business.dto.response.TBOrgDto;
 import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.service.TBOrgService;
 import com.qmth.themis.business.service.TBOrgService;
+import com.qmth.themis.business.service.TEExamService;
+import com.qmth.themis.business.service.ThemisCacheService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.Map;
 import java.util.Map;
+import java.util.Set;
 
 
 /**
 /**
  * @Description: 机构 服务实现类
  * @Description: 机构 服务实现类
@@ -24,6 +29,12 @@ public class TBOrgServiceImpl extends ServiceImpl<TBOrgMapper, TBOrg> implements
     @Resource
     @Resource
     TBOrgMapper tbOrgMapper;
     TBOrgMapper tbOrgMapper;
 
 
+    @Resource
+    TEExamService teExamService;
+
+    @Resource
+    ThemisCacheService themisCacheService;
+
     /**
     /**
      * 查询机构分页信息
      * 查询机构分页信息
      *
      *
@@ -37,4 +48,21 @@ public class TBOrgServiceImpl extends ServiceImpl<TBOrgMapper, TBOrg> implements
     public IPage<TBOrgDto> queryByPage(IPage<Map> iPage, String code, String name, Integer enable) {
     public IPage<TBOrgDto> queryByPage(IPage<Map> iPage, String code, String name, Integer enable) {
         return tbOrgMapper.queryByPage(iPage, code, name, enable);
         return tbOrgMapper.queryByPage(iPage, code, name, enable);
     }
     }
+
+    /**
+     * 根据考试批次id集合合并orgId
+     *
+     * @param examIdSet
+     * @return
+     */
+    @Override
+    public LinkedMultiValueMap<Long, Long> mergeOrgId(Set<Long> examIdSet) {
+        LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();
+        for (Long l : examIdSet) {
+            ExamCacheBean examCacheBean = teExamService.getExamCacheBean(l);
+            TBOrg tbOrg = themisCacheService.addOrgCache(examCacheBean.getOrgId());
+            orgExamIdMap.add(tbOrg.getId(), l);
+        }
+        return orgExamIdMap;
+    }
 }
 }

+ 22 - 6
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -18,10 +18,7 @@ import com.qmth.themis.business.dao.TOeExamRecordMapper;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.response.MarkResultDto;
 import com.qmth.themis.business.dto.response.MarkResultDto;
 import com.qmth.themis.business.dto.response.TEStudentMonitorRecordDto;
 import com.qmth.themis.business.dto.response.TEStudentMonitorRecordDto;
-import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
-import com.qmth.themis.business.entity.TOeExamAnswer;
-import com.qmth.themis.business.entity.TOeExamRecord;
-import com.qmth.themis.business.entity.TSyncExamStudentScore;
+import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.business.util.*;
@@ -38,6 +35,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.LinkedMultiValueMap;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.File;
@@ -113,6 +111,9 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     @Resource
     @Resource
     ThemisCacheService themisCacheService;
     ThemisCacheService themisCacheService;
 
 
+    @Resource
+    TBOrgService tbOrgService;
+
     @Transactional
     @Transactional
     @Override
     @Override
     public Long saveByPrepare(Long examId, Long examActivityId, Long examStudentId, Long paperId,
     public Long saveByPrepare(Long examId, Long examActivityId, Long examStudentId, Long paperId,
@@ -1745,7 +1746,13 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      */
      */
     @Override
     @Override
     public List<Long> dataCount() {
     public List<Long> dataCount() {
-        return tOeExamRecordMapper.dataCount();
+        TEOrgSummary teOrgSummary = themisCacheService.addOrgSummaryCache(0L);
+        List<Long> list = new ArrayList<>();
+        list.add(Objects.nonNull(teOrgSummary.getOnlineCount()) ? Long.parseLong(teOrgSummary.getOnlineCount().toString()) : 0L);
+        list.add(Objects.nonNull(teOrgSummary.getExamCount()) ? Long.parseLong(teOrgSummary.getExamCount().toString()) : 0L);
+        list.add(Objects.nonNull(teOrgSummary.getFinishCount()) ? Long.parseLong(teOrgSummary.getFinishCount().toString()) : 0L);
+        list.add(Objects.nonNull(teOrgSummary.getFinishStudentCount()) ? Long.parseLong(teOrgSummary.getFinishStudentCount().toString()) : 0L);
+        return list;
     }
     }
 
 
     /**
     /**
@@ -1755,7 +1762,16 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      */
      */
     @Override
     @Override
     public List<OrgDataCountBean> orgDataCount() {
     public List<OrgDataCountBean> orgDataCount() {
-        return tOeExamRecordMapper.orgDataCount();
+        Set<Long> examIdSet = themisCacheService.getTodayExamListCache();
+        LinkedMultiValueMap<Long, Long> orgExamIdMap = tbOrgService.mergeOrgId(examIdSet);
+        List<OrgDataCountBean> orgDataCountBeanList = new ArrayList<>();
+        //统计机构信息
+        orgExamIdMap.forEach((k, v) -> {
+            TEOrgSummary teOrgSummary = themisCacheService.addOrgSummaryCache(k);
+            TBOrg tbOrg = themisCacheService.addOrgCache(k);
+            orgDataCountBeanList.add(new OrgDataCountBean(tbOrg.getCode(), tbOrg.getName(), teOrgSummary.getOnlineCount(), teOrgSummary.getExamCount()));
+        });
+        return orgDataCountBeanList;
     }
     }
 
 
     /**
     /**

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

@@ -1661,60 +1661,60 @@
         count(toer.id) > 0) a;
         count(toer.id) > 0) a;
     </select>
     </select>
 
 
-    <select id="dataCount" resultType="java.lang.Long">
-        select count(1) as c
-        from t_oe_exam_record toer
-        where toer.client_websocket_status = 'ON_LINE'
-        union all
-        select count(1) as c
-        from t_oe_exam_record toer
-        where toer.STATUS in ('ANSWERING', 'RESUME_PREPARE')
-          and toer.client_websocket_status = 'ON_LINE'
-        union all
-        select count(1) as c
-        from t_oe_exam_record toer
-        where toer.STATUS in ('FINISHED', 'PERSISTED')
-        union all
-        select count(distinct tees.id) as c
-        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')
-    </select>
+<!--    <select id="dataCount" resultType="java.lang.Long">-->
+<!--        select count(1) as c-->
+<!--        from t_oe_exam_record toer-->
+<!--        where toer.client_websocket_status = 'ON_LINE'-->
+<!--        union all-->
+<!--        select count(1) as c-->
+<!--        from t_oe_exam_record toer-->
+<!--        where toer.STATUS in ('ANSWERING', 'RESUME_PREPARE')-->
+<!--          and toer.client_websocket_status = 'ON_LINE'-->
+<!--        union all-->
+<!--        select count(1) as c-->
+<!--        from t_oe_exam_record toer-->
+<!--        where toer.STATUS in ('FINISHED', 'PERSISTED')-->
+<!--        union all-->
+<!--        select count(distinct tees.id) as c-->
+<!--        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')-->
+<!--    </select>-->
 
 
-    <select id="orgDataCount" resultType="com.qmth.themis.business.bean.admin.OrgDataCountBean">
-        select t.name           as name,
-               t.code           as code,
-               sum(onlineCount) as onlineCount,
-               sum(examCount)   as examCount
-        from (select tbo.name,
-                     tbo.code,
-                     count(toer.id) as onlineCount,
-                     0              as examCount
-              from t_b_org tbo
-                       join t_e_exam tee on
-                  tbo.id = tee.org_id
-                       join t_oe_exam_record toer on
-                  tee.id = toer.exam_id
-              WHERE toer.client_websocket_status = 'ON_LINE'
-              group by tbo.name,
-                       tbo.code
-              union all
-              select tbo.name,
-                     tbo.code,
-                     0              as onlineCount,
-                     count(toer.id) as examCount
-              from t_b_org tbo
-                       join t_e_exam tee on
-                  tbo.id = tee.org_id
-                       join t_oe_exam_record toer on
-                  tee.id = toer.exam_id
-              WHERE toer.STATUS in ('ANSWERING', 'RESUME_PREPARE')
-                and toer.client_websocket_status = 'ON_LINE'
-              group by tbo.name,
-                       tbo.code) t
-        group by t.name,
-                 t.code
-    </select>
+<!--    <select id="orgDataCount" resultType="com.qmth.themis.business.bean.admin.OrgDataCountBean">-->
+<!--        select t.name           as name,-->
+<!--               t.code           as code,-->
+<!--               sum(onlineCount) as onlineCount,-->
+<!--               sum(examCount)   as examCount-->
+<!--        from (select tbo.name,-->
+<!--                     tbo.code,-->
+<!--                     count(toer.id) as onlineCount,-->
+<!--                     0              as examCount-->
+<!--              from t_b_org tbo-->
+<!--                       join t_e_exam tee on-->
+<!--                  tbo.id = tee.org_id-->
+<!--                       join t_oe_exam_record toer on-->
+<!--                  tee.id = toer.exam_id-->
+<!--              WHERE toer.client_websocket_status = 'ON_LINE'-->
+<!--              group by tbo.name,-->
+<!--                       tbo.code-->
+<!--              union all-->
+<!--              select tbo.name,-->
+<!--                     tbo.code,-->
+<!--                     0              as onlineCount,-->
+<!--                     count(toer.id) as examCount-->
+<!--              from t_b_org tbo-->
+<!--                       join t_e_exam tee on-->
+<!--                  tbo.id = tee.org_id-->
+<!--                       join t_oe_exam_record toer on-->
+<!--                  tee.id = toer.exam_id-->
+<!--              WHERE toer.STATUS in ('ANSWERING', 'RESUME_PREPARE')-->
+<!--                and toer.client_websocket_status = 'ON_LINE'-->
+<!--              group by tbo.name,-->
+<!--                       tbo.code) t-->
+<!--        group by t.name,-->
+<!--                 t.code-->
+<!--    </select>-->
 
 
     <select id="mapDataCount" resultType="com.qmth.themis.business.bean.admin.MapDataCountBean">
     <select id="mapDataCount" resultType="com.qmth.themis.business.bean.admin.MapDataCountBean">
         select tir.country,
         select tir.country,