|
@@ -18,12 +18,16 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class BytedancePromoterReportServiceImpl implements IBytedancePromoterReportService {
|
|
public class BytedancePromoterReportServiceImpl implements IBytedancePromoterReportService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private BytedancePromoterReportMapper promoterReportMapper;
|
|
private BytedancePromoterReportMapper promoterReportMapper;
|
|
|
|
|
+ private static String sendUrl = "http://172.16.0.108:8765/webhook/media_report";
|
|
|
|
|
+ private static ExecutorService sendExecutorService = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<JSONObject> getAccountList() {
|
|
public List<JSONObject> getAccountList() {
|
|
@@ -31,7 +35,7 @@ public class BytedancePromoterReportServiceImpl implements IBytedancePromoterRep
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getBytedanceRetryPromoterHourReport(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page) {
|
|
|
|
|
|
|
+ public void getBytedanceRetryPromoterHourReport(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Integer isSend) {
|
|
|
try {
|
|
try {
|
|
|
String url = "https://api.oceanengine.com/open_api/v3.0/report/custom/get/";
|
|
String url = "https://api.oceanengine.com/open_api/v3.0/report/custom/get/";
|
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
@@ -97,10 +101,13 @@ public class BytedancePromoterReportServiceImpl implements IBytedancePromoterRep
|
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
}
|
|
|
- getBytedanceRetryPromoterHourReport(errorId, advertiserId, accessToken, startDate, endDate, page + 1);
|
|
|
|
|
|
|
+ getBytedanceRetryPromoterHourReport(errorId, advertiserId, accessToken, startDate, endDate, page + 1, isSend);
|
|
|
} else {
|
|
} else {
|
|
|
log.info("账户ID:{},日期:{},广告时报(最细粒度)数据请求成功", advertiserId, startDate);
|
|
log.info("账户ID:{},日期:{},广告时报(最细粒度)数据请求成功", advertiserId, startDate);
|
|
|
promoterReportMapper.deleteInfoByErrorId(errorId);
|
|
promoterReportMapper.deleteInfoByErrorId(errorId);
|
|
|
|
|
+ if (isSend == 1) {
|
|
|
|
|
+ sendMessage(advertiserId, startDate, endDate, 1, "hour", 1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -109,7 +116,7 @@ public class BytedancePromoterReportServiceImpl implements IBytedancePromoterRep
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getBytedancePromoterRetryDailyReport(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page) {
|
|
|
|
|
|
|
+ public void getBytedancePromoterRetryDailyReport(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Integer isSend) {
|
|
|
try {
|
|
try {
|
|
|
String url = "https://api.oceanengine.com/open_api/v3.0/report/custom/get/";
|
|
String url = "https://api.oceanengine.com/open_api/v3.0/report/custom/get/";
|
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
@@ -174,11 +181,13 @@ public class BytedancePromoterReportServiceImpl implements IBytedancePromoterRep
|
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
}
|
|
|
- getBytedancePromoterRetryDailyReport(errorId, advertiserId, accessToken, startDate, endDate, page + 1);
|
|
|
|
|
|
|
+ getBytedancePromoterRetryDailyReport(errorId, advertiserId, accessToken, startDate, endDate, page + 1, isSend);
|
|
|
} else {
|
|
} else {
|
|
|
log.info("账户ID:{},日期:{},广告日报(最细粒度)数据请求成功", advertiserId, startDate);
|
|
log.info("账户ID:{},日期:{},广告日报(最细粒度)数据请求成功", advertiserId, startDate);
|
|
|
promoterReportMapper.deleteInfoByErrorId(errorId);
|
|
promoterReportMapper.deleteInfoByErrorId(errorId);
|
|
|
-
|
|
|
|
|
|
|
+ if (isSend == 1) {
|
|
|
|
|
+ sendMessage(advertiserId, startDate, endDate, 1, "daily", 1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -390,4 +399,34 @@ public class BytedancePromoterReportServiceImpl implements IBytedancePromoterRep
|
|
|
public List<JSONObject> getAllList() {
|
|
public List<JSONObject> getAllList() {
|
|
|
return promoterReportMapper.getAllList();
|
|
return promoterReportMapper.getAllList();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|