|
|
@@ -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; |
|
|
|
} |
|
|
|
} |