Browse Source

新增超管数据统计

wangliang 2 years ago
parent
commit
0fd156f1c5

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

@@ -7,6 +7,9 @@ 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.bean.admin.DataCountBean;
+import com.qmth.themis.business.bean.admin.MapDataCountBean;
+import com.qmth.themis.business.bean.admin.OrgDataCountBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.response.RoomCodeQueryDto;
@@ -523,4 +526,18 @@ public class SysController {
         }
         return ResultUtil.ok(true);
     }
+
+    @ApiOperation(value = "数据统计接口")
+    @RequestMapping(value = "/data_count", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "超管数据统计接口", response = Result.class)})
+    public Result dataCount() {
+        List<Long> list = tOeExamRecordService.dataCount();
+        List<OrgDataCountBean> orgDataCountBeanList = tOeExamRecordService.orgDataCount();
+        List<MapDataCountBean> mapDataCountBeanList = tOeExamRecordService.mapDataCount();
+        if (!CollectionUtils.isEmpty(list)) {
+            return ResultUtil.ok(new DataCountBean(list, orgDataCountBeanList, mapDataCountBeanList));
+        } else {
+            return ResultUtil.ok(new DataCountBean(orgDataCountBeanList, mapDataCountBeanList));
+        }
+    }
 }

+ 101 - 0
themis-business/src/main/java/com/qmth/themis/business/bean/admin/DataCountBean.java

@@ -0,0 +1,101 @@
+package com.qmth.themis.business.bean.admin;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @Description: 数据统计
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/8/19
+ */
+public class DataCountBean implements Serializable {
+
+    @ApiModelProperty(name = "当前在线人数")
+    private Long onlineCount = 0L;
+
+    @ApiModelProperty(name = "当前考试人数")
+    private Long examCount = 0L;
+
+    @ApiModelProperty(name = "累计考试科次")
+    private Long examRecordCount = 0L;
+
+    @ApiModelProperty(name = "累计服务考生")
+    private Long examStudentCount = 0L;
+
+    @ApiModelProperty(name = "机构考生分布")
+    private List<OrgDataCountBean> orgDataCountBeanList;
+
+    @ApiModelProperty(name = "在线考生地域分布")
+    private List<MapDataCountBean> mapDataCountBeanList;
+
+    public DataCountBean() {
+
+    }
+
+    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.orgDataCountBeanList = orgDataCountBeanList;
+        this.mapDataCountBeanList = mapDataCountBeanList;
+    }
+
+    public DataCountBean(List<OrgDataCountBean> orgDataCountBeanList, List<MapDataCountBean> mapDataCountBeanList) {
+        this.orgDataCountBeanList = orgDataCountBeanList;
+        this.mapDataCountBeanList = mapDataCountBeanList;
+    }
+
+    public Long getOnlineCount() {
+        return onlineCount;
+    }
+
+    public void setOnlineCount(Long onlineCount) {
+        this.onlineCount = onlineCount;
+    }
+
+    public Long getExamCount() {
+        return examCount;
+    }
+
+    public void setExamCount(Long examCount) {
+        this.examCount = examCount;
+    }
+
+    public Long getExamRecordCount() {
+        return examRecordCount;
+    }
+
+    public void setExamRecordCount(Long examRecordCount) {
+        this.examRecordCount = examRecordCount;
+    }
+
+    public Long getExamStudentCount() {
+        return examStudentCount;
+    }
+
+    public void setExamStudentCount(Long examStudentCount) {
+        this.examStudentCount = examStudentCount;
+    }
+
+    public List<OrgDataCountBean> getOrgDataCountBeanList() {
+        return orgDataCountBeanList;
+    }
+
+    public void setOrgDataCountBeanList(List<OrgDataCountBean> orgDataCountBeanList) {
+        this.orgDataCountBeanList = orgDataCountBeanList;
+    }
+
+    public List<MapDataCountBean> getMapDataCountBeanList() {
+        return mapDataCountBeanList;
+    }
+
+    public void setMapDataCountBeanList(List<MapDataCountBean> mapDataCountBeanList) {
+        this.mapDataCountBeanList = mapDataCountBeanList;
+    }
+}

+ 48 - 0
themis-business/src/main/java/com/qmth/themis/business/bean/admin/MapDataCountBean.java

