From bb8e2e575954cda7e3f350a7b520c9379c1e3700 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Fri, 24 Jun 2022 15:01:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A5=BF=E6=B5=B7=E5=B2=B8=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusControllerV2.java | 59 ++++++------------- 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java index 1268c4cb..867ef7d2 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusControllerV2.java @@ -291,11 +291,11 @@ public class CensusControllerV2 { }); }); CompletableFuture allKnowledgeVisitsAmount = CompletableFuture.supplyAsync(() -> { // 获取平台知识库浏览量 - return jdbcTemplate.queryForObject("SELECT SUM(visits)visits FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class); + return jdbcTemplate.queryForObject("SELECT SUM(visits) visits FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class); }).thenAccept(sum -> { result.add(new HashMap() { { - put("amount", sum); + put("amount", sum == null ? 0L : sum); put("type", "知识库总浏览量"); } }); @@ -336,45 +336,22 @@ public class CensusControllerV2 { case TSINGTAO_XHA: { // 青岛西海岸 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 List result_ = new CopyOnWriteArrayList<>(); - CompletableFuture cloud = - CompletableFuture.runAsync(() -> { // 云脑专网 - OkHttpClient client = new OkHttpClient(); - String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 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 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); + OkHttpClient client = new OkHttpClient(); + String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 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); + } return result_.stream().filter(index -> index != null).findAny().orElse(0l); }).thenAccept(sum -> { result.add(new HashMap() {