Browse Source

首页统计

xdd 1 month ago
parent
commit
9c091e0706

+ 11 - 6
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -2,10 +2,8 @@ package com.fs.api.controller;
 
 import com.fs.common.core.redis.RedisCache;
 import com.fs.statis.StatisticsRedisConstant;
-import com.fs.statis.cache.IStatisticsCacheService;
 import com.fs.statis.dto.*;
 import com.fs.statis.service.IStatisticsService;
-import com.hc.openapi.tool.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import com.fs.common.core.domain.R;
@@ -21,10 +19,6 @@ import static com.fs.statis.StatisticsRedisConstant.*;
 @RestController
 @RequestMapping("/index/statistics")
 public class IndexStatisticsController {
-    @Autowired
-    private IStatisticsCacheService statisticsService;
-    @Autowired
-    private IStatisticsService statisticsService1;
     @Autowired
     private RedisCache redisCache;
     /**
@@ -43,6 +37,7 @@ public class IndexStatisticsController {
         return R.ok().put("data",analysisPreviewDTO);
     }
 
+
     /**
      * 消费余额
      */
@@ -53,6 +48,16 @@ public class IndexStatisticsController {
         return R.ok().put("data", consumptionBalanceDataDTO);
     }
 
+    /**
+     * 获取统计流量
+     * @return
+     */
+    @GetMapping("/trafficLog")
+    public R getTrafficLog(){
+        TrafficLogDTO trafficLogDTO = redisCache.getCacheObject(DATA_OVERVIEW_TRAFFIC_LOG);
+        return R.ok().put("data",trafficLogDTO);
+    }
+
     /**
      * 观看趋势
      */

+ 15 - 0
fs-service-system/src/main/java/com/fs/course/mapper/FsCourseTrafficLogMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 import com.fs.course.domain.FsCourseTrafficLog;
 import com.fs.course.param.FsCourseTrafficLogParam;
 import com.fs.course.vo.FsCourseTrafficLogListVO;
+import com.fs.statis.dto.TrafficLogDTO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -72,4 +73,18 @@ public interface FsCourseTrafficLogMapper
     void insertOrUpdateTrafficLog(FsCourseTrafficLog trafficLog);
 
     List<FsCourseTrafficLogListVO> selectTrafficNew(FsCourseTrafficLogParam param);
+
+
+    /**
+     * 获取当天统计流量
+     * @return Long
+     */
+    Long getTodayTrafficLog();
+
+    /**
+     * 获取当月统计流量
+     * @return Long
+     */
+    Long getMonthTrafficLog();
+
 }

+ 6 - 2
fs-service-system/src/main/java/com/fs/statis/StatisticsRedisConstant.java

