From b279459972849640c9650940eb5e4b71a8e984e6 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Fri, 24 Jun 2022 15:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A5=BF=E6=B5=B7=E5=B2=B8=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=B0=83=E6=95=B4=E4=B8=BA=E7=8E=B0=E5=9C=BA?= =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusControllerV2.java | 132 +++++++----------- .../resources/domain/tsingtao-xha.properties | 2 +- 2 files changed, 55 insertions(+), 79 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 867ef7d2..e9efe1a4 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 @@ -437,93 +437,69 @@ public class CensusControllerV2 { } break; case TSINGTAO_XHA: { // 青岛西海岸 - allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台数据资源总数目 - OkHttpClient client = new OkHttpClient(); - Long total = 0L; - Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build(); - try (Response response = client.newCall(request).execute()) { - if (response.isSuccessful()) { - JSONObject jsonObject = JSON.parseObject(response.body().string()); - if (jsonObject.containsKey("data")) { - total = jsonObject.getJSONObject("data").getLongValue("total"); - } - } else { - logger.error("青岛西海岸获取失败"); + OkHttpClient client = new OkHttpClient(); + Long total = 0L; + Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build(); + try (Response response = client.newCall(request).execute()) { + if (response.isSuccessful()) { + JSONObject jsonObject = JSON.parseObject(response.body().string()); + if (jsonObject.containsKey("data")) { + total = jsonObject.getJSONObject("data").getLongValue("total"); + Long finalTotal = total; + result.add(new HashMap() { + { + put("amount", finalTotal); + put("type", "总数据量"); + } + }); } - } catch (Exception exception) { - logger.error("青岛西海岸失败", exception); + } else { + logger.error("青岛西海岸获取失败"); } - return total; - }).thenAccept(sum -> { - result.add(new HashMap() { - { - put("amount", sum); - put("type", "总数据量"); - } - }); - }); // 处理总数目 + } catch (Exception exception) { + logger.error("青岛西海岸失败", exception); + } - applyInfo = CompletableFuture.runAsync(() -> { - OkHttpClient client = new OkHttpClient(); - Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build(); - try (Response response = client.newCall(request).execute()) { - if (response.isSuccessful()) { - JSONObject jsonObject = JSON.parseObject(response.body().string()); - if (jsonObject.containsKey("data")) { - result.add(new HashMap() { - { - put("amount", jsonObject.getJSONObject("data").getLongValue("requestCount")); - put("type", "总申请次数"); - } - }); - result.add(new HashMap() { - { - put("amount", jsonObject.getJSONObject("data").getIntValue("satisfactionRate")); - put("type", "满足率"); - } - }); - result.add(new HashMap() { - { - put("resourceTop5", jsonObject.getJSONObject("data").getJSONArray("resourceTop5").stream().map(index -> (JSONObject) JSON.toJSON(index)).map(index -> new HashMap() { - { - put("服务名称", index.getString("service_name")); - put("申请次数", index.getLongValue("count")); - } - }).collect(Collectors.toList())); - } - }); - } - } else { - logger.error("青岛西海岸获取失败"); + OkHttpClient client1 = new OkHttpClient(); + Request request1 = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build(); + try (Response response = client1.newCall(request1).execute()) { + if (response.isSuccessful()) { + JSONObject jsonObject = JSON.parseObject(response.body().string()); + if (jsonObject.containsKey("data")) { + result.add(new HashMap() { + { + put("amount", jsonObject.getJSONObject("data").getLongValue("requestCount")); + put("type", "总申请次数"); + } + }); + result.add(new HashMap() { + { + put("amount", jsonObject.getJSONObject("data").getIntValue("satisfactionRate")); + put("type", "满足率"); + } + }); + result.add(new HashMap() { + { + put("resourceTop5", jsonObject.getJSONObject("data").getJSONArray("resourceTop5").stream().map(index -> (JSONObject) JSON.toJSON(index)).map(index -> new HashMap() { + { + put("服务名称", index.getString("service_name")); + put("申请次数", index.getLongValue("count")); + } + }).collect(Collectors.toList())); + } + }); + } - } catch (Exception exception) { - logger.error("青岛西海岸失败", exception); + } else { + logger.error("青岛西海岸获取失败"); } - }); + } catch (Exception exception) { + logger.error("青岛西海岸失败", exception); + } } break; } - if (allAmount == null) { - allAmount = CompletableFuture.runAsync(() -> { - try { - Thread.sleep(100l); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - }); - } - if (applyInfo == null) { - applyInfo = CompletableFuture.runAsync(() -> { - try { - Thread.sleep(100l); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - }); - } - CompletableFuture all = CompletableFuture.allOf(allAmount, applyInfo); - all.join(); return new Result().ok(result); } diff --git a/renren-admin/src/main/resources/domain/tsingtao-xha.properties b/renren-admin/src/main/resources/domain/tsingtao-xha.properties index bd3d41d2..25eef1ce 100644 --- a/renren-admin/src/main/resources/domain/tsingtao-xha.properties +++ b/renren-admin/src/main/resources/domain/tsingtao-xha.properties @@ -3,5 +3,5 @@ tsingtao-xha.localhls=http://10.134.135.9:8001/hx-weatherwarning/camera/getCamer tsingtao-xha.cloudcam=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraListByName?name=%s&pageNo=%d&pageSize=%d tsingtao-xha.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=%s&pageNo=%d&pageSize=%d tsingtao-xha.resourcecount=http://10.10.30.24:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=&type=&orderField=requestNum&orderType=desc&pageNum=1&pageSize=10&serviceType=data&rq=1655106309671.43 -tsingtao-xha.resourceapplyinfo=http://10.134.135.24:30058/shareportal/platform/index/abilityMarket/count +tsingtao-xha.resourceapplyinfo=http://10.10.30.24:30058/share-portal/platform/index/abilityMarket/count tsingtao-xha.sjzy=http://10.10.30.24:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=%s&type=&orderField=%s&orderType=%s&pageNum=%s&pageSize=%s&serviceType=data&rq=1655106309671.43 \ No newline at end of file