|
|
@@ -19,6 +19,8 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
|
|
|
|
|
|
@@ -27,9 +29,12 @@ import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
|
|
|
public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
|
|
|
@Autowired
|
|
|
private AdqReportMapper adqReportMapper;
|
|
|
+ private static String sendUrl = "http://172.16.0.108:8765/webhook/media_report";
|
|
|
+ private static ExecutorService sendExecutorService = Executors.newFixedThreadPool(5);
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
- public void getCreativeHourRetry(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page) {
|
|
|
+ public void getCreativeHourRetry(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Integer isSend) {
|
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
|
paramsMap.put("access_token", accessToken);
|
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
|
@@ -83,15 +88,18 @@ public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
|
|
|
adqReportMapper.addsHourList(hourList);
|
|
|
}
|
|
|
if (totalNumber >= 1000) {
|
|
|
- getCreativeHourRetry(errorId, advertiserId, accessToken, startDate, endDate, page + 1);
|
|
|
+ getCreativeHourRetry(errorId, advertiserId, accessToken, startDate, endDate, page + 1, isSend);
|
|
|
} else {
|
|
|
log.error("请求创意时报完成,account_id:{},日期:{}", advertiserId, startDate);
|
|
|
adqReportMapper.deleteInfoByErrorId(errorId);
|
|
|
+ if (isSend == 1) {
|
|
|
+ sendMessage(advertiserId, startDate, endDate, 3, "hour", 1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getCreativeDailyRetry(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page) {
|
|
|
+ public void getCreativeDailyRetry(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Integer isSend) {
|
|
|
|
|
|
try {
|
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
|
@@ -146,13 +154,48 @@ public class AdqRetryReportServiceImpl implements IAdqRetryReportService {
|
|
|
adqReportMapper.addsDaily(dailies);
|
|
|
}
|
|
|
if (totalNumber >= 1000) {
|
|
|
- getCreativeDailyRetry(errorId, advertiserId, accessToken, startDate, endDate, page + 1);
|
|
|
+ getCreativeDailyRetry(errorId, advertiserId, accessToken, startDate, endDate, page + 1, isSend);
|
|
|
} else {
|
|
|
log.error("请求创意日报完成,account_id:{},日期:{}", advertiserId, startDate);
|
|
|
adqReportMapper.deleteInfoByErrorId(errorId);
|
|
|
+ sendMessage(advertiserId, startDate, endDate, 3, "daily", 1);
|
|
|
+ if (isSend == 1) {
|
|
|
+ sendMessage(advertiserId, startDate, endDate, 3, "daily", 1);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private static void sendMessage(Long account_id, String start_date, String end_date, Integer media_type, String type, Integer count) {
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|