Bläddra i källkod

定时任务拆分 异步

yumeng 5 år sedan
förälder
incheckning
767241e3ca
15 ändrade filer med 686 tillägg och 375 borttagningar
  1. 8 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountBidJob.java
  2. 18 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAdvertiserCrawlerJob.java
  3. 30 21
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java
  4. 22 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java
  5. 56 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java
  6. 57 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCampaignReportLoadJob.java
  7. 56 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  8. 58 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyGroupReportLoadJob.java
  9. 42 36
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountReportLoadJob.java
  10. 45 35
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCampaignReportLoadJob.java
  11. 46 38
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java
  12. 43 35
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyGroupReportLoadJob.java
  13. 35 28
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java
  14. 8 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/RefreshTokenJob.java
  15. 162 158
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/mock/MockController.java

+ 8 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountBidJob.java

@@ -21,6 +21,13 @@ public class AccountBidJob implements Job {
      */
     @Override
     public void execute(JobExecutionContext jobExecutionContext) {
-        bidWarningService.BidWarning();
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                bidWarningService.BidWarning();
+            }
+        };
+        thread.start();
+
     }
 }

+ 18 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAdvertiserCrawlerJob.java

@@ -15,17 +15,28 @@ public class KuaishouAdvertiserCrawlerJob implements Job {
     private IKuaishouAdAccountService kuaishouAdAccountService;
     @Autowired
     private IKuaishouAppService kuaishouAppService;
+
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        try{
+        try {
 
-            List<KuaishouAdAccount> list = kuaishouAdAccountService.querySyncAccount();
-            if (list != null){
-                for(KuaishouAdAccount account : list){
-                    kuaishouAppService.adAccountFetch(account,"");
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    List<KuaishouAdAccount> list = kuaishouAdAccountService.querySyncAccount();
+                    if (list != null) {
+                        for (KuaishouAdAccount account : list) {
+                            kuaishouAppService.adAccountFetch(account, "");
+                        }
+                    }
                 }
-            }
-        }catch (Exception e){
+
+
+            };
+            thread.start();
+
+
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }

+ 30 - 21
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java

@@ -26,26 +26,35 @@ public class KuaishouCampaignGroupJob implements Job {
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
 
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-
-        executorService = Executors.newFixedThreadPool(5);
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        //1:获取全量广告计划数据
-                        kuaishouInterfaceService.getCampaignList(token, null, null);
-                        //1:获取全量广告组数据
-                        kuaishouInterfaceService.getGroupList(token, null, null);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                    }
-                }
-            });
-        });
-        log.info("快手物料数据同步完成");
+
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                executorService = Executors.newFixedThreadPool(8);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                //1:获取全量广告计划数据
+                                kuaishouInterfaceService.getCampaignList(token, null, null);
+                                //1:获取全量广告组数据
+                                kuaishouInterfaceService.getGroupList(token, null, null);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+
+        };
+        thread.start();
+
+
     }
 }

+ 22 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java

@@ -1,8 +1,8 @@
 package org.jeecg.modules.ctop.job;
 
-import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
@@ -22,21 +22,28 @@ public class KuaishouCommentAutoDelete implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<BindAccountLogin>();
-        queryWrapper.eq("login_type", "kuaishou");
-        queryWrapper.eq("status", 1);
-        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-        if (list != null && list.size() > 0) {
-            for (BindAccountLogin account : list) {
-                try {
-                    log.info("正在删除评论:{}", account.getAccountName());
-                    kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
-                    kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
-                    Thread.sleep(10000);
-                } catch (Exception e) {
-                    e.printStackTrace();
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<BindAccountLogin>();
+                queryWrapper.eq("login_type", "kuaishou");
+                queryWrapper.eq("status", 1);
+                List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+                if (list != null && list.size() > 0) {
+                    for (BindAccountLogin account : list) {
+                        try {
+                            log.info("正在删除评论:{}", account.getAccountName());
+                            kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
+                            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
+                            Thread.sleep(10000);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
                 }
             }
-        }
+        };
+        thread.start();
+
     }
 }

