Przeglądaj źródła

Merge remote-tracking branch 'origin/test' into test

yumeng 5 lat temu
rodzic
commit
7f42ef06ad
30 zmienionych plików z 1037 dodań i 111 usunięć
  1. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 123 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java
  3. 48 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyReportLoadJob.java
  4. 46 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceHourlyReportLoadJob.java
  5. 0 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceReportLoadJob.java
  6. 49 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyReportLoadJob.java
  7. 47 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyReportLoadJob.java
  8. 41 0
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  9. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  10. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  11. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  12. 369 24
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  13. 3 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCampaign.java
  14. 3 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java
  15. 3 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java
  16. 3 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCampaign.java
  17. 3 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCreative.java
  18. 3 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java
  19. 5 3
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceAdvertiserDailyReport.java
  20. 5 3
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceAdvertiserHourlyReport.java
  21. 9 4
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCampaignDailyReport.java
  22. 8 4
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCampaignHourlyReport.java
  23. 9 4
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCreativeDailyReport.java
  24. 9 11
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCreativeHourlyReport.java
  25. 10 4
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedancePlanDailyReport.java
  26. 8 4
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedancePlanHourlyReport.java
  27. 10 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IReportService.java
  28. 190 13
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java
  29. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/IByteDanceAdvertiserDataService.java
  30. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -111,6 +111,8 @@ public class ShiroConfig {
 		//头条接口
         filterChainDefinitionMap.put("/bytedance", "anon");
 		filterChainDefinitionMap.put("/toutiao/dictitem/list", "anon");
+        filterChainDefinitionMap.put("/toutiao/loadAllData", "anon");
+        filterChainDefinitionMap.put("/toutiao/loadSingleData", "anon");
 		filterChainDefinitionMap.put("/toutiao/advertiser/**", "anon");
         filterChainDefinitionMap.put("/toutiao/industry/list", "anon");
         filterChainDefinitionMap.put("/template/bytedance/industry/list", "anon");

+ 123 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java

@@ -1,6 +1,13 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.bytedance.service.IReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IFileInfoService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.entity.ByteDanceCustomAudience;
 import cn.com.ctop.toutiao.entity.ByteDanceUserOrientationTemplate;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
@@ -12,12 +19,16 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.system.entity.SysDictItem;
 import org.jeecg.modules.system.service.ISysDictItemService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -248,4 +259,116 @@ public class ByteDanceAdvertiserPostController {
         result.setResult(pageList);
         return result;
     }
+
+    @GetMapping("loadAllData")
+    public Map<String, Object> loadAllData() {
+        Map<String, Object> result = new HashMap<>();
+        Date endDate = new Date();
+        Date hourlyStartDate = DateUtils.addDay(endDate, -7);
+        Date startDate = DateUtils.addDay(endDate, -180);
+//        List<CtopOauthToken> bytedanceTokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+//        if(null!=bytedanceTokens&&bytedanceTokens.size()>0){
+//            bytedanceTokens.forEach(token -> {
+//                //1: 获取广告主信息数据
+//                reportService.getAdvertiserReport(token,startDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+//                //2:获取广告组信息数据
+//                reportService.getAdvertiserCampaignReport(token,startDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+//                //3:获取广告计划信息数据
+//                reportService.getAdvertiserPlanReport(token,startDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+//                //4: 获取广告创意信息数据
+//                reportService.getAdvertiserCreativeReport(token,startDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+//
+//                //1: 获取广告主信息数据
+//                reportService.getAdvertiserReport(token,hourlyStartDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+//                //2:获取广告组信息数据
+//                reportService.getAdvertiserCampaignReport(token,hourlyStartDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+//                //3:获取广告计划信息数据
+//                reportService.getAdvertiserPlanReport(token,hourlyStartDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+//                //4: 获取广告创意信息数据
+//                reportService.getAdvertiserCreativeReport(token,hourlyStartDate,endDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+//            });
+//        }
+        List<CtopOauthToken> kuaishouTokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        if (null != kuaishouTokens && kuaishouTokens.size() > 0) {
+            kuaishouTokens.forEach(token -> {
+                //1: 获取广告主信息数据
+                kuaishouInterfaceService.getAdvertiserReportDaily(token, startDate, endDate);
+                //2:获取广告计划信息数据
+                kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, startDate, endDate);
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, startDate, endDate);
+                //4: 获取广告创意信息数据
+                kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, startDate, endDate);
+
+                //1: 获取广告主信息数据
+                kuaishouInterfaceService.getAdvertiserReportHourly(token, hourlyStartDate, endDate);
+                //2:获取广告计划信息数据
+                kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, hourlyStartDate, endDate);
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, hourlyStartDate, endDate);
+                //4: 获取广告创意信息数据
+                kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, hourlyStartDate, endDate);
+            });
+        }
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
+        return result;
+    }
+
+    @GetMapping("loadSingleData")
+    public Map<String, Object> loadSingleData(Long accountId) {
+        Map<String, Object> result = new HashMap<>();
+        Date endDate = new Date();
+        Date hourlyStartDate = DateUtils.addDay(endDate, -7);
+        Date startDate = DateUtils.addDay(endDate, -180);
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
+        if (null != token) {
+            if (null != token.getMediaId() && token.getMediaId().equals(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE)) {
+                //1: 获取广告主信息数据
+                reportService.getAdvertiserReport(token, startDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                //2:获取广告组信息数据
+                reportService.getAdvertiserCampaignReport(token, startDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                //3:获取广告计划信息数据
+                reportService.getAdvertiserPlanReport(token, startDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                //4: 获取广告创意信息数据
+                reportService.getAdvertiserCreativeReport(token, startDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+
+                //1: 获取广告主信息数据
+                reportService.getAdvertiserReport(token, hourlyStartDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                //2:获取广告组信息数据
+                reportService.getAdvertiserCampaignReport(token, hourlyStartDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                //3:获取广告计划信息数据
+                reportService.getAdvertiserPlanReport(token, hourlyStartDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                //4: 获取广告创意信息数据
+                reportService.getAdvertiserCreativeReport(token, hourlyStartDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+            }
+            if (null != token.getMediaId() && token.getMediaId().equals(CtopAdConstant.PLATFORM_TYPE_KUAISHOU)) {
+                //1: 获取广告主信息数据
+                kuaishouInterfaceService.getAdvertiserReportDaily(token, startDate, endDate);
+                //2:获取广告计划信息数据
+                kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, startDate, endDate);
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, startDate, endDate);
+                //4: 获取广告创意信息数据
+                kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, startDate, endDate);
+
+                //1: 获取广告主信息数据
+                kuaishouInterfaceService.getAdvertiserReportHourly(token, hourlyStartDate, endDate);
+                //2:获取广告计划信息数据
+                kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, hourlyStartDate, endDate);
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, hourlyStartDate, endDate);
+                //4: 获取广告创意信息数据
+                kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, hourlyStartDate, endDate);
+            }
+        }
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
+        return result;
+    }
+
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
 }

+ 48 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyReportLoadJob.java

@@ -0,0 +1,48 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author syh
+ * 第二天凌晨跑前一天的数据
+ */
+@Slf4j
+public class BytedanceDailyReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+        tokens.forEach(token -> {
+            //1: 获取广告主信息数据
+            reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            //2:获取广告组信息数据
+            reportService.getAdvertiserCampaignReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            //3:获取广告计划信息数据
+            reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            //4: 获取广告创意信息数据
+            reportService.getAdvertiserCreativeReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        });
+    }
+}

