From 0b7d80da4a53024ad35fdd0342a5477cea05c700 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 21 Jun 2022 16:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E5=9B=BE=E6=95=B0=E6=8D=AE=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=80=BB=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusControllerV2.java | 152 ++++++++++++++++++ .../common/domain/Tsingtao_xhaProperties.java | 2 + .../resources/domain/tsingtao-xha.properties | 4 +- 3 files changed, 157 insertions(+), 1 deletion(-) 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 dcbe6ea6..693293ce 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 @@ -395,4 +395,156 @@ public class CensusControllerV2 { return new Result().ok(result); } + + @GetMapping("/dataResourceInfo") + @ApiOperation("数据资源简况") + @LogOperation("数据资源简况") + public Result>> dataResourceInfo() { + List> result = new CopyOnWriteArrayList<>(); + CompletableFuture allAmount = null; + CompletableFuture applyInfo = null; // 申请情况 + switch (Constant.ProjectPlace.getByFlag(projectPlace)) { + case BAOTOU: { // TODO 包头 + result.add(new HashMap() { + { + put("amount", 0L); + put("type", "总数据量"); + } + }); + result.add(new HashMap() { + { + put("amount", 0l); + put("type", "总申请次数"); + } + }); + result.add(new HashMap() { + { + put("amount", 1); + put("type", "满足率"); + } + }); + result.add(new HashMap() { + { + put("resourceTop5", new ArrayList<>()); + } + }); + } + break; + case TSINGTAO: { // TODO 青岛大数据局 + result.add(new HashMap() { + { + put("amount", 0L); + put("type", "总数据量"); + } + }); + result.add(new HashMap() { + { + put("amount", 0l); + put("type", "总申请次数"); + } + }); + result.add(new HashMap() { + { + put("amount", 1); + put("type", "满足率"); + } + }); + result.add(new HashMap() { + { + put("resourceTop5", new ArrayList<>()); + } + }); + } + 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("包头获取失败"); + } + } catch (Exception exception) { + logger.error("包头失败", exception); + } + return total; + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "总数据量"); + } + }); + }); // 处理总数目 + + 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("包头获取失败"); + } + } 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/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java index 7061fc43..49522ae2 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -18,4 +18,6 @@ public class Tsingtao_xhaProperties { private String localhls; private String cloudcam; private String localcam; + private String resourcecount; + private String resourceapplyinfo; } diff --git a/renren-admin/src/main/resources/domain/tsingtao-xha.properties b/renren-admin/src/main/resources/domain/tsingtao-xha.properties index d62ea6cc..969361b4 100644 --- a/renren-admin/src/main/resources/domain/tsingtao-xha.properties +++ b/renren-admin/src/main/resources/domain/tsingtao-xha.properties @@ -1,4 +1,6 @@ tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls tsingtao-xha.localhls=http://10.134.135.9:8001/hx-weatherwarning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls tsingtao-xha.cloudcam=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10 -tsingtao-xha.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10 \ No newline at end of file +tsingtao-xha.localcam=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraListByName?name=&pageNo=1&pageSize=10 +tsingtao-xha.resourcecount=http://10.16.3.224: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 \ No newline at end of file