Jelajahi Sumber

调整定时任务

yumeng 5 tahun lalu
induk
melakukan
dc50f30f26

+ 41 - 34
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyMaterialReportRetryJob.java

@@ -33,43 +33,50 @@ public class BytedanceDailyMaterialReportRetryJob implements Job {
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         log.info("头条素材报表重试定时任务开始");
-        List<BytedanceReportMaterialRetry> retryList = bytedanceReportService.getRetryList();
-        //
-        //多线程
-        final ExecutorService executorService = Executors.newFixedThreadPool(3);
-        retryList.forEach(retry -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        String startDate = retry.getStartDate();
-                        String endDate = retry.getEndDate();
-                        Long accountId = retry.getAccountId();
-                        Integer type = retry.getType();
-                        CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
-                        log.info("头条素材报表重试定时任务,当前accountId为:" + token.getAccountId());
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
 
-                        Long days = DateUtils.getDiscrepantDays(startDate, endDate); //间隔天数
-                        String start = null;
-                        String end = null;
-                        for (int i = 0; i <= days; i++) {
-                            start = DateUtils.addDay(startDate, i);
-                            end = start;
-                            //获取头条素材报表数据
-                            int code = bytedanceReportService.bytedanceMaterialReportRetry(type, token, start, end);
-                            if(code ==200 || code == 1){
-                                if(type == 1){
-                                    //重试成功清洗数据
-                                    byteDanceVideoReportDailyService.videoInfoListByAccountId(start,end,accountId);
+                List<BytedanceReportMaterialRetry> retryList = bytedanceReportService.getRetryList();
+                //
+                //多线程
+                final ExecutorService executorService = Executors.newFixedThreadPool(3);
+                retryList.forEach(retry -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                String startDate = retry.getStartDate();
+                                String endDate = retry.getEndDate();
+                                Long accountId = retry.getAccountId();
+                                Integer type = retry.getType();
+                                CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
+                                log.info("头条素材报表重试定时任务,当前accountId为:" + token.getAccountId());
+                                Long days = DateUtils.getDiscrepantDays(startDate, endDate); //间隔天数
+                                String start = null;
+                                String end = null;
+                                for (int i = 0; i <= days; i++) {
+                                    start = DateUtils.addDay(startDate, i);
+                                    end = start;
+                                    //获取头条素材报表数据
+                                    int code = bytedanceReportService.bytedanceMaterialReportRetry(type, token, start, end);
+                                    if (code == 200 || code == 1) {
+                                        if (type == 1) {
+                                            //重试成功清洗数据
+                                            byteDanceVideoReportDailyService.videoInfoListByAccountId(start, end, accountId);
+                                        }
+                                    }
                                 }
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
                             }
                         }
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                    }
-                }
-            });
-        });
+                    });
+                });
+            }
+        };
+        thread.start();
+
     }
 }