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