+ 46 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceHourlyReportLoadJob.java

@@ -0,0 +1,46 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author syh
+ */
+@Slf4j
+public class BytedanceHourlyReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IReportService reportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = new Date();
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条小时数据异常:未获取到可用的token");
+            return;
+        }
+        tokens.forEach(token -> {
+            //1: 获取广告主信息数据
+            reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+            //2:获取广告组信息数据
+            reportService.getAdvertiserCampaignReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+            //3:获取广告计划信息数据
+            reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+            //4: 获取广告创意信息数据
+            reportService.getAdvertiserCreativeReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+        });
+    }
+}

+ 0 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceReportLoadJob.java

@@ -1,12 +0,0 @@
-package org.jeecg.modules.ctop.job;
-
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-
-public class BytedanceReportLoadJob implements Job {
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        //1:查询所有
-    }
-}

+ 49 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyReportLoadJob.java

@@ -0,0 +1,49 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+
+        tokens.forEach(token -> {
+            //1: 获取广告主信息数据
+            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+            //2:获取广告计划信息数据
+            kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
+            //3:获取广告组信息数据
+            kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getDate, getDate);
+            //4: 获取广告创意信息数据
+            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate);
+
+        });
+    }
+}

+ 47 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyReportLoadJob.java

@@ -0,0 +1,47 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author syh
+ */
+@Slf4j
+public class KuaishouHourlyReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = new Date();
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+
+        tokens.forEach(token -> {
+            //1: 获取广告主信息数据
+            kuaishouInterfaceService.getAdvertiserReportHourly(token, getDate, getDate);
+            //2:获取广告计划信息数据
+            kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, getDate, getDate);
+            //3:获取广告组信息数据
+            kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, getDate, getDate);
+            //4: 获取广告创意信息数据
+            kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, getDate, getDate);
+        });
+    }
+}

+ 41 - 0
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,10 +1,12 @@
 package org.jeecg;
 
+import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IFileInfoService;
 import cn.com.ctop.common.module.utils.OSSUtils;
 import cn.com.ctop.common.module.utils.StringUtils;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.entity.ByteDanceUserOrientationTemplate;
 import cn.com.ctop.toutiao.entity.BytedanceInterestCategory;
 import cn.com.ctop.toutiao.mapper.ByteDanceUserOrientationTemplateMapper;
@@ -13,6 +15,8 @@ import cn.com.ctop.toutiao.mapper.BytedanceInterestCategoryMapper;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.jsonschema.JsonschemaUtil;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.jeecg.modules.demo.mock.MockController;
@@ -29,10 +33,12 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
+@Slf4j
 public class SampleTest {
 
     @Resource
@@ -46,6 +52,8 @@ public class SampleTest {
 
     @Autowired
     private ICreateInternalService createInternalService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
 
     @Test
     public void testLogin() {
@@ -53,6 +61,39 @@ public class SampleTest {
         System.out.println(map.toString());
     }
 
+    @Autowired
+    private IReportService reportService;
+
+    @Test
+    public void testJob() {
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(4 + "");
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+        tokens.forEach(token -> {
+            //1: 获取广告主信息数据
+//            kuaishouInterfaceService.getAdvertiserReportDaily(token,getDate);
+            //2:获取广告计划信息数据
+//            kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token,getDate);
+            //3:获取广告组信息数据
+//            kuaishouInterfaceService.getAdvertiserGroupReportDaily(token,getDate);
+            //4: 获取广告创意信息数据
+//            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token,getDate);
+//            //1: 获取广告主信息数据
+//            kuaishouInterfaceService.getAdvertiserReportHourly(token, getDate);
+//            //2:获取广告计划信息数据
+            kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, getDate);
+//            //3:获取广告组信息数据
+            kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, getDate);
+//            //4: 获取广告创意信息数据
+            kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, getDate);
+        });
+    }
+
     @Test
     public void testFileType() {
         File file = new File("D:\\工作文件\\360借条\\快手后台数据-户1.csv");

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.common.module.service;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -18,4 +19,6 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
     Map<String, Object> getByteDanceAccessToken(String accountId);
 
     Map<String, Object> getKuaiShouRefreshToken(Long accountId, String refreshToken);
+
+    List<CtopOauthToken> getTokenListByType(String platformTypeBytedance);
 }

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -145,4 +146,11 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         }
         return null;
     }
+
+    @Override
+    public List<CtopOauthToken> getTokenListByType(String platformType) {
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("media_id", platformType);
+        return this.list(queryWrapper);
+    }
 }

