|
@@ -6,7 +6,6 @@ import cn.hutool.core.map.MapUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
@@ -14,9 +13,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.hz.pm.api.common.enumeration.CommonEnum; |
|
|
import com.hz.pm.api.common.enumeration.CommonEnum; |
|
|
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; |
|
|
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; |
|
|
|
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
import com.hz.pm.api.common.model.constant.TypeReferenceConst; |
|
|
import com.hz.pm.api.common.model.constant.TypeReferenceConst; |
|
|
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; |
|
|
import com.hz.pm.api.common.statemachine.event.ProjectStatusChangeEvent; |
|
|
import com.hz.pm.api.common.util.BizUtils; |
|
|
import com.hz.pm.api.common.util.BizUtils; |
|
|
|
|
|
import com.hz.pm.api.datascope.model.DataScopeDTO; |
|
|
|
|
|
import com.hz.pm.api.datascope.utils.DataScopeUtil; |
|
|
import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; |
|
|
import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; |
|
|
import com.hz.pm.api.external.model.enumeration.MhUnitTypeEnum; |
|
|
import com.hz.pm.api.external.model.enumeration.MhUnitTypeEnum; |
|
|
import com.hz.pm.api.projectdeclared.manage.DefaultDeclaredProjectManage; |
|
|
import com.hz.pm.api.projectdeclared.manage.DefaultDeclaredProjectManage; |
|
@@ -45,6 +47,7 @@ import com.hz.pm.api.todocenter.constant.WorkNoticeConst; |
|
|
import com.hz.pm.api.user.helper.MhUnitCache; |
|
|
import com.hz.pm.api.user.helper.MhUnitCache; |
|
|
import com.hz.pm.api.user.model.dto.UnitDTO; |
|
|
import com.hz.pm.api.user.model.dto.UnitDTO; |
|
|
import com.hz.pm.api.user.model.entity.MhUnit; |
|
|
import com.hz.pm.api.user.model.entity.MhUnit; |
|
|
|
|
|
import com.hz.pm.api.user.security.model.UserFullInfoDTO; |
|
|
import com.hz.pm.api.user.security.model.UserInfoDetails; |
|
|
import com.hz.pm.api.user.security.model.UserInfoDetails; |
|
|
import com.hz.pm.api.user.service.IMhUnitService; |
|
|
import com.hz.pm.api.user.service.IMhUnitService; |
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
@@ -83,6 +86,7 @@ import java.util.stream.Collectors; |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
public class DeclaredRecordManage { |
|
|
public class DeclaredRecordManage { |
|
|
|
|
|
|
|
|
|
|
|
private final UserInfoHelper userInfoHelper; |
|
|
private final ProjectCodeGenUtil projectCodeGenUtil; |
|
|
private final ProjectCodeGenUtil projectCodeGenUtil; |
|
|
private final IMhProjectService mhProjectService; |
|
|
private final IMhProjectService mhProjectService; |
|
|
private final IMhProjectSchemaTargetDataService schemaTargetDataService; |
|
|
private final IMhProjectSchemaTargetDataService schemaTargetDataService; |
|
@@ -108,24 +112,98 @@ public class DeclaredRecordManage { |
|
|
if (req.getCreateDateMax() != null) { |
|
|
if (req.getCreateDateMax() != null) { |
|
|
query.lt(MhProject::getCreateTime, req.getCreateDateMax().minusDays(1)); |
|
|
query.lt(MhProject::getCreateTime, req.getCreateDateMax().minusDays(1)); |
|
|
} |
|
|
} |
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
if (!user.getSuperAdmin() && !user.getRegionAdmin()) { |
|
|
|
|
|
query.eq(MhProject::getUnitId, user.getMhUnitId()); |
|
|
|
|
|
} |
|
|
|
|
|
if (req.getUnitStrip() != null) { |
|
|
if (req.getUnitStrip() != null) { |
|
|
query.eq(MhProject::getUnitStrip, req.getUnitStrip()); |
|
|
query.eq(MhProject::getUnitStrip, req.getUnitStrip()); |
|
|
} |
|
|
} |
|
|
return query; |
|
|
return query; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean buildMhProjectLibPermission(LambdaQueryWrapper<MhProject> query, UserFullInfoDTO user) { |
|
|
|
|
|
boolean queryState = true; |
|
|
|
|
|
Optional<DataScopeDTO> currentUserDataScope = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); |
|
|
|
|
|
if (!currentUserDataScope.isPresent()) { |
|
|
|
|
|
log.warn("没有取到权限信息 当前查询 没有权限条件"); |
|
|
|
|
|
queryState = false; |
|
|
|
|
|
} else { |
|
|
|
|
|
switch (currentUserDataScope.get().getRole()) { |
|
|
|
|
|
case NORMAL_MEMBER: |
|
|
|
|
|
//普通用户 只能看到自己单位去申报的 |
|
|
|
|
|
query.eq(MhProject::getUnitId, user.getMhUnitId()); |
|
|
|
|
|
break; |
|
|
|
|
|
case COMPANY_MANAGER: |
|
|
|
|
|
List<Long> childUnitIds = mhUnitCache.getChildrenIdsRecursion(user.getMhUnitId()); |
|
|
|
|
|
childUnitIds.add(user.getMhUnitId()); |
|
|
|
|
|
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 |
|
|
|
|
|
query.in(MhProject::getUnitId, childUnitIds); |
|
|
|
|
|
break; |
|
|
|
|
|
case SUPER_ADMIN: |
|
|
|
|
|
//超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 |
|
|
|
|
|
break; |
|
|
|
|
|
case VISITOR: |
|
|
|
|
|
//访客可以看全市的 |
|
|
|
|
|
break; |
|
|
|
|
|
case DASHBOARD: |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
//没有权限的话 就让它查不到 |
|
|
|
|
|
queryState = false; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return queryState; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean buildProjectLibPermission(LambdaQueryWrapper<Project> query, UserFullInfoDTO user) { |
|
|
|
|
|
boolean queryState = true; |
|
|
|
|
|
Optional<DataScopeDTO> currentUserDataScope = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); |
|
|
|
|
|
if (!currentUserDataScope.isPresent()) { |
|
|
|
|
|
log.warn("没有取到权限信息 当前查询 没有权限条件"); |
|
|
|
|
|
queryState = false; |
|
|
|
|
|
} else { |
|
|
|
|
|
switch (currentUserDataScope.get().getRole()) { |
|
|
|
|
|
case NORMAL_MEMBER: |
|
|
|
|
|
//普通用户 只能看到自己单位去申报的 |
|
|
|
|
|
query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); |
|
|
|
|
|
break; |
|
|
|
|
|
case COMPANY_MANAGER: |
|
|
|
|
|
List<Long> childUnitIds = mhUnitCache.getChildrenIdsRecursion(user.getMhUnitId()); |
|
|
|
|
|
childUnitIds.add(user.getMhUnitId()); |
|
|
|
|
|
List<String> viewUnitIdList = CollUtils.convert(childUnitIds, String::valueOf); |
|
|
|
|
|
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 |
|
|
|
|
|
query.in(Project::getBuildOrgCode, viewUnitIdList); |
|
|
|
|
|
break; |
|
|
|
|
|
case SUPER_ADMIN: |
|
|
|
|
|
//超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 |
|
|
|
|
|
break; |
|
|
|
|
|
case VISITOR: |
|
|
|
|
|
//访客可以看全市的 |
|
|
|
|
|
break; |
|
|
|
|
|
case DASHBOARD: |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
//没有权限的话 就让它查不到 |
|
|
|
|
|
queryState = false; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return queryState; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public PageVo<DeclaredProjectListVO> pageDeclaredProject(DeclaredProjectListReq req) { |
|
|
public PageVo<DeclaredProjectListVO> pageDeclaredProject(DeclaredProjectListReq req) { |
|
|
LambdaQueryWrapper<MhProject> query = buildQuery(req); |
|
|
LambdaQueryWrapper<MhProject> query = buildQuery(req); |
|
|
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
// 查询审核中、失败、待立项备案的项目信息 |
|
|
// 查询审核中、失败、待立项备案的项目信息 |
|
|
LambdaQueryWrapper<Project> pQuery = Wrappers.lambdaQuery(Project.class) |
|
|
LambdaQueryWrapper<Project> pQuery = Wrappers.lambdaQuery(Project.class) |
|
|
.in(Project::getStatus, ProjectStatusEnum.DECLARED_APPROVED_RECORD_FAILED.getCode(), |
|
|
.in(Project::getStatus, ProjectStatusEnum.DECLARED_APPROVED_RECORD_FAILED.getCode(), |
|
|
ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD.getCode(), |
|
|
ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD.getCode(), |
|
|
ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING.getCode()) |
|
|
ProjectStatusEnum.DECLARED_APPROVED_RECORD_AUDITING.getCode()) |
|
|
.select(Project::getId, Project::getProjectCode, Project::getStage, Project::getStatus, Project::getCreateOn); |
|
|
.select(Project::getId, Project::getProjectCode, Project::getStage, Project::getStatus, Project::getCreateOn); |
|
|
|
|
|
if (!buildProjectLibPermission(pQuery, user)) { |
|
|
|
|
|
return PageVo.empty(); |
|
|
|
|
|
} |
|
|
|
|
|
if (!buildMhProjectLibPermission(query, user)) { |
|
|
|
|
|
return PageVo.empty(); |
|
|
|
|
|
} |
|
|
List<Project> projects = projectService.list(pQuery); |
|
|
List<Project> projects = projectService.list(pQuery); |
|
|
Map<String, Project> projectMap = BizUtils.groupFirstMap(projects, Project::getProjectCode, |
|
|
Map<String, Project> projectMap = BizUtils.groupFirstMap(projects, Project::getProjectCode, |
|
|
Comparator.comparing(Project::getCreateOn).reversed()); |
|
|
Comparator.comparing(Project::getCreateOn).reversed()); |
|
|