Browse Source

组级人群报表——只拉取淘特project_id=458

zhaoxian 3 years ago
parent
commit
7f552cb7f9

+ 6 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/OauthTokenMapper.java

@@ -1,9 +1,12 @@
 package cn.com.ctop.job.kuaishou.data.mapper;
 package cn.com.ctop.job.kuaishou.data.mapper;
 
 
 import cn.com.ctop.job.kuaishou.data.entity.OauthToken;
 import cn.com.ctop.job.kuaishou.data.entity.OauthToken;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
+import java.util.List;
+
 /**
 /**
  * token信息
  * token信息
  *
  *
@@ -11,5 +14,7 @@ import org.apache.ibatis.annotations.Param;
  * @version V1.0
  * @version V1.0
  */
  */
 public interface OauthTokenMapper extends BaseMapper<OauthToken> {
 public interface OauthTokenMapper extends BaseMapper<OauthToken> {
-  String getByAccountId(@Param("accountId") Long accountId);
+    String getByAccountId(@Param("accountId") Long accountId);
+
+    List<JSONObject> getByProjectId(@Param("projectId") long projectId);
 }
 }

+ 11 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/xml/OauthTokenMapper.xml

@@ -5,4 +5,15 @@
     <select id="getByAccountId" resultType="java.lang.String">
     <select id="getByAccountId" resultType="java.lang.String">
        SELECT access_token  from  `jeecg-boot`.ctop_oauth_token WHERE account_id = #{accountId}
        SELECT access_token  from  `jeecg-boot`.ctop_oauth_token WHERE account_id = #{accountId}
     </select>
     </select>
+
+
+    <select id="getByProjectId" resultType="com.alibaba.fastjson.JSONObject;">
+        select t1.access_token as 'accessToken',t1.account_id as 'accountId',t1.access_token_expires_in as 'accessTokenExpiresIn'
+        from `jeecg-boot`.ctop_oauth_token t1
+        left join `jeecg-boot`.ctop_user_allocation t2
+                           on t1.account_id = t2.account_id
+        where t2.account_status = 0
+          and t2.project_id = #{projectId}
+        group by account_id
+    </select>
 </mapper>
 </mapper>

+ 5 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IOauthTokenService.java

@@ -1,8 +1,11 @@
 package cn.com.ctop.job.kuaishou.data.service;
 package cn.com.ctop.job.kuaishou.data.service;
 
 
 import cn.com.ctop.job.kuaishou.data.entity.OauthToken;
 import cn.com.ctop.job.kuaishou.data.entity.OauthToken;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
