wangliang 1 жил өмнө
parent
commit
801434b9a9
19 өөрчлөгдсөн 249 нэмэгдсэн , 36 устгасан
  1. 1 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java
  2. 1 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java
  3. 1 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamReexamController.java
  4. 1 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateController.java
  5. 1 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateWarnInfoController.java
  6. 2 0
      themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java
  7. 0 1
      themis-business/src/main/java/com/qmth/themis/business/dao/TEOrgSummaryMapper.java
  8. 37 0
      themis-business/src/main/java/com/qmth/themis/business/dao/TERegionSummaryMapper.java
  9. 6 6
      themis-business/src/main/java/com/qmth/themis/business/dao/TOeExamRecordMapper.java
  10. 0 11
      themis-business/src/main/java/com/qmth/themis/business/entity/TERegionSummary.java
  11. 31 0
      themis-business/src/main/java/com/qmth/themis/business/enums/RegionSummaryEnum.java
  12. 4 0
      themis-business/src/main/java/com/qmth/themis/business/service/TERegionSummaryService.java
  13. 19 0
      themis-business/src/main/java/com/qmth/themis/business/service/ThemisCacheService.java
  14. 46 0
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TERegionSummaryServiceImpl.java
  15. 6 1
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java
  16. 35 0
      themis-business/src/main/java/com/qmth/themis/business/service/impl/ThemisCacheServiceImpl.java
  17. 42 0
      themis-business/src/main/resources/mapper/TERegionSummaryMapper.xml
  18. 12 12
      themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml
  19. 4 0
      themis-task/src/main/java/com/qmth/themis/task/quartz/ExamSummaryJob.java

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

@@ -10,7 +10,7 @@ import com.google.common.reflect.TypeToken;
 import com.qmth.boot.core.solar.config.SolarProperties;
 import com.qmth.boot.core.solar.service.SolarService;
 import com.qmth.themis.admin.config.DictionaryConfig;
-import com.qmth.themis.business.annotation.RedisLimitAnnotation;
+//import com.qmth.themis.business.annotation.RedisLimitAnnotation;
 import com.qmth.themis.business.bean.admin.DataCountBean;
 import com.qmth.themis.business.bean.admin.MapDataCountBean;
 import com.qmth.themis.business.bean.admin.OrgDataCountBean;

+ 1 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -5,7 +5,7 @@ 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.annotation.Logs;
-import com.qmth.themis.business.annotation.RedisLimitAnnotation;
+//import com.qmth.themis.business.annotation.RedisLimitAnnotation;
 import com.qmth.themis.business.cache.ExamingDataCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;

+ 1 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamReexamController.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 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.annotation.RedisLimitAnnotation;
+//import com.qmth.themis.business.annotation.RedisLimitAnnotation;
 import com.qmth.themis.business.bean.admin.ReexamListRequestBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;

+ 1 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateController.java

@@ -6,7 +6,7 @@ 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.annotation.RedisLimitAnnotation;
+//import com.qmth.themis.business.annotation.RedisLimitAnnotation;
 import com.qmth.themis.business.bean.admin.*;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;

+ 1 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateWarnInfoController.java

@@ -2,7 +2,7 @@ package com.qmth.themis.admin.api;
 
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.themis.business.annotation.RedisLimitAnnotation;
+//import com.qmth.themis.business.annotation.RedisLimitAnnotation;
 import com.qmth.themis.business.bean.admin.InvigilateListWarningBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;

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

