@@ -70,39 +70,12 @@ public class BizConst { | |||||
public static final String NINE_AREA_CODE_LAST = "000"; | public static final String NINE_AREA_CODE_LAST = "000"; | ||||
/** | /** | ||||
* 省/直辖市 level | |||||
*/ | |||||
public static final int GOV_L1 = 1; | |||||
/** | |||||
* 市 level | |||||
*/ | |||||
public static final int GOV_L2 = 2; | |||||
/** | |||||
* 区/县 level | |||||
*/ | |||||
public static final int GOV_L3 = 3; | |||||
/** | |||||
* 密码正则:长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种 | * 密码正则:长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种 | ||||
*/ | */ | ||||
public static final String REGEX_PASS = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$"; | public static final String REGEX_PASS = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$"; | ||||
public static final ApiResponse<Void> UNAUTHENTICATED = ApiResponse.of(401, "用户未登录", null); | public static final ApiResponse<Void> UNAUTHENTICATED = ApiResponse.of(401, "用户未登录", null); | ||||
public static final int MAX_EXPORT_COUNT = 5000; | |||||
public static final String RESPONSE_KEY_DATA = "data"; | |||||
public static final String RESPONSE_KEY_ID = "id"; | |||||
public static final String RESPONSE_KEY_DING_CODE = "dingCode"; | |||||
public static final String RESPONSE_KEY_MATTER_NAME = "matterName"; | |||||
public static final String RESPONSE_KEY_ORG_NAME = "orgName"; | |||||
public static final String RESPONSE_KEY_USER_STATE = "userState"; | |||||
public static final String RESPONSE_KEY_AREA_NAME = "areaName"; | |||||
public static final String ORG_NAME = "organizationName"; | |||||
public static final String ORG_CODE = "organizationCode"; | |||||
public static final String DEV = "dev"; | public static final String DEV = "dev"; | ||||
public static final String PRE = "pre"; | public static final String PRE = "pre"; | ||||
@@ -118,4 +91,5 @@ public class BizConst { | |||||
static { | static { | ||||
JSON_NOT_IGNORE_NULL_VALUE = JSONConfig.create().setIgnoreNullValue(false); | JSON_NOT_IGNORE_NULL_VALUE = JSONConfig.create().setIgnoreNullValue(false); | ||||
} | } | ||||
} | } |
@@ -0,0 +1,36 @@ | |||||
package com.hz.pm.api.common.model.constant; | |||||
import java.util.Arrays; | |||||
import java.util.List; | |||||
/** | |||||
* <p> | |||||
* MhUnitConst | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 14:55 2024/8/27 | |||||
*/ | |||||
public class MhUnitConst { | |||||
private MhUnitConst() { | |||||
} | |||||
public static final long ROOT_UNIT_ID = 1; | |||||
public static final String UNIT_XCB = "信创办"; | |||||
public static final String UNIT_SOE = "国有企业"; | |||||
public static final String ROOT_UNIT_NAME = "市信创办"; | |||||
public static final String UNIT_HZ = "杭州市"; | |||||
public static final String CITY_SELF = "市级部门"; | |||||
public static final String COUNTY_SELF = "区县部门"; | |||||
public static final List<String> UNIT_SORT = Arrays.asList("市", "上城", "拱墅", "西湖", "滨江", "萧山", "余杭", "临平", "钱塘", "富阳", "临安", "桐庐", "淳安", "建德"); | |||||
} |
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||||
import com.hz.pm.api.common.exception.ReturnException; | import com.hz.pm.api.common.exception.ReturnException; | ||||
import com.hz.pm.api.common.helper.RegionCacheHelper; | import com.hz.pm.api.common.helper.RegionCacheHelper; | ||||
import com.hz.pm.api.common.model.constant.BizConst; | import com.hz.pm.api.common.model.constant.BizConst; | ||||
import com.hz.pm.api.common.model.constant.MhUnitConst; | |||||
import com.hz.pm.api.common.util.BizUtils; | import com.hz.pm.api.common.util.BizUtils; | ||||
import com.hz.pm.api.common.util.EnvironmentUtil; | import com.hz.pm.api.common.util.EnvironmentUtil; | ||||
import com.hz.pm.api.expert.entity.ExpertUserFullInfo; | import com.hz.pm.api.expert.entity.ExpertUserFullInfo; | ||||
@@ -419,11 +420,13 @@ public class MeetingManage { | |||||
// 超管看所有 | // 超管看所有 | ||||
break; | break; | ||||
case COMPANY_MANAGER: | case COMPANY_MANAGER: | ||||
List<Long> viewOrgIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); | |||||
if (viewOrgIds.isEmpty()) { | |||||
return PageVo.empty(); | |||||
if (MhUnitConst.ROOT_UNIT_ID != userDetail.getMhUnitId()) { | |||||
List<Long> viewOrgIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); | |||||
if (viewOrgIds.isEmpty()) { | |||||
return PageVo.empty(); | |||||
} | |||||
query.in(Meeting::getHoldOrgCode, viewOrgIds); | |||||
} | } | ||||
query.in(Meeting::getHoldOrgCode, viewOrgIds); | |||||
break; | break; | ||||
default: | default: | ||||
query.eq(Meeting::getHoldOrgCode, userDetail.getMhUnitIdStr()); | query.eq(Meeting::getHoldOrgCode, userDetail.getMhUnitIdStr()); | ||||
@@ -954,11 +957,13 @@ public class MeetingManage { | |||||
case SUPER_ADMIN: | case SUPER_ADMIN: | ||||
break; | break; | ||||
case COMPANY_MANAGER: | case COMPANY_MANAGER: | ||||
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); | |||||
if (CollUtil.isEmpty(viewUnitIds)) { | |||||
return PageVo.empty(); | |||||
if (MhUnitConst.ROOT_UNIT_ID != userDetail.getMhUnitId()) { | |||||
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); | |||||
if (CollUtil.isEmpty(viewUnitIds)) { | |||||
return PageVo.empty(); | |||||
} | |||||
query.in(Project::getBuildOrgCode, viewUnitIds); | |||||
} | } | ||||
query.in(Project::getBuildOrgCode, viewUnitIds); | |||||
break; | break; | ||||
default: | default: | ||||
query.eq(Project::getBuildOrgCode, userDetail.getMhUnitIdStr()); | query.eq(Project::getBuildOrgCode, userDetail.getMhUnitIdStr()); | ||||
@@ -15,6 +15,7 @@ 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.ProjectProcessType; | import com.hz.pm.api.common.enumeration.ProjectProcessType; | ||||
import com.hz.pm.api.common.helper.UserInfoHelper; | import com.hz.pm.api.common.helper.UserInfoHelper; | ||||
import com.hz.pm.api.common.model.constant.MhUnitConst; | |||||
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.ProjectStateChangeEvent; | import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; | ||||
import com.hz.pm.api.common.util.ExcelDownUtil; | import com.hz.pm.api.common.util.ExcelDownUtil; | ||||
@@ -74,6 +75,8 @@ import java.io.IOException; | |||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.*; | import java.util.*; | ||||
import java.util.concurrent.atomic.AtomicInteger; | import java.util.concurrent.atomic.AtomicInteger; | ||||
import java.util.function.BiConsumer; | |||||
import java.util.function.Function; | |||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
/** | /** | ||||
@@ -367,6 +370,12 @@ public class DeclaredProjectManage { | |||||
private boolean projectQueryPermission(LambdaQueryWrapper<Project> query, | private boolean projectQueryPermission(LambdaQueryWrapper<Project> query, | ||||
UserFullInfoDTO user, | UserFullInfoDTO user, | ||||
Long declaredUnitId) { | Long declaredUnitId) { | ||||
BiConsumer<LambdaQueryWrapper<Project>, List<Long>> addUnitIdsToQuery = (q, unitIds) -> { | |||||
List<String> unitIdStrList = CollUtils.convert(unitIds, String::valueOf); | |||||
q.and(q1 -> q1.in(Project::getBuildOrgCode, unitIdStrList) | |||||
.or(q2 -> q2.eq(Project::getStage, ProjectStatus.NOT_APPROVED.getCode()) | |||||
.in(Project::getSuperOrgCode, unitIdStrList))); | |||||
}; | |||||
boolean queryState = true; | boolean queryState = true; | ||||
Optional<DataScopeDTO> currDs = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); | Optional<DataScopeDTO> currDs = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); | ||||
if (!currDs.isPresent()) { | if (!currDs.isPresent()) { | ||||
@@ -379,25 +388,36 @@ public class DeclaredProjectManage { | |||||
query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); | query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); | ||||
break; | 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); | |||||
if (declaredUnitId == null) { | |||||
if (user.getMhUnitId() != MhUnitConst.ROOT_UNIT_ID) { | |||||
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); | |||||
addUnitIdsToQuery.accept(query, viewUnitIds); | |||||
} | |||||
} else { | |||||
boolean userUnitIsRoot = user.getMhUnitId() == MhUnitConst.ROOT_UNIT_ID; | |||||
boolean queryUnitIsRoot = declaredUnitId == MhUnitConst.ROOT_UNIT_ID; | |||||
boolean userUnitEqQueryUnit = user.getMhUnitId().equals(declaredUnitId); | |||||
if ((userUnitIsRoot && !queryUnitIsRoot) | |||||
|| (!userUnitIsRoot && userUnitEqQueryUnit)) { | |||||
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId); | |||||
addUnitIdsToQuery.accept(query, viewUnitIds); | |||||
} else if (!userUnitIsRoot && queryUnitIsRoot) { | |||||
queryState = false; | |||||
} else if (!userUnitIsRoot) { | |||||
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); | |||||
if (viewUnitIds.contains(declaredUnitId)) { | |||||
addUnitIdsToQuery.accept(query, mhUnitCache.getViewChildIdsRecursion(declaredUnitId)); | |||||
} else { | |||||
queryState = false; | |||||
} | |||||
} | |||||
} | } | ||||
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; | break; | ||||
case SUPER_ADMIN: { | case SUPER_ADMIN: { | ||||
if (declaredUnitId != null) { | |||||
if (declaredUnitId != null && MhUnitConst.ROOT_UNIT_ID != declaredUnitId) { | |||||
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId); | 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))); | |||||
addUnitIdsToQuery.accept(query, viewUnitIds); | |||||
} | } | ||||
} | } | ||||
break; | break; | ||||
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil; | |||||
import cn.hutool.extra.spring.SpringUtil; | import cn.hutool.extra.spring.SpringUtil; | ||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.hz.pm.api.common.model.constant.ExistsSqlConst; | import com.hz.pm.api.common.model.constant.ExistsSqlConst; | ||||
import com.hz.pm.api.common.model.constant.MhUnitConst; | |||||
import com.hz.pm.api.common.statemachine.event.AbstractStateChangeEvent; | import com.hz.pm.api.common.statemachine.event.AbstractStateChangeEvent; | ||||
import com.hz.pm.api.performance.model.entity.ProjectCoreBusinessIndicators; | import com.hz.pm.api.performance.model.entity.ProjectCoreBusinessIndicators; | ||||
import com.hz.pm.api.projectlib.model.entity.Project; | import com.hz.pm.api.projectlib.model.entity.Project; | ||||
@@ -89,8 +90,11 @@ public class ProjectManageUtil { | |||||
.orderByDesc(Project::getUpdateOn); | .orderByDesc(Project::getUpdateOn); | ||||
// 处理申报单位查询 | // 处理申报单位查询 | ||||
if (req.getBuildOrgCode() != null && NumberUtil.isLong(req.getBuildOrgCode())) { | if (req.getBuildOrgCode() != null && NumberUtil.isLong(req.getBuildOrgCode())) { | ||||
List<Long> viewOrgCodes = getMhUnitCache().getViewChildIdsRecursion(Long.parseLong(req.getBuildOrgCode())); | |||||
query.in(Project::getBuildOrgCode, viewOrgCodes); | |||||
long buildOrgCode = Long.parseLong(req.getBuildOrgCode()); | |||||
if (buildOrgCode != MhUnitConst.ROOT_UNIT_ID) { | |||||
List<Long> viewOrgCodes = getMhUnitCache().getViewChildIdsRecursion(buildOrgCode); | |||||
query.in(Project::getBuildOrgCode, viewOrgCodes); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 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.model.constant.MhUnitConst; | |||||
import com.hz.pm.api.common.util.StrUtils; | import com.hz.pm.api.common.util.StrUtils; | ||||
import com.hz.pm.api.external.model.enumeration.MhUnitTypeEnum; | import com.hz.pm.api.external.model.enumeration.MhUnitTypeEnum; | ||||
import com.hz.pm.api.user.helper.MhUnitCache; | import com.hz.pm.api.user.helper.MhUnitCache; | ||||
@@ -32,6 +33,8 @@ import java.util.*; | |||||
import java.util.function.Function; | import java.util.function.Function; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
import static com.hz.pm.api.common.model.constant.MhUnitConst.*; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* MhUnitManage | * MhUnitManage | ||||
@@ -52,8 +55,6 @@ public class MhUnitManage { | |||||
private final MhUnitCache mhUnitCache; | private final MhUnitCache mhUnitCache; | ||||
private final IUserInfoService userInfoService; | private final IUserInfoService userInfoService; | ||||
private static final List<String> REGION_SORTS = Arrays.asList("市", "上城", "拱墅", "西湖", "滨江", "萧山", "余杭", "临平", "钱塘", "富阳", "临安", "桐庐", "淳安", "建德"); | |||||
public List<MhUnitTreeDTO> getMhUnitTree(String name) { | public List<MhUnitTreeDTO> getMhUnitTree(String name) { | ||||
List<UnitDTO> retUnits; | List<UnitDTO> retUnits; | ||||
List<UnitDTO> allUnits = mhUnitCache.all(); | List<UnitDTO> allUnits = mhUnitCache.all(); | ||||
@@ -85,7 +86,7 @@ public class MhUnitManage { | |||||
List<MhUnitTreeDTO> nodes = allUnits.stream() | List<MhUnitTreeDTO> nodes = allUnits.stream() | ||||
.filter(w -> MhUnitTypeEnum.SASAC.equals(w.getType()) || | .filter(w -> MhUnitTypeEnum.SASAC.equals(w.getType()) || | ||||
((MhUnitTypeEnum.REGION.equals(w.getType()) || MhUnitTypeEnum.NODE.equals(w.getType())) | ((MhUnitTypeEnum.REGION.equals(w.getType()) || MhUnitTypeEnum.NODE.equals(w.getType())) | ||||
&& w.getName().endsWith("信创办"))) | |||||
&& w.getName().endsWith(MhUnitConst.UNIT_XCB))) | |||||
.map(w -> BeanUtil.copyProperties(w, MhUnitTreeDTO.class)) | .map(w -> BeanUtil.copyProperties(w, MhUnitTreeDTO.class)) | ||||
.collect(Collectors.toList()); | .collect(Collectors.toList()); | ||||
mhUnitOptionSort(nodes); | mhUnitOptionSort(nodes); | ||||
@@ -93,11 +94,11 @@ public class MhUnitManage { | |||||
} | } | ||||
private static void mhUnitOptionSort(List<MhUnitTreeDTO> nodes) { | private static void mhUnitOptionSort(List<MhUnitTreeDTO> nodes) { | ||||
Function<MhUnitTreeDTO, Integer> firstSortFunc = w -> CollUtil.indexOf(REGION_SORTS, x -> w.getName().startsWith(x)); | |||||
Function<MhUnitTreeDTO, Integer> firstSortFunc = w -> CollUtil.indexOf(UNIT_SORT, x -> w.getName().startsWith(x)); | |||||
Function<MhUnitTreeDTO, Integer> secondSortFunc = w -> { | Function<MhUnitTreeDTO, Integer> secondSortFunc = w -> { | ||||
if (w.getName().contains("信创办")) { | |||||
if (w.getName().contains(MhUnitConst.UNIT_XCB)) { | |||||
return 1; | return 1; | ||||
} else if (w.getName().contains("国有企业")) { | |||||
} else if (w.getName().contains(UNIT_SOE)) { | |||||
return 3; | return 3; | ||||
} else { | } else { | ||||
return 2; | return 2; | ||||
@@ -112,13 +113,13 @@ public class MhUnitManage { | |||||
List<MhUnitTreeDTO> nodes = allUnits.stream() | List<MhUnitTreeDTO> nodes = allUnits.stream() | ||||
.filter(w -> MhUnitTypeEnum.SASAC.equals(w.getType()) || | .filter(w -> MhUnitTypeEnum.SASAC.equals(w.getType()) || | ||||
((MhUnitTypeEnum.REGION.equals(w.getType()) || MhUnitTypeEnum.NODE.equals(w.getType())) | ((MhUnitTypeEnum.REGION.equals(w.getType()) || MhUnitTypeEnum.NODE.equals(w.getType())) | ||||
&& (w.getName().endsWith("信创办") | |||||
|| "市级部门".equals(w.getName()) | |||||
|| "杭州市".equals(w.getName()) | |||||
|| "区县部门".equals(w.getName())))) | |||||
&& (w.getName().endsWith(UNIT_XCB) | |||||
|| CITY_SELF.equals(w.getName()) | |||||
|| UNIT_HZ.equals(w.getName()) | |||||
|| COUNTY_SELF.equals(w.getName())))) | |||||
.map(w -> { | .map(w -> { | ||||
MhUnitTreeDTO unit = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); | MhUnitTreeDTO unit = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); | ||||
if ("区县部门".equals(w.getName())) { | |||||
if (COUNTY_SELF.equals(w.getName())) { | |||||
UnitDTO parent = mhUnitCache.getById(unit.getParentId()); | UnitDTO parent = mhUnitCache.getById(unit.getParentId()); | ||||
if (parent != null) { | if (parent != null) { | ||||
String parentName = StrUtil.blankToDefault(parent.getShortName(), parent.getName()); | String parentName = StrUtil.blankToDefault(parent.getShortName(), parent.getName()); | ||||