From f05d6e69657838b5bc95053658492c1dd0c1e406 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 5 Jan 2023 09:44:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=87=8F=E5=B0=91=E7=8E=AF?= =?UTF-8?q?=E6=AF=94=E7=94=A8=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java index 3a3257b1..2368f0d6 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java @@ -42,6 +42,7 @@ import java.io.IOException; import java.net.URLEncoder; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.stream.Collectors; @@ -645,8 +646,8 @@ public class CensusController { // TODO 同比环比 @GetMapping("/similitude") - @ApiOperation("资源数量环比") - @LogOperation("资源数量环比") +// @ApiOperation("资源数量环比") +// @LogOperation("资源数量环比") @ApiImplicitParams({}) public Result similitude() { long countApply = tAbilityApplicationService.countApplyAll(); // 资源申请量 @@ -712,17 +713,30 @@ public class CensusController { } @GetMapping("/similitude_dept") - @ApiOperation("部门资源数量环比") - @LogOperation("部门资源数量环比") +// @ApiOperation("部门资源数量环比") +// @LogOperation("部门资源数量环比") @ApiImplicitParams({}) public Result similitudeDept() { - List> resultList1 = (List>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{ - put("snapshot", true); - }}); // 能力申请统计原始数据 - - List> resultList2 = (List>) resourceService.selectDeptDetailTypeCountList(new HashMap() {{ - put("snapshot", true); - }}); // 能力上架统计原始数据 + List> resultList1 = new ArrayList<>(); + List> resultList2 = new ArrayList<>(); + try { + resultList1 = CompletableFuture.supplyAsync(() -> { + return (List>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{ + put("snapshot", true); + }}); // 能力申请统计原始数据 + }, executor).get(); + resultList2 = CompletableFuture.supplyAsync(() -> { + return (List>) resourceService.selectDeptDetailTypeCountList(new HashMap() {{ + put("snapshot", true); + }}); // 能力上架统计原始数据 + }, executor).get(); + } catch (InterruptedException e) { + logger.error("", e); + throw new RuntimeException(e); + } catch (ExecutionException e) { + logger.error("", e); + throw new RuntimeException(e); + } Integer county_apply_sum = resultList1.stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量 @@ -813,7 +827,7 @@ public class CensusController { add(new LinkedHashMap() {{ put("tip", "区市部门"); put("level", "county"); - put("dept_count", sysDeptService.countByType(3)); + put("dept_count", sysDeptService.countByType(3).longValue()); put("apply_sum", county_apply_sum); put("resource_sum", county_resource_sum); put("resource_weekly_change", finalCounty_resource_weekly_change); @@ -824,7 +838,7 @@ public class CensusController { add(new LinkedHashMap() {{ put("tip", "市级部门"); put("level", "municipal"); - put("dept_count", sysDeptService.countByType(2)); + put("dept_count", sysDeptService.countByType(2).longValue()); put("apply_sum", municipal_apply_sum); put("resource_sum", municipal_resource_sum); put("resource_weekly_change", finalMunicipal_resource_weekly_change);