+import java.util.List;
+
 /**
 /**
  * token信息
  * token信息
  *
  *
@@ -12,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IOauthTokenService extends IService<OauthToken> {
 public interface IOauthTokenService extends IService<OauthToken> {
 
 
   String getByAccountId(Long accountId);
   String getByAccountId(Long accountId);
+
+    List<JSONObject> getByProjectId(long projectId);
 }
 }

+ 1 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/KuaishouUnitAudienceAgeReportDailyServiceImpl.java

@@ -103,6 +103,7 @@ public class KuaishouUnitAudienceAgeReportDailyServiceImpl extends ServiceImpl<K
             JSONArray units = new JSONArray();
             JSONArray units = new JSONArray();
             requestJson.put("unit_ids", unitIds);
             requestJson.put("unit_ids", unitIds);
             String result = HttpUtils.httpPostRequest(postUrl + KuaishouConstant.AUDIENCE_REPORT, requestJson, headers);
             String result = HttpUtils.httpPostRequest(postUrl + KuaishouConstant.AUDIENCE_REPORT, requestJson, headers);
+            Thread.sleep(500L);
             JSONObject resultJson = JSONObject.parseObject(result);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 Integer code = resultJson.getInteger("code");

+ 8 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/OauthTokenServiceImpl.java

@@ -3,10 +3,13 @@ package cn.com.ctop.job.kuaishou.data.service.impl;
 import cn.com.ctop.job.kuaishou.data.entity.OauthToken;
 import cn.com.ctop.job.kuaishou.data.entity.OauthToken;
 import cn.com.ctop.job.kuaishou.data.mapper.OauthTokenMapper;
 import cn.com.ctop.job.kuaishou.data.mapper.OauthTokenMapper;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.List;
+
 /**
 /**
  * token信息
  * token信息
  *
  *
@@ -22,4 +25,9 @@ public class OauthTokenServiceImpl extends ServiceImpl<OauthTokenMapper, OauthTo
   public String getByAccountId(Long accountId) {
   public String getByAccountId(Long accountId) {
     return tokenMapper.getByAccountId(accountId);
     return tokenMapper.getByAccountId(accountId);
   }
   }
+
+  @Override
+  public List<JSONObject> getByProjectId(long projectId) {
+    return tokenMapper.getByProjectId(projectId);
+  }
 }
 }

+ 14 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/utils/DateUtils.java

@@ -23,7 +23,6 @@ public class DateUtils {
     return sdf.format(date);
     return sdf.format(date);
   }
   }
 
 
-
   public static String getAnotherDay(String format, String date, Integer num) {
   public static String getAnotherDay(String format, String date, Integer num) {
 
 
     SimpleDateFormat sdf = new SimpleDateFormat(format);
     SimpleDateFormat sdf = new SimpleDateFormat(format);
@@ -65,4 +64,18 @@ public class DateUtils {
     }
     }
     return dateList;
     return dateList;
   }
   }
+
+  public static Date addDay(Date date, int day) {
+    Calendar calendar = Calendar.getInstance();
+    calendar.setTime(date);
+    calendar.add(Calendar.DAY_OF_YEAR, day);
+    return calendar.getTime();
+  }
+
+  public static Date getNowDate() throws ParseException {
+    SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
+    String nowDate = getNowDate("yyyy-MM-dd");
+    return dsdf.parse(nowDate);
+  }
+
 }
 }

+ 243 - 250
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/AdUnitReportJob.java

@@ -1,13 +1,10 @@
 package cn.com.ctop.job.kuaishou.handler;
 package cn.com.ctop.job.kuaishou.handler;
 
 
 import cn.com.ctop.job.kuaishou.data.service.IAdUnitReportService;
 import cn.com.ctop.job.kuaishou.data.service.IAdUnitReportService;
-import cn.com.ctop.job.kuaishou.data.service.IKuaishouMaterialVideoReportDailyService;
-import cn.com.ctop.job.kuaishou.data.service.IKuaishouMaterialVideoReportHourlyService;
 import cn.com.ctop.job.kuaishou.data.service.IKuaishouUnitAudienceAgeReportDailyService;
 import cn.com.ctop.job.kuaishou.data.service.IKuaishouUnitAudienceAgeReportDailyService;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
 import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
 import cn.com.ctop.job.kuaishou.data.utils.Check;
 import cn.com.ctop.job.kuaishou.data.utils.Check;
 import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
 import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.context.XxlJobHelper;
@@ -16,8 +13,8 @@ import lombok.extern.slf4j.Slf4j;
 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.Arrays;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Executors;
@@ -26,281 +23,277 @@ import java.util.concurrent.Executors;
 @Component
 @Component
 public class AdUnitReportJob {
 public class AdUnitReportJob {
 
 
-  @Autowired
-  private IOauthTokenService tokenService;
+    @Autowired
+    private IOauthTokenService tokenService;
 
 
-  @Autowired
-  private IAdUnitReportService adUnitReportService;
-
-  private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
-  private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
-
-
-  /**
-   * 获取广告组信息
-   * 前一天
-   *
-   * @throws Exception
-   */
-  @XxlJob("AdUnitListReportJob")
-  public void AdUnitListReportJob(){
-    String param = XxlJobHelper.getJobParam(); // 执行参数
-    if (Check.isNull(param)) {
-      log.error("入参为空");
-      return;
-    }
-    String token = tokenService.getByAccountId(Long.valueOf(param));
-    if (Check.isNull(token)) {
-      log.error("此账户未获取到相关token,accountId:{}", param);
-      return;
-    }
-
-    // 前一天 时间
-    String endTime = DateUtils.getNowDate("yyyy-MM-dd");
-    String startTime = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
-    dailyExecutorService.submit(
-        new Runnable() {
-          @Override
-          public void run() {
-            try {
-              adUnitReportService.getAdUnitReport(Long.valueOf(param),token, startTime, endTime, 1);
-            }catch (Exception e){
-              log.info(String.valueOf(e));;
-            }
-          }
-        });
-  }
+    @Autowired
+    private IAdUnitReportService adUnitReportService;
 
 
+    private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
 
 
 
 
+    /**
+     * 获取广告组信息
+     * 前一天
+     *
+     * @throws Exception
+     */
+    @XxlJob("AdUnitListReportJob")
+    public void AdUnitListReportJob() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
 
 
-  /**
-   * 快手广告计划信息
-   * 前一天
-   *
-   * @throws Exception
-   */
-  @XxlJob("KuaishouCampaignListJob")
-  public void KuaishouCampaignListJob(){
-    String param = XxlJobHelper.getJobParam(); // 执行参数
-    if (Check.isNull(param)) {
-      log.error("入参为空");
-      return;
-    }
-    String token = tokenService.getByAccountId(Long.valueOf(param));
-    if (Check.isNull(token)) {
-      log.error("此账户未获取到相关token,accountId:{}", param);
-      return;
+        // 前一天 时间
+        String endTime = DateUtils.getNowDate("yyyy-MM-dd");
+        String startTime = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            adUnitReportService.getAdUnitReport(Long.valueOf(param), token, startTime, endTime, 1);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
+                            ;
+                        }
+                    }
+                });
     }
     }
 
 
