Browse Source

项目库 预审申报项目 可被提交

master
PoffyZhang 1 year ago
parent
commit
c487be156d
5 changed files with 127 additions and 1 deletions
  1. +33
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/utils/DataScopeUtil.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java
  3. +79
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  4. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java
  5. +12
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserInfoDetails.java

+ 33
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/utils/DataScopeUtil.java View File

@@ -0,0 +1,33 @@
package com.ningdatech.pmapi.datascope.utils;

import com.ningdatech.pmapi.datascope.model.DataScopeDTO;
import com.ningdatech.pmapi.datascope.provider.DataScopeContext;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;

import java.util.Objects;
import java.util.Optional;

/**
* @Classname DataScopeUtil
* @Description
* @Date 2023/3/28 16:00
* @Author PoffyZhang
*/
public class DataScopeUtil {

public static Optional<DataScopeDTO> getCurrentUserDataScope(UserInfoDetails loginUser) {
if (Objects.isNull(loginUser) || Objects.isNull(loginUser.getRoleCode())) {
return Optional.empty();
}
return DataScopeContext.getDataScope(loginUser.getRoleCode().name());
}

public static Optional<DataScopeDTO> getCurrentUserDataScope() {
UserInfoDetails loginUser = LoginUserUtil.loginUserDetail();
if (Objects.isNull(loginUser) || Objects.isNull(loginUser.getRoleCode())) {
return Optional.empty();
}
return DataScopeContext.getDataScope(loginUser.getRoleCode().name());
}
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java View File

@@ -34,7 +34,7 @@ public class ProjectLibController {
@GetMapping("/list")
@ApiOperation("项目库列表")
public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) {
return projectLibManage.projectLibList(req);
return projectLibManage.projectLibListWithPermission(req);
}

@GetMapping("/{id}")


+ 79
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

@@ -9,6 +9,8 @@ import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.common.constant.CommonConst;
import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.datascope.model.DataScopeDTO;
import com.ningdatech.pmapi.datascope.utils.DataScopeUtil;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.handle.ProcessExecuteChainHandle;
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper;
@@ -22,8 +24,11 @@ import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService;
import com.ningdatech.pmapi.projectlib.service.IProjectRenewalFundDeclarationService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@@ -43,6 +48,7 @@ import java.util.Optional;
*/
@Component
@RequiredArgsConstructor
@Slf4j
public class ProjectLibManage {

private final IProjectService projectService;
@@ -76,6 +82,37 @@ public class ProjectLibManage {
return PageVo.of(records, total);
}

public PageVo<ProjectLibListItemVO> projectLibListWithPermission(ProjectListReq req) {
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req);
UserInfoDetails userInfoDetails = buildProjectLibPermission(query);
Page<Project> page = projectService.page(req.page(), query);
long total;
if ((total = page.getTotal()) == 0) {
return PageVo.empty();
}
List<ProjectLibListItemVO> 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());
if(userInfoDetails.getIsOrgAdmin() &&
ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus())){
item.setCanPreDeclared(Boolean.TRUE);
}
return item;
});
return PageVo.of(records, total);
}

public List<Project> projectList(ProjectListReq req) {
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req);
return projectService.list(query);
@@ -159,4 +196,46 @@ public class ProjectLibManage {
excelExportWriter.setHeadPropertyFlag(Boolean.FALSE);
ExcelDownUtil.excelExportFile(response, excelExportWriter);
}

/**
* build 项目的角色权限到req
* @param query
*/
public UserInfoDetails buildProjectLibPermission(LambdaQueryWrapper<Project> query){
UserInfoDetails loginUser = LoginUserUtil.loginUserDetail();
Optional<DataScopeDTO> currentUserDataScope = DataScopeUtil.getCurrentUserDataScope(loginUser);
if(!currentUserDataScope.isPresent()){
log.warn("没有取到权限信息 当前查询 没有权限条件");
return loginUser;
}
Boolean isOrgAdmin = Boolean.FALSE;
switch (currentUserDataScope.get().getRole()){
case ORDINARY_USER:
//普通用户 只能看到自己单位去申报的
query.eq(Project::getBuildOrgCode ,loginUser.getOrganizationCode());
break;
case ORG_ADMIN:
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目
query.and(q1 -> q1.eq(Project::getBuildOrgCode ,loginUser.getOrganizationCode()).or(q2 ->
q2.eq(Project::getStage,ProjectStatusEnum.NOT_APPROVED.getCode())
.eq(Project::getStatus,ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode())
.eq(Project::getSuperOrgCode,loginUser.getOrganizationCode())));
break;
case SUPER_ADMIN:
//超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员
break;
case REGION_ADMIN:
//区域管理员 看到自己区域的项目
query.eq(Project::getAreaCode,loginUser.getRegionCode());
break;
case VISITOR:
//访客可以看全市的
break;
default:
//没有权限的话 就让它查不到
query.eq(Project::getId,"NULL");
break;
}
return loginUser;
}
}

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java View File

@@ -90,4 +90,6 @@ public class ProjectLibListItemVO {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime updateOn;

@ApiModelProperty("能否被预审申报")
private Boolean canPreDeclared = Boolean.FALSE;
}

+ 12
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserInfoDetails.java View File

@@ -14,6 +14,7 @@ import org.springframework.security.core.userdetails.UserDetails;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
@@ -113,4 +114,15 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails {
return null;
}

public Boolean getIsOrgAdmin(){
if(CollUtil.isNotEmpty(this.userRoleList)){
for(Role role : this.userRoleList){
RoleEnum roleEnum = RoleEnum.mathByName(role.getCode());
if(Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.ORG_ADMIN.name())){
return Boolean.TRUE;
}
}
}
return Boolean.FALSE;
}
}

Loading…
Cancel
Save