فهرست منبع

异步报表、次留率报表定时任务增加日志

hcst_sunzhen 5 سال پیش
والد
کامیت
760e06dd62

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

@@ -33,7 +33,7 @@ public class BytedanceDailyAccountReportAsyncJob implements Job {
 
 
         Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate = DateUtils.addDay(new Date(), -1);
         String date = DateUtils.formatDate(getDate);
         String date = DateUtils.formatDate(getDate);
-
+        log.info("头条异步广告主报表执行开始。跑的是:"+ date + "的数据");
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         if (null == tokens || tokens.size() <= 0) {
         if (null == tokens || tokens.size() <= 0) {
             log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
             log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");

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

@@ -31,7 +31,7 @@ public class BytedanceDailyCampaignReportAsyncJob implements Job {
 
 
         Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate = DateUtils.addDay(new Date(), -1);
         String date = DateUtils.formatDate(getDate);
         String date = DateUtils.formatDate(getDate);
-
+        log.info("头条异步广告组报表数据执行开始,跑的是"+ date + "的数据");
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         if (null == tokens || tokens.size() <= 0) {
         if (null == tokens || tokens.size() <= 0) {
             log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
             log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyCreativeReportAsyncJob.java

@@ -31,8 +31,8 @@ public class BytedanceDailyCreativeReportAsyncJob implements Job {
 
 
         Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate = DateUtils.addDay(new Date(), -1);
         String date = DateUtils.formatDate(getDate);
         String date = DateUtils.formatDate(getDate);
-
-        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        log.info("头条创意报表异步任务执行开始.跑的是" + date + "的数据");
+     List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         if (null == tokens || tokens.size() <= 0) {
         if (null == tokens || tokens.size() <= 0) {
             log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
             log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
             return ;
             return ;

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

@@ -30,9 +30,9 @@ public class BytedanceDailyMaterialReportJob implements Job {
 
 
     @Override
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-
         Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate = DateUtils.addDay(new Date(), -1);
         String date = DateUtils.formatDate(getDate);
         String date = DateUtils.formatDate(getDate);
+        log.info("头条获取素材报表数据任务开始,任务时间:" + date);
 
 
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         if (null == tokens || tokens.size() <= 0) {
         if (null == tokens || tokens.size() <= 0) {

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

@@ -30,7 +30,7 @@ public class BytedanceDailyMaterialReportRetryJob implements Job {
 
 
     @Override
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-
+        log.info("头条素材报表重试定时任务开始");
         List<BytedanceReportMaterialRetry> retryList = bytedanceReportService.getRetryList();
         List<BytedanceReportMaterialRetry> retryList = bytedanceReportService.getRetryList();
         //
         //
         //多线程
         //多线程

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

@@ -31,6 +31,7 @@ public class BytedanceDailyPlanReportAsyncJob implements Job {
 
 
         Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate = DateUtils.addDay(new Date(), -1);
         String date = DateUtils.formatDate(getDate);
         String date = DateUtils.formatDate(getDate);
+        log.info("头条广告计划异步任务开始执行,跑的是" + date + "的数据");
 
 
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         if (null == tokens || tokens.size() <= 0) {
         if (null == tokens || tokens.size() <= 0) {

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

@@ -30,6 +30,7 @@ public class KuaishouDailyAccountReportNextDayStayJob implements Job {
 
 
     @Override
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        log.info("快手次留率定时任务开始");
         Thread thread = new Thread() {
         Thread thread = new Thread() {
             @Override
             @Override
             public void run() {
             public void run() {

+ 6 - 6
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java

@@ -106,7 +106,7 @@ public class BytedanceReportController {
 
 
         Result<List<JSONObject>> result = new Result<>();
         Result<List<JSONObject>> result = new Result<>();
         try {
         try {
-            log.info("头条获取素材报表数据任务执行开始");
+            log.info("头条获取异步报表数据任务执行开始");
             Long starttime = System.currentTimeMillis();
             Long starttime = System.currentTimeMillis();
             List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
             List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
             if (null == tokens || tokens.size() <= 0) {
             if (null == tokens || tokens.size() <= 0) {
@@ -133,13 +133,13 @@ public class BytedanceReportController {
     public Result<List<JSONObject>> bytedanceAsyncTaskGet(@RequestBody JSONObject requestJson) {
     public Result<List<JSONObject>> bytedanceAsyncTaskGet(@RequestBody JSONObject requestJson) {
         Result<List<JSONObject>> result = new Result<>();
         Result<List<JSONObject>> result = new Result<>();
         try {
         try {
-            log.info("头条获取素材报表数据定时任务执行开始");
+            log.info("头条下载异步报表数据定时任务执行开始");
             Long starttime = System.currentTimeMillis();
             Long starttime = System.currentTimeMillis();
             bytedanceReportService.bytedanceAsyncTaskGet();
             bytedanceReportService.bytedanceAsyncTaskGet();
             Long endtime = System.currentTimeMillis();
             Long endtime = System.currentTimeMillis();
-            log.info("头条异步报表数据定时任务执行结束,执行耗时:{}秒", (endtime - starttime) / 1000);
+            log.info("头条下载异步报表数据定时任务执行结束,执行耗时:{}秒", (endtime - starttime) / 1000);
         } catch (Exception e) {
         } catch (Exception e) {
-            log.error("头条获取异步报表数据定时任务执行报错");
+            log.error("头条下载异步报表数据定时任务执行报错");
             e.printStackTrace();
             e.printStackTrace();
             result.setSuccess(false);
             result.setSuccess(false);
         }
         }
@@ -164,7 +164,7 @@ public class BytedanceReportController {
                 return result;
                 return result;
             }
             }
 
 
-            final ExecutorService executorService = Executors.newFixedThreadPool(8);
+            final ExecutorService executorService = Executors.newFixedThreadPool(3);
             tokens.forEach(token -> {
             tokens.forEach(token -> {
                 executorService.submit(new Runnable() {
                 executorService.submit(new Runnable() {
                     @Override
                     @Override
@@ -211,7 +211,7 @@ public class BytedanceReportController {
 
 
                 //
                 //
                 //多线程
                 //多线程
-                final ExecutorService executorService = Executors.newFixedThreadPool(8);
+                final ExecutorService executorService = Executors.newFixedThreadPool(3);
                 retryList.forEach(retry -> {
                 retryList.forEach(retry -> {
                     executorService.submit(new Runnable() {
                     executorService.submit(new Runnable() {
                         @Override
                         @Override

+ 21 - 6
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java

@@ -924,7 +924,9 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                         e.printStackTrace();
                         e.printStackTrace();
                     } catch (IOException e) {
                     } catch (IOException e) {
                         e.printStackTrace();
                         e.printStackTrace();
-                    } finally {
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }finally {
                         try {
                         try {
                             if (response != null) {
                             if (response != null) {
                                 response.close();
                                 response.close();
@@ -947,17 +949,23 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         String path = "/open_api/2/async_task/download/";
         String path = "/open_api/2/async_task/download/";
 
 
         String url = open_api_domain + path;
         String url = open_api_domain + path;
-        String fileName = task.getAccountId() + "_" + "type" + type + "_" +System.currentTimeMillis() + ".csv";
+        String fileName = task.getAccountId() + "_" + "type" + type + "_" + task.getTaskId() + "_" + System.currentTimeMillis() + ".csv";
         Map<String, Object> requestMap = new HashMap<>();
         Map<String, Object> requestMap = new HashMap<>();
         requestMap.put("advertiser_id", task.getAccountId());
         requestMap.put("advertiser_id", task.getAccountId());
         requestMap.put("task_id", task.getTaskId());
         requestMap.put("task_id", task.getTaskId());
         String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token.getAccessToken(), fileName);
         String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token.getAccessToken(), fileName);
-        if(task.getAccountId() !=1649961222605831L && task.getAccountId() != 1643726941045772L){
+       // if(task.getAccountId() !=1649961222605831L && task.getAccountId() != 1643726941045772L){
 
 
 
 
             if(type == 1){
             if(type == 1){
                 //素材异步报表
                 //素材异步报表
-                bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync(localPath);
+                if(task.getTaskId() == 847656L){
+                    bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync("D:\\data\\report\\history\\1649961222605831_type1_847656_1588935984126.csv");
+                }else{
+                    bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync(localPath);
+                }
+
+
             }else if(type == 2){
             }else if(type == 2){
                 //账户异步报表
                 //账户异步报表
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyAccountFileAsync(localPath);
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyAccountFileAsync(localPath);
@@ -966,11 +974,18 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyCampaignFileAsync(localPath);
                 bytedanceDailyReportTaskMapper.loadBytedanceDailyCampaignFileAsync(localPath);
             }else if(type == 4){
             }else if(type == 4){
                 //plan异步报表
                 //plan异步报表
-                bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync(localPath);
+                if(task.getTaskId() == 849925L) {
+                    bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync("D:\\data\\report\\history\\1649961222605831_type1_847656_1588935984126.csv");
+                }else{
+
+                    bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync(localPath);
+                }
+
+
             }else{
             }else{
                 log.error("异步报表类型传入错误,task_id:" + task.getTaskId() + ";类型:" + type);
                 log.error("异步报表类型传入错误,task_id:" + task.getTaskId() + ";类型:" + type);
             }
             }
-        }
+       // }
     }
     }
 
 
     /////////////////////////////////////////////////////////\
     /////////////////////////////////////////////////////////\