wfansh 4 mesiacov pred
rodič
commit
45dc26b753

+ 5 - 5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/mapper/GADailyReportMapper.java

@@ -1,16 +1,16 @@
 package org.jeecg.modules.adweb.dmp.mapper;
 package org.jeecg.modules.adweb.dmp.mapper;
 
 
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 
 import org.jeecg.modules.adweb.dmp.entity.GADailyReport;
 import org.jeecg.modules.adweb.dmp.entity.GADailyReport;
+import org.jeecg.modules.adweb.dmp.vo.report.PeriodicStatsVO;
+
+import java.util.List;
 
 
 /**
 /**
- * @Description: dmp_ga_daily_report
- * @Author: jeecg-boot
- * @Date:   2024-10-10
- * @Version: V1.0
+ * @Description: dmp_ga_daily_report @Author: jeecg-boot @Date: 2024-10-10 @Version: V1.0
  */
  */
 public interface GADailyReportMapper extends BaseMapper<GADailyReport> {
 public interface GADailyReportMapper extends BaseMapper<GADailyReport> {
 
 
+    List<PeriodicStatsVO> getPeriodicStats(String siteCode);
 }
 }

+ 32 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/mapper/xml/GADailyReportMapper.xml

@@ -2,4 +2,36 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.adweb.dmp.mapper.GA">
 <mapper namespace="org.jeecg.modules.adweb.dmp.mapper.GA">
 
 
+    <select id="getPeriodicStats" resultType="org.jeecg.modules.adweb.dmp.vo.report.PeriodicStatsVO">
+        SELECT
+        tp.time_period,
+        COALESCE(SUM(d.total_users), 0) AS total_users,
+        COALESCE(SUM(d.page_views), 0) AS page_views
+        FROM
+        (
+        SELECT 'today' AS time_period
+        UNION ALL SELECT 'yesterday'
+        UNION ALL SELECT 'thisWeek'
+        UNION ALL SELECT 'lastWeek'
+        UNION ALL SELECT 'thisMonth'
+        UNION ALL SELECT 'lastMonth'
+        UNION ALL SELECT 'allTime'
+        ) tp
+        LEFT JOIN
+        dmp_ga_daily_report d
+        ON
+        d.site_code = #{siteCode}
+        AND (
+        (tp.time_period = 'today' AND DATE(d.date) = CURDATE()) OR
+        (tp.time_period = 'yesterday' AND DATE(d.date) = CURDATE() - INTERVAL 1 DAY) OR
+        (tp.time_period = 'thisWeek' AND YEARWEEK(d.date, 1) = YEARWEEK(CURDATE(), 1)) OR
+        (tp.time_period = 'lastWeek' AND YEARWEEK(d.date, 1) = YEARWEEK(CURDATE() - INTERVAL 1 WEEK, 1)) OR
+        (tp.time_period = 'thisMonth' AND YEAR(d.date) = YEAR(CURDATE()) AND MONTH(d.date) = MONTH(CURDATE())) OR
+        (tp.time_period = 'lastMonth' AND YEAR(d.date) = YEAR(CURDATE() - INTERVAL 1 MONTH) AND MONTH(d.date) =
+        MONTH(CURDATE() - INTERVAL 1 MONTH)) OR
+        (tp.time_period = 'allTime')
+        )
+        GROUP BY
+        tp.time_period;
+    </select>
 </mapper>
 </mapper>

+ 9 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/service/IGADailyReportService.java

@@ -5,6 +5,7 @@ import static org.jeecg.modules.adweb.dmp.vo.report.SiteOverviewStatsVO.DailySta
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
 import org.jeecg.modules.adweb.dmp.entity.GADailyReport;
 import org.jeecg.modules.adweb.dmp.entity.GADailyReport;
+import org.jeecg.modules.adweb.dmp.vo.report.PeriodicStatsVO;
 
 
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
@@ -21,5 +22,12 @@ public interface IGADailyReportService extends IService<GADailyReport> {
      *
      *
      * <p>填充每日询盘数据
      * <p>填充每日询盘数据
      */
      */
-    List<DailyStatsVO> getDailyStatsWithinPeriod(String siteCode, Date start, Date end);
+    List<DailyStatsVO> getDailyStatsWithinDateRange(String siteCode, Date start, Date end);
+
+    /**
+     * 查询分时间段的{@PeriodicStatsVO},如今天,昨天,本周,上周,本月,上月,全部 *
+     *
+     * <p>填充每日询盘数据
+     */
+    List<PeriodicStatsVO> getPeriodicStats(String siteCode);
 }
 }

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/vo/report/PeriodicStatsVO.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.adweb.dmp.vo.report;
+
+import lombok.Data;
+
+@Data
+public class PeriodicStatsVO {
+
+    private String period;
+
+    private int totalUsers;
+
+    private int pageViews;
+}