|
@@ -0,0 +1,54 @@
|
|
|
+package cn.com.ctop.job.bytedance.handler;
|
|
|
+
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
|
|
|
+import com.xxl.job.core.biz.model.ReturnT;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import com.xxl.job.core.log.XxlJobLogger;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 头条广告物料数据获取任务
|
|
|
+ *
|
|
|
+ * @author 宋英豪
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class BytedanceTodayPlaneLoadJob {
|
|
|
+ @Autowired
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
+ static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceAdvertiserDataService advertiserDataService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceCampaignService campaignService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceCreativeService creativeService;
|
|
|
+
|
|
|
+ @XxlJob("bytedanceTodayPlaneLoadJob")
|
|
|
+ public ReturnT<String> execute(String params) throws Exception {
|
|
|
+ Date getDate = new Date();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String dateString = dateFormat.format(getDate);
|
|
|
+ //1:查询当日数据
|
|
|
+ List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
|
|
|
+ tokens.forEach(token -> executorService.submit(() -> {
|
|
|
+ try {
|
|
|
+ advertiserDataService.getAdvertiserPlan(token, "", null, dateString);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ XxlJobLogger.log("当日计划数据同步完成完成");
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+}
|