Ver código fonte

Merge remote-tracking branch 'origin/test-report' into test-report

# Conflicts:
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
yumeng 5 anos atrás
pai
commit
070e1c7a52

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

@@ -0,0 +1,37 @@
+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.IKuaiShouHistoryReportTaskService;
+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;
+
+@Slf4j
+public class KuaishouDailyReportTaskJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaiShouHistoryReportTaskService reportTaskService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("快手获取日报数据任务执行失败:未获取到可用的token");
+            return;
+        }
+        String getDateStr = DateUtils.formatDate(getDate);
+        tokens.forEach(token -> {
+            reportTaskService.createTask(token.getAccountId(), token.getAccessToken(), getDateStr);
+        });
+    }
+}

+ 7 - 6
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,7 +1,6 @@
 package org.jeecg;
 
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportTaskService;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -17,8 +16,6 @@ public class SampleTest {
 
     @Autowired
     private IKuaiShouHistoryReportTaskService reportTaskService;
-    @Autowired
-    private IKuaiShouDailyReportTaskService dailyReportTaskService;
 
     @Test
     public void kuaisShouReport() {
@@ -27,8 +24,8 @@ public class SampleTest {
         try {
 
 
-            //  reportTaskService.createTask(3727345L, "871fc2c248782a94ad2962c941555abc");
-            dailyReportTaskService.getTaskList(3727345L, "871fc2c248782a94ad2962c941555abc", "2020-03-11");
+            reportTaskService.createTask(3727345L, "871fc2c248782a94ad2962c941555abc");
+            reportTaskService.getTaskList();
 
 
 
@@ -97,6 +94,10 @@ public class SampleTest {
     }
 
 
+
+
+
+
 }
 
 

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouHistoryReportTaskService.java

@@ -11,7 +11,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @date 2020-03-09
  */
 public interface IKuaiShouHistoryReportTaskService extends IService<KuaiShouHistoryReportTask> {
-    void createTask(Long accountId, String token);
+    void createTask(Long accountId, String token, String date);
 
     void getTaskList();
 

+ 6 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java

@@ -19,7 +19,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -62,7 +61,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
     private KuaishouReportDailyCreativeMapper reportDailyCreativeMapper;
 
     @Override
-    public void createTask(Long accountId, String token) {
+    public void createTask(Long accountId, String token, String date) {
         if (Check.isNull(accountId) || Check.isNull(token)) {
             log.error("token或accountId为空");
             return;
@@ -74,11 +73,9 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
             headers.put("Access-Token", token);
             JSONObject param = new JSONObject();
             param.put("advertiser_id", accountId);
-            String endDate = DateUtils.getDate("yyyy-MM-dd");
-            String startDate = DateUtils.addMonth(endDate, -6);
             JSONObject taskParams = new JSONObject();
-            taskParams.put("start_date", "2020-03-11");
-            taskParams.put("end_date", "2020-03-11");
+            taskParams.put("start_date", date);
+            taskParams.put("end_date", date);
 
             if (Check.isNull(typeList)) {
                 getTypeList();
@@ -97,8 +94,8 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                         JSONObject dataJson = resultJson.getJSONObject("data");
                         KuaiShouHistoryReportTask reportTask = new KuaiShouHistoryReportTask();
                         reportTask.setAccountId(accountId);
-                        reportTask.setStartDate(startDate);
-                        reportTask.setEndDate(endDate);
+                        reportTask.setStartDate(date);
+                        reportTask.setEndDate(date);
                         reportTask.setTaskId(dataJson.getString("task_id"));
                         reportTask.setViewType(type);
                         reportTask.setTaskStatus(0);
@@ -208,7 +205,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
 
     private void getTypeList() {
         typeList = new ArrayList<>();
-        typeList.add(1);
+//        typeList.add(1);
         typeList.add(2);
         typeList.add(3);
         typeList.add(4);