From 3c26501e07cf08451d089bc99a31c1338dc517c8 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 6 Apr 2023 15:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E5=AE=A1=E5=88=97=E8=A1=A8=20?= =?UTF-8?q?=E7=94=B3=E6=8A=A5=E5=8D=95=E4=BD=8D=20=E4=B9=9F=E8=A6=81?= =?UTF-8?q?=E5=8F=AF=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PrequalificationDeclaredController.java | 2 +- .../PrequalificationDeclaredProjectManage.java | 88 +++++++++++++++++++--- .../pmapi/projectlib/manage/ProjectLibManage.java | 2 +- 3 files changed, 78 insertions(+), 14 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java index 78bdd25..4828dca 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PrequalificationDeclaredController.java @@ -36,7 +36,7 @@ public class PrequalificationDeclaredController { @ApiOperation(value = "可预审申报项目列表", notes = "可预审申报项目列表") @GetMapping("/list") public PageVo list(@Validated @ModelAttribute PrequalificationDeclaredListReq preReq) { - return prequalificationDeclaredProjectManage.projectLibList(preReq); + return prequalificationDeclaredProjectManage.pageInfo(preReq); } @ApiOperation(value = "申报预审", notes = "申报预审") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java index 1457c1c..c55a5ee 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java @@ -1,18 +1,23 @@ package com.ningdatech.pmapi.projectdeclared.manage; +import cn.hutool.core.collection.CollUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelExportStyle; +import com.ningdatech.pmapi.datascope.model.DataScopeDTO; +import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; import com.ningdatech.pmapi.projectdeclared.model.dto.PretrialDeclaredExportDTO; import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; @@ -40,16 +45,14 @@ import com.wflow.workflow.service.ProcessInstanceService; import com.wflow.workflow.service.ProcessModelService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -69,8 +72,6 @@ public class PrequalificationDeclaredProjectManage { private final IProjectStagingService projectStagingService; - private final ProjectLibManage projectLibManage; - private final UserInfoHelper userInfoHelper; private final ProcessModelService processModelService; @@ -227,7 +228,7 @@ public class PrequalificationDeclaredProjectManage { * @param preReq * @return */ - public PageVo projectLibList(PrequalificationDeclaredListReq preReq) { + public PageVo pageInfo(PrequalificationDeclaredListReq preReq) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); if(!user.getIsOrgAdmin()){ @@ -239,10 +240,73 @@ public class PrequalificationDeclaredProjectManage { //项目阶段 状态 已定 待预审 req.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); req.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); + LambdaQueryWrapper query = ProjectHelper.projectQuery(req); + buildPermission(query,user); + Page page = projectService.page(req.page(), query); + long total; + if ((total = page.getTotal()) == 0) { + return PageVo.empty(); + } + List records = CollUtils.convert(page.getRecords(), w -> { + ProjectLibListItemVO item = new ProjectLibListItemVO(); + item.setId(w.getId()); + item.setProjectName(w.getProjectName()); + item.setCreateOn(w.getCreateOn()); + item.setDeclaredAmount(w.getDeclareAmount()); + item.setStage(w.getStage()); + item.setStatus(w.getStatus()); + item.setProjectType(w.getProjectType()); + item.setProjectYear(w.getProjectYear()); + item.setBuildOrg(w.getBuildOrgName()); + item.setBizDomain(w.getBizDomain()); + item.setProcessStatus(w.getProcessStatus()); + item.setInstCode(w.getInstCode()); + item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); + if(user.getIsOrgAdmin() && + ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) + && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getOrganizationCode()) + && w.getSuperOrgCode().equals(user.getOrganizationCode())){ + item.setCanPreDeclared(Boolean.TRUE); + } + return item; + }); + return PageVo.of(records, total); + } - //放入用户的主管单位 - req.setSuperOrgCode(user.getOrganizationCode()); - return projectLibManage.projectLibList(req); + /** + * build 项目的角色权限到req + * @param query + */ + public UserFullInfoDTO buildPermission(LambdaQueryWrapper query,UserFullInfoDTO user){ + Optional currentUserDataScope = DataScopeUtil.getCurrentUserDataScope(user); + if(!currentUserDataScope.isPresent()){ + log.warn("没有取到权限信息 当前查询 没有权限条件"); + return user; + } + switch (currentUserDataScope.get().getRole()){ + //其它角色 只看自己单位 + case SUPER_ADMIN: + case REGION_MANAGER: + case VISITOR: + case DASHBOARD: + case NORMAL_MEMBER: + //普通用户 只能看到自己单位去申报的 + query.eq(Project::getBuildOrgCode ,user.getOrganizationCode()); + break; + //单位管理角色看 自己单位申报 + 需要本单位来申报的 + case COMPANY_MANAGER: + //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 + query.and(q1 -> q1.eq(Project::getBuildOrgCode ,user.getOrganizationCode()).or(q2 -> + q2.eq(Project::getStage,ProjectStatusEnum.NOT_APPROVED.getCode()) + .eq(Project::getStatus,ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) + .eq(Project::getSuperOrgCode,user.getOrganizationCode()))); + break; + default: + //没有权限的话 就让它查不到 + query.eq(Project::getId,0L); + break; + } + return user; } public void exportList(HttpServletResponse response, PrequalificationDeclaredListReq preReq) { @@ -252,9 +316,9 @@ public class PrequalificationDeclaredProjectManage { req.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); req.setStatus(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()); UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - //放入用户的单位 - req.setSuperOrgCode(user.getOrganizationCode()); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); + //角色权限 + buildPermission(query,user); List records = projectService.list(query); List collect = records.stream().map(r -> { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index add992f..d17c755 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -217,7 +217,7 @@ public class ProjectLibManage { log.warn("没有取到权限信息 当前查询 没有权限条件"); return user; } - Boolean isOrgAdmin = Boolean.FALSE; + switch (currentUserDataScope.get().getRole()){ case NORMAL_MEMBER: //普通用户 只能看到自己单位去申报的