@@ -7,11 +7,15 @@ public class StatisticsRedisConstant {
     /**
      * 经销商统计
      */
-    public static final String DATA_OVERVIEW_DEALER_AGGREGATED = "overview:DealerAggregatedDTO";
+    public static final String DATA_OVERVIEW_DEALER_AGGREGATED = "overview:dealerAggregated";
     /**
      * 短信余额
      */
-    public static final String DATA_OVERVIEW_DEALER_SMS_BALANCE = "overview:SMS:BALANCE";
+    public static final String DATA_OVERVIEW_DEALER_SMS_BALANCE = "overview:sms:balance";
+    /**
+     * 流量统计
+     */
+    public static final String DATA_OVERVIEW_TRAFFIC_LOG = "overview:traffic_log";
     /**
      * 余额类
      */

+ 0 - 39
fs-service-system/src/main/java/com/fs/statis/cache/IStatisticsCacheService.java

@@ -1,39 +0,0 @@
-package com.fs.statis.cache;
-
-import com.fs.statis.dto.*;
-
-import java.util.List;
-
-public interface IStatisticsCacheService {
-    /**
-     * 分析概览 - 经销商统计
-     */
-    DealerAggregatedDTO dealerAggregated();
-
-    /**
-     * 消费余额
-     */
-    ConsumptionBalanceDataDTO rechargeConsumption();
-
-    /**
-     * 分析概览
-     */
-    AnalysisPreviewDTO analysisPreview(AnalysisPreviewQueryDTO param);
-
-
-    /**
-     * 会员观看、完播人数趋势图
-     * @param param 请求参数
-     * @return 会员观看、完播人数趋势图
-     */
-    List<WatchEndPlayTrendDTO> watchEndPlayTrend(AnalysisPreviewQueryDTO param);
-    void setWatchEndPlayTrend(Integer type,List<WatchEndPlayTrendDTO> data);
-
-    /**
-     * 经销商会员观看TOP10
-     * @param param 请求参数
-     * @return TOP10
-     * @return
-     */
-    List<DeaMemberTopTenDTO> deaMemberTopTen(AnalysisPreviewQueryDTO param);
-}

+ 0 - 85
fs-service-system/src/main/java/com/fs/statis/cache/impl/StatisticsCacheServiceImpl.java

@@ -1,85 +0,0 @@
-package com.fs.statis.cache.impl;
-
-import com.fs.statis.cache.IStatisticsCacheService;
-import com.fs.statis.dto.*;
-import com.fs.statis.service.IStatisticsService;
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-@Service
-public class StatisticsCacheServiceImpl implements IStatisticsCacheService {
-    @Autowired
-    private IStatisticsService statisticsService;
-
-    private static final Cache<Integer, DealerAggregatedDTO> DEALER_AGGREGATED_DTO_CACHE = Caffeine.newBuilder()
-            .maximumSize(1000)
-            .expireAfterWrite(10, TimeUnit.MINUTES)
-            .build();
-
-    private static final Cache<Integer, ConsumptionBalanceDataDTO> RECHARGE_CONSUMPTION = Caffeine.newBuilder()
-            .maximumSize(1000)
-            .expireAfterWrite(10, TimeUnit.MINUTES)
-            .build();
-
-    private static final Cache<Integer, AnalysisPreviewDTO> ANALYSIS_PREVIEW_CONSUMPTION = Caffeine.newBuilder()
-            .maximumSize(1000)
-            .expireAfterWrite(10, TimeUnit.MINUTES)
-            .build();
-
-    private static final Cache<Integer, List<WatchEndPlayTrendDTO>> WATCH_END_PLAY_TREND = Caffeine.newBuilder()
-            .maximumSize(1000)
-            .build();
-
-    private static final Cache<Integer, List<DeaMemberTopTenDTO>> DEA_MEMBER_TOP_TEN = Caffeine.newBuilder()
-            .maximumSize(1000)
-            .expireAfterWrite(10, TimeUnit.MINUTES)
-            .build();
-
-    @Override
-    public DealerAggregatedDTO dealerAggregated() {
-        return DEALER_AGGREGATED_DTO_CACHE.get(1,e->{
-            return statisticsService.dealerAggregated();
-        });
-    }
-
-    @Override
-    public ConsumptionBalanceDataDTO rechargeConsumption() {
-        return RECHARGE_CONSUMPTION.get(1,e->{
-            return statisticsService.rechargeConsumption();
-        });
-    }
-
-    @Override
-    public AnalysisPreviewDTO analysisPreview(AnalysisPreviewQueryDTO param) {
-        return ANALYSIS_PREVIEW_CONSUMPTION.get(1,e->{
-            return statisticsService.analysisPreview(param);
-        });
-    }
-
-    @Override
-    public List<WatchEndPlayTrendDTO> watchEndPlayTrend(AnalysisPreviewQueryDTO param) {
-        return WATCH_END_PLAY_TREND.get(param.getType(),e->{
-            return statisticsService.watchEndPlayTrend(param);
-        });
-    }
-
-    @Override
-    public void setWatchEndPlayTrend(Integer type,List<WatchEndPlayTrendDTO> data) {
-        WATCH_END_PLAY_TREND.put(type,data);
-    }
-
-
-    @Override
-    public List<DeaMemberTopTenDTO> deaMemberTopTen(AnalysisPreviewQueryDTO param) {
-        return DEA_MEMBER_TOP_TEN.get(param.getType(),e->{
-            return statisticsService.deaMemberTopTen(param);
-        });
-    }
-
-}

+ 20 - 0
fs-service-system/src/main/java/com/fs/statis/dto/TrafficLogDTO.java

@@ -0,0 +1,20 @@
+package com.fs.statis.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 获取统计流量
+ */
+@Data
+public class TrafficLogDTO implements Serializable {
+    /**
+     * 今日流量
+     */
+    private Long today;
+    /**
+     * 本月流量
+     */
+    private Long thisMonth;
+}

+ 5 - 0
fs-service-system/src/main/java/com/fs/statis/service/IStatisticsService.java

@@ -94,4 +94,9 @@ public interface IStatisticsService {
 
     List<RewardMoneyTrendDTO> rewardMoneyTrendDTO(AnalysisPreviewQueryDTO param);
 
+    /**
+     * 获取统计流量
+     * @return TrafficLogDTO
+     */
+    TrafficLogDTO getTrafficLog();
 }

+ 16 - 0
fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsServiceImpl.java

@@ -2,6 +2,7 @@ package com.fs.statis.service.impl;
 
 import com.fs.common.core.redis.RedisCache;
 import com.fs.company.cache.ICompanyCacheService;
+import com.fs.course.mapper.FsCourseTrafficLogMapper;
 import com.fs.statis.StatisticsRedisConstant;
 import com.fs.statis.dto.*;
 import com.fs.statis.mapper.ConsumptionBalanceMapper;
@@ -38,6 +39,9 @@ public class StatisticsServiceImpl implements IStatisticsService {
     @Autowired
     private RedisCache redisCache;
 
+    @Autowired
+    private FsCourseTrafficLogMapper fsCourseTrafficLogMapper;
+
 
     @Override
     public void dataOverviewTask() {
@@ -45,11 +49,13 @@ public class StatisticsServiceImpl implements IStatisticsService {
         ConsumptionBalanceDataDTO consumptionBalanceDataDTO = this.rechargeConsumption();
         AuthorizationInfoDTO authorizationInfoDTO = authorizationInfo();
         Long smsBalance = this.smsBalance();
+        TrafficLogDTO trafficLog = this.getTrafficLog();
 
         redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED, dealerAggregatedDTO);
         redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_BALANCE, consumptionBalanceDataDTO);
         redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO, authorizationInfoDTO);
         redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_SMS_BALANCE, smsBalance);
