|
@@ -0,0 +1,40 @@
|
|
|
+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.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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class ByteDancePlanRuleDataJob {
|
|
|
+ @Autowired
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private IReportService reportService;
|
|
|
+ static ExecutorService executorService = Executors.newFixedThreadPool(10);
|
|
|
+
|
|
|
+ @XxlJob("bytedancePlanLoadJob")
|
|
|
+ public ReturnT<String> execute(String param) throws Exception {
|
|
|
+ Date date = new Date();
|
|
|
+ if(null!=param&&!"".equals(param.trim())){
|
|
|
+ Long accountId = Long.parseLong(param);
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
+ reportService.getAdvertiserPlanRuleData(token,date,date,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ }else{
|
|
|
+ List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
|
|
|
+ tokens.forEach(token -> executorService.submit(() -> reportService.getAdvertiserPlanRuleData(token,date,date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY)));
|
|
|
+ }
|
|
|
+ XxlJobLogger.log("头条全量计划数据获取完成");
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+}
|