-    // 前一天 时间
-    String endTime = DateUtils.getNowDate("yyyy-MM-dd");
-    String startTime = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
-    dailyExecutorService.submit(
-            new Runnable() {
-              @Override
-              public void run() {
-                try {
-                  adUnitReportService.getAdPlanReport(Long.valueOf(param),token, startTime, endTime, 1);
-                }catch (Exception e){
-                  log.info(String.valueOf(e));;
-                }
-              }
-            });
-  }
-
-
-
-  /**
-   * 代理商t-1数据获取
-   *
-   * @throws
-   */
-  @XxlJob("kuaiShouAgentReportJob")
-  public void kuaiShouAgentReportJob() throws Exception {
-    adUnitReportService.getAgentReport();
-  }
-
-
-
 
 
+    /**
+     * 快手广告计划信息
+     * 前一天
+     *
+     * @throws Exception
+     */
+    @XxlJob("KuaishouCampaignListJob")
+    public void KuaishouCampaignListJob() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
 
 
-  /**
-   * 快手-账户日报-adScene(按广告场景)
-   * DAILY 天
-   * @throws Exception
-   */
-  @XxlJob("KuaishouAccountAdSceneDailyReportJob")
-  public void KuaishouAccountAdSceneDailyReportJob() throws Exception {
-    String param = XxlJobHelper.getJobParam(); // 执行参数
-    if (Check.isNull(param)) {
-      log.error("入参为空");
-      return;
-    }
-    String token = tokenService.getByAccountId(Long.valueOf(param));
-    if (Check.isNull(token)) {
-      log.error("此账户未获取到相关token,accountId:{}", param);
-      return;
+        // 前一天 时间
+        String endTime = DateUtils.getNowDate("yyyy-MM-dd");
+        String startTime = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            adUnitReportService.getAdPlanReport(Long.valueOf(param), token, startTime, endTime, 1);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
+                            ;
+                        }
+                    }
+                });
     }
     }
 
 
-    String date = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
-    //广告场景
-    List<String> reportDims = Arrays.asList("adScene");
-    dailyExecutorService.submit(
-            new Runnable() {
-              @Override
-              public void run() {
-                adUnitReportService.getKuaishouAccountAdSceneDaily(Long.valueOf(param), token, date, date, 1,"DAILY",reportDims);
-              }
-            });
-  }
 
 
+    /**
+     * 代理商t-1数据获取
+     *
+     * @throws
+     */
+    @XxlJob("kuaiShouAgentReportJob")
+    public void kuaiShouAgentReportJob() throws Exception {
+        adUnitReportService.getAgentReport();
+    }
 
 
 
 
+    /**
+     * 快手-账户日报-adScene(按广告场景)
+     * DAILY 天
+     *
+     * @throws Exception
+     */
+    @XxlJob("KuaishouAccountAdSceneDailyReportJob")
+    public void KuaishouAccountAdSceneDailyReportJob() throws Exception {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
 
 
-  /**
-   * 快手-人群报表
-   * @throws Exception
-   */
-  @XxlJob("KuaishouAudienceReportJob")
-  public void KuaishouAudienceReportJob() throws Exception {
-    String param = XxlJobHelper.getJobParam(); // 执行参数
-    if (Check.isNull(param)) {
-      log.error("入参为空");
-      return;
-    }
-    String token = tokenService.getByAccountId(Long.valueOf(param));
-    if (Check.isNull(token)) {
-      log.error("此账户未获取到相关token,accountId:{}", param);
-      return;
+        String date = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
+        //广告场景
+        List<String> reportDims = Arrays.asList("adScene");
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        adUnitReportService.getKuaishouAccountAdSceneDaily(Long.valueOf(param), token, date, date, 1, "DAILY", reportDims);
+                    }
+                });
     }
     }
 
 
