Przeglądaj źródła

promotion project增加字段重试

hpk 1 rok temu
rodzic
commit
cb37c9fc93

+ 6 - 7
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java

@@ -6,7 +6,6 @@ import cn.com.ctop.job.bytedance.data.service.*;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
-import com.google.common.collect.Lists;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -190,8 +189,8 @@ public class BytedanceController {
         for (JSONObject jsonObject : costAccount) {
         for (JSONObject jsonObject : costAccount) {
             dailyRetrExecutorService.submit(() -> {
             dailyRetrExecutorService.submit(() -> {
                 Long adverId = jsonObject.getLong("advertiserId");
                 Long adverId = jsonObject.getLong("advertiserId");
-                cdpProjectService.getProjectList(adverId, null, null, null);
-                cdpProjectService.getProjectList(adverId, null, "del", null);
+                cdpProjectService.getProjectList(adverId, null, null, null,null,1);
+                cdpProjectService.getProjectList(adverId, null, "del", null,null,1);
             });
             });
         }
         }
     }
     }
@@ -202,7 +201,7 @@ public class BytedanceController {
         for (JSONObject jsonObject : costAccount) {
         for (JSONObject jsonObject : costAccount) {
             dailyRetrExecutorService.submit(() -> {
             dailyRetrExecutorService.submit(() -> {
                 Long adverId = jsonObject.getLong("advertiserId");
                 Long adverId = jsonObject.getLong("advertiserId");
-                cdpProjectService.getpromotionList(adverId,null,null);
+                cdpProjectService.getPromotionList(adverId,null,null,null,1);
             });
             });
         }
         }
     }
     }
@@ -228,8 +227,8 @@ public class BytedanceController {
                 log.info("项目ID数不能超过100");
                 log.info("项目ID数不能超过100");
                 return;
                 return;
             }
             }
-            cdpProjectService.getProjectList(advertiserId, ids, null, null);
-            cdpProjectService.getProjectList(advertiserId, ids, "del", null);
+            cdpProjectService.getProjectList(advertiserId, ids, null, null,null,1);
+            cdpProjectService.getProjectList(advertiserId, ids, "del", null,null,1);
         }
         }
     }
     }
 
 
@@ -254,7 +253,7 @@ public class BytedanceController {
                 log.info("项目ID数不能超过100");
                 log.info("项目ID数不能超过100");
                 return;
                 return;
             }
             }
-            cdpProjectService.getpromotionList(advertiserId, ids, null);
+            cdpProjectService.getPromotionList(advertiserId, ids, null,null,1);
         }
         }
     }
     }
 
 

+ 2 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedanceCdpProjectService.java

