|
|
@@ -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<ProjectLibListItemVO> projectLibList(PrequalificationDeclaredListReq preReq) { |
|
|
|
public PageVo<ProjectLibListItemVO> 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<Project> query = ProjectHelper.projectQuery(req); |
|
|
|
buildPermission(query,user); |
|
|
|
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()); |
|
|
|
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<Project> query,UserFullInfoDTO user){ |
|
|
|
Optional<DataScopeDTO> 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<Project> query = ProjectHelper.projectQuery(req); |
|
|
|
//角色权限 |
|
|
|
buildPermission(query,user); |
|
|
|
List<Project> records = projectService.list(query); |
|
|
|
|
|
|
|
List<PretrialDeclaredExportDTO> collect = records.stream().map(r -> { |
|
|
|