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);