@@ -13,9 +13,9 @@ import java.util.List;
  */
  */
 public interface IBytedanceCdpProjectService {
 public interface IBytedanceCdpProjectService {
 
 
-    void getpromotionList(Long advertiserId, JSONArray ids, String date);
+    void getPromotionList(Long advertiserId, JSONArray ids, String date, Long errorId, Integer isLog);
 
 
-    void getProjectList(Long advertiserId, JSONArray ids,String type, String date);
+    void getProjectList(Long advertiserId, JSONArray ids,String type, String date, Long errorId, Integer isLog);
 
 
     List<Long> queryAllAdverIdList(String type);
     List<Long> queryAllAdverIdList(String type);
 
 

+ 40 - 17
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedanceCdpProjectServiceImpl.java

@@ -1,7 +1,9 @@
 package cn.com.ctop.job.bytedance.data.service.impl;
 package cn.com.ctop.job.bytedance.data.service.impl;
 
 
 import cn.com.ctop.job.bytedance.data.entity.BytedanceCdpProject;
 import cn.com.ctop.job.bytedance.data.entity.BytedanceCdpProject;
+import cn.com.ctop.job.bytedance.data.entity.BytedanceErrorLog;
 import cn.com.ctop.job.bytedance.data.mapper.BytedanceCdpProjectMapper;
 import cn.com.ctop.job.bytedance.data.mapper.BytedanceCdpProjectMapper;
+import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
 import cn.com.ctop.job.bytedance.data.mapper.BytedanceRefreshTokenMapper;
 import cn.com.ctop.job.bytedance.data.mapper.BytedanceRefreshTokenMapper;
 import cn.com.ctop.job.bytedance.data.service.IBytedanceCdpProjectService;
 import cn.com.ctop.job.bytedance.data.service.IBytedanceCdpProjectService;
 import cn.com.ctop.job.bytedance.data.utils.*;
 import cn.com.ctop.job.bytedance.data.utils.*;
@@ -39,6 +41,9 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
     @Autowired
     @Autowired
     private BytedanceRefreshTokenMapper tokenMapper;
     private BytedanceRefreshTokenMapper tokenMapper;
 
 
+    @Autowired
+    private BytedancePromoterReportMapper promoterReportMapper;
+
     @Override
     @Override
     public List<Long> queryAllAdverIdList(String type) {
     public List<Long> queryAllAdverIdList(String type) {
         return bytedanceCdpProjectMapper.queryAllAdverIdList(type);
         return bytedanceCdpProjectMapper.queryAllAdverIdList(type);
@@ -75,11 +80,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
     }
     }
 
 
     @Override
     @Override
-    public void getpromotionList(Long advertiserId, JSONArray ids, String date) {
-        this.getpromotionListVo(advertiserId, ids, date, 1, 1);
+    public void getPromotionList(Long advertiserId, JSONArray ids, String date, Long errorId, Integer isLog) {
+        this.getPromotionListVo(advertiserId, ids, date, 1, 1, errorId, isLog);
     }
     }
 
 
-    private void getpromotionListVo(Long advertiserId, JSONArray ids, String date, Integer page, int count) {
+    private void getPromotionListVo(Long advertiserId, JSONArray ids, String date, Integer page, int count, Long errorId, Integer isLog) {
         try {
         try {
             log.info("执行id:{}", advertiserId);
             log.info("执行id:{}", advertiserId);
             boolean nextPage = false;
             boolean nextPage = false;
@@ -129,15 +134,18 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
                     //40100请求超频
                     //40100请求超频
                     if (40100 == code && count <= 5) {
                     if (40100 == code && count <= 5) {
                         Thread.sleep(800);
                         Thread.sleep(800);
-                        getpromotionListVo(advertiserId, ids, date, page, count + 1);
+                        getPromotionListVo(advertiserId, ids, date, page, count + 1, errorId, isLog);
                     } else {
                     } else {
+                        insertErrorLog(isLog, advertiserId, "-", "-", "promotion_list", null);
                         log.error("获取广告列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
                         log.error("获取广告列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
                     }
                     }
                     return;
                     return;
                 }
                 }
             }
             }
             if (nextPage) {
             if (nextPage) {
-                getpromotionListVo(advertiserId, ids, date, page + 1, 1);
+                getPromotionListVo(advertiserId, ids, date, page + 1, 1, errorId, isLog);
+            } else if (errorId != null) {
+                promoterReportMapper.deleteInfoByErrorId(errorId);
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
@@ -165,12 +173,11 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
     }
     }
 
 
     @Override
     @Override
-    public void getProjectList(Long advertiserId, JSONArray ids, String type, String date) {
-        this.getProjectListVo(advertiserId, ids, type, date, 1, 1);
-//        this.getProjectListVo(advertiserId, "del", date, 1, 1);
+    public void getProjectList(Long advertiserId, JSONArray ids, String type, String date, Long errorId, Integer isLog) {
+        this.getProjectListVo(advertiserId, ids, type, date, 1, 1, errorId, isLog);
     }
     }
 
 
-    private void getProjectListVo(Long advertiserId, JSONArray ids, String type, String date, Integer page, int count) {
+    private void getProjectListVo(Long advertiserId, JSONArray ids, String type, String date, Integer page, int count, Long errorId, Integer isLog) {
         try {
         try {
             boolean nextPage = false;
             boolean nextPage = false;
             String accessToken = tokenMapper.onlyGetToken(advertiserId);
             String accessToken = tokenMapper.onlyGetToken(advertiserId);
@@ -223,15 +230,18 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
                     //40100请求超频
                     //40100请求超频
                     if (40100 == code && count <= 5) {
                     if (40100 == code && count <= 5) {
                         Thread.sleep(800);
                         Thread.sleep(800);
-                        getProjectListVo(advertiserId, ids, type, date, page, count + 1);
+                        getProjectListVo(advertiserId, ids, type, date, page, count + 1, errorId, isLog);
                     } else {
                     } else {
+                        insertErrorLog(isLog, advertiserId, "-", "-", "project_list", null);
                         log.error("获取项目列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
                         log.error("获取项目列表失败(url:{}),入参:{}\n结果:{}", url, JSONObject.toJSONString(params), obj);
                     }
                     }
                     return;
                     return;
                 }
                 }
             }
             }
             if (nextPage) {
             if (nextPage) {
-                getProjectListVo(advertiserId, ids, type, date, page + 1, 1);
+                getProjectListVo(advertiserId, ids, type, date, page + 1, 1, errorId, isLog);
+            } else if (errorId != null) {
+                promoterReportMapper.deleteInfoByErrorId(errorId);
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
@@ -544,7 +554,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
         }
         }
         if (nextPage) {
         if (nextPage) {
             rebackadqCreativesVo(accountId, accessToken, startDate, endDate, page + 1, isDeleted, 1);
             rebackadqCreativesVo(accountId, accessToken, startDate, endDate, page + 1, isDeleted, 1);
-        }else{
+        } else {
             log.info("账户({})获取动态创意完成", accountId);
             log.info("账户({})获取动态创意完成", accountId);
         }
         }
     }
     }
@@ -652,7 +662,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
             List<String> imageIds = new ArrayList<>();
             List<String> imageIds = new ArrayList<>();
             List<String> videoIds = new ArrayList<>();
             List<String> videoIds = new ArrayList<>();
             JSONArray videoArr = creativeComponents.getJSONArray("video");
             JSONArray videoArr = creativeComponents.getJSONArray("video");
-            if(!Check.isNull(videoArr)) {
+            if (!Check.isNull(videoArr)) {
                 for (int i = 0; i < videoArr.size(); i++) {
                 for (int i = 0; i < videoArr.size(); i++) {
                     JSONObject obj = videoArr.getJSONObject(i);
                     JSONObject obj = videoArr.getJSONObject(i);
                     JSONObject value = obj.getJSONObject("value");
                     JSONObject value = obj.getJSONObject("value");
@@ -663,7 +673,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
                 }
                 }
             }
             }
             JSONArray imageArr = creativeComponents.getJSONArray("image");
             JSONArray imageArr = creativeComponents.getJSONArray("image");
-            if(!Check.isNull(imageArr)) {
+            if (!Check.isNull(imageArr)) {
                 for (int i = 0; i < imageArr.size(); i++) {
                 for (int i = 0; i < imageArr.size(); i++) {
                     JSONObject obj = imageArr.getJSONObject(i);
                     JSONObject obj = imageArr.getJSONObject(i);
                     JSONObject value = obj.getJSONObject("value");
                     JSONObject value = obj.getJSONObject("value");
@@ -674,7 +684,7 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
                 }
                 }
             }
             }
             JSONArray imageListArr = creativeComponents.getJSONArray("image_list");
             JSONArray imageListArr = creativeComponents.getJSONArray("image_list");
-            if(!Check.isNull(imageListArr)) {
+            if (!Check.isNull(imageListArr)) {
                 for (int i = 0; i < imageListArr.size(); i++) {
                 for (int i = 0; i < imageListArr.size(); i++) {
                     JSONObject obj = imageListArr.getJSONObject(i);
                     JSONObject obj = imageListArr.getJSONObject(i);
                     JSONObject value = obj.getJSONObject("value");
                     JSONObject value = obj.getJSONObject("value");
@@ -692,10 +702,10 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
                     }
                     }
                 }
                 }
             }
             }
-            if (!Check.isNull(videoIds)){
+            if (!Check.isNull(videoIds)) {
                 object.put("video_list", StringUtils.join(videoIds, ","));
                 object.put("video_list", StringUtils.join(videoIds, ","));
             }
             }
-            if (!Check.isNull(imageIds)){
+            if (!Check.isNull(imageIds)) {
                 object.put("image_list", StringUtils.join(imageIds, ","));
                 object.put("image_list", StringUtils.join(imageIds, ","));
             }
             }
 
 
@@ -767,4 +777,17 @@ public class BytedanceCdpProjectServiceImpl implements IBytedanceCdpProjectServi
             }
             }
         }
         }
     }
     }
