From e43cc1bfdbd5f2b48f5c1a7f9f0cb4ad397339fb Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 23 Jun 2022 09:31:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A5=BF=E6=B5=B7=E5=B2=B8=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E8=AE=BE=E6=96=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/resource/service/impl/ResourceServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 369c51b9..a143a22c 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -420,8 +420,8 @@ public class ResourceServiceImpl extends CrudServiceImpl { re.add(new HashMap() { { - put("amount", sum); - put("type", "视频资源数量"); + put("count", sum + ""); + put("type", "基础设施"); } }); }); From b140d7f4d60b52e6a5ac9d9aae64fc7edf90d531 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 23 Jun 2022 10:29:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=86=85=E4=B8=8D=E9=9C=80=E7=BB=9F=E8=AE=A1=E7=9A=84=E8=B5=84?= =?UTF-8?q?=E6=BA=90=20=E6=8E=92=E9=99=A4=E6=8E=A5=E5=8F=A3=E5=87=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 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 b9be86de..203125c1 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 @@ -59,35 +59,28 @@ public class CensusController { @ApiOperation("各类资源数目") public Result>> resourceAmount() { List> dbAmount = resourceService.getAmountGroupByType(); - List temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList()); + dbAmount = dbAmount.stream().filter(index -> Arrays.asList(censusTypes).contains(index.get("type").toString())).collect(Collectors.toList()); + List> finalDbAmount = dbAmount; + + List temp = finalDbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList()); Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型 - if (index.equals("数据资源")) { - Map nullMap = new HashMap() { - { - put("amount", 10413); - put("type", "数据资源"); - } - }; - dbAmount.add(nullMap); - } else { - Map nullMap = new HashMap() { - { - put("amount", 0); - put("type", index); - } - }; - dbAmount.add(nullMap); - } + Map nullMap = new HashMap() { + { + put("amount", 0); + put("type", index); + } + }; + finalDbAmount.add(nullMap); }); - Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum(); + Long sum = finalDbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum(); Map sumMap = new HashMap() { { put("amount", sum); put("type", "资源汇聚总量"); } }; - dbAmount.add(sumMap); - return new Result>>().ok(dbAmount); + finalDbAmount.add(sumMap); + return new Result>>().ok(finalDbAmount); } @GetMapping(value = "/whole_amount")