|
@@ -2,6 +2,8 @@ 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.service.IRuleDataPlanService;
|
|
|
+import cn.com.ctop.common.module.service.IRuleDataTargetService;
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
@@ -9,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -19,11 +23,22 @@ public class ByteDancePlanRuleDataJob {
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
@Autowired
|
|
|
private IReportService reportService;
|
|
|
+ @Autowired
|
|
|
+ private IRuleDataPlanService ruleDataPlanService;
|
|
|
+ @Autowired
|
|
|
+ private IRuleDataTargetService ruleDataTargetService;
|
|
|
private ExecutorService executorService = Executors.newFixedThreadPool(10);
|
|
|
@XxlJob("bytedancePlanRuleLoadJob")
|
|
|
public void execute() throws Exception {
|
|
|
Date date = new Date();
|
|
|
List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
|
|
|
- tokens.forEach(token -> executorService.submit(()->reportService.getAdvertiserPlanRuleData(token,date,date,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY)));
|
|
|
+ tokens.forEach(token -> executorService.submit(()->{
|
|
|
+ //1:删除历史数据
|
|
|
+ Map<String,Object> params = new HashMap<>();
|
|
|
+ params.put("account_id",token.getAccountId());
|
|
|
+ ruleDataPlanService.removeByMap(params);
|
|
|
+ ruleDataTargetService.removeByMap(params);
|
|
|
+ reportService.getAdvertiserPlanRuleData(token,date,date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ }));
|
|
|
}
|
|
|
}
|