limeng %!s(int64=2) %!d(string=hai) anos
pai
achega
3c5fe1aea2
Modificáronse 25 ficheiros con 1256 adicións e 241 borrados
  1. 15 8
      leiSP-admin/src/main/resources/ehcache/ehcache-shiro.xml
  2. 5 2
      leiSP-admin/src/main/resources/templates/main.html
  3. 11 1
      leiSP-common/src/main/java/com/sooka/common/constant/Constants.java
  4. 13 0
      leiSP-common/src/main/java/com/sooka/common/core/controller/BaseController.java
  5. 84 0
      mybusiness/src/main/java/com/business/controller/VisualizationController.java
  6. 57 0
      mybusiness/src/main/java/com/business/domain/ImputationData.java
  7. 33 0
      mybusiness/src/main/java/com/business/mapper/ImputationDataMapper.java
  8. 35 0
      mybusiness/src/main/java/com/business/service/ImputationDataService.java
  9. 57 0
      mybusiness/src/main/java/com/business/service/impl/ImputationDataServiceImpl.java
  10. 31 1
      mybusiness/src/main/java/com/sooka/system/controller/TULogController.java
  11. 26 0
      mybusiness/src/main/java/com/sooka/system/domain/TULog.java
  12. 36 0
      mybusiness/src/main/java/com/sooka/system/mapper/TUInterfaceinfoMapper.java
  13. 12 0
      mybusiness/src/main/java/com/sooka/system/mapper/TULogMapper.java
  14. 37 0
      mybusiness/src/main/java/com/sooka/system/service/ITUInterfaceinfoService.java
  15. 22 8
      mybusiness/src/main/java/com/sooka/system/service/ITULogService.java
  16. 3 0
      mybusiness/src/main/java/com/sooka/system/service/impl/Guiji_Base_Service.java
  17. 52 0
      mybusiness/src/main/java/com/sooka/system/service/impl/TUInterfaceinfoServiceImpl.java
  18. 18 0
      mybusiness/src/main/java/com/sooka/system/service/impl/TULogServiceImpl.java
  19. 190 0
      mybusiness/src/main/java/com/util/StaticScheduleTask.java
  20. 87 0
      mybusiness/src/main/resources/mapper/imputationData/ImputationDataMapper.xml
  21. 117 0
      mybusiness/src/main/resources/mapper/system/TUInterfaceinfoMapper.xml
  22. 114 0
      mybusiness/src/main/resources/mapper/system/TULogMapper.xml
  23. 167 196
      mybusiness/src/main/resources/static/visualization/js/echarts_div.js
  24. 21 23
      mybusiness/src/main/resources/static/visualization/js/th_jk.js
  25. 13 2
      mybusiness/src/main/resources/templates/visualization/index.html

+ 15 - 8
leiSP-admin/src/main/resources/ehcache/ehcache-shiro.xml

@@ -3,7 +3,7 @@
 
     <!-- 磁盘缓存位置 -->
     <diskStore path="java.io.tmpdir"/>
-    
+
     <!-- maxEntriesLocalHeap:堆内存中最大缓存对象数,0没有限制 -->
     <!-- maxElementsInMemory: 在内存中缓存的element的最大数目。-->
     <!-- eternal:elements是否永久有效,如果为true,timeouts将被忽略,element将永不过期 -->
@@ -11,7 +11,7 @@
     <!-- timeToLiveSeconds:失效前的存活秒数,创建时间到失效时间的间隔为存活时间,当eternal为false时,这个属性才有效,0为不限制 -->
     <!-- overflowToDisk: 如果内存中数据超过内存限制,是否要缓存到磁盘上 -->
     <!-- statistics:是否收集统计信息。如果需要监控缓存使用情况,应该打开这个选项。默认为关闭(统计会影响性能)。设置statistics="true"开启统计 -->
-    
+
     <!-- 默认缓存 -->
     <defaultCache
             maxEntriesLocalHeap="1000"
@@ -41,7 +41,7 @@
            timeToIdleSeconds="0"
            statistics="true">
     </cache>
-    
+
     <!-- 系统缓存 -->
     <cache name="sys-cache"
            maxEntriesLocalHeap="1000"
@@ -49,7 +49,7 @@
            overflowToDisk="true"
            statistics="true">
     </cache>
-    
+
     <!-- 系统参数缓存 -->
     <cache name="sys-config"
            maxEntriesLocalHeap="1000"
@@ -57,7 +57,7 @@
            overflowToDisk="true"
            statistics="true">
     </cache>
-    
+
     <!-- 系统字典缓存 -->
     <cache name="sys-dict"
            maxEntriesLocalHeap="1000"
@@ -65,7 +65,7 @@
            overflowToDisk="true"
            statistics="true">
     </cache>
-    
+
     <!-- 系统会话缓存 -->
     <cache name="shiro-activeSessionCache"
            maxElementsInMemory="10000"
@@ -76,6 +76,13 @@
            diskPersistent="true"
            diskExpiryThreadIntervalSeconds="600">
     </cache>
-    
+
+    <!-- 分页数缓存,用于解决日志表数据量过大问题 -->
+    <cache name="log-total"
+           maxEntriesLocalHeap="1000"
+           eternal="true"
+           overflowToDisk="true"
+           statistics="true">
+    </cache>
+
 </ehcache>
-	

+ 5 - 2
leiSP-admin/src/main/resources/templates/main.html