+        redisCache.setCacheObject(StatisticsRedisConstant.DATA_OVERVIEW_TRAFFIC_LOG,trafficLog);
     }
 
 
@@ -647,4 +653,14 @@ public class StatisticsServiceImpl implements IStatisticsService {
 
         return rewardMoneyTrendDTOS;
     }
+
+    @Override
+    public TrafficLogDTO getTrafficLog() {
+        TrafficLogDTO trafficLogDTO = new TrafficLogDTO();
+        Long todayTrafficLog = fsCourseTrafficLogMapper.getTodayTrafficLog();
+        Long monthTrafficLog = fsCourseTrafficLogMapper.getMonthTrafficLog();
+        trafficLogDTO.setToday(todayTrafficLog);
+        trafficLogDTO.setThisMonth(monthTrafficLog);
+        return trafficLogDTO;
+    }
 }

+ 17 - 0
fs-service-system/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml

@@ -76,6 +76,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         group by company_id,`month`,project,course_id
     </select>
+    <select id="getTodayTrafficLog" resultType="java.lang.Long">
+        SELECT
+            COALESCE(SUM(internet_traffic), 0) AS today_traffic_bytes
+        FROM
+            fs_course_traffic_log
+        WHERE
+            DATE(create_time) = CURDATE()
+    </select>
+    <select id="getMonthTrafficLog" resultType="java.lang.Long">
+        SELECT
+            COALESCE(SUM(internet_traffic), 0) AS month_traffic_bytes
+        FROM
+            fs_course_traffic_log
+        WHERE
+            YEAR(create_time) = YEAR(CURDATE())
+          AND MONTH(create_time) = MONTH(CURDATE())
+    </select>
 
     <insert id="insertFsCourseTrafficLog" parameterType="FsCourseTrafficLog" useGeneratedKeys="true" keyProperty="logId">
         insert into fs_course_traffic_log