Ver Fonte

adq产品报表

huangpingkang há 1 ano atrás
pai
commit
4c1de0aa0c

+ 2 - 2
job-adq/src/main/java/cn/com/ctop/job/adq/data/service/impl/AdqAssetReportServiceImpl.java

@@ -95,7 +95,7 @@ public class AdqAssetReportServiceImpl implements IAdqAssetReportService {
                     adqErrorLogMapper.deleteInfoByErrorId(errId);
                 }
                 if (isSend != null && isSend == 1) {
-                    AlertUtils.sendMessage(advertiserId, startDate, endDate, 3, "asset_daily", 1);
+                    AlertUtils.sendMessage(advertiserId, startDate, endDate, 3, "daily", 1, "asset");
                 }
             }
         } catch (Exception e) {
@@ -213,7 +213,7 @@ public class AdqAssetReportServiceImpl implements IAdqAssetReportService {
                         adqErrorLogMapper.deleteInfoByErrorId(errId);
                     }
                     if (isSend != null && isSend == 1) {
-                        AlertUtils.sendMessage(advertiserId, "-", "-", 3, "asset_info", 1);
+                        AlertUtils.sendMessage(advertiserId, "-", "-", 3, "daily", 1, "asset_info");
                     }
                 }
 

+ 5 - 34
job-adq/src/main/java/cn/com/ctop/job/adq/data/service/impl/AdqRetryReportServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.job.adq.data.mapper.AdqAccountReportMapper;
 import cn.com.ctop.job.adq.data.mapper.AdqCreativeReportMapper;
 import cn.com.ctop.job.adq.data.mapper.AdqErrorLogMapper;
 import cn.com.ctop.job.adq.data.service.IAdqRetryReportService;
+import cn.com.ctop.job.adq.data.utils.AlertUtils;
 import cn.com.ctop.job.adq.data.utils.Check;
 import cn.com.ctop.job.adq.data.utils.FieldsConfig;
 import cn.com.ctop.job.adq.data.utils.HttpUtils;
@@ -91,7 +92,7 @@ public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
             log.error("请求创意时报完成,account_id:{},日期:{}", advertiserId, startDate);
             adqErrorLogMapper.deleteInfoByErrorId(errorId);
             if (isSend == 1) {
-                sendMessage(advertiserId, startDate, endDate, 3, "hour", 1, "creative");
+                AlertUtils.sendMessage(advertiserId, startDate, endDate, 3, "hour", 1, "creative");
             }
         }
     }
@@ -153,7 +154,7 @@ public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
                 log.error("请求创意日报完成,account_id:{},日期:{}", advertiserId, startDate);
                 adqErrorLogMapper.deleteInfoByErrorId(errorId);
                 if (isSend == 1) {
-                    sendMessage(advertiserId, startDate, endDate, 3, "daily", 1, "creative");
+                    AlertUtils.sendMessage(advertiserId, startDate, endDate, 3, "daily", 1, "creative");
                 }
             }
         } catch (Exception e) {
@@ -216,7 +217,7 @@ public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
                 log.info("请求账户时报完成,account_id:{},日期:{}", advertiserId, startDate);
                 adqErrorLogMapper.deleteInfoByErrorId(errorId);
                 if (isSend == 1) {
-                    sendMessage(advertiserId, startDate, endDate, 3, "daily", 1, "account");
+                    AlertUtils.sendMessage(advertiserId, startDate, endDate, 3, "daily", 1, "account");
                 }
             }
         } catch (Exception e) {
@@ -278,7 +279,7 @@ public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
                 log.error("请求账户日报完成,account_id:{},日期:{}", advertiserId, startDate);
                 adqErrorLogMapper.deleteInfoByErrorId(errorId);
                 if (isSend == 1) {
-                    sendMessage(advertiserId, startDate, endDate, 3, "daily", 1, "account");
+                    AlertUtils.sendMessage(advertiserId, startDate, endDate, 3, "daily", 1, "account");
                 }
             }
         } catch (Exception e) {
@@ -286,34 +287,4 @@ public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
         }
     }
 
-
-    private static void sendMessage(Long account_id, String start_date, String end_date, Integer media_type, String type, Integer count, String dimension) {
-        if (count > 5) {
-            log.error("超过最大次数,account_id:{}", count);
-            return;
-        }
-        sendExecutorService.submit(new Runnable() {
-            @Override
-            public void run() {
-                Map<String, Object> param = new HashMap<>();
-                param.put("account_id", account_id);
-                param.put("start_date", start_date);
-                param.put("end_date", end_date);
-                param.put("media_type", media_type);
-                param.put("type", type);
-                param.put("dimension", dimension);
-                String s = HttpUtils.httpPostRequest(sendUrl, param, new HashMap<>());
-                JSONObject jsonObject = JSONObject.parseObject(s);
-                if (!Check.isNull(jsonObject)) {
-                    Integer code = jsonObject.getInteger("code");
-                    if (code == 200) {
-                        log.info("请求数据清洗服务成功,account_id:{}", account_id);
-                    } else {
-                        sendMessage(account_id, start_date, end_date, media_type, type, count + 1, dimension);
-                    }
-                }
-            }
-        });
-    }
-
 }

+ 3 - 2
job-adq/src/main/java/cn/com/ctop/job/adq/data/utils/AlertUtils.java

@@ -13,7 +13,7 @@ public class AlertUtils {
     private static final String sendUrl = "http://172.16.0.108:8765/webhook/media_report";
     private static final ExecutorService sendExecutorService = Executors.newFixedThreadPool(5);
 
-    public static void sendMessage(Long account_id, String start_date, String end_date, Integer media_type, String type, Integer count) {
+    public static void sendMessage(Long account_id, String start_date, String end_date, Integer media_type, String type, Integer count, String dimension) {
         if (count > 5) {
             log.error("超过最大次数,account_id:{}", count);
             return;
@@ -27,6 +27,7 @@ public class AlertUtils {
                 param.put("end_date", end_date);
                 param.put("media_type", media_type);
                 param.put("type", type);
+                param.put("dimension", dimension);
                 String s = HttpUtils.httpPostRequest(sendUrl, param, new HashMap<>());
                 JSONObject jsonObject = JSONObject.parseObject(s);
                 if (!Check.isNull(jsonObject)) {
@@ -34,7 +35,7 @@ public class AlertUtils {
                     if (code == 200) {
                         log.info("请求数据清洗服务成功,account_id:{}", account_id);
                     } else {
-                        sendMessage(account_id, start_date, end_date, media_type, type, count + 1);
+                        sendMessage(account_id, start_date, end_date, media_type, type, count + 1, dimension);
                     }
                 }
             }