From b44c828f9fb5ff4f7b04b5db7d2ec16f7182c995 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 27 Aug 2024 16:09:57 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E4=BF=AE=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hz/pm/api/common/model/constant/BizConst.java | 28 +------------ .../pm/api/common/model/constant/MhUnitConst.java | 36 ++++++++++++++++ .../hz/pm/api/meeting/manage/MeetingManage.java | 21 ++++++---- .../manage/DeclaredProjectManage.java | 48 +++++++++++++++------- .../api/projectlib/helper/ProjectManageUtil.java | 8 +++- .../com/hz/pm/api/user/manage/MhUnitManage.java | 23 ++++++----- 6 files changed, 102 insertions(+), 62 deletions(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/BizConst.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/BizConst.java index 19d7039..c9a7d2b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/BizConst.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/BizConst.java @@ -70,39 +70,12 @@ public class BizConst { 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位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种 */ 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 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 PRE = "pre"; @@ -118,4 +91,5 @@ public class BizConst { static { JSON_NOT_IGNORE_NULL_VALUE = JSONConfig.create().setIgnoreNullValue(false); } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java new file mode 100644 index 0000000..c6ff5c6 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/MhUnitConst.java @@ -0,0 +1,36 @@ +package com.hz.pm.api.common.model.constant; + +import java.util.Arrays; +import java.util.List; + +/** + *

+ * MhUnitConst + *

+ * + * @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 UNIT_SORT = Arrays.asList("市", "上城", "拱墅", "西湖", "滨江", "萧山", "余杭", "临平", "钱塘", "富阳", "临安", "桐庐", "淳安", "建德"); + + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java index 26b9b1f..0126aad 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java @@ -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.helper.RegionCacheHelper; 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.EnvironmentUtil; import com.hz.pm.api.expert.entity.ExpertUserFullInfo; @@ -419,11 +420,13 @@ public class MeetingManage { // 超管看所有 break; case COMPANY_MANAGER: - List viewOrgIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); - if (viewOrgIds.isEmpty()) { - return PageVo.empty(); + if (MhUnitConst.ROOT_UNIT_ID != userDetail.getMhUnitId()) { + List viewOrgIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); + if (viewOrgIds.isEmpty()) { + return PageVo.empty(); + } + query.in(Meeting::getHoldOrgCode, viewOrgIds); } - query.in(Meeting::getHoldOrgCode, viewOrgIds); break; default: query.eq(Meeting::getHoldOrgCode, userDetail.getMhUnitIdStr()); @@ -954,11 +957,13 @@ public class MeetingManage { case SUPER_ADMIN: break; case COMPANY_MANAGER: - List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); - if (CollUtil.isEmpty(viewUnitIds)) { - return PageVo.empty(); + if (MhUnitConst.ROOT_UNIT_ID != userDetail.getMhUnitId()) { + List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(userDetail.getMhUnitId()); + if (CollUtil.isEmpty(viewUnitIds)) { + return PageVo.empty(); + } + query.in(Project::getBuildOrgCode, viewUnitIds); } - query.in(Project::getBuildOrgCode, viewUnitIds); break; default: query.eq(Project::getBuildOrgCode, userDetail.getMhUnitIdStr()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java index c176865..2828f82 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java @@ -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.ProjectProcessType; 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.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.common.util.ExcelDownUtil; @@ -74,6 +75,8 @@ import java.io.IOException; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.BiConsumer; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -367,6 +370,12 @@ public class DeclaredProjectManage { private boolean projectQueryPermission(LambdaQueryWrapper query, UserFullInfoDTO user, Long declaredUnitId) { + BiConsumer, List> addUnitIdsToQuery = (q, unitIds) -> { + List 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; Optional currDs = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); if (!currDs.isPresent()) { @@ -379,25 +388,36 @@ public class DeclaredProjectManage { query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); break; case COMPANY_MANAGER: { - List 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 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 viewUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId); + addUnitIdsToQuery.accept(query, viewUnitIds); + } else if (!userUnitIsRoot && queryUnitIsRoot) { + queryState = false; + } else if (!userUnitIsRoot) { + List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); + if (viewUnitIds.contains(declaredUnitId)) { + addUnitIdsToQuery.accept(query, mhUnitCache.getViewChildIdsRecursion(declaredUnitId)); + } else { + queryState = false; + } + } } - List 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) { + if (declaredUnitId != null && MhUnitConst.ROOT_UNIT_ID != declaredUnitId) { List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(declaredUnitId); - List 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; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java index 4f45701..8c4ddba 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; 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.MhUnitConst; import com.hz.pm.api.common.statemachine.event.AbstractStateChangeEvent; import com.hz.pm.api.performance.model.entity.ProjectCoreBusinessIndicators; import com.hz.pm.api.projectlib.model.entity.Project; @@ -89,8 +90,11 @@ public class ProjectManageUtil { .orderByDesc(Project::getUpdateOn); // 处理申报单位查询 if (req.getBuildOrgCode() != null && NumberUtil.isLong(req.getBuildOrgCode())) { - List 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 viewOrgCodes = getMhUnitCache().getViewChildIdsRecursion(buildOrgCode); + query.in(Project::getBuildOrgCode, viewOrgCodes); + } } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java index 074624d..5309e6c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil; 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.hz.pm.api.common.model.constant.MhUnitConst; import com.hz.pm.api.common.util.StrUtils; import com.hz.pm.api.external.model.enumeration.MhUnitTypeEnum; import com.hz.pm.api.user.helper.MhUnitCache; @@ -32,6 +33,8 @@ import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +import static com.hz.pm.api.common.model.constant.MhUnitConst.*; + /** *

* MhUnitManage @@ -52,8 +55,6 @@ public class MhUnitManage { private final MhUnitCache mhUnitCache; private final IUserInfoService userInfoService; - private static final List REGION_SORTS = Arrays.asList("市", "上城", "拱墅", "西湖", "滨江", "萧山", "余杭", "临平", "钱塘", "富阳", "临安", "桐庐", "淳安", "建德"); - public List getMhUnitTree(String name) { List retUnits; List allUnits = mhUnitCache.all(); @@ -85,7 +86,7 @@ public class MhUnitManage { List nodes = allUnits.stream() .filter(w -> MhUnitTypeEnum.SASAC.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)) .collect(Collectors.toList()); mhUnitOptionSort(nodes); @@ -93,11 +94,11 @@ public class MhUnitManage { } private static void mhUnitOptionSort(List nodes) { - Function firstSortFunc = w -> CollUtil.indexOf(REGION_SORTS, x -> w.getName().startsWith(x)); + Function firstSortFunc = w -> CollUtil.indexOf(UNIT_SORT, x -> w.getName().startsWith(x)); Function secondSortFunc = w -> { - if (w.getName().contains("信创办")) { + if (w.getName().contains(MhUnitConst.UNIT_XCB)) { return 1; - } else if (w.getName().contains("国有企业")) { + } else if (w.getName().contains(UNIT_SOE)) { return 3; } else { return 2; @@ -112,13 +113,13 @@ public class MhUnitManage { List nodes = allUnits.stream() .filter(w -> MhUnitTypeEnum.SASAC.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 -> { MhUnitTreeDTO unit = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); - if ("区县部门".equals(w.getName())) { + if (COUNTY_SELF.equals(w.getName())) { UnitDTO parent = mhUnitCache.getById(unit.getParentId()); if (parent != null) { String parentName = StrUtil.blankToDefault(parent.getShortName(), parent.getName());