+
+    private void insertErrorLog(Integer isLog, Long advertiserId, String startDate, String endDate, String dataDimension, String msg) {
+        if (isLog != null && 1 == isLog) {
+            BytedanceErrorLog errorInfo = new BytedanceErrorLog();
+            errorInfo.setAdvertiserId(advertiserId);
+            errorInfo.setStartDate(startDate);
+            errorInfo.setEndDate(endDate);
+            errorInfo.setMsg(msg);
+            errorInfo.setDataDimension(dataDimension);
+            errorInfo.setDataType("daily");
+            promoterReportMapper.replaceErrorInfo(errorInfo);
+        }
+    }
 }
 }

+ 8 - 8
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceCdpProjectJob.java

@@ -48,8 +48,8 @@ public class BytedanceCdpProjectJob {
 
 
             List<String> days = DateUtils.getDays("2025-06-01", "2025-07-22");
             List<String> days = DateUtils.getDays("2025-06-01", "2025-07-22");
             for (String day : days) {
             for (String day : days) {
-                ids.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, day)));
-                ids.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getpromotionList(id, null, day)));
+                ids.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, day,null,1)));
+                ids.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getPromotionList(id, null, day,null,1)));
             }
             }
         }
         }
     }
     }
@@ -80,8 +80,8 @@ public class BytedanceCdpProjectJob {
             String today = DateUtils.getNowDate("yyyy-MM-dd");
             String today = DateUtils.getNowDate("yyyy-MM-dd");
             List<Long> nowAdIds = cdpProjectService.queryAdvertiserIds("bytedance_advertiser_report_hour", DateUtils.getYYMMDDTime(today));
             List<Long> nowAdIds = cdpProjectService.queryAdvertiserIds("bytedance_advertiser_report_hour", DateUtils.getYYMMDDTime(today));
             if (!Check.isNull(nowAdIds)) {
             if (!Check.isNull(nowAdIds)) {
-                nowAdIds.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, today)));
-                nowAdIds.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getpromotionList(id, null, today)));
+                nowAdIds.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, today,null,1)));
+                nowAdIds.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getPromotionList(id, null, today,null,1)));
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
@@ -97,15 +97,15 @@ public class BytedanceCdpProjectJob {
             String yesterday = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
             String yesterday = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
             List<Long> adIds = cdpProjectService.queryAdvertiserIds("bytedance_advertiser_report_daily", DateUtils.getYYMMDDTime(yesterday));
             List<Long> adIds = cdpProjectService.queryAdvertiserIds("bytedance_advertiser_report_daily", DateUtils.getYYMMDDTime(yesterday));
             if (!Check.isNull(adIds)) {
             if (!Check.isNull(adIds)) {
-                adIds.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, yesterday)));
-                adIds.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getpromotionList(id, null, yesterday)));
+                adIds.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, yesterday,null,1)));
+                adIds.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getPromotionList(id, null, yesterday,null,1)));
             }
             }
             //拉取前天数据
             //拉取前天数据
             String yesterday2 = DateUtils.getNowAddDate("yyyy-MM-dd", -2);
             String yesterday2 = DateUtils.getNowAddDate("yyyy-MM-dd", -2);
             List<Long> adIds2 = cdpProjectService.queryAdvertiserIds("bytedance_advertiser_report_daily", DateUtils.getYYMMDDTime(yesterday2));
             List<Long> adIds2 = cdpProjectService.queryAdvertiserIds("bytedance_advertiser_report_daily", DateUtils.getYYMMDDTime(yesterday2));
             if (!Check.isNull(adIds2)) {
             if (!Check.isNull(adIds2)) {
-                adIds2.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, yesterday2)));
-                adIds2.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getpromotionList(id, null, yesterday2)));
+                adIds2.forEach(id -> projectExecutorService.submit(() -> cdpProjectService.getProjectList(id, null, null, yesterday2,null,1)));
+                adIds2.forEach(id -> promExecutorService.submit(() -> cdpProjectService.getPromotionList(id, null, yesterday2,null,1)));
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();

+ 22 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceReportRetryJob.java

@@ -52,6 +52,9 @@ public class BytedanceReportRetryJob {
     @Autowired
     @Autowired
     private IDianZhongService dianZhongService;
     private IDianZhongService dianZhongService;
 
 
+    @Autowired
+    private IBytedanceCdpProjectService cdpProjectService;
+
     @Resource
     @Resource
     private DianZhongConfig dianZhongConfig;
     private DianZhongConfig dianZhongConfig;
 
 
@@ -153,6 +156,25 @@ public class BytedanceReportRetryJob {
                             }
                             }
                         }
                         }
                     });
                     });
+                } else if ("promotion_list".equals(dataDimension)) {
+                    productDailyRetrExecutor.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (!Check.isNull(accessToken)) {
+                                cdpProjectService.getPromotionList(advertiserId, null, null, id, null);
+                            }
+                        }
+                    });
+                } else if ("project_list".equals(dataDimension)) {
+                    productDailyRetrExecutor.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (!Check.isNull(accessToken)) {
+                                cdpProjectService.getProjectList(advertiserId, null, null, null, id, null);
+                                cdpProjectService.getProjectList(advertiserId, null, "del", null, id, null);
+                            }
+                        }
+                    });
                 }
                 }