+ 56 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java

@@ -0,0 +1,56 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 快手广告主分天数据
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyAccountReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+                    //1: 获取广告主信息数据
+                    kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

+ 57 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCampaignReportLoadJob.java

@@ -0,0 +1,57 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 广告计划分天报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyCampaignReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+
+                    //获取广告计划信息数据
+                    kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
+
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

+ 56 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java

@@ -0,0 +1,56 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 获取创意分天报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyCreativeReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+
+                    // 获取广告创意信息数据
+                    kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate);
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

+ 58 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyGroupReportLoadJob.java

@@ -0,0 +1,58 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 获取广告组分天报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyGroupReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+
+                    //获取广告组信息数据
+                    kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getDate, getDate);
+
+                });
+            }
+
+        };
+        thread.start();
+
+    }
+}

+ 42 - 36
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountReportLoadJob.java

@@ -36,42 +36,48 @@ public class KuaishouHourlyAccountReportLoadJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Date getDate = new Date();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
-        String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取头条数据异常:为获取到可用的token");
-            return;
-        }
-        executorService = Executors.newFixedThreadPool(5);
-        countDownLatch = new CountDownLatch(tokens.size());
-        Date finalGetDate = getDate;
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        // 获取广告主时报
-                        kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate);
-
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                        countDownLatch.countDown();
-                    }
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
+                }
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
                 }
-            });
-        });
-        try {
-            countDownLatch.await();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        executorService.shutdown();
+                executorService = Executors.newFixedThreadPool(7);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                // 获取广告主时报
+                                kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                executorService.shutdown();
+            }
+        };
+        thread.start();
+
     }
 }

+ 45 - 35
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCampaignReportLoadJob.java

@@ -20,6 +20,7 @@ import java.util.concurrent.Executors;
 
 /**
  * 获取广告计划分时报表
+ *
  * @author syh
  */
 @Slf4j
@@ -35,41 +36,50 @@ public class KuaishouHourlyCampaignReportLoadJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Date getDate = new Date();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
-        String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取头条数据异常:为获取到可用的token");
-            return;
-        }
-        executorService = Executors.newFixedThreadPool(5);
-        countDownLatch = new CountDownLatch(tokens.size());
-        Date finalGetDate = getDate;
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        // 获取 广告计划时报
-                        kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, finalGetDate, finalGetDate);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                        countDownLatch.countDown();
-                    }
+
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
+                }
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                // 获取 广告计划时报
+                                kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
                 }
-            });
-        });
-        try {
-            countDownLatch.await();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        executorService.shutdown();
+                executorService.shutdown();
+            }
+        };
+        thread.start();
+
+
     }
 }

+ 46 - 38
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java

@@ -36,45 +36,53 @@ public class KuaishouHourlyCreativeReportLoadJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Date getDate = new Date();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
-        String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取头条数据异常:为获取到可用的token");
-            return;
-        }
-        executorService = Executors.newFixedThreadPool(5);
-        countDownLatch = new CountDownLatch(tokens.size());
-        Date finalGetDate = getDate;
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
+                }
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
 
-                        //4: 获取广告创意信息数据
-                        kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, finalGetDate, finalGetDate);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                        countDownLatch.countDown();
-                    }
+                                //4: 获取广告创意信息数据
+                                kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                executorService.shutdown();
+                for (CtopOauthToken token : tokens) {
+                    kuaishouInterfaceService.updateCreativeReportHourlyStatistic(token, getDate);
                 }
-            });
-        });
-        try {
-            countDownLatch.await();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        executorService.shutdown();
-        for (CtopOauthToken token : tokens) {
-            kuaishouInterfaceService.updateCreativeReportHourlyStatistic(token, getDate);
-        }
+            }
+
+        };
+        thread.start();
+
     }
 }

+ 43 - 35
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyGroupReportLoadJob.java

