From c0042b8adc3d01d88c1ea9ac5f430c6a59741e9a Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 5 Jan 2023 14:07:14 +0800 Subject: [PATCH] ... --- .../common/controller/CensusController.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 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 2368f0d6..6eb94bcc 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 @@ -719,6 +719,8 @@ public class CensusController { public Result similitudeDept() { List> resultList1 = new ArrayList<>(); List> resultList2 = new ArrayList<>(); + Long county_dept_count = 0l; + Long municipal_dept_count = 0l; try { resultList1 = CompletableFuture.supplyAsync(() -> { return (List>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{ @@ -730,12 +732,12 @@ public class CensusController { put("snapshot", true); }}); // 能力上架统计原始数据 }, executor).get(); + county_dept_count = CompletableFuture.supplyAsync(() -> sysDeptService.countByType(3), executor).get(); + municipal_dept_count = CompletableFuture.supplyAsync(() -> sysDeptService.countByType(2), executor).get(); } catch (InterruptedException e) { - logger.error("", e); - throw new RuntimeException(e); + logger.error("异步获取数据失败", e); } catch (ExecutionException e) { - logger.error("", e); - throw new RuntimeException(e); + logger.error("异步获取数据失败", e); } Integer county_apply_sum = resultList1.stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString())) @@ -748,11 +750,11 @@ public class CensusController { Integer municipal_resource_sum = resultList2.stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市上架总量 - Integer county_resource_weekly_change = 0; - Integer county_resource_month_change = 0; + Integer county_resource_weekly_change; + Integer county_resource_month_change; - Integer municipal_resource_weekly_change = 0; - Integer municipal_resource_month_change = 0; + Integer municipal_resource_weekly_change; + Integer municipal_resource_month_change; SysDateSnapshotDTO resource_weekly = sysDateSnapshotService.selectForFlag(SnapshotType.RESOURCE_WEEKLY.getFlag()); // 最近的上架周快照 SysDateSnapshotDTO resource_month = sysDateSnapshotService.selectForFlag(SnapshotType.RESOURCE_MONTH.getFlag()); // 最近的上架月快照 @@ -771,7 +773,6 @@ public class CensusController { int temp = resource_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区上架总量 county_resource_month_change = county_resource_sum - temp; - temp = resource_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市上架总量 municipal_resource_month_change = municipal_resource_sum - temp; @@ -783,17 +784,16 @@ public class CensusController { SysDateSnapshotDTO apply_weekly = sysDateSnapshotService.selectForFlag(SnapshotType.APPLY_WEEKLY.getFlag()); // 最近的申请周快照 SysDateSnapshotDTO apply_month = sysDateSnapshotService.selectForFlag(SnapshotType.APPLY_MONTH.getFlag()); // 最近的申请月快照 - Integer county_apply_weekly_change = 0; - Integer county_apply_month_change = 0; + Integer county_apply_weekly_change; + Integer county_apply_month_change; - Integer municipal_apply_weekly_change = 0; - Integer municipal_apply_month_change = 0; + Integer municipal_apply_weekly_change; + Integer municipal_apply_month_change; if (apply_weekly != null) { int temp = apply_weekly.getSnapshot().stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量 county_apply_weekly_change = county_apply_sum - temp; - temp = apply_weekly.getSnapshot().stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市申请总量 municipal_apply_weekly_change = municipal_apply_sum - temp; @@ -806,7 +806,6 @@ public class CensusController { int temp = apply_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量 county_apply_month_change = county_apply_sum - temp; - temp = apply_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString())) .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市申请总量 municipal_apply_month_change = municipal_apply_sum - temp; @@ -823,11 +822,13 @@ public class CensusController { Integer finalMunicipal_apply_weekly_change = municipal_apply_weekly_change; Integer finalMunicipal_apply_month_change = municipal_apply_month_change; Integer finalCounty_apply_month_change = county_apply_month_change; + Long finalCounty_dept_count = county_dept_count; + Long finalMunicipal_dept_count = municipal_dept_count; List> result = new ArrayList>() {{ add(new LinkedHashMap() {{ put("tip", "区市部门"); put("level", "county"); - put("dept_count", sysDeptService.countByType(3).longValue()); + put("dept_count", finalCounty_dept_count); put("apply_sum", county_apply_sum); put("resource_sum", county_resource_sum); put("resource_weekly_change", finalCounty_resource_weekly_change); @@ -838,7 +839,7 @@ public class CensusController { add(new LinkedHashMap() {{ put("tip", "市级部门"); put("level", "municipal"); - put("dept_count", sysDeptService.countByType(2).longValue()); + put("dept_count", finalMunicipal_dept_count); put("apply_sum", municipal_apply_sum); put("resource_sum", municipal_resource_sum); put("resource_weekly_change", finalMunicipal_resource_weekly_change);