|
@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import com.xxl.job.core.log.XxlJobLogger;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -33,16 +35,29 @@ public class BytedanceAdvertiserDailyReportLoadJob {
|
|
|
|
|
|
@XxlJob("bytedanceAdvertiserDailyReport")
|
|
|
public ReturnT<String> execute(String params) throws Exception {
|
|
|
- log.info("头条广告主日报获取任务执行开始");
|
|
|
+ XxlJobLogger.log("头条广告主日报获取任务执行开始");
|
|
|
Date getDate = DateUtils.addDay(new Date(), -1);
|
|
|
//1:查询当日数据
|
|
|
List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
if (null == tokens || tokens.isEmpty()) {
|
|
|
- log.info("定时获取头条数据异常:为获取到可用的token");
|
|
|
+ XxlJobLogger.log("定时获取头条数据异常:为获取到可用的token");
|
|
|
return ReturnT.FAIL;
|
|
|
}
|
|
|
executorService = Executors.newFixedThreadPool(5);
|
|
|
- tokens.forEach(token -> executorService.submit(() -> reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY)));
|
|
|
+ CountDownLatch countDownLatch = new CountDownLatch(tokens.size());
|
|
|
+ tokens.forEach(token -> {
|
|
|
+ executorService.submit(() -> {
|
|
|
+ try {
|
|
|
+ reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ } catch (Exception e) {
|
|
|
+ XxlJobLogger.log(e);
|
|
|
+ } finally {
|
|
|
+ countDownLatch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ countDownLatch.await();
|
|
|
+ XxlJobLogger.log("头条广告主日报获取任务执行开始");
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|