فهرست منبع

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

zizg 1 سال پیش
والد
کامیت
0c08ba15d3

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

@@ -184,4 +184,13 @@ public class AnalysisCommonController {
         Map<String,Object> map = analysisSynthesizeService.moduleUserVisits(type);
         return JsonResult.getSuccessResult(map);
     }
+
+    @ApiOperation("组织访问量")
+    @PostMapping("organizationVisits")
+    public JsonPageResult organizationVisits(@RequestBody QueryData queryData){
+        JsonPageResult jsonResult = JsonPageResult.getSuccess("");
+        IPage result = analysisSynthesizeService.organizationVisits(queryData);
+        jsonResult.setPageData(result);
+        return jsonResult;
+    }
 }

+ 40 - 0
src/main/java/com/redxun/knowledge/analysis/entity/vo/SynthesizeCompanyVo.java

@@ -0,0 +1,40 @@
+package com.redxun.knowledge.analysis.entity.vo;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 文件名: SynthesizeCompanyVo
+ * 作者: zizg
+ * 时间: 2023/3/28
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@ApiModel("综合统计 组织访问量Vo")
+@Data
+public class SynthesizeCompanyVo implements Serializable {
+
+    @ApiModelProperty("公司名称")
+    private String company;
+
+    @ApiModelProperty("总访问量")
+    private Integer total;
+
+    @ApiModelProperty("知识仓库访问量")
+    private Integer knowledge;
+
+    @ApiModelProperty("知识地图访问量")
+    private Integer map;
+
+    @ApiModelProperty("知识专辑访问量")
+    private Integer album;
+
+    @ApiModelProperty("搜索服务访问量")
+    private Integer search;
+}

+ 1 - 1
src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisSearchMapper.java

@@ -34,5 +34,5 @@ public interface AnalysisSearchMapper {
      * @param sort
      * @return
      */
-    List<SystemCompanyVo> organizationSearchs(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay, String sort);
+    List<SystemCompanyVo> organizationSearchs(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay, @Param("sort") String sort);
 }

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

@@ -1,6 +1,7 @@
 package com.redxun.knowledge.analysis.mapper;
 
 import com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo;
+import com.redxun.knowledge.analysis.entity.vo.SynthesizeCompanyVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -25,4 +26,13 @@ public interface AnalysisSynthesizeMapper {
      * @return
      */
     List<AlbumDetailVisitsVo> moduleUserVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    /**
+     * 组织访问量
+     * @param firstDay
+     * @param lastDay
+     * @param sort
+     * @return
+     */
+    List<SynthesizeCompanyVo> organizationVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay,@Param("sort") String sort);
 }

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

@@ -1,14 +1,21 @@
 package com.redxun.knowledge.analysis.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.redxun.common.base.entity.QueryData;
+import com.redxun.common.tool.StringUtils;
 import com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo;
 import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
+import com.redxun.knowledge.analysis.entity.vo.SynthesizeCompanyVo;
 import com.redxun.knowledge.analysis.mapper.AnalysisSynthesizeMapper;
