Przeglądaj źródła

次留定时任务和一些问题

hcst_sunzhen 5 lat temu
rodzic
commit
f392bf7311

+ 31 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.job.KuaishouDailyAccountReportLoadJob;
 import org.jeecg.modules.ctop.service.ICleanMaterialService;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -851,5 +852,35 @@ public class TestController {
 
     }
 
+    @GetMapping(value = "/KuaishouDailyAccountReportLoadJob")
+    public void KuaishouDailyAccountReportLoadJob(){
+        Date getDate = DateUtils.addDay(new Date(), -2);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取快手数据异常:未获取到可用的token");
+            return;
+        }
+
+        executorService = Executors.newFixedThreadPool(3);
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    //1: 获取广告主信息数据
+                    kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+                }
+            });
+        });
+    }
+
+
+
+
+
+
+
+
+
 
 }

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

@@ -0,0 +1,59 @@
+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.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;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 快手广告主次留数据--凌晨跑两天前的次留,统一跑起来
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class KuaishouDailyAccountReportNextDayStayJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = DateUtils.addDay(new Date(), -2);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取快手数据异常:未获取到可用的token");
+                    return;
+                }
+
+                executorService = Executors.newFixedThreadPool(3);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            //1: 获取广告主信息数据
+                            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+                        }
+                    });
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java

@@ -154,7 +154,7 @@ public class KuaishouReportDailyAccount implements Serializable {
     private BigDecimal eventNextDayStayCost;
 
     @JsonProperty("event_next_day_stay_ratio")
-    private Long eventNextDayStayRatio;
+    private BigDecimal eventNextDayStayRatio;
 
     @JsonProperty("form_action_ratio")
     private Double formActionRatio;

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

@@ -952,20 +952,24 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         requestMap.put("advertiser_id", task.getAccountId());
         requestMap.put("task_id", task.getTaskId());
         String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token.getAccessToken(), fileName);
-        if(type == 1){
-            //素材异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync(localPath);
-        }else if(type == 2){
-            //账户异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyAccountFileAsync(localPath);
-        }else if(type == 3){
-            //campaign异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyCampaignFileAsync(localPath);
-        }else if(type == 4){
-            //plan异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync(localPath);
-        }else{
-            log.error("异步报表类型传入错误,task_id:" + task.getTaskId() + ";类型:" + type);
+        if(task.getAccountId() !=1649961222605831L && task.getAccountId() != 1643726941045772L){
+
+
+            if(type == 1){
+                //素材异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync(localPath);
+            }else if(type == 2){
+                //账户异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyAccountFileAsync(localPath);
+            }else if(type == 3){
+                //campaign异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyCampaignFileAsync(localPath);
+            }else if(type == 4){
+                //plan异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync(localPath);
+            }else{
+                log.error("异步报表类型传入错误,task_id:" + task.getTaskId() + ";类型:" + type);
+            }
         }
     }