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 -> {