|
|
@@ -3,6 +3,7 @@ package cn.com.ctop.job.bytedance.handler;
|
|
|
|
|
|
import cn.com.ctop.job.bytedance.data.service.IAdminAdvertiserListService;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
|
@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
@@ -28,32 +30,33 @@ public class AdminAdvertiserListJob {
|
|
|
@Autowired
|
|
|
private IAdminAdvertiserListService adminAdvertiserListService;
|
|
|
private static ExecutorService adminService = Executors.newFixedThreadPool(2);
|
|
|
- private static ExecutorService agentExecutorService = Executors.newFixedThreadPool(5);
|
|
|
+ private static ExecutorService agentExecutorService = Executors.newFixedThreadPool(3);
|
|
|
|
|
|
|
|
|
@XxlJob("agentData")
|
|
|
public void agentData() {
|
|
|
- List<JSONObject> adminAdvertiserList = adminAdvertiserListService.getAdminAdvertiserList();
|
|
|
+ List<JSONObject> adminAdvertiserList = adminAdvertiserListService.getNotAgentAdvertiserList();
|
|
|
+
|
|
|
for (JSONObject adminAdvertiserJson : adminAdvertiserList) {
|
|
|
Long adminAdvertiserId = adminAdvertiserJson.getLong("adminAdvertiserId");
|
|
|
String accessToken = adminAdvertiserJson.getString("accessToken");
|
|
|
- List<Long> infos = adminAdvertiserListService.getAgentAdvertiserList(adminAdvertiserId);
|
|
|
- if (Check.isNull(infos)) {
|
|
|
- log.info("没有需要获取代理商信息的账户id,adminAdvertiserId:{}", adminAdvertiserId);
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<List<Long>> advertiserList = Lists.partition(infos, 50);
|
|
|
- for (List<Long> longs : advertiserList) {
|
|
|
- agentExecutorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- if (!Check.isNull(accessToken)) {
|
|
|
- adminAdvertiserListService.getAgentInfo(adminAdvertiserId, accessToken, longs);
|
|
|
-
|
|
|
+ Long advertiserId = adminAdvertiserJson.getLong("advertiserId");
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
+ ids.add(advertiserId);
|
|
|
+ agentExecutorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (!Check.isNull(accessToken)) {
|
|
|
+ try {
|
|
|
+ adminAdvertiserListService.getAgentInfo(adminAdvertiserId, accessToken, ids);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|