瀏覽代碼

项目列表增加所属领域查询

tags/24080901
WendyYang 8 月之前
父節點
當前提交
1182c0f2e8
共有 4 個文件被更改,包括 82 次插入21 次删除
  1. +57
    -14
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java
  2. +22
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java
  3. +1
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java
  4. +2
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java

+ 57
- 14
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java 查看文件

@@ -18,6 +18,8 @@ import com.hz.pm.api.common.model.constant.TypeReferenceConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.common.util.ExcelDownUtil;
import com.hz.pm.api.common.util.ExcelExportStyle;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.utils.DataScopeUtil;
import com.hz.pm.api.external.model.enumeration.MhUnitTypeEnum;
import com.hz.pm.api.projectdeclared.model.dto.*;
import com.hz.pm.api.projectdeclared.model.entity.ProjectDraft;
@@ -348,36 +350,77 @@ public class DeclaredProjectManage {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req);
// 当非预审申报的时候 是自己单位 当是预审申报的时候 要主管单位
preQuery(query, user);
if (!projectQueryPermission(query, user, req.getDeclaredUnitId())) {
return PageVo.empty();
}
query.eq(Project::getNewest, Boolean.TRUE);
Page<Project> page = projectService.page(req.page(), query);
long total;
if ((total = page.getTotal()) == 0) {
if (page.getTotal() == 0) {
return PageVo.empty();
}
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(),
w -> BeanUtil.copyProperties(w, ProjectLibListItemVO.class));
return PageVo.of(records, total);
return PageVo.of(records, page.getTotal());
}

//当非预审申报的时候 是自己单位 当是预审申报的时候 要主管单位 并且他是单位管理员
private void preQuery(LambdaQueryWrapper<Project> query, UserFullInfoDTO user) {
//如果当前登录是单位管理员
String mhUnitId = user.getMhUnitIdStr();
if (user.getIsOrgAdmin()) {
query.and(s1 -> s1.eq(Project::getSuperOrgCode, mhUnitId)
.or(q2 -> q2.eq(Project::getBuildOrgCode, mhUnitId)));
private boolean projectQueryPermission(LambdaQueryWrapper<Project> query,
UserFullInfoDTO user,
Long declaredUnitId) {
boolean queryState = true;
Optional<DataScopeDTO> currDs = DataScopeUtil.getCurrentUserDataScopeHasUserId(user);
if (!currDs.isPresent()) {
log.warn("没有取到权限信息 当前查询 没有权限条件");
queryState = false;
} else {
//否则 只能看到 非预审 并且
query.and(q2 -> q2.eq(Project::getBuildOrgCode, mhUnitId));
switch (currDs.get().getRole()) {
case NORMAL_MEMBER:
//普通用户 只能看到自己单位去申报的
query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr());
break;
case COMPANY_MANAGER: {
List<Long> childUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId());
if (declaredUnitId != null && childUnitIds.contains(declaredUnitId)
&& !Objects.equals(declaredUnitId, user.getMhUnitId())) {
childUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId);
}
List<String> viewUnitIdList = CollUtils.convert(childUnitIds, String::valueOf);
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目
query.and(q1 -> q1.in(Project::getBuildOrgCode, viewUnitIdList)
.or(q2 -> q2.eq(Project::getStage, ProjectStatus.NOT_APPROVED.getCode())
.in(Project::getSuperOrgCode, viewUnitIdList)));
}
break;
case SUPER_ADMIN: {
if (declaredUnitId != null) {
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId);
List<String> viewUnitIdList = CollUtils.convert(viewUnitIds, String::valueOf);
query.and(q1 -> q1.in(Project::getBuildOrgCode, viewUnitIdList)
.or(q2 -> q2.eq(Project::getStage, ProjectStatus.NOT_APPROVED.getCode())
.in(Project::getSuperOrgCode, viewUnitIdList)));
}
}
break;
case VISITOR:
//访客可以看全市的
break;
case DASHBOARD:
break;
default:
//没有权限的话 就让它查不到
queryState = false;
break;
}
}
return queryState;
}

public void exportList(HttpServletResponse response, ProjectListReq param) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(param);
//当非预审申报的时候 是自己单位 当是预审申报的时候 要主管单位
preQuery(query, user);
if (!projectQueryPermission(query, user, param.getDeclaredUnitId())) {
throw BizException.wrap("暂无数据可以导出");
}
query.eq(Project::getNewest, Boolean.TRUE);
List<Project> records = projectService.list(query);



+ 22
- 7
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java 查看文件

@@ -42,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

/**
@@ -126,7 +127,7 @@ public class ProjectReviewManage {
public PageVo<ProjectLibListItemVO> pageReviewProject(ProjectListReq req) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
LambdaQueryWrapper<Project> query = ProjectManageUtil.initQuery();
if (!projectQueryPermission(query, user)) {
if (!projectQueryPermission(query, user, req.getDeclaredUnitId())) {
return PageVo.empty();
}
ProjectManageUtil.projectQuery(query, req);
@@ -145,7 +146,9 @@ public class ProjectReviewManage {
return PageVo.of(records, total);
}

private boolean projectQueryPermission(LambdaQueryWrapper<Project> query, UserFullInfoDTO user) {
private boolean projectQueryPermission(LambdaQueryWrapper<Project> query,
UserFullInfoDTO user,
Long declaredUnitId) {
boolean queryState = true;
Optional<DataScopeDTO> currDs = DataScopeUtil.getCurrentUserDataScopeHasUserId(user);
if (!currDs.isPresent()) {
@@ -157,17 +160,29 @@ public class ProjectReviewManage {
//普通用户 只能看到自己单位去申报的
query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr());
break;
case COMPANY_MANAGER:
case COMPANY_MANAGER: {
List<Long> childUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId());
if (declaredUnitId != null && childUnitIds.contains(declaredUnitId)
&& !Objects.equals(declaredUnitId, user.getMhUnitId())) {
childUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId);
}
List<String> viewUnitIdList = CollUtils.convert(childUnitIds, String::valueOf);
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目
query.and(q1 -> q1.in(Project::getBuildOrgCode, viewUnitIdList)
.or(q2 -> q2.eq(Project::getStage, ProjectStatus.NOT_APPROVED.getCode())
.in(Project::getSuperOrgCode, viewUnitIdList)));
break;
case SUPER_ADMIN:
//超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员
break;
}
break;
case SUPER_ADMIN: {
if (declaredUnitId != null) {
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId);
List<String> viewUnitIdList = CollUtils.convert(viewUnitIds, String::valueOf);
query.and(q1 -> q1.in(Project::getBuildOrgCode, viewUnitIdList)
.or(q2 -> q2.eq(Project::getStage, ProjectStatus.NOT_APPROVED.getCode())
.in(Project::getSuperOrgCode, viewUnitIdList)));
}
}
break;
case VISITOR:
//访客可以看全市的
break;


+ 1
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java 查看文件

@@ -58,6 +58,7 @@ public class ProjectManageUtil {
.le(req.getApproveAmountMax() != null, Project::getApprovalAmount, req.getApproveAmountMax())

.like(req.getBuildOrg() != null, Project::getBuildOrgName, req.getBuildOrg())
.eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip())
.eq(req.getBuildOrgCode() != null, Project::getBuildOrgCode, req.getBuildOrgCode())
.like(StringUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName())
.eq(req.getSuperOrgCode() != null, Project::getSuperOrgCode, req.getSuperOrgCode())


+ 2
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java 查看文件

@@ -120,4 +120,6 @@ public class ProjectListReq extends PagePo {

private Boolean isStartDeclaredProject;

private Long declaredUnitId;

}

Loading…
取消
儲存