@@ -332,10 +332,13 @@
             success: function(result) {
                 let content = "";
                 for(let i=0;i<result.length;i++){
-                    let temp = "<p style='font-size: 15px;'><a style='color: #333;' onclick='openPerTab()'>【{deptName}】用户【{userName}】的权限还有{remainingDays}天到期,请及时处理!</a></p>";
+                    let temp = "<p style='font-size: 15px;'><a style='color: #333;' onclick='openPerTab()'>【{deptName}】用户【{userName}】的权限已到期,请及时处理!</a></p>";
+                    if(result[i].remainingDays >= 0){
+                        temp = "<p style='font-size: 15px;'><a style='color: #333;' onclick='openPerTab()'>【{deptName}】用户【{userName}】的权限还有{remainingDays}天到期,请及时处理!</a></p>";
+                        temp = temp.replace("{remainingDays}",result[i].remainingDays);
+                    }
                     temp = temp.replace("{deptName}",result[i].deptName);
                     temp = temp.replace("{userName}",result[i].userName);
-                    temp = temp.replace("{remainingDays}",result[i].remainingDays);
                     content += temp;
                 }
                 if(content != ""){

+ 11 - 1
leiSP-common/src/main/java/com/sooka/common/constant/Constants.java

@@ -2,7 +2,7 @@ package com.sooka.common.constant;
 
 /**
  * 通用常量信息
- * 
+ *
  * @author lei_wang
  */
 public class Constants
@@ -91,4 +91,14 @@ public class Constants
      * 资源映射路径 前缀
      */
     public static final String RESOURCE_PREFIX = "/profile";
+
+    /**
+     * 日志管理 数据总数 cache name
+     */
+    public static final String LOG_TOTAL_CACHE = "log-total";
+
+    /**
+     * 日志管理 数据总数 cache key
+     */
+    public static final String LOG_TOTAL_KEY = "log-total";
 }

+ 13 - 0
leiSP-common/src/main/java/com/sooka/common/core/controller/BaseController.java

@@ -35,6 +35,7 @@ public class BaseController
 {
     protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
 
+
     /**
      * 将前台传递过来的日期格式的字符串,自动转化为Date类型
      */
@@ -117,6 +118,18 @@ public class BaseController
         return rspData;
     }
 
+    /**
+     * 响应请求分页数据
+     */
+    protected TableDataInfo getDataTable(List<?> list, Long total)
+    {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(0);
+        rspData.setRows(list);
+        rspData.setTotal(total);
+        return rspData;
+    }
+
 
     protected TableDataInfo getDataTable(String msg)
     {

+ 84 - 0
mybusiness/src/main/java/com/business/controller/VisualizationController.java

@@ -1,10 +1,13 @@
 package com.business.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.business.domain.ImputationData;
+import com.business.service.ImputationDataService;
 import com.sooka.common.core.controller.BaseController;
 import com.sooka.common.core.domain.AjaxResult;
 import com.sooka.system.domain.TUInterfaceinfo;
 import com.sooka.system.service.ITUInterfaceinfoService;
+import com.util.StaticScheduleTask;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -24,6 +27,9 @@ public class VisualizationController extends BaseController {
     @Autowired
     private ITUInterfaceinfoService interfaceinfoService;
 
+    @Autowired
+    private ImputationDataService imputationDataService;
+
     @GetMapping("index")
     public String index(){
         return "/visualization/index";
@@ -33,6 +39,9 @@ public class VisualizationController extends BaseController {
        return null;
     }
 
+    /**
+     * 查询 接口数量和接口占比
+     * */
     @PostMapping("countAndPercent")
     @ResponseBody
     public JSONObject getCountAndPercent(String year){
@@ -44,4 +53,79 @@ public class VisualizationController extends BaseController {
         return jsonObject;
     }
 
+    /**
+     * 查询省接口调用频次TOP5、TOP20
+     * */
+    @PostMapping("getProvinceFrequency")
+    @ResponseBody
+    public JSONObject getProvinceFrequency(){
+        JSONObject jsonObject = new JSONObject();
+        //省top5
+        List<TUInterfaceinfo> list_top5 = interfaceinfoService.getProvinceTop5Frequency();
+        //省top20
+        List<TUInterfaceinfo> list_top20 = interfaceinfoService.getProvinceTop20Frequency();
+        jsonObject.put("top5",list_top5);
+        jsonObject.put("top20",list_top20);
+        return jsonObject;
+    }
+
+    /**
+     * 查询市接口调用频次TOP5、TOP20
+     * */
+    @PostMapping("getCityFrequency")
+    @ResponseBody
+    public JSONObject getCityFrequency(){
+        JSONObject jsonObject = new JSONObject();
+        //市top5
+        List<TUInterfaceinfo> list_top5 = interfaceinfoService.getCityTop5Frequency();
+        //市top20
+        List<TUInterfaceinfo> list_top20 = interfaceinfoService.getCityTop20Frequency();
+        jsonObject.put("top5",list_top5);
+        jsonObject.put("top20",list_top20);
+        return jsonObject;
+    }
+
+    /**
+     * 查询归集和接口排名TOP10
+     * */
+    @PostMapping("getImputationDataAndInterfaceRanking")
+    @ResponseBody
+    public JSONObject getImputationDataAndInterfaceRanking(){
+        JSONObject jsonObject = new JSONObject();
+        //数据
+        List<TUInterfaceinfo> list_data = interfaceinfoService.getImputationDataRanking();
+        //接口
+        List<TUInterfaceinfo> list_interface = interfaceinfoService.getImputationInterfaceRanking();
+        jsonObject.put("data",list_data);
+        jsonObject.put("interface",list_interface);
+        return jsonObject;
+    }
+
+    /**
+     * 查询归集和接口排名TOP10
+     * */
+    @PostMapping("getImputationDataList")
+    @ResponseBody
+    public String[] getImputationDataList(String year){
+        String[] arr = new String[12];
+        ImputationData id = new ImputationData();
+        id.setYear(year);
+        ImputationData data = imputationDataService.selectImputationData(id);
+        arr[0] = data.getJan();
+        arr[1] = data.getFeb();
+        arr[2] = data.getMar();
+        arr[3] = data.getApr();
+        arr[4] = data.getMay();
+        arr[5] = data.getJun();
+        arr[6] = data.getJul();
+        arr[7] = data.getAug();
+        arr[8] = data.getSep();
+        arr[9] = data.getOct();
+        arr[10] = data.getNov();
+        arr[11] = data.getDecb();
+        return arr;
+    }
+
+
+
 }

+ 57 - 0
mybusiness/src/main/java/com/business/domain/ImputationData.java

@@ -0,0 +1,57 @@
+package com.business.domain;
+
+import com.sooka.common.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 附件操作对象 sys_file_info
+ *
+ * @author lei_Wang
+ * @date 2020-08-03
+ */
+@Data
+public class ImputationData extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 年份 */
+    private String year;
+
+    /** 1月 */
+    private String jan;
+
+    /** 2月 */
+    private String feb;
+
+    /** 3月 */
+    private String mar;
+
+    /** 4月 */
+    private String apr;
+
+    /** 5月 */
+    private String may;
+
+    /** 6月 */
+    private String jun;
+
+    /** 7月 */
+    private String jul;
+
+    /** 8月 */
+    private String aug;
+
+    /** 9月 */
+    private String sep;
+
+    /** 10月 */
+    private String oct;
+
+    /** 11月 */
+    private String nov;
+
+    /** 12月 */
+    private String decb;
+
+
+}

+ 33 - 0
mybusiness/src/main/java/com/business/mapper/ImputationDataMapper.java

@@ -0,0 +1,33 @@
+package com.business.mapper;
+
+import com.business.domain.ImputationData;
+
+import java.util.List;
+
+/**
+ * @author Administrator
+ */
+public interface ImputationDataMapper {
+    /**
+     * 查询日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    public ImputationData selectImputationData(ImputationData imputationData);
+    /**
+     * 新增日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    public int insertImputationData(ImputationData imputationData);
+
+    /**
+     * 修改日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    public int updateImputationData(ImputationData imputationData);
+}

+ 35 - 0
mybusiness/src/main/java/com/business/service/ImputationDataService.java

@@ -0,0 +1,35 @@
+package com.business.service;
+
+import com.business.domain.ImputationData;
+
+import java.util.List;
+
+/**
+ * @author Administrator
+ */
+public interface ImputationDataService {
+
+    /**
+     * 查询日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    public ImputationData selectImputationData(ImputationData imputationData);
+
+    /**
+     * 新增日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    public int insertImputationData(ImputationData imputationData);
+
+    /**
+     * 修改日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    public int updateImputationData(ImputationData imputationData);
+}

+ 57 - 0
mybusiness/src/main/java/com/business/service/impl/ImputationDataServiceImpl.java

@@ -0,0 +1,57 @@
+package com.business.service.impl;
+
+import com.business.domain.ImputationData;
+import com.business.mapper.ImputationDataMapper;
+import com.business.service.ImputationDataService;
+import com.sooka.common.utils.DateUtils;
+import com.sooka.system.domain.TULog;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @author Administrator
+ */
+@Service
+public class ImputationDataServiceImpl   implements ImputationDataService {
+
+    @Resource
+    ImputationDataMapper imputationDataMapper;
+    /**
+     * 查询日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    @Override
+    public ImputationData selectImputationData(ImputationData imputationData){
+        return imputationDataMapper.selectImputationData(imputationData);
+    }
+
+    /**
+     * 新增日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    @Override
+    public int insertImputationData(ImputationData imputationData)
+    {
+        return imputationDataMapper.insertImputationData(imputationData);
+    }
+
+    /**
+     * 修改日志归集数据
+     *
+     * @param imputationData 日志归集数据
+     * @return 结果
+     */
+    @Override
+    public int updateImputationData(ImputationData imputationData)
+    {
+        return imputationDataMapper.updateImputationData(imputationData);
+    }
+
+
+}

+ 31 - 1
mybusiness/src/main/java/com/sooka/system/controller/TULogController.java

@@ -1,14 +1,28 @@
 package com.sooka.system.controller;
 
+import java.io.Serializable;
+import java.util.Deque;
 import java.util.List;
 
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
 import com.sooka.common.annotation.Log;
+import com.sooka.common.constant.ShiroConstants;
 import com.sooka.common.core.controller.BaseController;
 import com.sooka.common.core.domain.AjaxResult;
+import com.sooka.common.core.page.PageDomain;
 import com.sooka.common.core.page.TableDataInfo;
+import com.sooka.common.core.page.TableSupport;
+import com.sooka.common.core.text.Convert;
 import com.sooka.common.enums.BusinessType;
+import com.sooka.common.utils.CacheUtils;
 import com.sooka.common.utils.poi.ExcelUtil;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.apache.shiro.cache.Cache;
+import org.apache.shiro.cache.CacheManager;
+import org.apache.shiro.cache.ehcache.EhCache;
+import org.apache.shiro.cache.ehcache.EhCacheManager;
+import org.apache.xmlbeans.impl.common.SystemCache;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
@@ -37,6 +51,7 @@ public class TULogController extends BaseController
     @Autowired
     private ITULogService tULogService;
 
+
     @RequiresPermissions("system:log:view")
     @GetMapping()
     public String log()
@@ -54,7 +69,22 @@ public class TULogController extends BaseController
     {
         startPage();
         List<TULog> list = tULogService.selectTULogList(tULog);
-        return getDataTable(list);
+        return getDataTable(list,this.getTotal(tULog));
+    }
+
+    /**
+     * 获取cache name
+     *
+     * @return 缓存名
+     */
+    public Long getTotal(TULog tULog)
+    {
+        Long total = Convert.toLong(CacheUtils.get(tULog.getCacheName(),tULog.getCacheKey()));
+        if(total == null){
+            total = tULogService.getLogCount();
+            CacheUtils.put(tULog.getCacheName(), tULog.getCacheKey(), total);
+        }
+        return total;
     }
 
     /**

+ 26 - 0
mybusiness/src/main/java/com/sooka/system/domain/TULog.java

@@ -1,9 +1,15 @@
 package com.sooka.system.domain;
 
 import com.sooka.common.annotation.Excel;
+import com.sooka.common.constant.Constants;
 import com.sooka.common.core.domain.BaseEntity;
+import com.sooka.common.core.text.Convert;
+import com.sooka.common.utils.CacheUtils;
+import com.sooka.system.service.ITULogService;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.shiro.cache.Cache;
+import org.springframework.beans.factory.annotation.Autowired;
 
 
 /**
@@ -78,6 +84,26 @@ public class TULog extends BaseEntity
     @Excel(name = "异常记录")
     private String exceptionLog;
 
+
+    /**
+     * 获取cache name
+     *
+     * @return 缓存名
+     */
+    public String getCacheName()
+    {
+        return Constants.LOG_TOTAL_CACHE;
+    }
+
+    /**
+     * 设置cache key
+     * @return 缓存键key
+     */
+    public String getCacheKey()
+    {
+        return Constants.LOG_TOTAL_KEY;
+    }
+
     public void setId(String id)
     {
         this.id = id;

+ 36 - 0
mybusiness/src/main/java/com/sooka/system/mapper/TUInterfaceinfoMapper.java

@@ -74,4 +74,40 @@ public interface TUInterfaceinfoMapper
      * @return 结果
      */
     public List<TUInterfaceinfo> getPercent(@Param("year") String year);
+
+    /**
+     * 查询省接口调用频次TOP5
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getProvinceTop5Frequency();
+
+    /**
+     * 查询市接口调用频次TOP5
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getCityTop5Frequency();
+
+    /**
+     * 查询省接口调用频次TOP20
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getProvinceTop20Frequency();
+
+    /**
+     * 查询市接口调用频次TOP20
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getCityTop20Frequency();
+
+    /**
+     * 查询归集接口排名
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getImputationInterfaceRanking();
+
+    /**
+     * 查询归集数据排名
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getImputationDataRanking();
 }

+ 12 - 0
mybusiness/src/main/java/com/sooka/system/mapper/TULogMapper.java

@@ -1,6 +1,7 @@
 package com.sooka.system.mapper;
 
 import java.util.List;
+import java.util.Map;
 
 import com.sooka.common.annotation.DataSource;
 import com.sooka.common.enums.DataSourceType;
@@ -62,4 +63,15 @@ public interface TULogMapper
      * @return 结果
      */
     public int deleteTULogByIds(String[] ids);
+
+    /**
+     * 查询数据总量
+     */
+    public Long getLogCount();
+
+    /**
+     * 查询日志表中的归集量
+     * @return 结果
+     */
+    public Map selectImputationLog(String year);
 }

+ 37 - 0
mybusiness/src/main/java/com/sooka/system/service/ITUInterfaceinfoService.java

@@ -70,4 +70,41 @@ public interface ITUInterfaceinfoService
      * @return 结果
      */
     public List<TUInterfaceinfo> getPercent(String year);
+
+    /**
+     * 查询省接口调用频次TOP5
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getProvinceTop5Frequency();
+
+    /**
+     * 查询市接口调用频次TOP5
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getCityTop5Frequency();
+
+    /**
+     * 查询省接口调用频次TOP20
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getProvinceTop20Frequency();
+
+    /**
+     * 查询市接口调用频次TOP20
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getCityTop20Frequency();
+
+    /**
+     * 查询归集接口排名
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getImputationInterfaceRanking();
+
+    /**
+     * 查询归集数据排名
+     * @return 结果
+     */
+    public List<TUInterfaceinfo> getImputationDataRanking();
+
 }

+ 22 - 8
mybusiness/src/main/java/com/sooka/system/service/ITULogService.java

@@ -1,19 +1,21 @@
 package com.sooka.system.service;
 
 import java.util.List;
+import java.util.Map;
+
 import com.sooka.system.domain.TULog;
 
 /**
  * 接口调用日志Service接口
- * 
+ *
  * @author lei
  * @date 2021-07-06
  */
-public interface ITULogService 
+public interface ITULogService
 {
     /**
      * 查询接口调用日志
-     * 
+     *
      * @param id 接口调用日志ID
      * @return 接口调用日志
      */
@@ -21,7 +23,7 @@ public interface ITULogService
 
     /**
      * 查询接口调用日志列表
-     * 
+     *
      * @param tULog 接口调用日志
      * @return 接口调用日志集合
      */
@@ -29,7 +31,7 @@ public interface ITULogService
 
     /**
      * 新增接口调用日志
-     * 
+     *
      * @param tULog 接口调用日志
      * @return 结果
      */
@@ -37,7 +39,7 @@ public interface ITULogService
 
     /**
      * 修改接口调用日志
-     * 
+     *
      * @param tULog 接口调用日志
      * @return 结果
      */
@@ -45,7 +47,7 @@ public interface ITULogService
 
     /**
      * 批量删除接口调用日志
-     * 
+     *
      * @param ids 需要删除的数据ID
      * @return 结果
      */
@@ -53,9 +55,21 @@ public interface ITULogService
 
     /**
      * 删除接口调用日志信息
-     * 
+     *
      * @param id 接口调用日志ID
      * @return 结果
      */
     public int deleteTULogById(String id);
+
+    /**
+     * 查询数据总量
+     * @return 结果
+     */
+    public Long getLogCount();
+
+    /**
+     * 查询日志表中的归集量
+     * @return 结果
+     */
+    public Map selectImputationLog(String year);
 }

+ 3 - 0
mybusiness/src/main/java/com/sooka/system/service/impl/Guiji_Base_Service.java

@@ -1,6 +1,7 @@
 package com.sooka.system.service.impl;
 
 import com.business.controller.WebSocketServer;
+import com.sooka.common.utils.CacheUtils;
 import com.sooka.common.utils.ServletUtils;
 import com.sooka.common.utils.uuid.UUID;
 import com.sooka.system.domain.BaseBusinessEntity;
@@ -60,6 +61,8 @@ public class Guiji_Base_Service {
         //归集接口
 //        tuLog.setPlatformInterfacetype("platform_interfacetype_2");
         tuLog.setPlatformInterfacetype(baseBusinessEntity.getInterfacetype());
+        /** 每次新增日志后要清空缓存,以达到更新缓存的效果 lm 202201011 add **/
+        CacheUtils.remove(tuLog.getCacheName(),tuLog.getCacheKey());
         tuLogMapper.insertTULog(tuLog);
 
         //推送websocket

+ 52 - 0
mybusiness/src/main/java/com/sooka/system/service/impl/TUInterfaceinfoServiceImpl.java

@@ -148,4 +148,56 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
     public List<TUInterfaceinfo> getPercent(String year){
         return tUInterfaceinfoMapper.getPercent(year);
     }
+
+    /**
+     * 查询省接口调用频次TOP5
+     * @return 结果
+     */
+    @Override
+    public List<TUInterfaceinfo> getProvinceTop5Frequency(){
+        return tUInterfaceinfoMapper.getProvinceTop5Frequency();
+    }
+
+    /**
+     * 查询市接口调用频次TOP5
+     * @return 结果
+     */
+    @Override
+    public List<TUInterfaceinfo> getCityTop5Frequency(){
+        return tUInterfaceinfoMapper.getCityTop5Frequency();
+    }
+
+    /**
+     * 查询省接口调用频次TOP20
+     * @return 结果
+     */
+    @Override
+    public List<TUInterfaceinfo> getProvinceTop20Frequency(){
+        return tUInterfaceinfoMapper.getProvinceTop20Frequency();
+    }
+
+    /**
+     * 查询市接口调用频次TOP20
+     * @return 结果
+     */
+    @Override
+    public List<TUInterfaceinfo> getCityTop20Frequency(){
+        return tUInterfaceinfoMapper.getCityTop20Frequency();
+    }
+
+    /**
+     * 查询归集接口排名
+     */
+    @Override
+    public List<TUInterfaceinfo> getImputationInterfaceRanking(){
+        return tUInterfaceinfoMapper.getImputationInterfaceRanking();
+    }
+
+    /**
+     * 查询归集数据排名
+     */
+    @Override
+    public List<TUInterfaceinfo> getImputationDataRanking(){
+        return tUInterfaceinfoMapper.getImputationDataRanking();
+    }
 }

+ 18 - 0
mybusiness/src/main/java/com/sooka/system/service/impl/TULogServiceImpl.java

@@ -1,6 +1,7 @@
 package com.sooka.system.service.impl;
 
 import java.util.List;
+import java.util.Map;
 
 import com.sooka.common.core.text.Convert;
 import com.sooka.common.utils.DateUtils;
@@ -96,4 +97,21 @@ public class TULogServiceImpl implements ITULogService
     {
         return tULogMapper.deleteTULogById(id);
     }
+
+    /**
+     * 查询数据总量
+     */
+    @Override
+    public Long getLogCount(){
+        return tULogMapper.getLogCount();
+    }
+
+    /**
+     * 查询日志表中的归集量
+     * @return 结果
+     */
+    @Override
+    public Map selectImputationLog(String year){
+        return tULogMapper.selectImputationLog(year);
+    }
 }

+ 190 - 0
mybusiness/src/main/java/com/util/StaticScheduleTask.java

@@ -0,0 +1,190 @@
+package com.util;
+
+import com.business.domain.ImputationData;
+import com.business.service.ImputationDataService;
+import com.sooka.common.utils.DateUtils;
+import com.sooka.common.utils.StringUtils;
+import com.sooka.system.service.ITULogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author limeng
+ * @date 2022年10月11日 8:50
+ */
+@Configuration
+@EnableScheduling
+public class StaticScheduleTask {
+
+    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    @Autowired
+    private ITULogService logService;
+
+    @Autowired
+    private ImputationDataService imputationDataService;
+
+    /**添加定时任务 每天凌晨1点**/
+    @Scheduled(cron = "0 0 1 * * ?")
+    private void configureTasks() {
+        for(int i=0;i<getYears().length;i++){
+            Map map = logService.selectImputationLog(getYears()[i]);
+            try {
+                ImputationData imputationData = new ImputationData();
+                imputationData.setYear(getYears()[i]);
+                ImputationData imd = imputationDataService.selectImputationData(imputationData);
+                ImputationData id = (ImputationData) mapToBean(map,new ImputationData().getClass());
+                if(imd == null){
+                    imputationDataService.insertImputationData(id);
+                }
+                imputationDataService.updateImputationData(id);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**获取当前年和前四年的年份**/
+    private String[] getYears() {
+        String[] arr = new String[5];
+        for(int i=0;i<arr.length;i++){
+            arr[i] = getYears(i-4);
+        }
+        return arr;
+    }
+
+    /**
+     * @Description 获取年份
+     * @param num 负数为之前年,0为当前年,正数为之后年
+     * @Throws
+     * @Return java.lang.String
+     * @Date 2022-10-12 10:28:15
+     * @Author
+     **/
+    public static String getYears(int num) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy");
+        Calendar c = Calendar.getInstance();
+        c.setTime(new Date());
+        c.add(Calendar.YEAR, num);
+        Date y = c.getTime();
+        return format.format(y);
+    }
+
+    /**比较两个日期大小**/
+    private boolean daysBefore(String time) {
+        Calendar calendar = null;
+        try {
+            calendar = getCalendar(time);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        Calendar now = Calendar.getInstance();
+        return calendar.before(now);
+    }
+
+    /**将String时间转换为Calendar**/
+    private static Calendar getCalendar(String time) throws ParseException {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(simpleDateFormat.parse(time));
+        return calendar;
+    }
+
+    /**
+     * 利用反射将map集合封装成bean对象
+     *
+     * @param map
+     * @param clazz
+     * @return
+     */
+    public static <T> T mapToBean(Map<String, Object> map, Class<?> clazz) throws Exception {
+        Object obj = clazz.newInstance();
+        if (map != null && !map.isEmpty() && map.size() > 0) {
+            for (Map.Entry<String, Object> entry : map.entrySet()) {
+                // 属性名
+                String propertyName = entry.getKey();
+                // 属性值
+                Object value = entry.getValue();
+                String setMethodName = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
+                //获取和map的key匹配的属性名称
+                Field field = getClassField(clazz, propertyName);
+                if (field == null){
+                    continue;
+                }
+                Class<?> fieldTypeClass = field.getType();
+                value = convertValType(value, fieldTypeClass);
+                try {
+                    clazz.getMethod(setMethodName, field.getType()).invoke(obj, value);
+                } catch (NoSuchMethodException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return (T) obj;
+    }
+
+    /**
+     * 根据给定对象类匹配对象中的特定字段
+     * @param clazz
+     * @param fieldName
+     * @return
+     */
+    private static Field getClassField(Class<?> clazz, String fieldName) {
+        if (Object.class.getName().equals(clazz.getName())) {
+            return null;
+        }
+        Field[] declaredFields = clazz.getDeclaredFields();
+        for (Field field : declaredFields) {
+            if (field.getName().equals(fieldName)) {
+                return field;
+            }
+        }
+        //如果该类还有父类,将父类对象中的字段也取出
+        Class<?> superClass = clazz.getSuperclass();
+        //递归获取
+        if (superClass != null) {
+            return getClassField(superClass, fieldName);
+        }
+        return null;
+    }
+
+    /**
+     * 将map的value值转为实体类中字段类型匹配的方法
+     * @param value
+     * @param fieldTypeClass
+     * @return
+     */
+    private static Object convertValType(Object value, Class<?> fieldTypeClass) {
+        Object retVal = null;
+        if (Long.class.getName().equals(fieldTypeClass.getName())
+                || long.class.getName().equals(fieldTypeClass.getName())) {
+            retVal = Long.parseLong(value.toString());
+        } else if (Integer.class.getName().equals(fieldTypeClass.getName())
+                || int.class.getName().equals(fieldTypeClass.getName())) {
+            retVal = Integer.parseInt(value.toString());
+        } else if (Float.class.getName().equals(fieldTypeClass.getName())
+                || float.class.getName().equals(fieldTypeClass.getName())) {
+            retVal = Float.parseFloat(value.toString());
+        } else if (Double.class.getName().equals(fieldTypeClass.getName())
+                || double.class.getName().equals(fieldTypeClass.getName())) {
+            retVal = Double.parseDouble(value.toString());;
+        } else {
+            retVal = value.toString();
+        }
+        return retVal;
+    }
+
+
+
+
+}

+ 87 - 0
mybusiness/src/main/resources/mapper/imputationData/ImputationDataMapper.xml

@@ -0,0 +1,87 @@
+<?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.business.mapper.ImputationDataMapper">
+
+    <resultMap id="imputationDataResult" type="ImputationData">
+        <result property="year"    column="year"    />
+        <result property="jan"    column="jan"    />
+        <result property="feb"    column="feb"    />
+        <result property="mar"    column="mar"    />
+        <result property="apr"    column="apr"    />
+        <result property="may"    column="may"    />
+        <result property="jun"    column="jun"    />
+        <result property="jul"    column="jul"    />
+        <result property="aug"    column="aug"    />
+        <result property="sep"    column="sep"    />
+        <result property="oct"    column="oct"    />
+        <result property="nov"    column="nov"    />
+        <result property="decb"    column="decb"    />
+    </resultMap>
+
+    <sql id="selectImputationDataVo">
+        select year, jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, decb from t_u_imputation_data
+    </sql>
+
+    <select id="selectImputationData" parameterType="ImputationData" resultMap="imputationDataResult">
+        <include refid="selectImputationDataVo"/>
+        <where>
+            <if test="year != null  and year != ''"> and year = #{year}</if>
+        </where>
+    </select>
+
+    <insert id="insertImputationData" parameterType="ImputationData">
+        insert into t_u_imputation_data
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                <if test="year != null">year,</if>
+                <if test="jan != null">jan,</if>
+                <if test="feb != null">feb,</if>
+                <if test="mar != null">mar,</if>
+                <if test="apr != null">apr,</if>
+                <if test="may != null">may,</if>
+                <if test="jun != null">jun,</if>
+                <if test="jul != null">jul,</if>
+                <if test="aug != null">aug,</if>
+                <if test="sep != null">sep,</if>
+                <if test="oct != null">oct,</if>
+                <if test="nov != null">nov,</if>
+                <if test="decb != null">decb,</if>
+            </trim>
+            <trim prefix="values (" suffix=")" suffixOverrides=",">
+                <if test="year != null">#{year},</if>
+                <if test="jan != null">#{jan},</if>
+                <if test="feb != null">#{feb},</if>
+                <if test="mar != null">#{mar},</if>
+                <if test="apr != null">#{apr},</if>
+                <if test="may != null">#{may},</if>
+                <if test="jun != null">#{jun},</if>
+                <if test="jul != null">#{jul},</if>
+                <if test="aug != null">#{aug},</if>
+                <if test="sep != null">#{sep},</if>
+                <if test="oct != null">#{oct},</if>
+                <if test="nov != null">#{nov},</if>
+                <if test="decb != null">#{decb},</if>
+            </trim>
+    </insert>
+
+    <update id="updateImputationData" parameterType="ImputationData">
+        update t_u_imputation_data
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="jan != null">jan = #{jan},</if>
+            <if test="feb != null">feb = #{feb},</if>
+            <if test="mar != null">mar = #{mar},</if>
+            <if test="apr != null">apr = #{apr},</if>
+            <if test="may != null">may = #{may},</if>
+            <if test="jun != null">jun = #{jun},</if>
+            <if test="jul != null">jul = #{jul},</if>
+            <if test="aug != null">aug = #{aug},</if>
+            <if test="sep != null">sep = #{sep},</if>
+            <if test="oct != null">oct = #{oct},</if>
+            <if test="nov != null">nov = #{nov},</if>
+            <if test="decb != null">decb = #{decb},</if>
+        </trim>
+        where year = #{year}
+    </update>
+
+</mapper>

+ 117 - 0
mybusiness/src/main/resources/mapper/system/TUInterfaceinfoMapper.xml

@@ -196,5 +196,122 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY dict_value
     </select>
 
+    <select id="getProvinceTop5Frequency" resultMap="TUInterfaceinfoResult">
+        SELECT
+            IFNULL(SUM(callsuccnum), 0) + IFNULL(SUM(callfailnum), 0) count,
+            dept_id,
+            dept_name
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            dept_id != ""
+        AND share_type IN (
+            'share_type_3',
+            'share_type_4'
+        )
+        GROUP BY
+            dept_id
+        ORDER BY
+            count DESC
+        LIMIT 0,
+         5
+    </select>
+
+    <select id="getCityTop5Frequency" resultMap="TUInterfaceinfoResult">
+        SELECT
+            IFNULL(SUM(callsuccnum), 0) + IFNULL(SUM(callfailnum), 0) count,
+            dept_id,
+            dept_name
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            dept_id != ""
+        AND share_type IN (
+            'share_type_1',
+            'share_type_2'
+        )
+        GROUP BY
+            dept_id
+        ORDER BY
+            count DESC
+        LIMIT 0,
+         5
+    </select>
+
+    <select id="getProvinceTop20Frequency" resultMap="TUInterfaceinfoResult">
+        SELECT
+            IFNULL(SUM(callsuccnum), 0) + IFNULL(SUM(callfailnum), 0) count,
+            dept_id,
+            dept_name
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            dept_id != ""
+        AND share_type IN (
+            'share_type_3',
+            'share_type_4'
+        )
+        GROUP BY
+            dept_id
+        ORDER BY
+            count DESC
+        LIMIT 0,
+         20
+    </select>
+
+    <select id="getCityTop20Frequency" resultMap="TUInterfaceinfoResult">
+        SELECT
+            IFNULL(SUM(callsuccnum), 0) + IFNULL(SUM(callfailnum), 0) count,
+            dept_id,
+            dept_name
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            dept_id != ""
+        AND share_type IN (
+            'share_type_1',
+            'share_type_2'
+        )
+        GROUP BY
+            dept_id
+        ORDER BY
+            count DESC
+        LIMIT 0,
+         20
+    </select>
+
+    <select id="getImputationInterfaceRanking" resultMap="TUInterfaceinfoResult">
+        SELECT
+            count('ct') count,
+            dept_id,
+            dept_name
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            dept_id != ''
+        GROUP BY
+            dept_id
+        ORDER BY
+            count DESC
+        LIMIT 0,
+         10
+    </select>
+
+    <select id="getImputationDataRanking" resultMap="TUInterfaceinfoResult">
+        SELECT
+            SUM(callsuccnum) count,
+            dept_id,
+            dept_name
+        FROM
+            t_u_interfaceinfo
+        WHERE
+            dept_id != ''
+        GROUP BY
+            dept_id
+        ORDER BY
+            count DESC
+        LIMIT 0,
+        10
+    </select>
 
 </mapper>

+ 114 - 0
mybusiness/src/main/resources/mapper/system/TULogMapper.xml

@@ -146,4 +146,118 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+    <select id="getLogCount" resultType="java.lang.Long">
+        SELECT count('ct') FROM t_u_log
+    </select>
+
+    <select id="selectImputationLog" resultType="java.util.LinkedHashMap">
+        SELECT
+            #{createTime} as year,
+                        IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 1 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS jan,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 2 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS feb,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 3 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS mar,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 4 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS apr,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 5 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS may,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 6 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS jun,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 7 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS jul,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 8 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS aug,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 9 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS sep,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 10 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS oct,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 11 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS nov,
+            IFNULL(SUM(
+                CASE MONTH (create_time)
+                WHEN 12 THEN
+                    1
+                ELSE
+                    0
+                END
+            ),0) AS decb
+        FROM
+            (
+                SELECT
+                    create_time
+                FROM
+                    t_u_log
+                WHERE
+                    YEAR (create_time) = #{createTime}
+            ) tb
+    </select>
+
 </mapper>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 167 - 196
mybusiness/src/main/resources/static/visualization/js/echarts_div.js


+ 21 - 23
mybusiness/src/main/resources/static/visualization/js/th_jk.js

@@ -6,15 +6,14 @@
         var hei = $(document).height();
         $("#particles-js").height(hei);
         $("#particles-js").width(wid);
-        //时间    间隔一秒执行一次获取当前时间的方法
+        //时间 间隔一秒执行一次获取当前时间的方法
         setInterval(function () {
             CurrentTime()
         }, 1000);
-        // 接口数量
+        /** 接口数量和占比 **/
         countAndPercent();
-        // 归集数据/接口排名
-        jkgj();
-        jkgj2();
+        /** 归集数据/接口排名 **/
+        imputationDataAndInterfaceRanking();
         // 切换
         var i = 0;//初始记录用户鼠标经过是第几个li
         var canmove = true;
@@ -28,12 +27,12 @@
             $('.tab_div1 .jkgj_tab').attr('v', i);
             $('.tab_div1 .jkgj_tab').hide();
             $('.tab_div1 .jkgj_tab').eq(i).show();
-
-            if ($('.tab_div1 .jkgj_tab').eq(1).is(':hidden')) {
-                jkgj();
-            } else if ($('.tab_div1 .jkgj_tab').eq(0).is(':hidden')) {
-                jkgj2();
-            }
+            //
+            // if ($('.tab_div1 .jkgj_tab').eq(1).is(':hidden')) {
+            //     jkgj();
+            // } else if ($('.tab_div1 .jkgj_tab').eq(0).is(':hidden')) {
+            //     jkgj2();
+            // }
         });
 
         $(".tab_div1").mouseenter(function () {//只要用户鼠标在这个tab1区域内,就不自动跳转
@@ -46,7 +45,6 @@
         });
 
         function li_timer() {
-            // wid = 100;
             if (canmove) {
                 i++;
                 if (i == $('.tab_tit span').length) {
@@ -57,13 +55,13 @@
                 $('.tab_div1 .jkgj_tab').eq(i).show();
             }
         }
-
         setInterval(li_timer, 5000);//每两秒切换
-        // 省、市接口调用切换
-        sjk1();
-        sjk2();
-        shjk1();
-        shjk2();
+
+        /** 市接口调用频次 **/
+        getCityFrequency();
+        /** 省接口调用频次 **/
+        getProvinceFrequency();
+
         // 切换
         var u = 0;//初始记录用户鼠标经过是第几个li
         var canmoveu = true;
@@ -75,11 +73,11 @@
             $('.tab_div2').hide();
             $('.tab_div2').eq(u).show();
             if ($('.tab_div2').eq(1).is(':hidden')) {
-                shjk1();
-                shjk2();
+                // 省接口调用频次
+                getProvinceFrequency();
             } else if ($('.tab_div2').eq(1).is(':hidden')) {
-                sjk1();
-                sjk2();
+                // 市接口调用频次
+                getCityFrequency();
             }
         });
 
@@ -107,7 +105,7 @@
 
         setInterval(li_timer2, 5000);//每两秒切换
         // 归集数据分析
-        gjsj();
+        imputationDataList();
         // 弹框数据归集
         // tk_gjsj();
     });

+ 13 - 2
mybusiness/src/main/resources/templates/visualization/index.html

@@ -201,7 +201,13 @@
         <i class="con_x"><img th:src="@{/visualization/images/thqzj_con_x.png}"></i>
         <div class="con_tit clearfix">
             <div class="fl div_tit2">归集数据分析</div>
-            <div class="tit_date"><i></i>2021-01-01&nbsp;至&nbsp;2022-08-08</div>
+            <div class="tit_date"><i></i>
+                <select id="line" th:onchange="changeYear()">
+                    <option selected th:value="2022">2022年</option>
+                    <option th:value="2021">2021年</option>
+                    <option th:value="2020">2020年</option>
+                </select>
+            </div>
         </div>
         <div id="gjsj"></div>
     </div>
@@ -317,9 +323,14 @@
 
     //占比选择年份方法
     function selectYear(){
-        console.log($("#pie").val());
         countAndPercent($("#pie").val());
     }
+
+    //归集数据分析选择年份方法
+    function changeYear(){
+        imputationDataList($("#line").val());
+    }
+
 </script>
 <script type="text/javascript" th:src="@{/visualization/js/echarts_div.js}"></script>
 <script type="text/javascript" th:src="@{/visualization/js/echarts-tooltip-carousel.js}"></script>