|
@@ -5,12 +5,15 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -30,15 +33,40 @@ public class KuaishouVideoRelateCreativesJob {
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouStrategyService kuaishouStrategyService;
|
|
|
|
|
|
static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
@XxlJob("kuaishouVideoRelateCreativesJob")
|
|
@XxlJob("kuaishouVideoRelateCreativesJob")
|
|
public void execute() throws Exception {
|
|
public void execute() throws Exception {
|
|
List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
- tokens.forEach(token -> executorService.submit(() -> {
|
|
|
|
- videoRelateCreatives(token.getAccountId());
|
|
|
|
- }));
|
|
|
|
|
|
+ if (null == tokens || tokens.isEmpty()) {
|
|
|
|
+ XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");
|
|
|
|
+ XxlJobHelper.handleFail();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //查询有效策略的账户ID
|
|
|
|
+ List<Long> accountIds = kuaishouStrategyService.queryActiveAccount();
|
|
|
|
+ if (Check.isNull(accountIds) || accountIds.size() == 0) {
|
|
|
|
+ XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到有效策略账户信息");
|
|
|
|
+ XxlJobHelper.handleFail();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //筛选出有效账户,获取该账户的组级人群报表数据
|
|
|
|
+ List<CtopOauthToken> activeTokens = new ArrayList<>();
|
|
|
|
+ for (Long accountId : accountIds) {
|
|
|
|
+ for (CtopOauthToken token : tokens) {
|
|
|
|
+ if (token.getAccountId() - accountId == 0) {
|
|
|
|
+ activeTokens.add(token);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(activeTokens) && activeTokens.size() > 0) {
|
|
|
|
+ activeTokens.forEach(token -> executorService.submit(() -> {
|
|
|
|
+ videoRelateCreatives(token.getAccountId());
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|