|
@@ -3,8 +3,10 @@ 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.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
|
|
|
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
|
|
|
import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.quartz.Job;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.quartz.JobExecutionException;
|
|
@@ -25,6 +27,8 @@ public class BytedanceDailyMaterialReportRetryJob implements Job {
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
@Autowired
|
|
|
private IBytedanceReportService bytedanceReportService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
|
|
|
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
@@ -38,9 +42,25 @@ public class BytedanceDailyMaterialReportRetryJob implements Job {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
try {
|
|
|
- CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(retry.getAccountId()));
|
|
|
+ String startDate = retry.getStartDate();
|
|
|
+ String endDate = retry.getEndDate();
|
|
|
+ Long accountId = retry.getAccountId();
|
|
|
+ CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
|
|
|
log.info("头条素材报表重试定时任务,当前accountId为:" + token.getAccountId());
|
|
|
- bytedanceReportService.bytedanceMaterialReportRetry(token, retry.getStartDate(), retry.getEndDate());
|
|
|
+
|
|
|
+ Long days = DateUtils.getDiscrepantDays(startDate, endDate); //间隔天数
|
|
|
+ String start = null;
|
|
|
+ String end = null;
|
|
|
+ for (int i = 0; i <= days; i++) {
|
|
|
+ start = DateUtils.addDay(startDate, i);
|
|
|
+ end = start;
|
|
|
+ //获取头条素材报表数据
|
|
|
+ int code = bytedanceReportService.bytedanceMaterialReportRetry(token, start, end);
|
|
|
+ if(code ==200 || code == 1){
|
|
|
+ //重试成功清洗数据
|
|
|
+ byteDanceVideoReportDailyService.videoInfoListByAccountId(start,end,accountId);
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|