|
@@ -0,0 +1,60 @@
|
|
|
|
+package org.jeecg.modules.ctop.job;
|
|
|
|
+
|
|
|
|
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+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 java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 头条素材报表按天跑前一天的数据任务
|
|
|
|
+ *
|
|
|
|
+ * @author sunzhen
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+public class BytedanceDailyMaterialReportJob implements Job {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBytedanceReportService bytedanceReportService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
|
+
|
|
|
|
+ Date getDate = DateUtils.addDay(new Date(), -1);
|
|
|
|
+ String date = DateUtils.formatDate(getDate);
|
|
|
|
+
|
|
|
|
+ List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
|
|
|
|
+ if (null == tokens || tokens.size() <= 0) {
|
|
|
|
+ log.info("头条获取素材报表数据任务执行失败:未获取到可用的token");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ final ExecutorService executorService = Executors.newFixedThreadPool(3);
|
|
|
|
+ tokens.forEach(token -> {
|
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ try {
|
|
|
|
+ //获取头条素材报表数据
|
|
|
|
+ bytedanceReportService.bytedanceMaterialReport(token, date, date);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|