+ 18 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.entity.*;
@@ -8,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
 import java.util.Map;
 
 public interface IKuaishouInterfaceService {
@@ -224,4 +226,20 @@ public interface IKuaishouInterfaceService {
      * @return
      */
     Map<String, Object> advertiserInfo(Long accountId, String accessToken);
+
+    void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getAdvertiserGroupReportDaily(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getAdvertiserCampaignReportHourly(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getAdvertiserGroupReportHourly(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getAdvertiserCreativeReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 }

+ 369 - 24
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
@@ -24,6 +25,7 @@ import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.TypeFactory;
 import lombok.extern.slf4j.Slf4j;
+import lombok.var;
 import org.apache.http.ParseException;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.LoadFileUtil;
@@ -101,6 +103,50 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private KuaiShouAdvertiserBaseInfoMapper advertiserBaseInfoMapper;
 
+    @Override
+    public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
+        getAdvertiserReportHourlyByPage(token, startDate, endDate, 1);
+    }
+
+    private void getAdvertiserReportHourlyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "HOURLY");
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告主时报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告主时报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var kuaishouReportHourlyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyAccount.class);
+            kuaishouReportHourlyAccount.setAccountId(token.getAccountId());
+            kuaishouReportHourlyAccount.setId("" + token.getAccountId() + kuaishouReportHourlyAccount.getStatDate() + kuaishouReportHourlyAccount.getStatHour());
+            hourlyAccountService.saveOrUpdate(kuaishouReportHourlyAccount);
+        }
+        getAdvertiserReportHourlyByPage(token, startDate, endDate, page + 1);
+    }
+
     /**
      * 广告主日报表信息
      *
@@ -110,7 +156,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param endDate
      * @param pageSize
      * @param pageNum
-     * @return
      */
     @Override
     public KuaishouResult<KuaishouReportHourlyAccount> getAccountHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
@@ -152,23 +197,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 }
 
             }
-
-
-            /*String result = HttpUtils.httpPostRequest(url, param, headers);
-            JSONObject resultJson = JSONArray.parseObject(result);
-            if (!Check.isNull(resultJson)) {
-
-            }
-            ObjectMapper mapper = new ObjectMapper();
-            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-            kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportHourlyAccount>>() {
-            });
-            List<KuaishouReportHourlyAccount> hourlyAccounts = kuaishouResult.getData().getDetails();
-            hourlyAccounts.forEach((hourlyAccount) -> {
-                hourlyAccount.setAccountId(advertiserId);
-                hourlyAccount.setId("" + hourlyAccount.getAccountId() + hourlyAccount.getStatDate() + hourlyAccount.getStatHour());
-                hourlyAccountService.saveOrUpdate(hourlyAccount);
-            });*/
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -176,6 +204,52 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
+        getAccountDailyReportByPage(token, startDate, endDate, 1);
+    }
+
+
+    private void getAccountDailyReportByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", 500);
+        param.put("page", page);
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告主报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告主报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var kuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
+            kuaishouReportDailyAccount.setAccountId(token.getAccountId());
+            kuaishouReportDailyAccount.setId("" + token.getAccountId() + kuaishouReportDailyAccount.getStatDate());
+            dailyAccountService.saveOrUpdate(kuaishouReportDailyAccount);
+        }
+        getAccountDailyReportByPage(token, startDate, endDate, page + 1);
+    }
+
+    @Override
     public KuaishouResult<KuaishouReportDailyAccount> getAccountDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_REPORT;
         Map<String, String> headers = new HashMap<String, String>();
@@ -208,9 +282,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             kuaishouReportDailyAccount.setId("" + advertiserId + kuaishouReportDailyAccount.getStatDate());
                             dailyAccountService.saveOrUpdate(kuaishouReportDailyAccount);
                         }
-
                     }
-
                 }
 
             }
@@ -221,6 +293,53 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
+        getCampaignDailyReportByPage(token, startDate, endDate, 1);
+    }
+
+    private void getCampaignDailyReportByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        System.out.println(result);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告计划报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告计划报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var campaign = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCampaign.class);
+            campaign.setAccountId(token.getAccountId());
+            campaign.setId("" + campaign.getAccountId() + campaign.getCampaignId() + campaign.getStatDate());
+            dailyCampaignService.saveOrUpdate(campaign);
+        }
+        getCampaignDailyReportByPage(token, startDate, endDate, page + 1);
+    }
+
+    @Override
     public KuaishouResult<KuaishouReportDailyCampaign> getCampaignDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_REPORT;
         Map<String, String> headers = new HashMap<>();
@@ -254,6 +373,52 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getAdvertiserCampaignReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
+        getCampaignReportHourlyByPage(token, startDate, endDate, 1);
+    }
+
+    private void getCampaignReportHourlyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "HOURLY");
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告计划时报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告计划时报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var hourlyCampaign = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyCampaign.class);
+            hourlyCampaign.setAccountId(token.getAccountId());
+            hourlyCampaign.setId("" + hourlyCampaign.getAccountId() + hourlyCampaign.getCampaignId() + hourlyCampaign.getStatDate() + hourlyCampaign.getStatHour());
+            hourlyCampaignService.saveOrUpdate(hourlyCampaign);
+        }
+        getAdvertiserReportHourlyByPage(token, startDate, endDate, page + 1);
+    }
+
+
+    @Override
     public KuaishouResult<KuaishouReportHourlyCampaign> getCampaignHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_REPORT;
         Map<String, String> headers = new HashMap<>();
@@ -299,6 +464,51 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaishouReportHourlyCreativeService hourlyCreativeService;
 
     @Override
+    public void getAdvertiserGroupReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
+        getAdvertiserGroupReportDailyByPage(token, startDate, endDate, 1);
+    }
+
+    private void getAdvertiserGroupReportDailyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告组报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告组报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var dailyGroup = JSONObject.toJavaObject(detailJson, KuaishouReportDailyGroup.class);
+            dailyGroup.setAccountId(token.getAccountId());
+            dailyGroup.setId("" + dailyGroup.getAccountId() + dailyGroup.getGroupId() + dailyGroup.getStatDate());
+            dailyGroupService.saveOrUpdate(dailyGroup);
+        }
+        getAdvertiserGroupReportDailyByPage(token, startDate, endDate, page + 1);
+    }
+
+    @Override
     public KuaishouResult<KuaishouReportDailyGroup> getGroupDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
         Map<String, String> headers = new HashMap<>();