@@ -36,41 +36,49 @@ public class KuaishouHourlyGroupReportLoadJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Date getDate = new Date();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
-        String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取头条数据异常:为获取到可用的token");
-            return;
-        }
-        executorService = Executors.newFixedThreadPool(5);
-        countDownLatch = new CountDownLatch(tokens.size());
-        Date finalGetDate = getDate;
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        //3:获取广告组信息数据
-                        kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, finalGetDate, finalGetDate);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                        countDownLatch.countDown();
-                    }
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
                 }
-            });
-        });
-        try {
-            countDownLatch.await();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        executorService.shutdown();
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                //3:获取广告组信息数据
+                                kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+
+                executorService.shutdown();
+            }
+        };
+        thread.start();
+
     }
 }

+ 35 - 28
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java

@@ -27,33 +27,40 @@ public class KuaishouMaterialsLoadJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        //增加接口的开始和结束日期
-        Date startDate = DateUtils.addDay(new Date(),-1);
-        Date endDate = new Date();
-
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-
-        executorService = Executors.newFixedThreadPool(5);
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-
-                        //1:获取全量创意数据
-                        kuaishouInterfaceService.getCreativeList(token,startDate,endDate);
-                        //2:获取全量视频素材数据
-                        kuaishouInterfaceService.getVideoList(token,startDate,endDate);
-                        //3: 获取图片信息数据
-                        kuaishouInterfaceService.getImageList(token,startDate,endDate);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                    }
-                }
-            });
-        });
-        log.info("快手物料数据同步完成");
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                //增加接口的开始和结束日期
+                Date startDate = DateUtils.addDay(new Date(), -1);
+                Date endDate = new Date();
+
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+
+                executorService = Executors.newFixedThreadPool(5);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+
+                                //1:获取全量创意数据
+                                kuaishouInterfaceService.getCreativeList(token, startDate, endDate);
+                                //2:获取全量视频素材数据
+                                kuaishouInterfaceService.getVideoList(token, startDate, endDate);
+                                //3: 获取图片信息数据
+                                kuaishouInterfaceService.getImageList(token, startDate, endDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+        };
+        thread.start();
+
     }
 }

+ 8 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/RefreshTokenJob.java

@@ -18,6 +18,13 @@ public class RefreshTokenJob implements Job {
      */
     @Override
     public void execute(JobExecutionContext jobExecutionContext) {
-        refreshTokenService.getRefresh();
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                refreshTokenService.getRefresh();
+            }
+        };
+        thread.start();
+
     }
 }

+ 162 - 158
jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/mock/MockController.java

@@ -1,205 +1,209 @@
 package org.jeecg.modules.demo.mock;
 
