Jelajahi Sumber

作者:张哲
时间:2023/03/23
类型:开发
描述:里程碑(3)搜索统计接口开发

zizg 2 tahun lalu
induk
melakukan
2265b60ab8

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

@@ -172,7 +172,7 @@ public class AnalysisCommonController {
     public JsonResult organizationSearchs(@RequestParam("type") String type,
                                           @RequestParam(value = "tops",required = false,defaultValue = "10") Integer tops,
                                           @RequestParam(value = "sort",required = false) String sort){
-        List<String> result = analysisSearchService.organizationSearchs(type,tops,sort);
+        List<SystemCompanyVo> result = analysisSearchService.organizationSearchs(type,tops,sort);
         return  JsonResult.getSuccessResult(result);
     }
 }

+ 34 - 0
src/main/java/com/redxun/knowledge/analysis/entity/vo/SystemCompanyVo.java

@@ -0,0 +1,34 @@
+package com.redxun.knowledge.analysis.entity.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 文件名: SystemCompanyVo
+ * 作者: zizg
+ * 时间: 2023/3/24
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Data
+public class SystemCompanyVo implements Serializable {
+
+    private String company;
+
+    private Integer total;
+
+    private Integer pz;
+
+    private Integer gz;
+
+    private Integer eip;
+
+    private Integer wp;
+
+    private Integer zs;
+
+    private Integer dcc;
+}

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

@@ -1,5 +1,6 @@
 package com.redxun.knowledge.analysis.mapper;
 
+import com.redxun.knowledge.analysis.entity.vo.SystemCompanyVo;
 import com.redxun.knowledge.analysis.entity.vo.SystemDetailVisitsVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -18,5 +19,20 @@ import java.util.List;
 @Mapper
 public interface AnalysisSearchMapper {
 
+    /**
+     * 各业务系统分布
+     * @param firstDay
+     * @param lastDay
+     * @return
+     */
     List<SystemDetailVisitsVo> searchSystemDetailVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    /**
+     * 组织访问量
+     * @param firstDay
+     * @param lastDay
+     * @param sort
+     * @return
+     */
+    List<SystemCompanyVo> organizationSearchs(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay, String sort);
 }

+ 24 - 3
src/main/java/com/redxun/knowledge/analysis/service/AnalysisSearchServiceImpl.java

@@ -1,8 +1,10 @@
 package com.redxun.knowledge.analysis.service;
 
 import com.redxun.knowledge.analysis.entity.enums.SystemDetailVisitsEnum;
+import com.redxun.knowledge.analysis.entity.vo.SystemCompanyVo;
 import com.redxun.knowledge.analysis.entity.vo.SystemDetailVisitsVo;
 import com.redxun.knowledge.analysis.mapper.AnalysisSearchMapper;
+import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.utils.DateUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +29,9 @@ public class AnalysisSearchServiceImpl {
     @Autowired
     private AnalysisSearchMapper analysisSearchMapper;
 
+    @Autowired
+    private UserService userService;
+
     /**
      * 各业务系统分布
      * @param type
@@ -59,8 +64,24 @@ public class AnalysisSearchServiceImpl {
      * @param sort
      * @return
      */
-    public List<String> organizationSearchs(String type, Integer tops, String sort) {
-
-        return null;
+    public List<SystemCompanyVo> organizationSearchs(String type, Integer tops, String sort) {
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        List<SystemCompanyVo> result = new ArrayList<>();
+        if (("total").equals(type)){
+            result = analysisSearchMapper.organizationSearchs(null,null,sort);
+        } else if (("year").equals(type)){
+            result = analysisSearchMapper.organizationSearchs(DateUtils.format(DateUtils.getFirstOfYear(year)),
+                    DateUtils.format(DateUtils.getLastOfYear(year)),sort);
+        } 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);
+            result = analysisSearchMapper.organizationSearchs(firstOfMonth, lastOfMonth,sort);
+        }
+        result = result.stream().limit(tops).collect(Collectors.toList());
+        //公司名称赋值
+        result.forEach(e -> e.setCompany(userService.findDeptByDeptId(e.getCompany()).getName()));
+        return result;
     }
 }

+ 136 - 0
src/main/resources/mapper/knowledge/analysis/AnalysisSearchMapper.xml

@@ -1,6 +1,7 @@
 <?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.AnalysisSearchMapper">
+
     <select id="searchSystemDetailVisits" resultType="com.redxun.knowledge.analysis.entity.vo.SystemDetailVisitsVo">
         select PLATFORM ,round(count(*) / sum(count(*)) over (),2) as percentage from KM_PV_LOG
         <where>
@@ -11,4 +12,139 @@
         </where>
         group by PLATFORM
     </select>
+
+    <select id="organizationSearchs" resultType="com.redxun.knowledge.analysis.entity.vo.SystemCompanyVo">
+        select
+        companyId as company, NVL(total.total, 0) as total,
+        NVL(pz.pz, 0) as pz,NVL(gz.gz, 0) as gz,NVL(eip.eip, 0) as eip,
+        NVL(wp.wp,0) as wp,NVL(zs.zs,0) as zs,NVL(dcc.dcc,0) as dcc
+        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(*) pz
+        from KM_PV_LOG
+        <where>
+            PLATFORM = '平展系统'
+            <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) pz
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) gz
+        from KM_PV_LOG
+        <where>
+            PLATFORM = '工作管理系统'
+            <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) gz
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) eip
+        from KM_PV_LOG
+        <where>
+            PLATFORM = 'EIP系统'
+            <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) eip
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) wp
+        from KM_PV_LOG
+        <where>
+            PLATFORM = '网盘系统'
+            <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) wp
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) zs
+        from KM_PV_LOG
+        <where>
+            PLATFORM = '知识管理系统'
+            <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) zs
+        using (companyId)
+        full join
+        (select COMPANY_ID as companyId, count(*) dcc
+        from KM_PV_LOG
+        <where>
+            PLATFORM = 'DCC管理系统'
+            <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) dcc
+        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 == 'zsDesc'">
+            order by zs desc
+        </if>
+        <if test="sort == 'zsAsc'">
+            order by zs
+        </if>
+        <if test="sort == 'eipDesc'">
+            order by eip desc
+        </if>
+        <if test="sort == 'eipAsc'">
+            order by eip
+        </if>
+        <if test="sort == 'dccDesc'">
+            order by dcc desc
+        </if>
+        <if test="sort == 'dccAsc'">
+            order by dcc
+        </if>
+        <if test="sort == 'gzDesc'">
+            order by gz desc
+        </if>
+        <if test="sort == 'gzAsc'">
+            order by gz
+        </if>
+        <if test="sort == 'pzDesc'">
+            order by pz desc
+        </if>
+        <if test="sort == 'pzAsc'">
+            order by pz
+        </if>
+        <if test="sort == 'wpDesc'">
+            order by wp desc
+        </if>
+        <if test="sort == 'wpAsc'">
+            order by wp
+        </if>
+    </select>
 </mapper>