@@ -331,6 +541,51 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getAdvertiserGroupReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
+        getGroupHourlyReportByPage(token, startDate, endDate, 1);
+    }
+
+    private void getGroupHourlyReportByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "HOURLY");
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告组时报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告组时报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var hourlyGroup = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyGroup.class);
+            hourlyGroup.setAccountId(token.getAccountId());
+            hourlyGroup.setId("" + hourlyGroup.getAccountId() + hourlyGroup.getGroupId() + hourlyGroup.getStatDate() + hourlyGroup.getStatHour());
+            hourlyGroupService.saveOrUpdate(hourlyGroup);
+        }
+        getGroupHourlyReportByPage(token, startDate, endDate, page + 1);
+    }
+
+    @Override
     public KuaishouResult<KuaishouReportHourlyGroup> getGroupHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
         Map<String, String> headers = new HashMap<>();
@@ -363,6 +618,52 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
+        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, 1);
+    }
+
+    private void getAdvertiserCreativeReportDailyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", 500);
+        param.put("page", page);
+
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告创意报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告创意报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var creative = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCreative.class);
+            creative.setAccountId(token.getAccountId());
+            creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
+            dailyCreativeService.saveOrUpdate(creative);
+        }
+        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, page + 1);
+    }
+
+    @Override
     public KuaishouResult<KuaishouReportDailyCreative> getCreativeDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
         Map<String, String> headers = new HashMap<String, String>();
@@ -395,6 +696,51 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getAdvertiserCreativeReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
+        getAdvertiserCreativeReportHourlyByPage(token, startDate, endDate, 1);
+    }
+
+    private void getAdvertiserCreativeReportHourlyByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", DateUtils.formatDate(startDate));
+        param.put("end_date", DateUtils.formatDate(endDate));
+        param.put("advertiser_id", token.getAccountId());
+        param.put("temporal_granularity", "HOURLY");
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广告创意时报表异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手广告创意时报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            var show = detailJson.getLong("show");
+            detailJson.put("photo_show", show);
+            var like = detailJson.getLong("like");
+            detailJson.put("photo_like", like);
+            var creative = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyCreative.class);
+            creative.setAccountId(token.getAccountId());
+            creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate() + creative.getStatHour());
+            hourlyCreativeService.saveOrUpdate(creative);
+        }
+        getAdvertiserCreativeReportHourlyByPage(token, startDate, endDate, page + 1);
+    }
+
+    @Override
     public KuaishouResult<KuaishouReportHourlyCreative> getCreativeHourlyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
         Map<String, String> headers = new HashMap<String, String>();
