huangpingkang 1 rok temu
rodzic
commit
4b19da60a7

+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceXingTuController.java

@@ -51,7 +51,7 @@ public class BytedanceXingTuController {
 
     @GetMapping("/taskReport")
     public void taskReport() {
-        List<JSONObject> xingTuTasks = bytedanceXingTuService.getXingTuActiveTask(null);
+        List<JSONObject> xingTuTasks = bytedanceXingTuService.getXingTuReportTask(null);
         for (JSONObject taskJson : xingTuTasks) {
             Integer taskStatus = taskJson.getInteger("task_status");
             Long advId = taskJson.getLong("advertiser_id");

+ 2 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedanceXingTuMapper.java

@@ -16,6 +16,8 @@ public interface BytedanceXingTuMapper {
 
     List<JSONObject> queryXingTuReportTask(@Param("advertiserId") Long advertiserId);
 
+    List<JSONObject> queryXingTuRetryJob();
+
     void insertTaskId(List<BytedanceXingTuTask> tasks);
 
     void updateTaskInfo(BytedanceXingTuTask task);

+ 13 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedanceXingTuMapper.xml

@@ -117,10 +117,22 @@
         on t.advertiser_id = x.advertiser_id
         join deepthink.bytedance_auth_list a
         on x.admin_advertiser_id = a.admin_advertiser_id
-        where t.om_task_status not in (2,6)
+        where t.om_task_status not in (1,2,6)
         and (t.end_time is null or t.end_time >= unix_timestamp(date_add(now(),Interval -65 day)))
         <if test="advertiserId != null">
             and t.advertiser_id = ${advertiserId}
         </if>
     </select>
+
+
+    <select id="queryXingTuRetryJob" resultType="com.alibaba.fastjson.JSONObject">
+        select is_send AS 'isSend', id AS 'id', start_date AS 'startDate', end_date AS 'endDate',l.msg,
+                l.advertiser_id AS 'advertiserId',data_dimension AS 'dataDimension', data_type AS 'dataType',access_token AS 'accessToken'
+        from media_api.bytedance_error_log l
+         join deepthink.bytedance_xingtu_advertiser_list x
+              on l.advertiser_id = x.advertiser_id
+         join deepthink.bytedance_auth_list a
+              on x.admin_advertiser_id = a.admin_advertiser_id
+        where data_dimension like 'xingtu_task_%'
+    </select>
 </mapper>

+ 1 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedanceXingTuService.java

@@ -8,6 +8,7 @@ public interface IBytedanceXingTuService {
     List<JSONObject> getXingTuAccount(Long advertiserId);
     List<JSONObject> getXingTuActiveTask(Long advertiserId);
     List<JSONObject> getXingTuReportTask(Long advertiserId);
+    List<JSONObject> getXingTuRetryJob();
     void getXingTuTaskList(Long advertiserId, String accessToken, String startDate, String endDate, Integer page,
                            Long errorId, Integer isLog, Integer isSend);
     void getXingTuTaskInfo(Long advertiserId, Long taskId, String accessToken, Long errorId, Integer isLog, Integer isSend);

+ 4 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceXingTuServiceImpl.java

@@ -47,6 +47,10 @@ public class BytedanceXingTuServiceImpl implements IBytedanceXingTuService {
         return bytedanceXingTuMapper.queryXingTuReportTask(advertiserId);
     }
 
+    public List<JSONObject> getXingTuRetryJob() {
+        return bytedanceXingTuMapper.queryXingTuRetryJob();
+    }
+
     public void getXingTuTaskList(Long advertiserId, String accessToken, String startDate, String endDate, Integer page,
                                   Long errorId, Integer isLog, Integer isSend) {
         try {

+ 28 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceReportRetryJob.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.job.bytedance.handler;
 
 
-import cn.com.ctop.job.bytedance.data.service.*;
 import cn.com.ctop.job.bytedance.data.enums.AccountTypeEnum;
 import cn.com.ctop.job.bytedance.data.service.*;
 import cn.com.ctop.job.bytedance.data.utils.Check;
@@ -42,6 +41,9 @@ public class BytedanceReportRetryJob {
     @Autowired
     private IByteDanceFlowDetailsReportService byteDanceFlowDetailsReportService;
 
+    @Autowired
+    private IBytedanceXingTuService bytedanceXingTuService;
+
 
     private static ExecutorService hourAccountRetrExecutorService = Executors.newFixedThreadPool(2);
     private static ExecutorService dailyAccountRetrExecutorService = Executors.newFixedThreadPool(2);
@@ -180,6 +182,31 @@ public class BytedanceReportRetryJob {
             log.info("抖小IAA重试列表为空");
         }
 
+        List<JSONObject> xingTuRetryJob = bytedanceXingTuService.getXingTuRetryJob();
+        if (!Check.isNull(xingTuRetryJob)) {
+            for (int i = 0; i < xingTuRetryJob.size(); i++) {
+                JSONObject jsonObject = xingTuRetryJob.get(i);
+                Long id = jsonObject.getLong("id");
+                Long advertiserId = jsonObject.getLong("advertiserId");
+                String startDate = jsonObject.getString("startDate");
+                String endDate = jsonObject.getString("endDate");
+                String dataDimension = jsonObject.getString("dataDimension");
+                Integer isSend = jsonObject.getInteger("isSend");
+                String accessToken = jsonObject.getString("accessToken");
+                Long taskId = jsonObject.getJSONObject("msg").getLong("taskId");
+
+                if ("xingtu_task_list".equalsIgnoreCase(dataDimension)) {
+                    bytedanceXingTuService.getXingTuTaskList(advertiserId, accessToken, startDate, endDate, 1, id, null, isSend);
+                } else if ("xingtu_task_info".equalsIgnoreCase(dataDimension)) {
+                    bytedanceXingTuService.getXingTuTaskInfo(advertiserId, taskId, accessToken, id, null, isSend);
+                } else if ("xingtu_task_report".equalsIgnoreCase(dataDimension)) {
+                    bytedanceXingTuService.getXingTuTaskReport(advertiserId, taskId, accessToken, 1, id, null, isSend);
+                }
+            }
+        } else {
+            log.info("巨量星图重试列表为空");
+        }
+
     }
 
 

+ 60 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceXingTuJob.java

@@ -0,0 +1,60 @@
+package cn.com.ctop.job.bytedance.handler;
+
+
+import cn.com.ctop.job.bytedance.data.service.IBytedanceXingTuService;
+import cn.com.ctop.job.bytedance.data.utils.DateUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+
+@Slf4j
+@Component
+public class BytedanceXingTuJob {
+    @Autowired
+    private IBytedanceXingTuService bytedanceXingTuService;
+
+    @XxlJob("xingTuTaskList")
+    public void taskList() {
+        String startDate = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
+        String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+        List<JSONObject> xingTuAccount = bytedanceXingTuService.getXingTuAccount(null);
+        for (JSONObject jsonObject : xingTuAccount) {
+            Long advId = jsonObject.getLong("advertiser_id");
+            String accessToken = jsonObject.getString("access_token");
+            bytedanceXingTuService.getXingTuTaskList(advId, accessToken, startDate, endDate, 1, null, 1, null);
+        }
+
+    }
+
+    @XxlJob("xingTuTaskInfo")
+    public void taskInfo() {
+        List<JSONObject> xingTuTasks = bytedanceXingTuService.getXingTuActiveTask(null);
+        for (JSONObject taskJson : xingTuTasks) {
+            Long advId = taskJson.getLong("advertiser_id");
+            Long taskId = taskJson.getLong("task_id");
+            String accessToken = taskJson.getString("access_token");
+            bytedanceXingTuService.getXingTuTaskInfo(advId, taskId, accessToken, null, 1, null);
+        }
+
+    }
+
+    @XxlJob("xingTuTaskReport")
+    public void taskReport() {
+        List<JSONObject> xingTuTasks = bytedanceXingTuService.getXingTuReportTask(null);
+        for (JSONObject taskJson : xingTuTasks) {
+            Long advId = taskJson.getLong("advertiser_id");
+            Long taskId = taskJson.getLong("task_id");
+            String accessToken = taskJson.getString("access_token");
+            bytedanceXingTuService.getXingTuTaskReport(advId, taskId, accessToken, 1, null, 1, null);
+        }
+
+    }
+
+
+}