+import cn.com.ctop.common.module.utils.Check;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.swing.filechooser.FileSystemView;
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.swing.filechooser.FileSystemView;
-
-import org.apache.commons.io.IOUtils;
-import org.jeecg.common.api.vo.Result;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import lombok.extern.slf4j.Slf4j;
-
 @RestController
 @RequestMapping("/api")
 @Slf4j
 public class MockController {
 
-	private final String JSON_PATH = "classpath:org/jeecg/modules/demo/mock/json";
+    private final String JSON_PATH = "classpath:org/jeecg/modules/demo/mock/json";
 
-	/**
-	 * 通用json访问接口
-	 * 格式: http://localhost:8080/jeecg-boot/api/json/{filename}
-	 * @param filename
-	 * @return
-	 */
-	@RequestMapping(value = "/json/{filename}", method = RequestMethod.GET)
-	public String getJsonData(@PathVariable String filename) {
-		String jsonpath = "classpath:org/jeecg/modules/demo/mock/json/"+filename+".json";
-		return readJson(jsonpath);
-	}
+    /**
+     * 通用json访问接口
+     * 格式: http://localhost:8080/jeecg-boot/api/json/{filename}
+     *
+     * @param filename
+     * @return
+     */
+    @RequestMapping(value = "/json/{filename}", method = RequestMethod.GET)
+    public String getJsonData(@PathVariable String filename) {
+        String jsonpath = "classpath:org/jeecg/modules/demo/mock/json/" + filename + ".json";
+        return readJson(jsonpath);
+    }
 
     @GetMapping(value = "/asynTreeList")
-	public String asynTreeList(String id) {
-		return readJson(JSON_PATH + "/asyn_tree_list_" + id + ".json");
-	}
+    public String asynTreeList(String id) {
+        return readJson(JSON_PATH + "/asyn_tree_list_" + id + ".json");
+    }
 
     @GetMapping(value = "/user")
-	public String user() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/user.json");
-	}
+    public String user() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/user.json");
+    }
 
     /**
-	 * 老的登录获取用户信息接口
-	 * @return
-	 */
-	@GetMapping(value = "/user/info")
-	public String userInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/user_info.json");
-	}
-
-	@GetMapping(value = "/role")
-	public String role() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/role.json");
-	}
-
-	@GetMapping(value = "/service")
-	public String service() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/service.json");
-	}
-
-	@GetMapping(value = "/permission")
-	public String permission() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/permission.json");
-	}
-
-	@GetMapping(value = "/permission/no-pager")
+     * 老的登录获取用户信息接口
+     *
+     * @return
+     */
+    @GetMapping(value = "/user/info")
+    public String userInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/user_info.json");
+    }
+
+    @GetMapping(value = "/role")
+    public String role() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/role.json");
+    }
+
+    @GetMapping(value = "/service")
+    public String service() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/service.json");
+    }
+
+    @GetMapping(value = "/permission")
+    public String permission() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/permission.json");
+    }
+
+    @GetMapping(value = "/permission/no-pager")
     public String permissionNoPage() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/permission_no_page.json");
-	}
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/permission_no_page.json");
+    }
 
     /**
-	 * 省市县
-	 */
-	@GetMapping(value = "/area")
-	public String area() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/area.json");
-	}
+     * 省市县
+     */
+    @GetMapping(value = "/area")
+    public String area() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/area.json");
+    }
 
     /**
-	  * 测试报表数据
-	 */
-	@GetMapping(value = "/report/getYearCountInfo")
-	public String getYearCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
-	@GetMapping(value = "/report/getMonthCountInfo")
-	public String getMonthCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
-	@GetMapping(value = "/report/getCntrNoCountInfo")
-	public String getCntrNoCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
-	@GetMapping(value = "/report/getCabinetCountInfo")
-	public String getCabinetCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
+     * 测试报表数据
+     */
+    @GetMapping(value = "/report/getYearCountInfo")
+    public String getYearCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
+
+    @GetMapping(value = "/report/getMonthCountInfo")
+    public String getMonthCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
+
+    @GetMapping(value = "/report/getCntrNoCountInfo")
+    public String getCntrNoCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
+
+    @GetMapping(value = "/report/getCabinetCountInfo")
+    public String getCabinetCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
 
     /**
-	   * 实时磁盘监控
-	 * @param request
-	 * @param response
-	 * @return
-	 */
-	@GetMapping("/queryDiskInfo")
-	public Result<List<Map<String,Object>>> queryDiskInfo(HttpServletRequest request, HttpServletResponse response){
-		Result<List<Map<String,Object>>> res = new Result<>();
-		try {
-			// 当前文件系统类
-	        FileSystemView fsv = FileSystemView.getFileSystemView();
-	        // 列出所有windows 磁盘
-	        File[] fs = File.listRoots();
-	        log.info("查询磁盘信息:"+fs.length+"个");
-	        List<Map<String,Object>> list = new ArrayList<>();
+     * 实时磁盘监控
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @GetMapping("/queryDiskInfo")
+    public Result<List<Map<String, Object>>> queryDiskInfo(HttpServletRequest request, HttpServletResponse response) {
+        Result<List<Map<String, Object>>> res = new Result<>();
+        try {
+            // 当前文件系统类
+            FileSystemView fsv = FileSystemView.getFileSystemView();
+            // 列出所有windows 磁盘
+            File[] fs = File.listRoots();
+            log.info("查询磁盘信息:" + fs.length + "个");
+            List<Map<String, Object>> list = new ArrayList<>();
 
             for (int i = 0; i < fs.length; i++) {
-	        	if(fs[i].getTotalSpace()==0) {
-	        		continue;
-	        	}
-	        	Map<String,Object> map = new HashMap<>();
-	        	map.put("name", fsv.getSystemDisplayName(fs[i]));
-	        	map.put("max", fs[i].getTotalSpace());
-	        	map.put("rest", fs[i].getFreeSpace());
-	        	map.put("restPPT", fs[i].getFreeSpace()*100/fs[i].getTotalSpace());
-	        	list.add(map);
-	        	log.info(map.toString());
-	        }
-	        res.setResult(list);
-	        res.success("查询成功");
-		} catch (Exception e) {
-			res.error500("查询失败"+e.getMessage());
-		}
-		return res;
-	}
-
-	/**
-	 * 工作台首页的数据
-	 * @return
-	 */
-	@GetMapping(value = "/list/search/projects")
-	public String projects() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_projects.json");
-	}
-
-	@GetMapping(value = "/workplace/activity")
-	public String activity() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_activity.json");
-	}
+                if (fs[i].getTotalSpace() == 0) {
+                    continue;
+                }
+                Map<String, Object> map = new HashMap<>();
+                map.put("name", fsv.getSystemDisplayName(fs[i]));
+                map.put("max", fs[i].getTotalSpace());
+                map.put("rest", fs[i].getFreeSpace());
+                map.put("restPPT", fs[i].getFreeSpace() * 100 / fs[i].getTotalSpace());
+                list.add(map);
+                log.info(map.toString());
+            }
+            res.setResult(list);
+            res.success("查询成功");
+        } catch (Exception e) {
+            res.error500("查询失败" + e.getMessage());
+        }
+        return res;
+    }
+
+    /**
+     * 工作台首页的数据
+     *
+     * @return
+     */
+    @GetMapping(value = "/list/search/projects")
+    public String projects() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_projects.json");
+    }
+
+    @GetMapping(value = "/workplace/activity")
+    public String activity() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_activity.json");
+    }
 
     @GetMapping(value = "/workplace/teams")