@@ -430,10 +776,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     /**
      * 创建广告计划
      *
-     * @param accessToken
-     * @param advertiserId
-     * @param requestJson
-     * @return
+     * @param accessToken token信息
+     * @param advertiserId  广告主id
+     * @param requestJson 请求参数拼装
      */
     @Override
     public Map<String, Object> campaignCreate(String accessToken, Long advertiserId, JSONObject requestJson) {

+ 3 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCampaign.java

@@ -21,8 +21,8 @@ public class KuaishouReportDailyCampaign implements Serializable {
     private String statDate;
     @JsonProperty
     private BigDecimal charge;
-    @TableField("photo_show")
-    private Long show;
+    @JsonProperty
+    private Long photoShow;
     @JsonProperty("photo_click")
     @TableField("photo_click")
     private Long photoClick;
@@ -35,8 +35,7 @@ public class KuaishouReportDailyCampaign implements Serializable {
     @JsonProperty
     private Long comment;
     @JsonProperty
-    @TableField("`like`")
-    private Long like;
+    private Long photoLike;
     @JsonProperty
     private Long follow;
     @JsonProperty("cancel_follow")

+ 3 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java

@@ -24,8 +24,8 @@ public class KuaishouReportDailyCreative implements Serializable {
     private String statDate;
     @JsonProperty
     private BigDecimal charge;
-    @TableField("photo_show")
-    private Long show;
+    @JsonProperty
+    private Long photoShow;
     @JsonProperty("photo_click")
     @TableField("photo_click")
     private Long photoClick;
@@ -38,8 +38,7 @@ public class KuaishouReportDailyCreative implements Serializable {
     @JsonProperty
     private Long comment;
     @JsonProperty
-    @TableField("`like`")
-    private Long like;
+    private Long photoLike;
     @JsonProperty
     private Long follow;
     @JsonProperty("cancel_follow")

+ 3 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java

@@ -25,8 +25,8 @@ public class KuaishouReportDailyGroup implements Serializable {
 
     @JsonProperty
     private BigDecimal charge;
-    @TableField("photo_show")
-    private Long show;
+    @JsonProperty
+    private Long photoShow;
     @JsonProperty("photo_click")
     @TableField("photo_click")
     private Long photoClick;
@@ -39,8 +39,7 @@ public class KuaishouReportDailyGroup implements Serializable {
     @JsonProperty
     private Long comment;
     @JsonProperty
-    @TableField("`like`")
-    private Long like;
+    private Long photoLike;
     @JsonProperty
     private Long follow;
     @JsonProperty("cancel_follow")

+ 3 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCampaign.java

@@ -29,8 +29,8 @@ public class KuaishouReportHourlyCampaign implements Serializable {
 
     @JsonProperty
     private BigDecimal charge;
-    @TableField("photo_show")
-    private Long show;
+    @JsonProperty
+    private Long photoShow;
     @JsonProperty("photo_click")
     @TableField("photo_click")
     private Long photoClick;
@@ -43,8 +43,7 @@ public class KuaishouReportHourlyCampaign implements Serializable {
     @JsonProperty
     private Long comment;
     @JsonProperty
-    @TableField("`like`")
-    private Long like;
+    private Long photoLike;
     @JsonProperty
     private Long follow;
     @JsonProperty("cancel_follow")

+ 3 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCreative.java

@@ -24,8 +24,8 @@ public class KuaishouReportHourlyCreative implements Serializable {
     private Integer statHour;
     @JsonProperty
     private BigDecimal charge;
-    @TableField("photo_show")
-    private Long show;
+    @JsonProperty
+    private Long photoShow;
     @JsonProperty("photo_click")
     @TableField("photo_click")
     private Long photoClick;
@@ -38,8 +38,7 @@ public class KuaishouReportHourlyCreative implements Serializable {
     @JsonProperty
     private Long comment;
     @JsonProperty
-    @TableField("`like`")
-    private Long like;
+    private Long photoLike;
     @JsonProperty
     private Long follow;
     @JsonProperty("cancel_follow")

+ 3 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java

@@ -24,8 +24,8 @@ public class KuaishouReportHourlyGroup implements Serializable {
     private Integer statHour;
     @JsonProperty
     private BigDecimal charge;
-    @TableField("photo_show")
-    private Long show;
+    @JsonProperty
+    private Long photoShow;
     @JsonProperty("photo_click")
     @TableField("photo_click")
     private Long photoClick;
@@ -38,8 +38,7 @@ public class KuaishouReportHourlyGroup implements Serializable {
     @JsonProperty
     private Long comment;
     @JsonProperty
-    @TableField("`like`")
-    private Long like;
+    private Long photoLike;
     @JsonProperty
     private Long follow;
     @JsonProperty("cancel_follow")

+ 5 - 3
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceAdvertiserDailyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -31,9 +30,9 @@ public class BytedanceAdvertiserDailyReport {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId()
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -596,6 +595,9 @@ public class BytedanceAdvertiserDailyReport {
         if (null != register) {
             this.register = register;
         }
+        this.createTime = new Date();
+        this.updateTime = new Date();
+        this.id = "" + this.advertiserId + this.statDatetime.substring(0, 10);
     }
 
     public BytedanceAdvertiserDailyReport() {

+ 5 - 3
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceAdvertiserHourlyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -31,9 +30,9 @@ public class BytedanceAdvertiserHourlyReport {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -600,6 +599,9 @@ public class BytedanceAdvertiserHourlyReport {
         if (null != register) {
             this.register = register;
         }
+        this.id = "" + advertiserId + this.statDatetime.substring(0, 13).replace(" ", "");
+        this.createTime = new Date();
+        this.updateTime = new Date();
     }
 
     public BytedanceAdvertiserHourlyReport() {

+ 9 - 4
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCampaignDailyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -31,9 +30,9 @@ public class BytedanceCampaignDailyReport {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId()
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -387,7 +386,7 @@ public class BytedanceCampaignDailyReport {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
-    public BytedanceCampaignDailyReport(JSONObject data) {
+    public BytedanceCampaignDailyReport(JSONObject data, Long setAdvertiserId) {
         Long playFeedBreak75 = data.getLong("play_75_feed_break");
         if (null != playFeedBreak75) {
             this.play75FeedBreak = playFeedBreak75;
@@ -511,7 +510,10 @@ public class BytedanceCampaignDailyReport {
         Long advertiserId = data.getLong("advertiser_id");
         if (null != advertiserId) {
             this.advertiserId = advertiserId;
+        } else {
+            this.advertiserId = setAdvertiserId;
         }
+
         Long button = data.getLong("button");
         if (null != button) {
             this.button = button;
@@ -620,6 +622,9 @@ public class BytedanceCampaignDailyReport {
         if (null != campaignName) {
             this.campaignName = campaignName;
         }
+        this.id = "" + this.campaignId + this.statDatetime.substring(0, 10);
+        this.createTime = new Date();
+        this.updateTime = new Date();
     }
 
     public BytedanceCampaignDailyReport() {

+ 8 - 4
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCampaignHourlyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -31,9 +30,9 @@ public class BytedanceCampaignHourlyReport {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -387,7 +386,7 @@ public class BytedanceCampaignHourlyReport {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
-    public BytedanceCampaignHourlyReport(JSONObject data) {
+    public BytedanceCampaignHourlyReport(JSONObject data, Long setAdvertiserId) {
         Long playFeedBreak75 = data.getLong("play_75_feed_break");
         if (null != playFeedBreak75) {
             this.play75FeedBreak = playFeedBreak75;
@@ -511,6 +510,8 @@ public class BytedanceCampaignHourlyReport {
         Long advertiserId = data.getLong("advertiser_id");
         if (null != advertiserId) {
             this.advertiserId = advertiserId;
+        } else {
+            this.advertiserId = setAdvertiserId;
         }
         Long button = data.getLong("button");
         if (null != button) {
@@ -620,6 +621,9 @@ public class BytedanceCampaignHourlyReport {
         if (null != campaignName) {
             this.campaignName = campaignName;
         }
+        this.id = "" + this.campaignId + this.statDatetime.substring(0, 13).replace(" ", "");
+        this.createTime = new Date();
+        this.updateTime = new Date();
     }
 
     public BytedanceCampaignHourlyReport() {

+ 9 - 4
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCreativeDailyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -30,9 +29,9 @@ public class BytedanceCreativeDailyReport {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -401,7 +400,7 @@ public class BytedanceCreativeDailyReport {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
-    public BytedanceCreativeDailyReport(JSONObject data) {
+    public BytedanceCreativeDailyReport(JSONObject data, Long setAdvertiserId) {
         Long playFeedBreak75 = data.getLong("play_75_feed_break");
         if (null != playFeedBreak75) {
             this.play75FeedBreak = playFeedBreak75;
@@ -525,6 +524,8 @@ public class BytedanceCreativeDailyReport {
         Long advertiserId = data.getLong("advertiser_id");
         if (null != advertiserId) {
             this.advertiserId = advertiserId;
+        } else {
+            this.advertiserId = setAdvertiserId;
         }
         Long button = data.getLong("button");
         if (null != button) {
@@ -646,6 +647,10 @@ public class BytedanceCreativeDailyReport {
         if (null != creativeId) {
             this.creativeId = creativeId;
         }
+
+        this.id = "" + this.creativeId + this.statDatetime.substring(0, 10);
+        this.createTime = new Date();
+        this.updateTime = new Date();
     }
 
     public BytedanceCreativeDailyReport() {

+ 9 - 11
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCreativeHourlyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -30,9 +29,9 @@ public class BytedanceCreativeHourlyReport {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -381,9 +380,6 @@ public class BytedanceCreativeHourlyReport {
     @Excel(name = "campaignId", width = 15)
     @ApiModelProperty(value = "campaignId")
     private Long campaignId;
-    @Excel(name = "广告组名称", width = 15)
-    @ApiModelProperty(value = "广告组名称")
-    private String campaignName;
     @Excel(name = "创意id", width = 15)
     @ApiModelProperty(value = "创意id")
     private Long creativeId;
@@ -398,7 +394,7 @@ public class BytedanceCreativeHourlyReport {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
-    public BytedanceCreativeHourlyReport(JSONObject data) {
+    public BytedanceCreativeHourlyReport(JSONObject data, Long setAdvertiserId) {
         Long playFeedBreak75 = data.getLong("play_75_feed_break");
         if (null != playFeedBreak75) {
             this.play75FeedBreak = playFeedBreak75;
@@ -522,6 +518,8 @@ public class BytedanceCreativeHourlyReport {
         Long advertiser_id = data.getLong("advertiser_id");
         if (null != advertiser_id) {
             this.advertiserId = advertiser_id;
+        } else {
+            this.advertiserId = setAdvertiserId;
         }
         Long button = data.getLong("button");
         if (null != button) {
@@ -627,10 +625,6 @@ public class BytedanceCreativeHourlyReport {
         if (null != campaignId) {
             this.campaignId = campaignId;
         }
-        String campaignName = data.getString("campaign_name");
-        if (null != campaignName) {
-            this.campaignName = campaignName;
-        }
         String adName = data.getString("ad_name");
         if (null != adName) {
             this.adName = adName;
@@ -643,6 +637,10 @@ public class BytedanceCreativeHourlyReport {
         if (null != creative_id) {
             this.creativeId = creative_id;
         }
+        this.id = "" + this.creativeId + this.statDatetime.substring(0, 13).replace(" ", "");
+        this.createTime = new Date();
+        this.updateTime = new Date();
+
     }
 
     public BytedanceCreativeHourlyReport() {

+ 10 - 4
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedancePlanDailyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -30,9 +29,9 @@ public class BytedancePlanDailyReport {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -392,7 +391,7 @@ public class BytedancePlanDailyReport {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
-    public BytedancePlanDailyReport(JSONObject data) {
+    public BytedancePlanDailyReport(JSONObject data, Long setAdvertiserId) {
         Long playFeedBreak75 = data.getLong("play_75_feed_break");
         if (null != playFeedBreak75) {
             this.play75FeedBreak = playFeedBreak75;
@@ -516,6 +515,8 @@ public class BytedancePlanDailyReport {
         Long advertiser_id = data.getLong("advertiser_id");
         if (null != advertiser_id) {
             this.advertiserId = advertiser_id;
+        } else {
+            this.advertiserId = setAdvertiserId;
         }
         Long button = data.getLong("button");
         if (null != button) {
@@ -629,6 +630,11 @@ public class BytedancePlanDailyReport {
         if (null != adId) {
             this.adId = adId;
         }
+
+        this.id = "" + this.adId + this.statDatetime.substring(0, 10);
+        System.out.println(this.id);
+        this.createTime = new Date();
+        this.updateTime = new Date();
     }
 
     public BytedancePlanDailyReport() {

+ 8 - 4
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedancePlanHourlyReport.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.bytedance.entity;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -30,9 +29,9 @@ public class BytedancePlanHourlyReport {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 广告主id
      */
@@ -392,7 +391,7 @@ public class BytedancePlanHourlyReport {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
-    public BytedancePlanHourlyReport(JSONObject data) {
+    public BytedancePlanHourlyReport(JSONObject data, Long setAdvertiserId) {
         Long playFeedBreak75 = data.getLong("play_75_feed_break");
         if (null != playFeedBreak75) {
             this.play75FeedBreak = playFeedBreak75;
@@ -516,6 +515,8 @@ public class BytedancePlanHourlyReport {
         Long advertiser_id = data.getLong("advertiser_id");
         if (null != advertiser_id) {
             this.advertiserId = advertiser_id;
+        } else {
+            this.advertiserId = setAdvertiserId;
         }
         Long button = data.getLong("button");
         if (null != button) {
@@ -629,6 +630,9 @@ public class BytedancePlanHourlyReport {
         if (null != adId) {
             this.adId = adId;
         }
+        this.id = "" + this.adId + this.statDatetime.substring(0, 13).replace(" ", "");
+        this.createTime = new Date();
+        this.updateTime = new Date();
     }
 
     public BytedancePlanHourlyReport() {

+ 10 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IReportService.java

@@ -1,8 +1,10 @@
 package cn.com.ctop.bytedance.service;
 
 import cn.com.ctop.bytedance.vo.ByteDanceAdvertiserReportDTO;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import com.alibaba.fastjson.JSONObject;
 
+import java.util.Date;
 import java.util.Map;
 
 public interface IReportService {
@@ -21,4 +23,12 @@ public interface IReportService {
     void insertPlatformInfo(String excelPath, String charset, Long accountId);
 
     Map<String, Object> debitAuto(JSONObject data);
+
+    void getAdvertiserReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl);
+
+    void getAdvertiserCampaignReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
+
+    void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
+
+    void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 }

+ 190 - 13
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java

@@ -16,12 +16,14 @@ import com.alibaba.fastjson.PropertyNamingStrategy;
 import com.alibaba.fastjson.serializer.SerializeConfig;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import lombok.var;
 import org.apache.poi.hssf.usermodel.HSSFDataFormat;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -73,15 +75,45 @@ public class ReportServiceImpl implements IReportService {
     @Autowired
     private IBytedanceCreativeHourlyReportService creativeHourlyReportService;
 
+    @Override
+    public void getAdvertiserReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
+        var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
+        getAdvertiserReportByPage(token, conditions, 1);
+    }
+
+    private void getAdvertiserReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, Integer page) {
+        conditions.setPage(page);
+        SerializeConfig config = new SerializeConfig();
+        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
+        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
+        JSONObject getObject = getAdvertiserStat(token, jsonObject);
+        Integer code = getObject.getInteger("code");
+        String message = getObject.getString("message");
+        if (null == code || code != 0) {
+            log.error("广告主数据获取异常:{}", message);
+            return;
+        }
+        JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
+        if (null == dataArray || dataArray.size() <= 0) {
+            log.info("广告主报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+
+        for (var i = 0; i < dataArray.size(); i++) {
+            var data = dataArray.getJSONObject(i);
+            if (null != conditions.getTimeGranularity() && conditions.getTimeGranularity().equals(CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY)) {
+                var hourlyReport = new BytedanceAdvertiserHourlyReport(data);
+                advertiserHourlyReportService.saveOrUpdate(hourlyReport);
+            } else {
+                var dailyReport = new BytedanceAdvertiserDailyReport(data);
+                advertiserDailyReportService.saveOrUpdate(dailyReport);
+            }
+        }
+        getAdvertiserReportByPage(token, conditions, page + 1);
+    }
 
     @Override
     public Map<String, Object> getAdvertiserReport(ByteDanceAdvertiserReportDTO conditions) {
-        conditions.setAdvertiserId(111463131228L);
-        conditions.setStartDate("2019-06-01");
-        conditions.setEndDate("2019-06-10");
-        conditions.setPageSize(1000);
-        conditions.setPage(1);
-        conditions.setTimeGranularity(CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         SerializeConfig config = new SerializeConfig();
         config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
         JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
@@ -105,12 +137,50 @@ public class ReportServiceImpl implements IReportService {
                         advertiserDailyReportService.saveOrUpdate(dailyReport);
                     }
                 }
+
             }
         }
         return getObject;
     }
 
     @Override
+    public void getAdvertiserCampaignReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL) {
+        var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePL);
+        getCampaignReportByPage(token, conditions, 1);
+    }
+
+    private void getCampaignReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
+        conditions.setPage(page);
+        SerializeConfig config = new SerializeConfig();
+        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
+        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
+        JSONObject getObject = getCampaignStat(token, jsonObject);
+        Integer code = getObject.getInteger("code");
+        String message = getObject.getString("message");
+        if (null == code || code != 0) {
+            log.error("广告组报表数据获取异常:{}", message);
+            return;
+        }
+        System.out.println(getObject.toJSONString());
+        JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
+        if (null == dataArray || dataArray.size() <= 0) {
+            log.info("广告组报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (var i = 0; i < dataArray.size(); i++) {
+            var data = dataArray.getJSONObject(i);
+            if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
+                var hourlyReport = new BytedanceCampaignHourlyReport(data, token.getAccountId());
+                campaignHourlyReportService.saveOrUpdate(hourlyReport);
+            } else {
+                var dailyReport = new BytedanceCampaignDailyReport(data, token.getAccountId());
+                campaignDailyReportService.saveOrUpdate(dailyReport);
+            }
+        }
+        getCampaignReportByPage(token, conditions, page + 1);
+    }
+
+    @Override
     public Map<String, Object> getCampaignReport(ByteDanceAdvertiserReportDTO conditions) {
         conditions.setAdvertiserId(111463131228L);
         conditions.setStartDate("2019-06-01");
@@ -134,10 +204,10 @@ public class ReportServiceImpl implements IReportService {
                 for (int i = 0; i < dataArray.size(); i++) {
                     JSONObject data = dataArray.getJSONObject(i);
                     if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
-                        BytedanceCampaignHourlyReport hourlyReport = new BytedanceCampaignHourlyReport(data);
+                        BytedanceCampaignHourlyReport hourlyReport = new BytedanceCampaignHourlyReport(data, token.getAccountId());
                         campaignHourlyReportService.saveOrUpdate(hourlyReport);
                     } else {
-                        BytedanceCampaignDailyReport dailyReport = new BytedanceCampaignDailyReport(data);
+                        BytedanceCampaignDailyReport dailyReport = new BytedanceCampaignDailyReport(data, token.getAccountId());
                         campaignDailyReportService.saveOrUpdate(dailyReport);
                     }
                 }
@@ -147,6 +217,44 @@ public class ReportServiceImpl implements IReportService {
     }
 
     @Override
+    public void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL) {
+        var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePL);
+        getPlanReportByPage(token, conditions, 1);
+    }
+
+    private void getPlanReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
+        conditions.setPage(page);
+        var config = new SerializeConfig();
+        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
+        var jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
+        var getObject = getAdStat(token, jsonObject);
+        var code = getObject.getInteger("code");
+        var message = getObject.getString("message");
+        if (null == code || code != 0) {
+            log.error("广告计划报表数据获取异常:{}", message);
+            return;
+        }
+        System.out.println(getObject.toJSONString());
+        var dataArray = getObject.getJSONObject("data").getJSONArray("list");
+        if (null == dataArray || dataArray.size() <= 0) {
+            log.info("广告计划报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (var i = 0; i < dataArray.size(); i++) {
+            var data = dataArray.getJSONObject(i);
+            if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
+                var hourlyReport = new BytedancePlanHourlyReport(data, token.getAccountId());
+                planHourlyReportService.saveOrUpdate(hourlyReport);
+            } else {
+                var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
+                planDailyReportService.saveOrUpdate(dailyReport);
+            }
+        }
+
+        getPlanReportByPage(token, conditions, page + 1);
+    }
+
+    @Override
     public Map<String, Object> getAdReport(ByteDanceAdvertiserReportDTO conditions) {
         conditions.setAdvertiserId(111463131228L);
         conditions.setStartDate("2019-06-01");
@@ -170,10 +278,10 @@ public class ReportServiceImpl implements IReportService {
                 for (int i = 0; i < dataArray.size(); i++) {
                     JSONObject data = dataArray.getJSONObject(i);
                     if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
-                        BytedancePlanHourlyReport hourlyReport = new BytedancePlanHourlyReport(data);
+                        BytedancePlanHourlyReport hourlyReport = new BytedancePlanHourlyReport(data, token.getAccountId());
                         planHourlyReportService.saveOrUpdate(hourlyReport);
                     } else {
-                        BytedancePlanDailyReport dailyReport = new BytedancePlanDailyReport(data);
+                        BytedancePlanDailyReport dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
                         planDailyReportService.saveOrUpdate(dailyReport);
                     }
                 }
@@ -183,6 +291,52 @@ public class ReportServiceImpl implements IReportService {
     }
 
     @Override
+    public void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL) {
+        var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePL);
+        getCreativeReportByPage(token, conditions, 1);
+    }
+
+    private ByteDanceAdvertiserReportDTO getReportDTO(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL) {
+        var conditions = new ByteDanceAdvertiserReportDTO();
+        conditions.setAdvertiserId(token.getAccountId());
+        conditions.setStartDate(DateUtils.formatDate(startDate));
+        conditions.setEndDate(DateUtils.formatDate(endDate));
+        conditions.setPageSize(1000);
+        conditions.setTimeGranularity(bytedanceReportTypePL);
+        return conditions;
+    }
+
+    private void getCreativeReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
+        conditions.setPage(page);
+        var config = new SerializeConfig();
+        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
+        var jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
+        var getObject = getCreativeStat(token, jsonObject);
+        var code = getObject.getInteger("code");
+        var message = getObject.getString("message");
+        if (null == code || code != 0) {
+            log.error("广告创意报表数据获取异常:{}", message);
+            return;
+        }
+        JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
+        if (null == dataArray || dataArray.size() <= 0) {
+            log.info("广告创意报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (var i = 0; i < dataArray.size(); i++) {
+            var data = dataArray.getJSONObject(i);
+            if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
+                var hourlyReport = new BytedanceCreativeHourlyReport(data, token.getAccountId());
+                creativeHourlyReportService.saveOrUpdate(hourlyReport);
+            } else {
+                var dailyReport = new BytedanceCreativeDailyReport(data, token.getAccountId());
+                creativeDailyReportService.saveOrUpdate(dailyReport);
+            }
+        }
+        getCreativeReportByPage(token, conditions, page + 1);
+    }
+
+    @Override
     public Map<String, Object> getCreativeReport(ByteDanceAdvertiserReportDTO conditions) {
         conditions.setAdvertiserId(111463131228L);
         conditions.setStartDate("2019-06-01");
@@ -206,10 +360,10 @@ public class ReportServiceImpl implements IReportService {
                 for (int i = 0; i < dataArray.size(); i++) {
                     JSONObject data = dataArray.getJSONObject(i);
                     if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
-                        BytedanceCreativeHourlyReport hourlyReport = new BytedanceCreativeHourlyReport(data);
+                        BytedanceCreativeHourlyReport hourlyReport = new BytedanceCreativeHourlyReport(data, token.getAccountId());
                         creativeHourlyReportService.saveOrUpdate(hourlyReport);
                     } else {
-                        BytedanceCreativeDailyReport dailyReport = new BytedanceCreativeDailyReport(data);
+                        BytedanceCreativeDailyReport dailyReport = new BytedanceCreativeDailyReport(data, token.getAccountId());
                         creativeDailyReportService.saveOrUpdate(dailyReport);
                     }
                 }
@@ -229,6 +383,10 @@ public class ReportServiceImpl implements IReportService {
     private JSONObject getAdStat(CtopOauthToken token, JSONObject conditions) {
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/report/ad/get/";
+        JSONArray groupBy = new JSONArray();
+        groupBy.add("STAT_GROUP_BY_FIELD_ID");
+        groupBy.add("STAT_GROUP_BY_FIELD_STAT_TIME");
+        conditions.put("group_by", groupBy);
         return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, conditions);
     }
 
@@ -672,18 +830,37 @@ public class ReportServiceImpl implements IReportService {
     public JSONObject getCreativeStat(CtopOauthToken token, JSONObject conditions) {
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/report/creative/get/";
+        JSONArray groupBy = new JSONArray();
+        groupBy.add("STAT_GROUP_BY_FIELD_ID");
+        groupBy.add("STAT_GROUP_BY_FIELD_STAT_TIME");
+        conditions.put("group_by", groupBy);
         return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, conditions);
     }
 
-    public static JSONObject getCampaignStat(CtopOauthToken token, JSONObject conditions) {
+    public JSONObject getCampaignStat(CtopOauthToken token, JSONObject conditions) {
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/report/campaign/get/";
+        JSONArray groupBy = new JSONArray();
+        groupBy.add("STAT_GROUP_BY_FIELD_ID");
+        groupBy.add("STAT_GROUP_BY_FIELD_STAT_TIME");
+        conditions.put("group_by", groupBy);
         return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, conditions);
     }
 
+    /**
+     * 获取广告主报表信息
+     *
+     * @param token
+     * @param conditions
+     * @return
+     */
     public JSONObject getAdvertiserStat(CtopOauthToken token, JSONObject conditions) {
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/report/advertiser/get/";
+        JSONArray groupBy = new JSONArray();
+        groupBy.add("STAT_GROUP_BY_FIELD_ID");
+        groupBy.add("STAT_GROUP_BY_FIELD_STAT_TIME");
+        conditions.put("group_by", groupBy);
         return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, conditions);
     }
 }

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/IByteDanceAdvertiserDataService.java

@@ -1,8 +1,8 @@
 package cn.com.ctop.toutiao.service;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.toutiao.entity.ByteDanceUserOrientationTemplate;
 import com.alibaba.fastjson.JSONObject;
-import cn.com.ctop.common.module.entity.CtopOauthToken;
 
 import java.util.Map;
 

+ 1 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -877,6 +877,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         return result;
     }
 
+
     public JSONObject flowPackageGetJSONObject(String accountId) {
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
         // 请求地址