From 633a1316194c8b6a23bda8864ed7b49fabc5233a Mon Sep 17 00:00:00 2001 From: wangliwen Date: Sun, 19 Jun 2022 14:36:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=9C=8D=E5=8A=A1=E3=80=81?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93=20=E7=BB=9F=E8=AE=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/db/V1.3__resource_attr_index.sql | 3 + .../common/controller/CensusControllerV2.java | 91 +++++++++++++++++++ .../db/V1.3__resource_attr_index.sql | 3 + 3 files changed, 97 insertions(+) create mode 100644 config/db/V1.3__resource_attr_index.sql create mode 100644 renren-admin/src/main/resources/db/V1.3__resource_attr_index.sql diff --git a/config/db/V1.3__resource_attr_index.sql b/config/db/V1.3__resource_attr_index.sql new file mode 100644 index 00000000..e4cf75a9 --- /dev/null +++ b/config/db/V1.3__resource_attr_index.sql @@ -0,0 +1,3 @@ +ALTER TABLE `share_platform`.`tb_data_attr` +ADD INDEX `resource_id`(`data_resource_id`), +ADD FULLTEXT INDEX `attr_value`(`attr_type`, `attr_value`); \ No newline at end of file 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 aba43f78..fb75b0c2 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 @@ -198,4 +198,95 @@ public class CensusControllerV2 { return result; } + + @GetMapping("/assemblerInfo") + @ApiOperation("组件服务简况") + @LogOperation("组件服务简况") + public Result>> assemblerInfo() { + List> result = Collections.synchronizedList(new ArrayList<>()); + CompletableFuture allAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总组件服务数目 + return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='组件服务' AND del_flag = 0;", Long.class); + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "上架总数"); + } + }); + }); + CompletableFuture aiAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台智能算法组件服务数目 + return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '智能算法' AND attr_type = '组件类型')", Long.class); + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "智能算法"); + } + }); + }); + CompletableFuture gisAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台图层服务组件服务数目 + return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '图层服务' AND attr_type = '组件类型')", Long.class); + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "图层服务"); + } + }); + }); + CompletableFuture busAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台业务组件组件服务数目 + return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '业务组件' AND attr_type = '组件类型')", Long.class); + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "业务组件"); + } + }); + }); + CompletableFuture devAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台业务组件组件服务数目 + return jdbcTemplate.queryForObject("SELECT COUNT(DISTINCT tb_data_resource.id) FROM tb_data_resource WHERE tb_data_resource.del_flag = 0 AND EXISTS(SELECT tb_data_attr.id FROM tb_data_attr WHERE tb_data_attr.data_resource_id = tb_data_resource.id AND tb_data_attr.attr_value = '开发组件' AND attr_type = '组件类型')", Long.class); + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "开发组件"); + } + }); + }); + CompletableFuture all = CompletableFuture.allOf(allAssemblyAmount, aiAssemblyAmount, gisAssemblyAmount, busAssemblyAmount, devAssemblyAmount); + all.join(); + return new Result().ok(result); + } + + @GetMapping("/knowledgeInfo") + @ApiOperation("知识库简况") + @LogOperation("知识库简况") + public Result>> knowledgeInfo() { + List> result = Collections.synchronizedList(new ArrayList<>()); + CompletableFuture allKnowledgeAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总知识库数目 + return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class); + }).thenAccept(sum -> { + result.add(new HashMap() { + { + put("amount", sum); + put("type", "知识库上架总量"); + } + }); + }); + CompletableFuture allKnowledgeVisitsAmount = CompletableFuture.supplyAsync(() -> { // 获取平台知识库浏览量 + 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("type", "知识库总浏览量"); + } + }); + }); + CompletableFuture all = CompletableFuture.allOf(allKnowledgeAmount, allKnowledgeVisitsAmount); + all.join(); + return new Result().ok(result); + } + } diff --git a/renren-admin/src/main/resources/db/V1.3__resource_attr_index.sql b/renren-admin/src/main/resources/db/V1.3__resource_attr_index.sql new file mode 100644 index 00000000..e4cf75a9 --- /dev/null +++ b/renren-admin/src/main/resources/db/V1.3__resource_attr_index.sql @@ -0,0 +1,3 @@ +ALTER TABLE `share_platform`.`tb_data_attr` +ADD INDEX `resource_id`(`data_resource_id`), +ADD FULLTEXT INDEX `attr_value`(`attr_type`, `attr_value`); \ No newline at end of file