From 5b66808e7c9745020608f97b42255b356ca88973 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 20 Jun 2022 09:18:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BD=BF=E7=94=A8=20CopyOnWr?= =?UTF-8?q?iteArrayList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../renren/common/controller/CensusControllerV2.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 6433763b..6ef03b50 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 @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; @@ -55,7 +56,7 @@ public class CensusControllerV2 { @GetMapping(value = "/whole_amount") @ApiOperation("平台概览") public Result>> wholeAmount() { - List> result = Collections.synchronizedList(new ArrayList<>()); + List> result = new CopyOnWriteArrayList<>(); CompletableFuture userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数 return sysUserService.countAllUser(); @@ -102,7 +103,7 @@ public class CensusControllerV2 { @ApiOperation("应用资源数量统计") @LogOperation("应用资源数量统计") public Result>> applicationNum() { - List> result = Collections.synchronizedList(new ArrayList<>()); + List> result = new CopyOnWriteArrayList<>(); CompletableFuture allApplicationAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总应用数目 return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='应用资源';", Long.class); @@ -156,7 +157,7 @@ public class CensusControllerV2 { } private List> resourceRank(Integer type) { - List> result = Collections.synchronizedList(new ArrayList<>()); + List> result; List> district = jdbcTemplate.queryForList("SELECT * FROM sys_dept WHERE type = " + type); List> listMap = district.stream().map(index -> { @@ -203,7 +204,7 @@ public class CensusControllerV2 { @ApiOperation("组件服务简况") @LogOperation("组件服务简况") public Result>> assemblerInfo() { - List> result = Collections.synchronizedList(new ArrayList<>()); + List> result = new CopyOnWriteArrayList<>(); CompletableFuture allAssemblyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总组件服务数目 return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='组件服务' AND del_flag = 0;", Long.class); }).thenAccept(sum -> { @@ -263,7 +264,7 @@ public class CensusControllerV2 { @ApiOperation("知识库简况") @LogOperation("知识库简况") public Result>> knowledgeInfo() { - List> result = Collections.synchronizedList(new ArrayList<>()); + List> result = new CopyOnWriteArrayList<>(); CompletableFuture allKnowledgeAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总知识库数目 return jdbcTemplate.queryForObject("SELECT COUNT(id) FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class); }).thenAccept(sum -> {