Procházet zdrojové kódy

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

zizg před 2 roky
rodič
revize
c2a999bee5

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

@@ -6,6 +6,7 @@ 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 io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -43,6 +44,9 @@ public class AnalysisCommonController {
     @Autowired
     private AnalysisMapServiceImpl analysisMapService;
 
+    @Autowired
+    private AnalysisSearchServiceImpl analysisSearchService;
+
     @ApiOperation("PC 各模块整体数量统计")
     @GetMapping("totalAmount")
     public JsonResult totalAmount() {
@@ -155,4 +159,20 @@ public class AnalysisCommonController {
         List<MapCompanyVo> result = analysisMapService.organizationMaps(type,tops,sort);
         return JsonResult.getSuccessResult(result);
     }
+
+    @ApiOperation("各业务系统分布")
+    @GetMapping("searchSystemDetailVisits")
+    public JsonResult searchSystemDetailVisits(@RequestParam("type") String type){
+        Map<String,Double> result = analysisSearchService.searchSystemDetailVisits(type);
+        return JsonResult.getSuccessResult(result);
+    }
+
+    @ApiOperation("组织访问量")
+    @GetMapping("organizationSearchs")
+    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);
+        return  JsonResult.getSuccessResult(result);
+    }
 }

+ 1 - 0
src/main/java/com/redxun/knowledge/analysis/entity/consts/PlatformConst.java

@@ -21,6 +21,7 @@ public class PlatformConst {
         list.add("工作管理系统");
         list.add("EIP系统");
         list.add("网盘系统");
+        list.add("DCC管理系统");
         return list;
     }
 }

+ 54 - 0
src/main/java/com/redxun/knowledge/analysis/entity/enums/SystemDetailVisitsEnum.java

@@ -0,0 +1,54 @@
+package com.redxun.knowledge.analysis.entity.enums;
+
+
+/**
+ * 文件名: SystemDetailVisitsEnum
+ * 作者: zizg
+ * 时间: 2023/3/23
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+public enum SystemDetailVisitsEnum {
+    PZ_PERCENTAGE("平展系统","pzPercentage"),
+    GZ_PERCENTAGE("工作管理系统","gzPercentage"),
+    EIP_PERCENTAGE("EIP系统","eipPercentage"),
+    WP_PERCENTAGE("网盘系统","wpPercentage"),
+    ZS_PERCENTAGE("知识管理系统","zsPercentage"),
+    DCC_PERCENTAGE("DCC管理系统","dccPercentage");
+
+    private String code;
+    private String message;
+
+    SystemDetailVisitsEnum(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public static String getMessage(String code) {
+        SystemDetailVisitsEnum[] systemDetailVisitsEnums = values();
+        for (SystemDetailVisitsEnum systemDetailVisitsEnum : systemDetailVisitsEnums) {
+            if (systemDetailVisitsEnum.code.equals(code)) {
+                return systemDetailVisitsEnum.message;
+            }
+        }
+        return null;
+    }
+}

+ 23 - 0
src/main/java/com/redxun/knowledge/analysis/entity/vo/SystemDetailVisitsVo.java

@@ -0,0 +1,23 @@
+package com.redxun.knowledge.analysis.entity.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 文件名: SystemDetailVisitsVo
+ * 作者: zizg
+ * 时间: 2023/3/23
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Data
+public class SystemDetailVisitsVo implements Serializable {
+
+    private String platform;
+
+    private Double percentage;
+
+}

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

@@ -0,0 +1,22 @@
+package com.redxun.knowledge.analysis.mapper;
+
+import com.redxun.knowledge.analysis.entity.vo.SystemDetailVisitsVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 文件名: AnalysisSearchMapper
+ * 作者: zizg
+ * 时间: 2023/3/23
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Mapper
+public interface AnalysisSearchMapper {
+
+    List<SystemDetailVisitsVo> searchSystemDetailVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+}

+ 66 - 0
src/main/java/com/redxun/knowledge/analysis/service/AnalysisSearchServiceImpl.java

@@ -0,0 +1,66 @@
+package com.redxun.knowledge.analysis.service;
+
+import com.redxun.knowledge.analysis.entity.enums.SystemDetailVisitsEnum;
+import com.redxun.knowledge.analysis.entity.vo.SystemDetailVisitsVo;
+import com.redxun.knowledge.analysis.mapper.AnalysisSearchMapper;
+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.*;
+import java.util.stream.Collectors;
+
+/**
+ * 文件名: AnalysisSearchServiceImpl
+ * 作者: zizg
+ * 时间: 2023/3/23
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Service
+@Slf4j
+public class AnalysisSearchServiceImpl {
+
+    @Autowired
+    private AnalysisSearchMapper analysisSearchMapper;
+
+    /**
+     * 各业务系统分布
+     * @param type
+     * @return
+     */
+    public Map<String, Double> searchSystemDetailVisits(String type) {
+        Map<String, Double> map = new HashMap<>();
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        List<SystemDetailVisitsVo> result = new ArrayList<>();
+        if (("total").equals(type)){
+            result = analysisSearchMapper.searchSystemDetailVisits(null,null);
+        } else if (("year").equals(type)){
+            result = analysisSearchMapper.searchSystemDetailVisits(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);
+            result = analysisSearchMapper.searchSystemDetailVisits(firstOfMonth, lastOfMonth);
+        }
+        result.forEach(e -> map.put(SystemDetailVisitsEnum.getMessage(e.getPlatform()),e.getPercentage()));
+        return map;
+    }
+
+    /**
+     * 组织访问量
+     * @param type
+     * @param tops
+     * @param sort
+     * @return
+     */
+    public List<String> organizationSearchs(String type, Integer tops, String sort) {
+
+        return null;
+    }
+}

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

@@ -0,0 +1,14 @@
+<?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>
+            <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 PLATFORM
+    </select>
+</mapper>