-    String date = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
-    //广告计划 ID 集
-    List<Long> campaignIds = Arrays.asList();
-    //广告组 ID 集
-    List<Long> unitIds = Arrays.asList();
-    //人群报表类型
-    List<String> reportDimsProvince = Arrays.asList("province");
-    List<String> reportDimsCity = Arrays.asList("city");
-    List<String> reportDimsGender = Arrays.asList("gender");
-    List<String> reportAge = Arrays.asList("ageSegment");
-    dailyExecutorService.submit(
-            new Runnable() {
-              @Override
-              public void run() {
-                adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds,reportDimsProvince,1);
-                adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds,reportDimsCity,1);
-                adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds,reportDimsGender,1);
-                adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds,reportAge,1);
-              }
-            });
-  }
-
-
 
 
+    /**
+     * 快手-人群报表
+     *
+     * @throws Exception
+     */
+    @XxlJob("KuaishouAudienceReportJob")
+    public void KuaishouAudienceReportJob() throws Exception {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
 
 
-  /**
-   * 快手-账户流水
-   * 默认是当天
-   * @throws Exception
-   */
-  @XxlJob("kuaishouFundDailyFlowsJob")
-  public void kuaishouFundDailyFlowsJob() throws Exception {
-    String param = XxlJobHelper.getJobParam(); // 执行参数
-    if (Check.isNull(param)) {
-      log.error("入参为空");
-      return;
-    }
-    String token = tokenService.getByAccountId(Long.valueOf(param));
-    if (Check.isNull(token)) {
-      log.error("此账户未获取到相关token,accountId:{}", param);
-      return;
+        String date = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
+        //广告计划 ID 集
+        List<Long> campaignIds = Arrays.asList();
+        //广告组 ID 集
+        List<Long> unitIds = Arrays.asList();
+        //人群报表类型
+        List<String> reportDimsProvince = Arrays.asList("province");
+        List<String> reportDimsCity = Arrays.asList("city");
+        List<String> reportDimsGender = Arrays.asList("gender");
+        List<String> reportAge = Arrays.asList("ageSegment");
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds, reportDimsProvince, 1);
+                        adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds, reportDimsCity, 1);
+                        adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds, reportDimsGender, 1);
+                        adUnitReportService.crowdAnalysisReport(Long.valueOf(param), token, date, campaignIds, unitIds, reportAge, 1);
+                    }
+                });
     }
     }
-    dailyExecutorService.submit(
-            new Runnable() {
-              @Override
-              public void run() {
-                adUnitReportService.getKuaishouDailyFlows(Long.valueOf(param), token,1);
-              }
-            });
-  }
 
 
 
 
+    /**
+     * 快手-账户流水
+     * 默认是当天
+     *
+     * @throws Exception
+     */
+    @XxlJob("kuaishouFundDailyFlowsJob")
+    public void kuaishouFundDailyFlowsJob() throws Exception {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        adUnitReportService.getKuaishouDailyFlows(Long.valueOf(param), token, 1);
+                    }
+                });
+    }
 
 
 
 
-  /**
-   * 快手-账户余额
-   *
-   * @throws Exception
-   */
-  @XxlJob("kuaishouFundGetBalanceJob")
-  public void kuaishouFundGetBalanceJob() throws Exception {
-    String param = XxlJobHelper.getJobParam(); // 执行参数
-    if (Check.isNull(param)) {
-      log.error("入参为空");
-      return;
-    }
-    String token = tokenService.getByAccountId(Long.valueOf(param));
-    if (Check.isNull(token)) {
-      log.error("此账户未获取到相关token,accountId:{}", param);
-      return;
+    /**
+     * 快手-账户余额
+     *
+     * @throws Exception
+     */
+    @XxlJob("kuaishouFundGetBalanceJob")
+    public void kuaishouFundGetBalanceJob() throws Exception {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        adUnitReportService.getKuaishouDailyFundGet(Long.valueOf(param), token);
+                    }
+                });
     }
     }
