|
@@ -1,47 +0,0 @@
|
|
-package com.xxl.job.executor.jobhandler;
|
|
|
|
-
|
|
|
|
-import com.xxl.job.core.context.XxlJobHelper;
|
|
|
|
-import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
|
-import com.xxl.job.executor.common.entity.CtopOauthToken;
|
|
|
|
-import com.xxl.job.executor.common.service.ICtopOauthTokenService;
|
|
|
|
-import com.xxl.job.executor.report.service.IReportService;
|
|
|
|
-import com.xxl.job.executor.utils.CtopAdConstant;
|
|
|
|
-import com.xxl.job.executor.utils.DateUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
|
-import java.util.concurrent.Executors;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Created by JQ.bi on 2020.09.03
|
|
|
|
- */
|
|
|
|
-public class BytedanceYesterdayAdvertiserHourlyLoadJob {
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ICtopOauthTokenService tokenService;
|
|
|
|
- @Autowired
|
|
|
|
- private IReportService reportService;
|
|
|
|
- private ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
|
-
|
|
|
|
- @XxlJob("byteDanceAdvertiserHourlyReport")
|
|
|
|
- public void execute() throws Exception {
|
|
|
|
- //查询需要拉取数据的账户token
|
|
|
|
- List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
|
|
|
|
- if (null == tokens || tokens.isEmpty()) {
|
|
|
|
- XxlJobHelper.log("获取昨日头条小时数据异常:未获取到可用的token");
|
|
|
|
- }
|
|
|
|
- Date yesterday = DateUtils.parseDate(DateUtils.getAnotherDay("yy-MM-dd", DateUtils.getNowDate("yy-MM-dd"), -1), "yy-MM-dd");
|
|
|
|
- tokens.forEach(it ->executorService.submit(() -> {
|
|
|
|
- try {
|
|
|
|
- reportService.getAdvertiserReport(it, yesterday, yesterday, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- XxlJobHelper.log("获取昨日头条小时数据异常:拉取数据异常");
|
|
|
|
- }
|
|
|
|
- }));
|
|
|
|
- if(!executorService.isShutdown()){
|
|
|
|
- executorService.shutdown();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|