ソースを参照

作者:张哲
时间:2023/03/27
类型:开发
描述:里程碑(3) 综合统计-各板块访问量分布

zizg 1 年間 前
コミット
1b2b1e1432

+ 11 - 4
src/main/java/com/redxun/knowledge/analysis/controller/AnalysisCommonController.java

@@ -7,10 +7,7 @@ import com.redxun.common.base.entity.JsonResult;
 import com.redxun.common.base.entity.QueryData;
 
 import com.redxun.knowledge.analysis.entity.vo.*;
-import com.redxun.knowledge.analysis.service.AnalysisAlbumServiceImpl;
-import com.redxun.knowledge.analysis.service.AnalysisCommonServiceImpl;
-import com.redxun.knowledge.analysis.service.AnalysisMapServiceImpl;
-import com.redxun.knowledge.analysis.service.AnalysisSearchServiceImpl;
+import com.redxun.knowledge.analysis.service.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -48,6 +45,9 @@ public class AnalysisCommonController {
     @Autowired
     private AnalysisSearchServiceImpl analysisSearchService;
 
+    @Autowired
+    private AnalysisSynthesizeServiceImpl analysisSynthesizeService;
+
     @ApiOperation("PC 各模块整体数量统计")
     @GetMapping("totalAmount")
     public JsonResult totalAmount() {
@@ -177,4 +177,11 @@ public class AnalysisCommonController {
         jsonResult.setPageData(result);
         return jsonResult;
     }
+
+    @ApiOperation("各板块访问量分布")
+    @GetMapping("moduleUserVisits")
+    public JsonResult moduleUserVisits(@RequestParam("type") String type){
+        Map<String,Object> map = analysisSynthesizeService.moduleUserVisits(type);
+        return JsonResult.getSuccessResult(map);
+    }
 }

+ 28 - 0
src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisSynthesizeMapper.java

@@ -0,0 +1,28 @@
+package com.redxun.knowledge.analysis.mapper;
+
+import com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 文件名: AnalysisSynthesizeMapper
+ * 作者: zizg
+ * 时间: 2023/3/27
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Mapper
+public interface AnalysisSynthesizeMapper {
+
+    /**
+     * 各板块访问量分布
+     * @param firstDay
+     * @param lastDay
+     * @return
+     */
+    List<AlbumDetailVisitsVo> moduleUserVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+}

+ 67 - 0
src/main/java/com/redxun/knowledge/analysis/service/AnalysisSynthesizeServiceImpl.java

@@ -0,0 +1,67 @@
+package com.redxun.knowledge.analysis.service;
+
+import com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo;
+import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
+import com.redxun.knowledge.analysis.mapper.AnalysisSynthesizeMapper;
+import com.redxun.knowledge.utils.DateUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * 文件名: AnalysisSynthesizeServiceImpl
+ * 作者: zizg
+ * 时间: 2023/3/27
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Service
+@Slf4j
+public class AnalysisSynthesizeServiceImpl {
+
+    @Autowired
+    private AnalysisSynthesizeMapper analysisSynthesizeMapper;
+
+    /**
+     * 各板块访问量分布
+     * @param type
+     * @return
+     */
+    public Map<String, Object> moduleUserVisits(String type) {
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        List<AlbumDetailVisitsVo> moduleUserVisitsVo =  new ArrayList<>();
+        if ("total".equals(type)){
+            moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserVisits(null,null);
+        } else if ("year".equals(type)) {
+            moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
+                    DateUtils.format(DateUtils.getLastOfYear(year)));
+        } else if ("month".equals(type)) {
+            int month = calendar.get(Calendar.MONTH);
+            String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
+            String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
+            moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserVisits(firstOfMonth, lastOfMonth);
+        }
+        Map<String, Object> result = new LinkedHashMap<>();
+        moduleUserVisitsVo.forEach(e -> {
+            if (e.getName().equals("搜索服务")){
+                result.put("search",e.getValue());
+                result.put("searchPercentage",e.getPercentage());
+            } else if (e.getName().equals("知识仓库")){
+                result.put("knowledge",e.getValue());
+                result.put("knowledgePercentage",e.getPercentage());
+            } else if (e.getName().equals("知识地图")){
+                result.put("map",e.getValue());
+                result.put("mapPercentage",e.getPercentage());
+            } else if (e.getName().equals("知识专辑")){
+                result.put("album",e.getValue());
+                result.put("albumPercentage",e.getPercentage());
+            }
+        });
+        return result;
+    }
+}

+ 10 - 0
src/main/resources/mapper/knowledge/analysis/AnalysisSynthesizeMapper.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.redxun.knowledge.analysis.mapper.AnalysisSynthesizeMapper">
+
+    <select id="moduleUserVisits" resultType="com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo">
+        select MODULE as name,count(*) as value,round(count(*) / sum(count(*)) over (),2) percentage
+        from KM_PV_LOG
+        group by MODULE
+    </select>
+</mapper>