Jelajahi Sumber

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

zizg 1 tahun lalu
induk
melakukan
5974ea0ce3

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

@@ -193,8 +193,8 @@ public class AnalysisCommonController {
     @ApiOperation("各板块访问量分布(UV)")
     @GetMapping("moduleUserUniqueVisits")
     public JsonResult moduleUserUniqueVisits(@RequestParam("type") String type){
-
-        return JsonResult.getSuccessResult("");
+        Map<String,Object> map = analysisSynthesizeService.moduleUserUniqueVisits(type);
+        return JsonResult.getSuccessResult(map);
     }
 
     @ApiOperation("组织访问量")

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

@@ -35,4 +35,12 @@ public interface AnalysisSynthesizeMapper {
      * @return
      */
     List<SynthesizeCompanyVo> organizationVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay,@Param("sort") String sort);
+
+    /**
+     * 各板块访问量分布(UV)
+     * @param firstDay
+     * @param lastDay
+     * @return
+     */
+    List<AlbumDetailVisitsVo> moduleUserUniqueVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
 }

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

@@ -110,4 +110,43 @@ public class AnalysisSynthesizeServiceImpl {
         result.forEach(e -> e.setCompany(userService.findDeptByDeptId(e.getCompany()).getName()));
         return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),result);
     }
+
+    /**
+     * 各板块访问量分布(UV)
+     * @param type
+     * @return
+     */
+    public Map<String, Object> moduleUserUniqueVisits(String type) {
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        List<AlbumDetailVisitsVo> moduleUserVisitsVo =  new ArrayList<>();
+        if ("total".equals(type)){
+            moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserUniqueVisits(null,null);
+        } else if ("year".equals(type)) {
+            moduleUserVisitsVo = analysisSynthesizeMapper.moduleUserUniqueVisits(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.moduleUserUniqueVisits(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;
+    }
 }

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

@@ -5,6 +5,12 @@
     <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
+        <where>
+            <if test="firstDay != null and lastDay != null">
+                TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
+            </if>
+        </where>
         group by MODULE
     </select>
 
@@ -105,4 +111,19 @@
             order by search
         </if>
     </select>
+
+    <select id="moduleUserUniqueVisits" resultType="com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo">
+        select MODULE as name, count (*) as value, round(count (*) / sum (count (*)) over (), 2) percentage from (
+        select distinct
+        module, sub_module, user_id, company_id, page, platform, ussd, company_id_,
+        create_dep_id_, tenant_id_, create_by_, to_char(create_time_,'yyyy-mm-dd') as createTime, update_by_, update_time_
+        from KM_PV_LOG)
+        <where>
+            <if test="firstDay != null and lastDay != null">
+                createTime &gt;= #{firstDay}
+                and createTime &lt;= #{lastDay}
+            </if>
+        </where>
+        group by MODULE
+    </select>
 </mapper>