-    dailyExecutorService.submit(
-            new Runnable() {
-              @Override
-              public void run() {
-                adUnitReportService.getKuaishouDailyFundGet(Long.valueOf(param), token);
-              }
-            });
-  }
-
 
 
-  @Autowired
-  private IKuaishouUnitAudienceAgeReportDailyService unitReportDailyService;
 
 
-  private static ExecutorService unitExecutorService = Executors.newFixedThreadPool(5);
-  /**
-   * 快手-广告组人群报表(年龄,性别,城市,省级)
-   */
-  @XxlJob("KuaishouUnitAudienceReportJob")
-  public void KuaishouUnitAudienceReportJob() throws Exception {
-    String param = XxlJobHelper.getJobParam(); // 执行参数
-    if (Check.isNull(param)) {
-      log.error("入参为空");
-      return;
-    }
-    Long accountId = Long.valueOf(param);
-    String token = tokenService.getByAccountId(accountId);
-    if (Check.isNull(token)) {
-      log.error("此账户未获取到相关token,accountId:{}", param);
-      return;
-    }
-    String date = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
-        //广告计划 ID 集
-        List<JSONObject> campaignArray = unitReportDailyService.selectPlanIdsByAccountIdAndTime(accountId, date);
-        if (Check.isNull(campaignArray)) {
-          log.error("未查询到计划ID");
-          return;
-        }
-        //广告组 ID 集
-        for (JSONObject obj : campaignArray) {
-          Long campaignId = obj.getLong("campaignId");
-          List<Long> unitIds = unitReportDailyService.selectUnitIdsByAccountIdAndTime(accountId, campaignId, date);
-          if (Check.isNull(unitIds)) {
-            continue;
-          }
-          if (unitIds.size() > 59) {
-            List<List<Long>> unitIdArray = Lists.partition(unitIds, 59);
-            for (List<Long> list : unitIdArray) {
-              unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, list);
+    @Autowired
+    private IKuaishouUnitAudienceAgeReportDailyService unitReportDailyService;
+
+    private static ExecutorService unitExecutorService = Executors.newFixedThreadPool(5);
+
+    /**
+     * 快手-广告组人群报表(年龄,性别,城市,省级)
+     */
+    @XxlJob("KuaishouUnitAudienceReportJob")
+    public void KuaishouUnitAudienceReportJob() throws Exception {
+        List<JSONObject> tokens = tokenService.getByProjectId(458L);    //淘特项目
+        String date = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
+        Date enDate = DateUtils.addDay(DateUtils.getNowDate(), -1);
+        for (JSONObject t : tokens) {
+            Long accountId = t.getLong("accountId");
+            String token = t.getString("accessToken");
+            if (Check.isNull(token)) {
+                log.error("此账户未获取到相关token,accountId:{}", accountId);
+                continue;
+            }
+            //过期跳过
+            if (enDate.after(t.getDate("accessTokenExpiresIn"))) {
+                continue;
+            }
+            //广告计划 ID 集
+            List<JSONObject> campaignArray = unitReportDailyService.selectPlanIdsByAccountIdAndTime(accountId, date);
+            if (Check.isNull(campaignArray)) {
+                log.error("未查询到计划ID");
+                return;
+            }
+            //广告组 ID 集
+            for (JSONObject obj : campaignArray) {
+                Long campaignId = obj.getLong("campaignId");
+                List<Long> unitIds = unitReportDailyService.selectUnitIdsByAccountIdAndTime(accountId, campaignId, date);
+                if (Check.isNull(unitIds)) {
+                    continue;
+                }
+                if (unitIds.size() > 59) {
+                    List<List<Long>> unitIdArray = Lists.partition(unitIds, 59);
+                    for (List<Long> list : unitIdArray) {
+                        unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, list);
+                    }
+                } else {
+                    unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, unitIds);
+                }
             }
             }
-          } else {
-            unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, unitIds);
-          }
         }
         }
-  }
-
+    }
 
 
 
 
 }
 }