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