diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java index ef89a5e..2359e52 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java @@ -191,10 +191,10 @@ public class ProjectLibManage { List fundDeclarations = renewalMap.get(w.getId()); if (fundDeclarations != null) { item.setAnnualAccumulateAmount(computeAmount(totalAnnualPaymentAmount, fundDeclarations)); - item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, fundDeclarations)); + item.setAnnualAccumulateAmountList(convertAccumulate(w, totalAnnualPaymentAmount, fundDeclarations)); } else { item.setAnnualAccumulateAmount(totalAnnualPaymentAmount); - item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, Collections.emptyList())); + item.setAnnualAccumulateAmountList(convertAccumulate(w, totalAnnualPaymentAmount, Collections.emptyList())); } return item; }); @@ -256,10 +256,10 @@ public class ProjectLibManage { List fundDeclarations = renewalMap.get(w.getId()); if (fundDeclarations != null) { item.setAnnualAccumulateAmount(computeAmount(totalAnnualPaymentAmount, fundDeclarations)); - item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, fundDeclarations)); + item.setAnnualAccumulateAmountList(convertAccumulate(w, totalAnnualPaymentAmount, fundDeclarations)); } else { item.setAnnualAccumulateAmount(totalAnnualPaymentAmount); - item.setAnnualAccumulateAmountList(convertAccmulate(w, totalAnnualPaymentAmount, Collections.emptyList())); + item.setAnnualAccumulateAmountList(convertAccumulate(w, totalAnnualPaymentAmount, Collections.emptyList())); } return item; }); @@ -295,8 +295,8 @@ public class ProjectLibManage { Map> map = Maps.newHashMap(); Map userMap = Maps.newHashMap(); if (CollUtil.isNotEmpty(tasks)) { - map = tasks.stream().collect(Collectors.groupingBy(Task::getProcessInstanceId)); - userMap = searchUser(tasks, userInfoHelper); + map = CollUtils.group(tasks, Task::getProcessInstanceId); + userMap = searchUser(tasks); } List records = Lists.newArrayList(); @@ -345,18 +345,19 @@ public class ProjectLibManage { return Collections.emptyList(); } - private Map searchUser(List tasks, UserInfoHelper userInfoHelper) { + private Map searchUser(List tasks) { if (CollUtil.isEmpty(tasks)) { return Collections.emptyMap(); } - Set userIds = tasks.stream().filter(w -> NumberUtil.isNumber(w.getAssignee())) + Set userIds = tasks.stream() + .filter(w -> NumberUtil.isNumber(w.getAssignee())) .map(w -> Long.parseLong(w.getAssignee())) .collect(Collectors.toSet()); if (userIds.isEmpty()) { return Collections.emptyMap(); } List users = userInfoHelper.listUserFullInfoByUserIds(userIds); - return users.stream().collect(Collectors.toMap(UserFullInfoDTO::getUserId, u -> u)); + return CollUtils.listToMap(users, UserFullInfoDTO::getUserId); } private Map> getProjectTags(Collection projectCodes) { @@ -530,17 +531,25 @@ public class ProjectLibManage { .map(ProjectPO::getInstCode) .filter(StringUtils::isNotBlank) .collect(Collectors.toSet()); - List tasks = taskService.createTaskQuery() - .processInstanceIdIn(instCodes) - .orderByTaskCreateTime() - .asc() - .list(); - Map> map = Maps.newHashMap(); - Map userMap = Maps.newHashMap(); + List tasks; + if (!instCodes.isEmpty()) { + tasks = taskService.createTaskQuery() + .processInstanceIdIn(instCodes) + .orderByTaskCreateTime() + .asc() + .list(); + } else { + tasks = Collections.emptyList(); + } + + Map> map; + Map userMap; if (CollUtil.isNotEmpty(tasks)) { - map = tasks.stream() - .collect(Collectors.groupingBy(Task::getProcessInstanceId)); - userMap = searchUser(tasks, userInfoHelper); + map = CollUtils.group(tasks, Task::getProcessInstanceId); + userMap = searchUser(tasks); + } else { + map = Collections.emptyMap(); + userMap = Collections.emptyMap(); } List records = Lists.newArrayList(); @@ -601,7 +610,7 @@ public class ProjectLibManage { return annualAmounts; } - public static List convertAccmulate(Project project, BigDecimal totalAnnualPlanAmount, List prfs) { + public static List convertAccumulate(Project project, BigDecimal totalAnnualPlanAmount, List prfs) { List annualAmounts = Lists.newArrayList(); annualAmounts.add(AnnualAmountVO.builder() .projectId(project.getId()) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java index eafef9c..392b83e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java @@ -187,10 +187,10 @@ public class ProjectRenewalFundManage { if (finalRenewalMap.containsKey(item.getId())) { List prfs = finalRenewalMap.get(item.getId()); item.setAnnualAccumulateAmount(ProjectLibManage.computeAmount(totalAnnualPaymentAmount, prfs)); - item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccmulate(w, totalAnnualPaymentAmount, prfs)); + item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccumulate(w, totalAnnualPaymentAmount, prfs)); } else { item.setAnnualAccumulateAmount(totalAnnualPaymentAmount); - item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccmulate(w, totalAnnualPaymentAmount, Collections.emptyList())); + item.setAnnualAccumulateAmountList(ProjectLibManage.convertAccumulate(w, totalAnnualPaymentAmount, Collections.emptyList())); } return item; }); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectInstService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectInstService.java index ba0ed70..74eda61 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectInstService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectInstService.java @@ -1,10 +1,14 @@ package com.hz.pm.api.projectlib.service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.IService; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.projectlib.model.entity.ProjectInst; +import java.util.Collection; +import java.util.List; + /** *

* 服务类 @@ -21,4 +25,11 @@ public interface IProjectInstService extends IService { .last(BizConst.LIMIT_1)); } + default List listByProjectIds(Collection projectIds) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIds) + .orderByDesc(ProjectInst::getProjectId); + return list(query); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java index fc982b0..46c12f2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java @@ -167,13 +167,9 @@ public class TodoCenterManage { if (CollUtil.isEmpty(projects)) { return PageVo.empty(); } - Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); - // 再查出项目关联的流程实例ID - List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + Map projectsMap = CollUtils.listToMap(projects, Project::getId); - List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) - .in(ProjectInst::getProjectId, projectIdList) - .orderByDesc(ProjectInst::getProjectId)); + List projectInstList = projectInstService.listByProjectIds(projectsMap.keySet()); Map projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java index a6a0b1e..88ddc2e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java @@ -1,6 +1,7 @@ package com.hz.pm.api.user.manage; import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -100,7 +101,7 @@ public class MhUnitManage { List selectedUnits = new ArrayList<>(); if (req.getId() != null) { // 查询单位 - LambdaQueryWrapper unitQuery = Wrappers.lambdaQuery(MhUnit.class) + Wrapper unitQuery = Wrappers.lambdaQuery(MhUnit.class) .select(MhUnit::getId) .like(StrUtils.isNotBlank(req.getName()), MhUnit::getName, req.getName()) .eq(MhUnit::getParentId, req.getId()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java index 876edad..2a80574 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java @@ -34,7 +34,6 @@ import com.hz.pm.api.user.util.LoginUserUtil; import com.hz.pm.api.workbench.converter.WorkbenchConverter; import com.hz.pm.api.workbench.model.vo.WorkbenchVO; import com.hz.pm.api.workbench.model.vo.WorkbenchVO.WarningStatistics; -import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.StrPool; @@ -106,7 +105,7 @@ public class WorkbenchManage { todoCenterStat.setTodoList(todoList); res.setTodoCerter(todoCenterStat); stopWatch.stop(); - log.info("待办中心数据 耗时,{} s", stopWatch.getTotalTimeSeconds()); + log.info("待办中心数据 耗时,{} s", stopWatch.getLastTaskTimeMillis()); }, ForkJoinPool.commonPool()), CompletableFuture.runAsync(() -> { StopWatch stopWatch = new StopWatch(); @@ -115,14 +114,14 @@ public class WorkbenchManage { //2.项目统计数据 res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year, user), defaultDeclaredProjectManage.declaredProjectOrgStatistics(year - 1, user))); - if (userInfoHelper.isSuperOrRegionAdmin(user.getUserId())) { + if (user.getSuperAdmin() || user.getRegionAdmin()) { res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year, user), defaultDeclaredProjectManage.declaredProjectRegionStatistics(year - 1, user))); } else { res.setRegionDeclared(new WorkbenchVO.DeclaredStatistics()); } stopWatch.stop(); - log.info("项目统计数据 耗时,{} s", stopWatch.getTotalTimeSeconds()); + log.info("项目统计数据 耗时,{} s", stopWatch.getTotalTimeMillis()); }, ForkJoinPool.commonPool()), CompletableFuture.runAsync(() -> { StopWatch stopWatch = new StopWatch();