|
@@ -5,11 +5,10 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanDailyReportService;
|
|
import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanDailyReportService;
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
|
+import com.xxl.job.core.log.XxlJobLogger;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.util.DateUtils;
|
|
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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -24,7 +23,7 @@ import java.util.concurrent.Executors;
|
|
* 头条计划时报数据任务
|
|
* 头条计划时报数据任务
|
|
*/
|
|
*/
|
|
@Slf4j
|
|
@Slf4j
|
|
-public class BytedancePlanHourlyReportLoadJob implements Job {
|
|
|
|
|
|
+public class BytedancePlanHourlyReportLoadJob {
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -36,9 +35,9 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
|
|
static CountDownLatch countDownLatch = null;
|
|
static CountDownLatch countDownLatch = null;
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
|
- log.info("头条时报数据获取开始");
|
|
|
|
|
|
+ @XxlJob("bytedancePlanHourlyReport")
|
|
|
|
+ public void execute(String param) {
|
|
|
|
+ XxlJobLogger.log("头条时报数据获取开始");
|
|
Date getDate = new Date();
|
|
Date getDate = new Date();
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
|
|
String hour = simpleDateFormat.format(getDate);
|
|
String hour = simpleDateFormat.format(getDate);
|
|
@@ -46,8 +45,7 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
|
|
List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
executorService = Executors.newFixedThreadPool(5);
|
|
executorService = Executors.newFixedThreadPool(5);
|
|
countDownLatch = new CountDownLatch(tokens.size());
|
|
countDownLatch = new CountDownLatch(tokens.size());
|
|
- tokens.forEach(token -> {
|
|
|
|
- executorService.submit(() -> {
|
|
|
|
|
|
+ tokens.forEach(token -> executorService.submit(() -> {
|
|
try {
|
|
try {
|
|
if (null != hour && "00".equals(hour)) {
|
|
if (null != hour && "00".equals(hour)) {
|
|
Date finalGetDate = DateUtils.addDay(getDate, -1);
|
|
Date finalGetDate = DateUtils.addDay(getDate, -1);
|
|
@@ -55,16 +53,16 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
|
|
}
|
|
}
|
|
reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ XxlJobLogger.log(e.getMessage());
|
|
} finally {
|
|
} finally {
|
|
countDownLatch.countDown();
|
|
countDownLatch.countDown();
|
|
}
|
|
}
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ }));
|
|
|
|
+
|
|
try {
|
|
try {
|
|
countDownLatch.await();
|
|
countDownLatch.await();
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ XxlJobLogger.log(e.getMessage());
|
|
}
|
|
}
|
|
//清洗缘多多数据渠道号
|
|
//清洗缘多多数据渠道号
|
|
if (null != hour && "00".equals(hour)) {
|
|
if (null != hour && "00".equals(hour)) {
|
|
@@ -73,7 +71,7 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
|
|
}
|
|
}
|
|
planDailyReportService.cleanYddHourlyChannelCode(113, getDate);
|
|
planDailyReportService.cleanYddHourlyChannelCode(113, getDate);
|
|
|
|
|
|
- log.info("头条计划时报数据获取完成");
|
|
|
|
|
|
+ XxlJobLogger.log("头条时报数据获取结束");
|
|
executorService.shutdown();
|
|
executorService.shutdown();
|
|
}
|
|
}
|
|
}
|
|
}
|