|
@@ -6,6 +6,7 @@ import cn.com.ctop.job.bytedance.data.service.IByteDanceAdvertiserDataService;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IOauthTokenService;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.DateUtils;
|
|
|
+import cn.com.ctop.job.bytedance.utils.RedisUtil;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -13,7 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -34,6 +38,77 @@ public class BytedanceAdvertiseLoadJob {
|
|
|
private IByteDanceAdvertiserDataService advertiserDataService;
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取广告主日报-遗漏数据补充
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @XxlJob("bytedanceAdvertiserDailyReportSupplement")
|
|
|
+ public void bytedanceAdvertiserDailyReportSupplement() throws Exception {
|
|
|
+
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
+
|
|
|
+ //获取广告主信息异常的key
|
|
|
+ Set<String> set = redisUtil.kesy("ADVERTISER*");
|
|
|
+ if (Check.isNull(set)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> list = new ArrayList<>(set);
|
|
|
+
|
|
|
+ for (String key : list) {
|
|
|
+
|
|
|
+ //添加重试
|
|
|
+ List<Object> adAccountList;
|
|
|
+ adAccountList = redisUtil.getList(key,null);
|
|
|
+ //遍历key下的所有信息
|
|
|
+ for (Object accountId : adAccountList) {
|
|
|
+
|
|
|
+ log.info("广告主遗漏数据补充,日期:{},accountId:{}",key,adAccountList.toString());
|
|
|
+ String token = tokenService.getByAccountId(Long.valueOf(String.valueOf(accountId)));
|
|
|
+ if (Check.isNull(token)) {
|
|
|
+ log.error("此账户未获取到相关token,accountId:{}", accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ OauthToken oauthToken = new OauthToken();
|
|
|
+ oauthToken.setAccessToken(token);
|
|
|
+ oauthToken.setAccountId(Long.valueOf(String.valueOf(accountId)));
|
|
|
+
|
|
|
+ advertiserDataService.getAdvertiserReport(oauthToken, key.replaceAll("ADVERTISER",""), key.replaceAll("ADVERTISER",""), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+
|
|
|
+ adAccountList = redisUtil.getList(key,null);
|
|
|
+
|
|
|
+ if (adAccountList.size() == 0){
|
|
|
+ redisUtil.delete(key);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000*2);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 广告主日报
|
|
|
*
|