Przeglądaj źródła

头条日报消耗全量拉取添加错误日志保存

lining 1 rok temu
rodzic
commit
40f22f5d5e

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

@@ -2,13 +2,17 @@ package cn.com.ctop.job.bytedance.data.service.impl;
 
 import cn.com.ctop.job.bytedance.data.entity.AdvertiserAccount;
 import cn.com.ctop.job.bytedance.data.entity.ByteDanceFlowDetailsReportDaily;
+import cn.com.ctop.job.bytedance.data.entity.BytedanceErrorLog;
 import cn.com.ctop.job.bytedance.data.mapper.ByteDanceFlowDetailsReportMapper;
+import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
 import cn.com.ctop.job.bytedance.data.service.IByteDanceFlowDetailsReportService;
+import cn.com.ctop.job.bytedance.data.utils.AlertUtils;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -32,6 +36,9 @@ public class ByteDanceFlowDetailsReportServiceImpl implements IByteDanceFlowDeta
     @Resource
     private ByteDanceFlowDetailsReportMapper byteDanceFlowDetailsReportMapper;
 
+    @Autowired
+    private BytedancePromoterReportMapper promoterReportMapper;
+
     @Override
     public List<AdvertiserAccount> getAdAccount() {
         return byteDanceFlowDetailsReportMapper.getAdAccount();
@@ -116,6 +123,11 @@ public class ByteDanceFlowDetailsReportServiceImpl implements IByteDanceFlowDeta
                 }
 
             }
+        }else{
+            //增加错误日志保存
+            log.info("账户id:{},日期:{}产品数据日报请求结果失败,返回数据:{}", advertiserId, startDate, result);
+            insertErrorLog(advertiserId, startDate, endDate);
+            return;
         }
 
         if (page < totalPage) {
@@ -125,6 +137,20 @@ public class ByteDanceFlowDetailsReportServiceImpl implements IByteDanceFlowDeta
                 throw new RuntimeException(e);
             }
             getBytedanceFlowDetailsDailyReport(advertiserId, accessToken, accountType, startDate, endDate, page + 1);
+        }else{
+            log.info("账户ID:{},日期:{},流水日报详情数据日报请求成功", advertiserId, startDate);
+            //send message to feishu
+//            AlertUtils.sendMessage(advertiserId, startDate, endDate, 1, "flow_details_daily", 1,null);
         }
     }
+
+    private void insertErrorLog(Long advertiserId, String startDate, String endDate) {
+        BytedanceErrorLog errorInfo = new BytedanceErrorLog();
+        errorInfo.setAdvertiserId(advertiserId);
+        errorInfo.setStartDate(startDate);
+        errorInfo.setEndDate(endDate);
+        errorInfo.setDataDimension("flow_details");
+        errorInfo.setDataType("daily");
+        promoterReportMapper.replaceErrorInfo(errorInfo);
+    }
 }