From 39b76c5c76771d433c9214c940e176445215dcbb Mon Sep 17 00:00:00 2001 From: wangliwen Date: Wed, 11 May 2022 16:10:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E7=8A=B6=E6=80=81=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 27 ++++++++++++++++--- .../controller/ResourceMountController.java | 3 ++- .../ResourceUndercarriageListener.java | 1 + 3 files changed, 26 insertions(+), 5 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 42eac9cd..0829cf6f 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 @@ -3,6 +3,7 @@ package io.renren.common.controller; import io.renren.common.utils.Result; import io.renren.modules.resource.service.ResourceService; +import io.renren.modules.sys.service.SysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -13,10 +14,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; /** @@ -31,6 +30,8 @@ public class CensusController { @Autowired private ResourceService resourceService; + @Autowired + private SysUserService sysUserService; @Value("${census.type}") private String[] censusTypes; // 大数据局名称 @@ -65,4 +66,22 @@ public class CensusController { dbAmount.add(sumMap); return new Result>>().ok(dbAmount); } + + @GetMapping(value = "/whole_amount") + @ApiOperation("平台整体情况") + public Result>> wholeAmount() { + List> result = new ArrayList>(); + CompletableFuture resourceAmount = CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量 + List> dbAmount = resourceService.getAmountGroupByType(); + Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum(); + return sum; + }); + CompletableFuture userAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数 + return sysUserService.countAllUser(); + }); + CompletableFuture all = CompletableFuture.allOf(resourceAmount, userAmount); + all.join(); + + return new Result>>().ok(result); + } } diff --git a/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java b/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java index 4a59de53..406b7e99 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/ResourceMountController.java @@ -151,6 +151,7 @@ public class ResourceMountController { }); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); resourceService.update(dto); + logger.error(resourceDTO.get().toString()); }); logger.info("-------------------1.保存申请表单成功--------------------------"); @@ -159,7 +160,7 @@ public class ResourceMountController { processStartDTO.setBusinessKey(resourceId.toString()); processStartDTO.setProcessDefinitionKey(undercarriage_key); // 限定资源下架 ObjectMapper oMapper = new ObjectMapper(); - Map variables = oMapper.convertValue(resourceDTO, Map.class); + Map variables = oMapper.convertValue(resourceDTO.get(), Map.class); processStartDTO.setVariables(variables); ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO); logger.info("-------------------2.启动流程成功--------------------------"); diff --git a/renren-admin/src/main/java/io/renren/modules/resource/listener/ResourceUndercarriageListener.java b/renren-admin/src/main/java/io/renren/modules/resource/listener/ResourceUndercarriageListener.java index eaadd9e1..ec59eb10 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/listener/ResourceUndercarriageListener.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/listener/ResourceUndercarriageListener.java @@ -91,6 +91,7 @@ public class ResourceUndercarriageListener implements TaskListener, ExecutionLis JsonElement jsonElement = gson.toJsonTree(kv); ResourceDTO re = gson.fromJson(jsonElement, ResourceDTO.class); if (re != null) { + logger.error(kv.toString()); re.setDelFlag(ResourceEntityDelFlag.UNDERCARRIAGE.getFlag()); resourceService.update(re); logger.error("下架审批通过 资源id:" + re.getId());