Procházet zdrojové kódy

Merge #76 into master from pingkang

fix

* pingkang: (3 commits)
  promotion daily
  fix
  fix

Signed-off-by: 黄平康 <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>
Merged-by: 黄平康 <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>

CR-link: https://codeup.aliyun.com/60c06368dbbed34fe0f0c263/job/hr_job-bytedance/change/76
huangpingkang před 1 rokem
rodič
revize
1cd78af7a8

+ 15 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java

@@ -330,6 +330,21 @@ public class BytedanceController {
         }
     }
 
+    @GetMapping("/promoterDaily")
+    public void promoterDaily(@RequestParam(required = false) Long advertiserId, String startDate, String endDate) {
+        List<JSONObject> costAccount = productReportService.getCostAccount(advertiserId, startDate, endDate);
+        for (JSONObject jsonObject : costAccount) {
+            executor10Service1.submit(() -> {
+                Long adverId = jsonObject.getLong("advertiserId");
+                String accessToken = jsonObject.getString("accessToken");
+                promoterReportService.getBytedancePromoterDaily(adverId, accessToken, startDate, endDate, 1, 1);
+            });
+        }
+    }
+
+
+
+
 
     @GetMapping("/getWxAppInfo")
     public void getWxAppInfo(Long advertiserId) {

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

@@ -19,6 +19,8 @@ public interface BytedancePromoterReportMapper {
 
     void deleteInfoByErrorId(@Param("errorId") Long errorId);
 
+    void updateStatusByErrorId(@Param("errorId") Long errorId);
+
     void replacePromoterReportDailies(@Param("list") List<BytedancePromoterReportDaily> promoterReportDailies);
     @DS("sd_group_commit")
     void replacePromoterReportDailiesSD(@Param("list") List<BytedancePromoterReportDaily> promoterReportDailies);

+ 6 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedancePromoterReportMapper.xml

@@ -1,6 +1,11 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper">
+    <update id="updateStatusByErrorId">
+        update bytedance_error_log
+        set error_status = 1
+        WHERE id = #{errorId}
+    </update>
     <delete id="deleteInfoByErrorId">
         DELETE
         FROM bytedance_error_log
@@ -12,6 +17,7 @@
         FROM bytedance_error_log t1
                  LEFT JOIN deepthink.bytedance_advertiser_list t2 ON t1.advertiser_id = t2.advertiser_id
                  LEFT JOIN deepthink.bytedance_auth_list t3 ON t2.admin_advertiser_id = t3.admin_advertiser_id
+        where t1.error_status = 0 or t1.update_time &lt;= date_add(now(),interval -1 hour )
     </select>
 
     <select id="getListBydate" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Integer">

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

@@ -143,6 +143,7 @@ public class BytedanceMiniAppServiceImpl implements IBytedanceMiniAppService {
                     JSONArray content = new JSONArray();
                     if (!Check.isNull(jsonObject)) {
                         Integer code = jsonObject.getInteger("err_no");
+                        String errMsg = jsonObject.getString("err_msg");
                         if (code == 0) {
                             JSONObject data = jsonObject.getJSONObject("data");
 
@@ -164,7 +165,9 @@ public class BytedanceMiniAppServiceImpl implements IBytedanceMiniAppService {
                             }
                         } else {
                             log.error("[{}]抖小ma_ecpm拉取失败{}~{},返回信息:{}", appId, startEventTime, endEventTime, s);
-                            insertErrorLog(isLog, startEventTime, endTime, "ma_ecpm:" + appId, "daily", s);
+                            if (errMsg == null || !errMsg.contains("access_token")) {
+                                insertErrorLog(isLog, startEventTime, endTime, "ma_ecpm:" + appId, "daily", s);
+                            }
                             return;
                         }
                     } else {

+ 18 - 3
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceReportRetryJob.java

@@ -3,6 +3,7 @@ package cn.com.ctop.job.bytedance.handler;
 
 import cn.com.ctop.job.bytedance.config.DianZhongConfig;
 import cn.com.ctop.job.bytedance.data.enums.AccountTypeEnum;
+import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
 import cn.com.ctop.job.bytedance.data.service.*;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import com.alibaba.fastjson.JSONObject;
@@ -59,6 +60,9 @@ public class BytedanceReportRetryJob {
     @Resource
     private DianZhongConfig dianZhongConfig;
 
+    @Autowired
+    private BytedancePromoterReportMapper promoterReportMapper;
+
 
     private static ExecutorService hourAccountRetrExecutorService = Executors.newFixedThreadPool(2);
     private static ExecutorService dailyAccountRetrExecutorService = Executors.newFixedThreadPool(2);
@@ -67,6 +71,7 @@ public class BytedanceReportRetryJob {
     private static ExecutorService hourPromoterRetrExecutorService = Executors.newFixedThreadPool(2);
 
     private static ExecutorService productDailyRetrExecutor = Executors.newFixedThreadPool(2);
+    private static ExecutorService materialRetrExecutor = Executors.newFixedThreadPool(3);
 
     private static ExecutorService flowDailyRetrExecutor = Executors.newFixedThreadPool(2);
     private static ExecutorService changduExecutorService = Executors.newFixedThreadPool(1);
@@ -93,6 +98,7 @@ public class BytedanceReportRetryJob {
                             @Override
                             public void run() {
                                 if (!Check.isNull(accessToken)) {
+                                    promoterReportMapper.updateStatusByErrorId(id);
                                     promoterReportService.getBytedanceRetryPromoterHourReport(id, advertiserId, accessToken, startDate, endDate, 1, isSend);
                                 }
                             }
@@ -103,6 +109,7 @@ public class BytedanceReportRetryJob {
                             @Override
                             public void run() {
                                 if (!Check.isNull(accessToken)) {
+                                    promoterReportMapper.updateStatusByErrorId(id);
                                     promoterReportService.getBytedancePromoterRetryDailyReport(id, advertiserId, accessToken, startDate, endDate, 1, isSend);
 
                                 }
@@ -114,6 +121,7 @@ public class BytedanceReportRetryJob {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
+                                promoterReportMapper.updateStatusByErrorId(id);
                                 productReportService.getBytedanceProductDailyReport(advertiserId, accessToken, startDate, endDate, 1, id, null, isSend);
                             }
                         }
@@ -124,6 +132,7 @@ public class BytedanceReportRetryJob {
                             @Override
                             public void run() {
                                 if (!Check.isNull(accessToken)) {
+                                    promoterReportMapper.updateStatusByErrorId(id);
                                     accountReportService.getBytedanceRetryAccountHourReport(id, advertiserId, accessToken, startDate, endDate, 1, isSend);
                                 }
                             }
@@ -135,6 +144,7 @@ public class BytedanceReportRetryJob {
                             @Override
                             public void run() {
                                 if (!Check.isNull(accessToken)) {
+                                    promoterReportMapper.updateStatusByErrorId(id);
                                     accountReportService.getBytedanceRetryAccountDailyReport(id, advertiserId, accessToken, startDate, endDate, 1, isSend);
                                 }
                             }
@@ -146,14 +156,16 @@ public class BytedanceReportRetryJob {
 
                         @Override
                         public void run() {
+                            promoterReportMapper.updateStatusByErrorId(id);
                             byteDanceFlowDetailsReportService.getBytedanceFlowDetailsDailyReport(advertiserId, accessToken, AccountTypeEnum.AD.getValue(), startDate, endDate, 1, id);
                         }
                     });
                 } else if ("material".equals(dataDimension)) {
-                    productDailyRetrExecutor.submit(new Runnable() {
+                    materialRetrExecutor.submit(new Runnable() {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
+                                promoterReportMapper.updateStatusByErrorId(id);
                                 bytedanceMaterialReportService.getBytedanceMaterialDailyReport(advertiserId, accessToken, startDate, endDate, 1, id, null, isSend, 1);
                             }
                         }
@@ -164,10 +176,11 @@ public class BytedanceReportRetryJob {
                     if (msgObject != null && msgObject.getJSONArray("material_ids") != null) {
                         materialIds.addAll(msgObject.getJSONArray("material_ids").toJavaList(Long.class));
                     }
-                    productDailyRetrExecutor.submit(new Runnable() {
+                    materialRetrExecutor.submit(new Runnable() {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
+                                promoterReportMapper.updateStatusByErrorId(id);
                                 bytedanceMaterialReportService.getBytedanceMaterialVideo(advertiserId, materialIds, accessToken, startDate, endDate, 1, id, null, isSend, 1);
                             }
                         }
@@ -177,6 +190,7 @@ public class BytedanceReportRetryJob {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
+                                promoterReportMapper.updateStatusByErrorId(id);
                                 cdpProjectService.getPromotionList(advertiserId, null, null, id, null);
                             }
                         }
@@ -186,6 +200,7 @@ public class BytedanceReportRetryJob {
                         @Override
                         public void run() {
                             if (!Check.isNull(accessToken)) {
+                                promoterReportMapper.updateStatusByErrorId(id);
                                 cdpProjectService.getProjectList(advertiserId, null, null, null, id, null);
                                 cdpProjectService.getProjectList(advertiserId, null, "del", null, id, null);
                             }
@@ -242,7 +257,7 @@ public class BytedanceReportRetryJob {
                     changduExecutorService.submit(new Runnable() {
                         @Override
                         public void run() {
-                            miniAppService.getMaEcpm(startDate, endDate, appId, 1, id, isSend);
+                            miniAppService.getMaEcpm(startDate, endDate, appId, 0, id, isSend);
                         }
                     });
                 }