-	public String teams() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_teams.json");
-	}
+    public String teams() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_teams.json");
+    }
 
     @GetMapping(value = "/workplace/radar")
-	public String radar() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_radar.json");
-	}
+    public String radar() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_radar.json");
+    }
 
     @GetMapping(value = "/task/process")
-	public String taskProcess() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/task_process.json");
-	}
+    public String taskProcess() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/task_process.json");
+    }
 
     /**
      * author:lvdandan-----date:20190315---for:添加数据日志json----
      *
      * @return 数据日志
      */
-	public String sysDataLogJson() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/sysdatalog.json");
-	}
+    public String sysDataLogJson() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/sysdatalog.json");
+    }
 
     /**
-	 * 读取json格式文件
-	 * @param jsonSrc
-	 * @return
-	 */
-	private String readJson(String jsonSrc) {
-		String json = "";
-		try {
-			//File jsonFile = ResourceUtils.getFile(jsonSrc);
-			//json = FileUtils.re.readFileToString(jsonFile);
-			//换个写法,解决springboot读取jar包中文件的问题
-			InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonSrc.replace("classpath:", ""));
-            json = stream.toString();
+     * 读取json格式文件
+     *
+     * @param jsonSrc
+     * @return
+     */
+    private String readJson(String jsonSrc) {
+        String json = "";
+        try {
+            //File jsonFile = ResourceUtils.getFile(jsonSrc);
+            //json = FileUtils.re.readFileToString(jsonFile);
+            //换个写法,解决springboot读取jar包中文件的问题
+            InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonSrc.replace("classpath:", ""));
+            if (!Check.isNull(stream)) {
+                json = stream.toString();
+            }
+
 //			json = IOUtils.toString(stream);
         } catch (Exception e) {
-			log.error(e.getMessage(),e);
-		}
-		return json;
-	}
+            log.error(e.getMessage(), e);
+        }
+        return json;
+    }
 }