西海岸的处理

This commit is contained in:
wangliwen 2022-06-24 15:01:40 +08:00
parent ce43a9fced
commit bb8e2e5759
1 changed files with 18 additions and 41 deletions

View File

@ -295,7 +295,7 @@ public class CensusControllerV2 {
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("amount", sum == null ? 0L : sum);
put("type", "知识库总浏览量");
}
});
@ -336,8 +336,6 @@ public class CensusControllerV2 {
case TSINGTAO_XHA: { // 青岛西海岸
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
List<Long> result_ = new CopyOnWriteArrayList<>();
CompletableFuture cloud =
CompletableFuture.runAsync(() -> { // 云脑专网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10);
logger.info(url);
@ -354,27 +352,6 @@ public class CensusControllerV2 {
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
}
});
CompletableFuture local =
CompletableFuture.runAsync(() -> { // 金宏网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getLocalcam(), "", 1, 10);
logger.info(url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
result_.add(jsonObject.getJSONObject("data").getLongValue("total"));
}
} else {
logger.error("青岛西海岸获取失败");
}
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
}
});
CompletableFuture.allOf(cloud, local);
return result_.stream().filter(index -> index != null).findAny().orElse(0l);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {