Procházet zdrojové kódy

添加头条视频消耗数据清洗任务

songyh před 4 roky
rodič
revize
478fda317b

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

@@ -225,4 +225,32 @@ public class SampleTest {
     public void etlBytedanceVideoReportInfo()throws Exception{
         etlBytedanceReportVideoDailyService.etlBytedanceVideo();
     }
+
+    @Autowired
+    private IReportService reportService;
+
+    @Test
+    public void loadBytedanceAccountReport(){
+        /**
+         * 1692555408132110
+         * 1692555631713287
+         * 1696734332089352
+         * 1696734333251598
+         */
+        CtopOauthToken token1 = tokenService.getTokenByAccountId(1692555408132110L);
+        reportService.getAdvertiserReport(token1, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        CtopOauthToken token2 = tokenService.getTokenByAccountId(1692555631713287L);
+        reportService.getAdvertiserReport(token2, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        CtopOauthToken token3 = tokenService.getTokenByAccountId(1696734332089352L);
+        reportService.getAdvertiserReport(token3, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        CtopOauthToken token4 = tokenService.getTokenByAccountId(1696734333251598L);
+        reportService.getAdvertiserReport(token4, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+
+        CtopOauthToken token5 = tokenService.getTokenByAccountId(10129666L);
+        kuaishouInterfaceService.getAdvertiserReportDaily(token5, DateUtils.parseDate("2021-05-07","yyyy-MM-dd"), DateUtils.parseDate("2021-05-11","yyyy-MM-dd"), null);
+        CtopOauthToken token6 = tokenService.getTokenByAccountId(10097961L);
+        kuaishouInterfaceService.getAdvertiserReportDaily(token6, DateUtils.parseDate("2021-05-07","yyyy-MM-dd"), DateUtils.parseDate("2021-05-11","yyyy-MM-dd"), null);
+        CtopOauthToken token7 = tokenService.getTokenByAccountId(10098039L);
+        kuaishouInterfaceService.getAdvertiserReportDaily(token7, DateUtils.parseDate("2021-05-07","yyyy-MM-dd"), DateUtils.parseDate("2021-05-11","yyyy-MM-dd"), null);
+    }
 }

+ 10 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java

@@ -2,6 +2,7 @@ package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAccountMaterialReportDailyService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
@@ -17,9 +18,10 @@ public class KuaishouEtlVideoJob {
     @Autowired
     private IKuaiShouVideoGetService videoGetService;
     @Autowired
+    private IEtlKuaishouAccountMaterialReportDailyService materialReportDailyService;
+    @Autowired
     private IEtlKuaishouVideoInfoService videoEtlInfoService;
 
-
     @XxlJob("kuaishouEtlVideoJob")
     public void execute() throws Exception {
         Date startDate = DateUtils.addDay(new Date(), -2);
@@ -51,5 +53,11 @@ public class KuaishouEtlVideoJob {
             videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
         }
     }
-
+    @XxlJob("etlKuaishouAccountMaterialReportInfo")
+    public void etlKuaishouAccountMaterialReportInfo(){
+        Date startDate = new Date();
+        for(int i=1;i<=2;i++){
+            materialReportDailyService.etlKuaishouAccountMaterialReportInfo(DateUtils.formatDate(DateUtils.addDay(new Date(),-i)));
+        }
+    }
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IEtlKuaishouAccountMaterialReportDailyService.java

@@ -12,4 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IEtlKuaishouAccountMaterialReportDailyService extends IService<EtlKuaishouAccountMaterialReportDaily> {
 
     void etlKuaishouAccountMaterialReportDailyData(String date);
+
+    void etlKuaishouAccountMaterialReportInfo(String formatDate);
 }

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouAccountMaterialReportDailyServiceImpl.java

@@ -30,6 +30,7 @@ public class EtlKuaishouAccountMaterialReportDailyServiceImpl extends ServiceImp
     @Autowired
     private ICtopOauthTokenService tokenService;
     static ExecutorService executorService = Executors.newFixedThreadPool(10);
+    static ExecutorService etlExecutorService = Executors.newFixedThreadPool(10);
     @Override
     public void etlKuaishouAccountMaterialReportDailyData(String date){
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
@@ -51,4 +52,26 @@ public class EtlKuaishouAccountMaterialReportDailyServiceImpl extends ServiceImp
         }
         log.info("{}数据获取完成",date);
     }
+
+    @Override
+    public void etlKuaishouAccountMaterialReportInfo(String formatDate) {
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        CountDownLatch countDownLatch = new CountDownLatch(tokens.size());
+        tokens.forEach(token -> etlExecutorService.submit(()->{
+            try {
+                List<EtlKuaishouAccountMaterialReportDaily> getList = etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyList(formatDate,token.getAccountId());
+                etlKuaishouAccountMaterialReportDailyMapper.replaceBatch(getList);
+            }catch (Exception e){
+                e.printStackTrace();
+            }finally {
+                countDownLatch.countDown();
+            }
+        }));
+        try {
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        log.info("{}数据获取完成",formatDate);
+    }
 }