+import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.utils.DateUtils;
+import com.redxun.knowledge.utils.PageListUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 文件名: AnalysisSynthesizeServiceImpl
@@ -26,6 +33,9 @@ public class AnalysisSynthesizeServiceImpl {
     @Autowired
     private AnalysisSynthesizeMapper analysisSynthesizeMapper;
 
+    @Autowired
+    private UserService userService;
+
     /**
      * 各板块访问量分布
      * @param type
@@ -64,4 +74,40 @@ public class AnalysisSynthesizeServiceImpl {
         });
         return result;
     }
+
+    /**
+     * 组织访问量
+     * @param queryData
+     * @return
+     */
+    public IPage organizationVisits(QueryData queryData) {
+        //获取排序规则
+        String sort = queryData.getSortField();
+        if (sort != null){
+            sort = sort + queryData.getSortOrder();
+        }
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        List<SynthesizeCompanyVo> result =  new ArrayList<>();
+        if ("total".equals(queryData.getParams().get("type"))){
+            result = analysisSynthesizeMapper.organizationVisits(null,null,sort);
+        } else if ("year".equals(queryData.getParams().get("type"))) {
+            result = analysisSynthesizeMapper.organizationVisits(DateUtils.format(DateUtils.getFirstOfYear(year)),
+                    DateUtils.format(DateUtils.getLastOfYear(year)),sort);
+        } else if ("month".equals(queryData.getParams().get("type"))) {
+            int month = calendar.get(Calendar.MONTH);
+            String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
+            String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
+            result = analysisSynthesizeMapper.organizationVisits(firstOfMonth, lastOfMonth,sort);
+        }
+        String tops = queryData.getParams().get("tops");
+        if(StringUtils.isNotEmpty(tops)){
+            result = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
+        } else {
+            result = result.stream().limit(10).collect(Collectors.toList());
+        }
+        //公司名称赋值
+        result.forEach(e -> e.setCompany(userService.findDeptByDeptId(e.getCompany()).getName()));
+        return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),result);
+    }
 }

+ 99 - 1
src/main/resources/mapper/knowledge/analysis/AnalysisSynthesizeMapper.xml

@@ -3,8 +3,106 @@
 <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
+        select MODULE as name, count (*) as value, round(count (*) / sum (count (*)) over (), 2) percentage
         from KM_PV_LOG
         group by MODULE
     </select>
+
+    <select id="organizationVisits" resultType="com.redxun.knowledge.analysis.entity.vo.SynthesizeCompanyVo">
+        select
+        companyId as company,NVL(total.total, 0) as total,NVL(knowledge.knowledge, 0) as knowledge,NVL(map.map, 0) as map,
+        NVL(album.album, 0) as album,NVL(search.search, 0) as search
+        from (
+        (select COMPANY_ID as companyId, count(*) total
+        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 COMPANY_ID) total
+        full join
+        (select COMPANY_ID as companyId, count(*) knowledge
+        from KM_PV_LOG
+        <where>
+            MODULE = '知识仓库'
+            <if test="firstDay != null and lastDay != null">
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
+            </if>
+        </where>
+        group by COMPANY_ID) knowledge
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) map
+        from KM_PV_LOG
+        <where>
+            MODULE = '知识地图'
+            <if test="firstDay != null and lastDay != null">
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
+            </if>
+        </where>
+        group by COMPANY_ID) map
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) album
+        from KM_PV_LOG
+        <where>
+            MODULE = '知识专辑'
+            <if test="firstDay != null and lastDay != null">
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
+            </if>
+        </where>
+        group by COMPANY_ID) album
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) search
+        from KM_PV_LOG
+        <where>
+            MODULE = '搜索服务'
+            <if test="firstDay != null and lastDay != null">
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
+            </if>
+        </where>
+        group by COMPANY_ID) search
+        using (companyId)
+        )
+        <if test="sort == null">
+            order by total desc
+        </if>
+        <if test="sort == 'totaldesc'">
+            order by total desc
+        </if>
+        <if test="sort == 'totalasc'">
+            order by total
+        </if>
+        <if test="sort == 'knowledgedesc'">
+            order by knowledge desc
+        </if>
+        <if test="sort == 'knowledgeasc'">
+            order by knowledge
+        </if>
+        <if test="sort == 'mapdesc'">
+            order by map desc
+        </if>
+        <if test="sort == 'mapasc'">
+            order by map
+        </if>
+        <if test="sort == 'albumdesc'">
+            order by album desc
+        </if>
+        <if test="sort == 'albumasc'">
+            order by album
+        </if>
+        <if test="sort == 'searchdesc'">
+            order by search desc
+        </if>
+        <if test="sort == 'searchasc'">
+            order by search
+        </if>
+    </select>
 </mapper>