Browse Source

Realtime report

wfansh 3 months ago
parent
commit
8c6b8df7cc

BIN
conf/adweb_v3.sql.zip


+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/controller/DMPDataController.java

@@ -37,7 +37,7 @@ import java.util.stream.Collectors;
 public class DMPDataController {
 
     @Value("${v3.dmp.realtimeReport}")
-    private boolean realtimeReport;
+    private boolean realtimeReport; // 实时报表开关,true-从DataBridge实时读取 false-从DB离线读取
 
     @Autowired private IGADailyReportService gaDailyReportService;
     @Autowired private IGACountryReportService gaCountryReportService;

+ 15 - 6
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/dmp/service/RealtimeReportService.java

@@ -41,7 +41,7 @@ import java.util.stream.Collectors;
  * 从DataBridge实时拉取GA报表数据,替代DB离线查询 - http://data-bridge.v3.adwebcloud.com:9002/swagger-ui/index.html
  *
  * @author wfansh
- * @deprecated 相比XXL定期同步 + DB离线查询,响应速度慢。后期DB数据量大产生性能瓶颈时,可重新评估并启用本方案
+ * @deprecated 相比XXL定期同步 + DB离线查询,响应速度慢。后期DB数据量大产生性能瓶颈时,可重新评估并启用本方案
  */
 @Deprecated
 @Slf4j
@@ -52,7 +52,17 @@ public class RealtimeReportService {
     @Autowired private IGoogleGTMService googleGTMService;
     @Autowired private AdwebEnquiryMapper adwebEnquiryMapper;
     @Autowired private GAReportService gaReportService;
-    @Autowired private AdwebRedisUtil redisUtil;
+    @Autowired private AdwebRedisUtil adwebRedisUtil;
+
+    /**
+     * 拉取Google Analytics - 时间段报表 - 今天,昨天,本周,上周,本月,上月,全部
+     *
+     * <p>填充各时间段询盘数据
+     */
+    public List<PeriodicStatsVO> getPeriodicStats(String siteCode) {
+        // TODO
+        return Collections.EMPTY_LIST;
+    }
 
     /**
      * 拉取Google Analytics - Daily报表
@@ -67,8 +77,7 @@ public class RealtimeReportService {
                     "dmp:realtime:getDailyStats"
                             + TTLCacheManager.TTL_SPLITTER
                             + 60 * 10) // Redis TTL为10分钟
-    public List<SiteOverviewStatsVO.DailyStatsVO> getDailyStats(
-            String siteCode, Date start, Date end) {
+    public List<DailyStatsVO> getDailyStats(String siteCode, Date start, Date end) {
         GoogleGTM googleGTM = this.getGTMAccount(siteCode);
         if (StringUtils.isBlank(googleGTM.getGaPropertyId())) {
             log.info("Google Analytics帐号未配置, siteCode = {}", siteCode);
@@ -443,7 +452,7 @@ public class RealtimeReportService {
     private synchronized GoogleGTM getGTMAccount(String siteCode) {
         final String redisKey = String.format("%s:account:%s", "googlegtm", siteCode);
 
-        GoogleGTM googleGTM = (GoogleGTM) redisUtil.get(redisKey);
+        GoogleGTM googleGTM = (GoogleGTM) adwebRedisUtil.get(redisKey);
         if (Objects.nonNull(googleGTM)) {
             return googleGTM;
         }
@@ -454,7 +463,7 @@ public class RealtimeReportService {
                         new LambdaQueryWrapper<GoogleGTM>().eq(GoogleGTM::getSiteCode, siteCode),
                         false);
         googleGTM = Objects.nonNull(googleGTM) ? googleGTM : new GoogleGTM(); // Redis存储对象不允许为空
-        redisUtil.set(redisKey, googleGTM, 30); // Redis TTL为30秒
+        adwebRedisUtil.set(redisKey, googleGTM, 30); // Redis TTL为30秒
 
         return googleGTM;
     }

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/marketing/googleads/service/GoogleAdsReportService.java

@@ -58,7 +58,7 @@ public class GoogleAdsReportService {
 
     @Autowired private IGoogleAdsService googleAdsService;
 
-    @Autowired private AdwebRedisUtil redisUtil;
+    @Autowired private AdwebRedisUtil adwebRedisUtil;
 
     private RestTemplate restTemplate;
 
@@ -286,7 +286,7 @@ public class GoogleAdsReportService {
     private synchronized GoogleAds getAdsAccount(String siteCode) {
         final String redisKey = String.format("%s:account:%s", "googleads", siteCode);
 
-        GoogleAds googleAds = (GoogleAds) redisUtil.get(redisKey);
+        GoogleAds googleAds = (GoogleAds) adwebRedisUtil.get(redisKey);
         if (Objects.nonNull(googleAds)) {
             return googleAds;
         }
@@ -297,7 +297,7 @@ public class GoogleAdsReportService {
                         new LambdaQueryWrapper<GoogleAds>().eq(GoogleAds::getSiteCode, siteCode),
                         false);
         googleAds = Objects.nonNull(googleAds) ? googleAds : new GoogleAds(); // Redis存储对象不允许为空
-        redisUtil.set(redisKey, googleAds, 30); // Redis TTL为30秒
+        adwebRedisUtil.set(redisKey, googleAds, 30); // Redis TTL为30秒
 
         return googleAds;
     }

+ 6 - 6
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/dataforseo/DataForSEOService.java

@@ -72,7 +72,7 @@ public class DataForSEOService {
 
     @Autowired private ISeoKeywordsSerpService seoKeywordsSerpService;
 
-    @Autowired private AdwebRedisUtil redisUtil;
+    @Autowired private AdwebRedisUtil adwebRedisUtil;
 
     private SerpApi serpApi;
 
@@ -117,7 +117,7 @@ public class DataForSEOService {
 
     /** 同步DataForSEO Serp结果 - 从Redis中获取正在运行的任务 */
     public void syncKeywordsSerpResults() {
-        Set<String> serpTaskRedisKeys = redisUtil.keys(this.getSerpTaskRedisKey("*"));
+        Set<String> serpTaskRedisKeys = adwebRedisUtil.keys(this.getSerpTaskRedisKey("*"));
 
         if (CollectionUtil.isEmpty(serpTaskRedisKeys)) {
             log.info("Redis中暂无需要同步的Serp关键词");
@@ -174,7 +174,7 @@ public class DataForSEOService {
             for (SerpGoogleOrganicTaskPostTaskInfo serpingTask : serpingTasks) {
                 Map<String, String> data = (Map<String, String>) serpingTask.getData();
                 String keywordId = data.get("tag");
-                redisUtil.set(this.getSerpTaskRedisKey(keywordId), serpingTask.getId());
+                adwebRedisUtil.set(this.getSerpTaskRedisKey(keywordId), serpingTask.getId());
 
                 serpingKeywordIds.add(Integer.parseInt(keywordId));
             }
@@ -212,7 +212,7 @@ public class DataForSEOService {
     private boolean onSerpResult(String serpTaskRedisKey) {
         try {
             // 1. 查询Serp task
-            String taskId = redisUtil.getString(serpTaskRedisKey);
+            String taskId = adwebRedisUtil.getString(serpTaskRedisKey);
             SerpGoogleOrganicTaskGetRegularTaskInfo serpTask =
                     serpApi.googleOrganicTaskGetRegular(taskId).getTasks().get(0);
             log.info("获取DataForSEO Serp任务,response = {}", FastJsonUtil.toJSONString(serpTask));
@@ -237,7 +237,7 @@ public class DataForSEOService {
             if (Objects.isNull(seoKeyword)) {
                 log.info("无法获取关键词 ID = {}", keywordId);
 
-                redisUtil.del(serpTaskRedisKey);
+                adwebRedisUtil.del(serpTaskRedisKey);
                 return false;
             }
 
@@ -299,7 +299,7 @@ public class DataForSEOService {
             keywordSerp.setSeDatetime(seDatetime);
             seoKeywordsSerpService.save(keywordSerp);
 
-            redisUtil.del(serpTaskRedisKey);
+            adwebRedisUtil.del(serpTaskRedisKey);
             return true;
         } catch (ApiException e) {
             log.error("同步DataForSEO Serp任务失败", e);

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/xxl/GAReportJob.java

@@ -27,7 +27,7 @@ public class GAReportJob {
      * @param siteCodes
      * @return
      */
-    @XxlJob("syncGAReportHandler")
+    @XxlJob("syncGAReportHandler") // Cron表达式示例:0 0 */8 * * ? 表示每8小时执行一次
     public ReturnT<String> syncGAReportHandler(String siteCodes) {
         log.info("同步GA报表数据...");
         gaReportService.syncGAReport(CommonUtil.splitAndTrim(siteCodes, ","));

+ 7 - 7
jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml

@@ -367,6 +367,13 @@ security:
         - /jmreport/bigscreen2/**
 
 ### 自定义
+### v3系统配置
+v3:
+  projectPath: D:/Advich/pem
+  dmp:
+    # DMP模块实时报表开关,true-从DataBridge实时读取 false-从DB离线读取
+    realtimeReport: false
+
 ### GA,GTM,Ads等数据交换中心
 data-bridge:
   api:
@@ -435,13 +442,6 @@ aws:
     accessKey: AKIAS37NJDKDETZ7PPEN
     secretKey: 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
 
-### v3系统配置
-v3:
-  projectPath: D:/Advich/pem
-  dmp:
-    # DMP模块实时报表开关,true-从DataBridge实时读取 false-从DB离线读取
-    realtimeReport: false
-
 ### 建站链接测试环境配置
 AdwebSiteConnect:
   host: 35.87.155.71

+ 7 - 7
jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml

@@ -369,6 +369,13 @@ security:
         - /api/getUserInfo
 
 ### 自定义
+### v3系统配置
+v3:
+  projectPath: /opt/adweb3/pem
+  dmp:
+    # DMP模块实时报表开关,true-从DataBridge实时读取 false-从DB离线读取
+    realtimeReport: false
+
 ### GA,GTM,Ads等数据交换中心
 data-bridge:
   api:
@@ -439,13 +446,6 @@ aws:
     accessKey: AKIAS37NJDKDETZ7PPEN
     secretKey: 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
 
-### v3系统配置
-v3:
-  projectPath: /opt/adweb3/pem
-  dmp:
-    # DMP模块实时报表开关,true-从DataBridge实时读取 false-从DB离线读取
-    realtimeReport: false
-
 ### 建站链接测试环境配置
 AdwebSiteConnect:
   host: 35.87.155.71

+ 7 - 7
jeecg-module-system/jeecg-system-start/src/main/resources/application-test.yml

@@ -366,6 +366,13 @@ security:
         - /jmreport/bigscreen2/**
 
 ### 自定义
+### v3系统配置
+v3:
+  projectPath: /opt/adweb3/pem
+  dmp:
+    # DMP模块实时报表开关,true-从DataBridge实时读取 false-从DB离线读取
+    realtimeReport: false
+
 ### GA,GTM,Ads等数据交换中心
 data-bridge:
   api:
@@ -436,13 +443,6 @@ aws:
     accessKey: AKIAS37NJDKDETZ7PPEN
     secretKey: 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
 
-### v3系统配置
-v3:
-  projectPath: /opt/adweb3/pem
-  dmp:
-    # DMP模块实时报表开关,true-从DataBridge实时读取 false-从DB离线读取
-    realtimeReport: false
-
 ### 建站链接测试环境配置
 AdwebSiteConnect:
   host: 35.87.155.71