@@ -0,0 +1,48 @@
+package com.qmth.themis.business.bean.admin;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 地图数据统计
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/8/19
+ */
+public class MapDataCountBean implements Serializable {
+
+    @ApiModelProperty(name = "国家")
+    private String country;
+
+    @ApiModelProperty(name = "省份")
+    private String province;
+
+    @ApiModelProperty(name = "在线人数")
+    private Integer onlineCount = 0;
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    public String getProvince() {
+        return province;
+    }
+
+    public void setProvince(String province) {
+        this.province = province;
+    }
+
+    public Integer getOnlineCount() {
+        return onlineCount;
+    }
+
+    public void setOnlineCount(Integer onlineCount) {
+        this.onlineCount = onlineCount;
+    }
+}

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

@@ -0,0 +1,59 @@
+package com.qmth.themis.business.bean.admin;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 机构数据统计
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/8/19
+ */
+public class OrgDataCountBean implements Serializable {
+
+    @ApiModelProperty(name = "机构名称")
+    private String name;
+
+    @ApiModelProperty(name = "机构编码")
+    private String code;
+
+    @ApiModelProperty(name = "在线人数")
+    private Integer onlineCount = 0;
+
+    @ApiModelProperty(name = "考试人数")
+    private Integer examCount = 0;
+
+    public Integer getOnlineCount() {
+        return onlineCount;
+    }
+
+    public void setOnlineCount(Integer onlineCount) {
+        this.onlineCount = onlineCount;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public Integer getExamCount() {
+        return examCount;
+    }
+
+    public void setExamCount(Integer examCount) {
+        this.examCount = examCount;
+    }
+}

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

@@ -558,4 +558,25 @@ public interface TOeExamRecordMapper extends BaseMapper<TOeExamRecord> {
      * @return
      */
     public List<Map> cleanExamFirstPrepareCache(@Param("examIds") Set<Long> examIds);
+
+    /**
+     * 数据统计
+     *
+     * @return
+     */
+    List<Long> dataCount();
+
+    /**
+     * 机构数据统计
+     *
+     * @return
+     */
+    List<OrgDataCountBean> orgDataCount();
+
+    /**
+     * 地图数据统计
+     *
+     * @return
+     */
+    List<MapDataCountBean> mapDataCount();
 }

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

@@ -563,4 +563,25 @@ public interface TOeExamRecordService extends IService<TOeExamRecord> {
      * @return
      */
     public List<Map> cleanExamFirstPrepareCache(Set<Long> examIds);
+
+    /**
+     * 数据统计
+     *
+     * @return
+     */
+    List<Long> dataCount();
+
+    /**
+     * 机构数据统计
+     *
+     * @return
+     */
+    List<OrgDataCountBean> orgDataCount();
+
+    /**
+     * 地图数据统计
+     *
+     * @return
+     */
+    List<MapDataCountBean> mapDataCount();
 }

+ 30 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -1517,4 +1517,34 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     public List<Map> cleanExamFirstPrepareCache(Set<Long> examIds) {
         return tOeExamRecordMapper.cleanExamFirstPrepareCache(examIds);
     }
+
+    /**
+     * 数据统计
+     *
+     * @return
+     */
+    @Override
+    public List<Long> dataCount() {
+        return tOeExamRecordMapper.dataCount();
+    }
+
+    /**
+     * 机构数据统计
+     *
+     * @return
+     */
+    @Override
+    public List<OrgDataCountBean> orgDataCount() {
+        return tOeExamRecordMapper.orgDataCount();
+    }
+
+    /**
+     * 地图数据统计
+     *
+     * @return
+     */
+    @Override
+    public List<MapDataCountBean> mapDataCount() {
+        return tOeExamRecordMapper.mapDataCount();
+    }
 }

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

@@ -1872,4 +1872,103 @@
         having
         count(toer.id) > 0) a;
     </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 = 'ANSWERING'
+                or toer.STATUS = '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 = 'FINISHED'
+                or toer.STATUS = 'PERSISTED')
+        union all
+        select
+            count(1) as c
+        from
+            t_e_exam_student tees
+        where
+            EXISTS (
+                    select
+                        toer.exam_student_id
+                    from
+                        t_oe_exam_record toer
+                    where
+                        (toer.STATUS = 'FINISHED'
+                            or toer.STATUS = 'PERSISTED')
+                      and tees.id = toer.exam_student_id)
+    </select>
+
+    <select id="orgDataCount" resultType="com.qmth.themis.business.bean.admin.OrgDataCountBean">
+        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 = 'ANSWERING'
+                or toer.STATUS = 'RESUME_PREPARE')
+          and toer.client_websocket_status = 'ON_LINE'
+        group by
+            tbo.name,
+            tbo.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
+                join t_e_exam tee on
+                toer.exam_id = tee.id
+        WHERE
+            toer.client_websocket_status = 'ON_LINE'
+            and tir.country != '0'
+	        and tir.province != '0'
+        group by
+            tir.country,
+            tir.province
+    </select>
 </mapper>