@@ -545,6 +545,8 @@ public class SystemConstant {
 
     public static final String orgSummaryCache = "org:summary:cache";
 
+    public static final String regionSummaryCache = "region:summary:cache";
+
     //    /**
     //     * ehcache配置
     //     */

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

@@ -49,7 +49,6 @@ public interface TEOrgSummaryMapper extends BaseMapper<TEOrgSummary> {
      */
     Integer orgSummaryByExamCount(@Param("examIdSet") List<Long> examIdSet);
 
-
     /**
      * 保存机构统计信息
      *

+ 37 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TERegionSummaryMapper.java

@@ -2,6 +2,9 @@ package com.qmth.themis.business.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.themis.business.entity.TERegionSummary;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,38 @@ import com.qmth.themis.business.entity.TERegionSummary;
  */
 public interface TERegionSummaryMapper extends BaseMapper<TERegionSummary> {
 
+    /**
+     * 保存地区统计信息
+     *
+     * @return
+     */
+    List<TERegionSummary> regionSummary();
+
+    /**
+     * 保存地区统计信息
+     *
+     * @param fieldName
+     * @param fieldValue
+     * @return
+     */
+    Boolean saveRegionSummary(@Param("fieldName") String fieldName, @Param("fieldValue") String fieldValue);
+
+    /**
+     * 更新地区统计信息
+     *
+     * @param country
+     * @param province
+     * @param fieldValue
+     * @return
+     */
+    Boolean updateRegionSummary(@Param("country") String country, @Param("province") String province, @Param("fieldValue") String fieldValue);
+
+    /**
+     * 查询地区统计信息count
+     *
+     * @param country
+     * @param province
+     * @return
+     */
+    int selectRegionSummaryCount(@Param("country") String country, @Param("province") String province);
 }

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

@@ -580,12 +580,12 @@ public interface TOeExamRecordMapper extends BaseMapper<TOeExamRecord> {
 //     */
 //    List<OrgDataCountBean> orgDataCount();
 
-    /**
-     * 地图数据统计
-     *
-     * @return
-     */
-    List<MapDataCountBean> mapDataCount();
+//    /**
+//     * 地图数据统计
+//     *
+//     * @return
+//     */
+//    List<MapDataCountBean> mapDataCount();
 
 //    /**
 //     * 根据id更新预警数量

+ 0 - 11
themis-business/src/main/java/com/qmth/themis/business/entity/TERegionSummary.java

@@ -23,9 +23,6 @@ public class TERegionSummary implements Serializable {
     @ApiModelProperty(value = "省份")
     private String province;
 
-    @ApiModelProperty(value = "城市")
-    private String city;
-
     @ApiModelProperty(value = "在线人数")
     private Integer onlineCount;
 
@@ -45,14 +42,6 @@ public class TERegionSummary implements Serializable {
         this.province = province;
     }
 
-    public String getCity() {
-        return city;
-    }
-
-    public void setCity(String city) {
-        this.city = city;
-    }
-
     public Integer getOnlineCount() {
         return onlineCount;
     }

+ 31 - 0
themis-business/src/main/java/com/qmth/themis/business/enums/RegionSummaryEnum.java

@@ -0,0 +1,31 @@
+package com.qmth.themis.business.enums;
+
+/**
+ * @Description: 地区信息统计表enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/10/28
+ */
+public enum RegionSummaryEnum {
+
+    country("country"),
+
+    province("province"),
+
+    onlineCount("online_count");
+
+    RegionSummaryEnum(String code) {
+        this.code = code;
+    }
+
+    private String code;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+}

+ 4 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TERegionSummaryService.java

@@ -13,4 +13,8 @@ import com.qmth.themis.business.entity.TERegionSummary;
  */
 public interface TERegionSummaryService extends IService<TERegionSummary> {
 
+    /**
+     * 保存地区统计信息
+     */
+    public void regionSummary();
 }

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

@@ -463,4 +463,23 @@ public interface ThemisCacheService {
      * @param orgId
      */
     public void removeOrgSummaryCache(Long orgId);
+
+    /**
+     * 获取地区统计缓存
+     *
+     * @return
+     */
+    public List<TERegionSummary> addRegionSummaryCache();
+
+    /**
+     * 更新地区统计缓存
+     *
+     * @return
+     */
+    public List<TERegionSummary> updateRegionSummaryCache();
+
+    /**
+     * 删除地区统计缓存
+     */
+    public void removeOrgSummaryCache();
 }

+ 46 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TERegionSummaryServiceImpl.java

@@ -3,8 +3,15 @@ package com.qmth.themis.business.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.dao.TERegionSummaryMapper;
 import com.qmth.themis.business.entity.TERegionSummary;
+import com.qmth.themis.business.enums.RegionSummaryEnum;
 import com.qmth.themis.business.service.TERegionSummaryService;
+import com.qmth.themis.business.service.ThemisCacheService;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.StringJoiner;
 
 /**
  * <p>
@@ -17,4 +24,43 @@ import org.springframework.stereotype.Service;
 @Service
 public class TERegionSummaryServiceImpl extends ServiceImpl<TERegionSummaryMapper, TERegionSummary> implements TERegionSummaryService {
 
+    @Resource
+    ThemisCacheService themisCacheService;
+
+    /**
+     * 保存地区统计信息
+     */
+    @Override
+    public void regionSummary() {
+        List<TERegionSummary> teRegionSummaryList = this.baseMapper.regionSummary();
+        if (!CollectionUtils.isEmpty(teRegionSummaryList)) {
+            for (TERegionSummary t : teRegionSummaryList) {
+                int count = this.baseMapper.selectRegionSummaryCount(t.getCountry(), t.getProvince());
+                StringJoiner stringJoinerFieldName = new StringJoiner(",");
+                StringJoiner stringJoinerFieldValue = new StringJoiner(",");
+                RegionSummaryEnum[] regionSummaryEnums = RegionSummaryEnum.values();
+                if (count == 0) {
+                    for (int i = 0; i < regionSummaryEnums.length; i++) {
+                        stringJoinerFieldName.add(regionSummaryEnums[i].getCode());
+                    }
+                    stringJoinerFieldValue.add("'" + t.getCountry() + "'")
+                            .add("'" + t.getProvince() + "'")
+                            .add(t.getOnlineCount() + "");
+                    this.baseMapper.saveRegionSummary(stringJoinerFieldName.toString(), stringJoinerFieldValue.toString());
+                } else {
+                    for (int i = 0; i < regionSummaryEnums.length; i++) {
+                        switch (regionSummaryEnums[i]) {
+                            case onlineCount:
+                                stringJoinerFieldValue.add(regionSummaryEnums[i].getCode() + "=" + t.getOnlineCount());
+                                break;
+                            default:
+                                break;
+                        }
+                    }
+                    this.baseMapper.updateRegionSummary(t.getCountry(), t.getProvince(), stringJoinerFieldValue.toString());
+                }
+            }
+            themisCacheService.updateRegionSummaryCache();
+        }
+    }
 }

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

@@ -1790,6 +1790,11 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      */
     @Override
     public List<MapDataCountBean> mapDataCount() {
-        return tOeExamRecordMapper.mapDataCount();
+        List<TERegionSummary> teRegionSummaryList = themisCacheService.addRegionSummaryCache();
+        if (!CollectionUtils.isEmpty(teRegionSummaryList)) {
+            return GsonUtil.fromJson(GsonUtil.toJson(teRegionSummaryList), new TypeToken<List<MapDataCountBean>>() {
+            }.getType());
+        }
+        return new ArrayList<MapDataCountBean>();
     }
 }

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

@@ -97,6 +97,9 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     @Resource
     TEOrgSummaryService teOrgSummaryService;
 
+    @Resource
+    TERegionSummaryService teRegionSummaryService;
+
     /**
      * 添加机构缓存
      *
@@ -635,6 +638,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
                 });
             }
             teOrgSummaryService.orgSummary(0L, null);//统计全局机构信息
+            teRegionSummaryService.regionSummary();
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
         }
@@ -886,4 +890,35 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     public void removeOrgSummaryCache(Long orgId) {
 
     }
+
+    /**
+     * 获取地区统计缓存
+     *
+     * @return
+     */
+    @Override
+    @Cacheable(value = SystemConstant.regionSummaryCache, unless = "#result == null")
+    public List<TERegionSummary> addRegionSummaryCache() {
+        return teRegionSummaryService.list();
+    }
+
+    /**
+     * 更新地区统计缓存
+     *
+     * @return
+     */
+    @Override
+    @CachePut(value = SystemConstant.regionSummaryCache, condition = "#result != null")
+    public List<TERegionSummary> updateRegionSummaryCache() {
+        return teRegionSummaryService.list();
+    }
+
+    /**
+     * 删除地区统计缓存
+     */
+    @Override
+    @CacheEvict(value = SystemConstant.regionSummaryCache)
+    public void removeOrgSummaryCache() {
+
+    }
 }

+ 42 - 0
themis-business/src/main/resources/mapper/TERegionSummaryMapper.xml

@@ -2,4 +2,46 @@
 <!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.TERegionSummaryMapper">
 
+    <select id="regionSummary" resultType="com.qmth.themis.business.entity.TERegionSummary">
+        select tir.country,
+        tir.province,
+        count(toer.id) as onlineCount
+        from t_ip_region tir
+        join t_oe_exam_record toer on tir.exam_record_id = toer.id
+        WHERE toer.client_websocket_status = 'ON_LINE'
+        group by
+        tir.country,
+        tir.province
+    </select>
+
+    <insert id="saveRegionSummary">
+        INSERT INTO t_e_region_summary
+            (${fieldName})
+        VALUES(${fieldValue})
+    </insert>
+
+    <update id="updateRegionSummary">
+        update t_e_region_summary
+        set ${fieldValue}
+        <where> 1 = 1
+            <if test="country != null and country != ''">
+                and country = #{country}
+            </if>
+            <if test="province != null and province != ''">
+                and province = #{province}
+            </if>
+        </where>
+    </update>
+
+    <select id="selectRegionSummaryCount" resultType="java.lang.Integer">
+        select count(1) from t_e_region_summary
+        <where> 1 = 1
+            <if test="country != null and country != ''">
+                and country = #{country}
+            </if>
+            <if test="province != null and province != ''">
+                and province = #{province}
+            </if>
+        </where>
+    </select>
 </mapper>

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

@@ -1716,18 +1716,18 @@
 <!--                 t.code-->
 <!--    </select>-->
 
-    <select id="mapDataCount" resultType="com.qmth.themis.business.bean.admin.MapDataCountBean">
-        select tir.country,
-               tir.province,
-               count(toer.id) as onlineCount
-        from t_ip_region tir
-                 join t_oe_exam_record toer on tir.exam_record_id = toer.id
-        WHERE toer.client_websocket_status = 'ON_LINE'
-          <!--and tir.country != '0' and tir.province != '0'-->
-        group by
-            tir.country,
-            tir.province
-    </select>
+<!--    <select id="mapDataCount" resultType="com.qmth.themis.business.bean.admin.MapDataCountBean">-->
+<!--        select tir.country,-->
+<!--               tir.province,-->
+<!--               count(toer.id) as onlineCount-->
+<!--        from t_ip_region tir-->
+<!--                 join t_oe_exam_record toer on tir.exam_record_id = toer.id-->
+<!--        WHERE toer.client_websocket_status = 'ON_LINE'-->
+<!--          &lt;!&ndash;and tir.country != '0' and tir.province != '0'&ndash;&gt;-->
+<!--        group by-->
+<!--            tir.country,-->
+<!--            tir.province-->
+<!--    </select>-->
 
 <!--    <update id="updateWarningCount">-->
 <!--        update t_oe_exam_record set warning_count = warning_count + 1, warning_unread = warning_unread + 1 where id = #{id}-->

+ 4 - 0
themis-task/src/main/java/com/qmth/themis/task/quartz/ExamSummaryJob.java

@@ -46,6 +46,9 @@ public class ExamSummaryJob extends QuartzJobBean {
     @Resource
     TEOrgSummaryService teOrgSummaryService;
 
+    @Resource
+    TERegionSummaryService teRegionSummaryService;
+
     @Override
     protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
         log.info("ExamSummaryJob进来了,context:{}", context);
@@ -84,6 +87,7 @@ public class ExamSummaryJob extends QuartzJobBean {
                         //当考试场次开始时间和场次结束时间在范围内,则统计,否则删除考试批次缓存列表,考试批次统计缓存信息
                         if (ac.getEnable().intValue() == 1 && startTime <= timestamp && endTime >= timestamp) {
                             teExamSummaryService.examSummary(l, Long.parseLong(k), v);
+                            teRegionSummaryService.regionSummary();
                         } else {
                             themisCacheService.removeTodayExamCache(l.toString(), k);
                         }