From acaaf1eddab26463d1421774669e757e0c27822f Mon Sep 17 00:00:00 2001 From: wxz Date: Mon, 18 May 2020 19:51:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9D=83=E9=99=90=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/ListOpePermsFormDTO.java | 10 + .../epmet/controller/AccessController.java | 16 +- .../com/epmet/feign/EpmetUserFeignClient.java | 2 +- .../com/epmet/feign/GovOrgFeignClient.java | 2 +- .../java/com/epmet/service/AccessService.java | 6 + .../epmet/service/impl/AccessServiceImpl.java | 145 ++++++++++ .../com/epmet/feign/GovAccessFeignClient.java | 10 +- .../GovAccessFeignClientFallback.java | 6 + .../epmet/service/impl/AccessServiceImpl.java | 257 +----------------- .../epmet/service/CustomerAgencyService.java | 1 - 10 files changed, 201 insertions(+), 254 deletions(-) diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java index 31e8aadd1f..af13b14a3c 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java @@ -1,4 +1,14 @@ package com.epmet.dto.form; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data public class ListOpePermsFormDTO { + + @NotBlank(message = "用户ID不能为空") + private String staffId; + @NotBlank(message = "当前单位不能为空") + private String currAgencyId; } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java index 74e40a8579..8a68bec452 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java @@ -10,6 +10,7 @@ import com.epmet.service.AccessService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.validation.constraints.NotBlank; import java.util.List; import java.util.Set; @@ -88,7 +89,7 @@ public class AccessController { } /** - * 用户是否具有指定权限 + * 用户是否具有指定功能权限 * @return */ @PostMapping("hasspecifiedpermission") @@ -98,6 +99,19 @@ public class AccessController { return new Result().ok(hasPermission); } + /** + * 列出功能权限列表 + * @return + */ + @PostMapping("listoperationpermissions") + public Result> listOperationPermissions(@RequestBody ListOpePermsFormDTO listOpePermsFormDTO) { + ValidatorUtils.validateEntity(listOpePermsFormDTO); + String currAgencyId = listOpePermsFormDTO.getCurrAgencyId(); + String staffId = listOpePermsFormDTO.getStaffId(); + Set operationPermissions = accessService.listOperationPermissions(staffId, currAgencyId); + return new Result>().ok(operationPermissions); + } + /** * 查询sql过滤片段 * @param form diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index cc93ea20d7..eaabe43f49 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -1,4 +1,4 @@ -package com.epmet.feign.fallback; +package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index 0e559e5d94..d6ab4325af 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -1,4 +1,4 @@ -package com.epmet.feign.fallback; +package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java index 8ba649e51d..831126f6bf 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java @@ -50,4 +50,10 @@ public interface AccessService { * @param form */ String getSqlFilterSegment(GetSQLFilterFormDTO form); + + /** + * 列出角色的功能权限 + * @return + */ + Set listOperationPermissions(String staffId, String currAgencyId); } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index ee246fe87d..c74e8db9c0 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -8,9 +8,13 @@ import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.commons.tools.utils.Result; import com.epmet.constant.OperationScopeConstant; import com.epmet.dao.OperationScopeDao; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.GetSQLFilterFormDTO; +import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.dto.result.RoleOpeScopeResultDTO; import com.epmet.redis.RoleOpeScopeRedis; import com.epmet.service.AccessService; @@ -43,6 +47,16 @@ public class AccessServiceImpl implements AccessService { @Autowired private RoleOpeScopeRedis roleOpeScopeRedis; + @Autowired + private GovOrgFeignClient govOrgFeignClient; + + @Autowired + private EpmetUserFeignClient userFeignClient; + + public static final String ORG_RELATION_SAME = "same"; + public static final String ORG_RELATION_SUB = "sub"; + public static final String ORG_RELATION_SUP = "sup"; + /** * 更新权限缓存 * @param staffId @@ -423,4 +437,135 @@ public class AccessServiceImpl implements AccessService { sb.replace(sb.lastIndexOf("OR"), sb.lastIndexOf("OR") + 3, ""); hasConditions.set(true); } + + @Override + public Set listOperationPermissions(String staffId, String currAgencyId) { + + // 1.拿到所属组织机构信息 + Result agencyByStaffRst = govOrgFeignClient.getAgencyByStaff(staffId); + if (!agencyByStaffRst.success()) { + logger.error("根据StaffId查询所属单位出错,StaffId:{}, 错误信息:{}", staffId, agencyByStaffRst.getMsg()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + CustomerAgencyDTO belongAgency = agencyByStaffRst.getData(); + if (belongAgency == null) { + logger.error("根据StaffId查询所属单位结果为空,StaffId:{}", staffId); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + // 2.拿到当前所处机关单位信息 + Result currAgencyRst = govOrgFeignClient.getAgencyById(currAgencyId); + CustomerAgencyDTO currAgencyDto = currAgencyRst.getData(); + if (!currAgencyRst.success() || currAgencyDto == null) { + logger.error("根据当前机构id[{}]查询pids失败:{}", currAgencyId, currAgencyRst.getMsg()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + // 查询机关单位中的角色 + List roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId()); + + // 当前组织和所属组织的orgId路径,以及他们的上下级关系 + String belongOrgIdPath = getOrgIdPath(belongAgency); + String currOrgIdPath = getOrgIdPath(currAgencyDto); + String currOrgRelation = getCurrOrgRelation(belongOrgIdPath, currOrgIdPath); + + Set filtedOps = new HashSet<>(); + + roleDTOS.forEach(roleDTO -> { + List opeAndScopeDTO = listAllRoleOperationScopesByRoleId(roleDTO.getId()); + filtedOps.addAll(filterOpesByScope(currOrgRelation, opeAndScopeDTO)); + }); + return filtedOps; + } + + /** + * 获取当前所处机关与所属机关的关系 + */ + private String getCurrOrgRelation(String belongOrgPath, String currAgencyPath) { + if (belongOrgPath.equals(currAgencyPath)) { + // 当前机关即该人员所属机关 + return ORG_RELATION_SAME; + } else if (currAgencyPath.indexOf(belongOrgPath.concat(":")) > -1) { + // 说明当前所在机关是人员所属机关子级,只取出scope为sub的 + return ORG_RELATION_SUB; + } else if (belongOrgPath.indexOf(currAgencyPath.concat(":")) > -1) { + // 说明当前所在机关是人员所属机关的上级 + return ORG_RELATION_SUP; + } + return belongOrgPath; + } + + /** + * 获取组织的orgId路径 + */ + public String getOrgIdPath(CustomerAgencyDTO agency) { + // 拼接单位ID全路径 + if ("0".equals(agency.getPid())) { + // 顶级组织 + return agency.getId(); + } else { + return agency.getPids().concat(":").concat(agency.getId()); + } + } + + public List queryGovStaffRoles(String staffId, String orgId) { + List roleDTOS = new ArrayList<>(); + StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); + formDTO.setStaffId(staffId); + formDTO.setOrgId(orgId); + Result> gridResult = userFeignClient.getRolesOfStaff(formDTO); + if (!CollectionUtils.isEmpty(gridResult.getData())) { + roleDTOS.addAll(gridResult.getData()); + } + return roleDTOS; + } + + /** + * 根据上下级关系过滤出要返回的权限列表 + * + * @param currOrgRelation + * @param roleOperations + * @return + */ + private HashSet filterOpesByScope(String currOrgRelation, List roleOperations) { + HashSet opeKeys = new HashSet<>(); + for (RoleOpeScopeResultDTO opeScope : roleOperations) { + String scopeKey = opeScope.getScopeKey(); + if (OpeScopeConstant.ORG_ALL.equals(scopeKey) || OpeScopeConstant.ALL.equals(scopeKey)) { + // 如果该操作的范围是org_all或者all,不需要根据上下级关系判断,直接返回即可。 + opeKeys.add(opeScope.getOperationKey()); + continue; + } + + if (!opeScope.getSeries().equals(OperationScopeConstant.SERIES_ORG_LEVEL)) { + // 如果不是org_level系列权限,跳过。(如果一个操作没有分配org_level系列权限,那么无法根据所在机构判断是否具有该功能权限) + // 此时不会给前台返回此功能权限。即要求所有操作必须分配至少一个org_level系列权限(如果实在不需要,可以分配成org_all)。 + continue; + } + + switch (currOrgRelation) { + case ORG_RELATION_SAME:// 就在所在机构下 + if (OpeScopeConstant.ORG_CURR.equals(scopeKey) + || OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey) + || OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) { + opeKeys.add(opeScope.getOperationKey()); + } + break; + case ORG_RELATION_SUB:// 所在机构的子级 + if (OpeScopeConstant.ORG_CURR_SUB.equals(scopeKey) + || OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey)) { + opeKeys.add(opeScope.getOperationKey()); + } + break; + case ORG_RELATION_SUP:// 所在机构的上级 + if (OpeScopeConstant.ORG_CURR_SUP.equals(scopeKey) + || OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) { + opeKeys.add(opeScope.getOperationKey()); + } + break; + } + } + return opeKeys; + } + } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java index d554ad636e..ff347a674c 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.OperationScopeDTO; +import com.epmet.dto.form.ListOpePermsFormDTO; import com.epmet.dto.form.OperationScopeFormDTO; import com.epmet.dto.form.StaffPermCacheFormDTO; import com.epmet.dto.result.RoleOpeScopeResultDTO; @@ -21,7 +22,7 @@ import java.util.Set; * @Author sun */ //url = "localhost:8099" -@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class) +@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class, url = "localhost:8099") public interface GovAccessFeignClient { /** @@ -55,4 +56,11 @@ public interface GovAccessFeignClient { @PostMapping("/gov/access/access/roleallopesandscopes/{roleId}") Result> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId); + /** + * 列出觉得的功能权限列表 + * @return + */ + @PostMapping("listoperationpermissions") + Result> listOperationPermissions(@RequestBody ListOpePermsFormDTO listOpePermsFormDTO); + } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java index 55f4143e0a..36ed3ae74f 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.OperationScopeDTO; +import com.epmet.dto.form.ListOpePermsFormDTO; import com.epmet.dto.form.OperationScopeFormDTO; import com.epmet.dto.form.StaffPermCacheFormDTO; import com.epmet.dto.result.RoleOpeScopeResultDTO; @@ -46,4 +47,9 @@ public class GovAccessFeignClientFallback implements GovAccessFeignClient { public Result> listRoleAllOperationScopesByRoleId(String roleId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listRoleAllOperationScopesByRoleId", roleId); } + + @Override + public Result> listOperationPermissions(ListOpePermsFormDTO listOpePermsFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listOperationPermissions", listOpePermsFormDTO); + } } diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index 4012555d6d..5f7926415b 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -1,24 +1,15 @@ package com.epmet.service.impl; -import com.epmet.commons.tools.constant.OpeScopeConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.GovStaffRoleDTO; -import com.epmet.dto.OperationScopeDTO; -import com.epmet.dto.form.StaffRoleFormDTO; -import com.epmet.dto.result.RoleOpeScopeResultDTO; -import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.dto.form.ListOpePermsFormDTO; import com.epmet.feign.GovAccessFeignClient; -import com.epmet.feign.GovOrgFeignClient; import com.epmet.service.AccessService; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import java.util.*; @@ -27,253 +18,21 @@ public class AccessServiceImpl implements AccessService { private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class); - @Autowired - private EpmetUserFeignClient userFeignClient; - @Autowired private GovAccessFeignClient govAccessFeignClient; - @Autowired - private GovOrgFeignClient govOrgFeignClient; - - public static final String ORG_RELATION_SAME = "same"; - public static final String ORG_RELATION_SUB = "sub"; - public static final String ORG_RELATION_SUP = "sup"; - - public List queryGovStaffRoles(String staffId, String orgId) { - List roleDTOS = new ArrayList<>(); - StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); - formDTO.setStaffId(staffId); - formDTO.setOrgId(orgId); - Result> gridResult = userFeignClient.getRolesOfStaff(formDTO); - if (!CollectionUtils.isEmpty(gridResult.getData())) { - roleDTOS.addAll(gridResult.getData()); - } - return roleDTOS; - } - @Override public Set listOpeKeysByStaffId(String app, String client, String staffId, String currAgencyId, String currGridId) { - // 1.拿到所属组织机构信息 - Result agencyByStaffRst = govOrgFeignClient.getAgencyByStaff(staffId); - if (!agencyByStaffRst.success()) { - logger.error("根据StaffId查询所属单位出错,StaffId:{}, 错误信息:{}", staffId, agencyByStaffRst.getMsg()); - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } - CustomerAgencyDTO belongAgency = agencyByStaffRst.getData(); - if (belongAgency == null) { - logger.error("根据StaffId查询所属单位结果为空,StaffId:{}", staffId); - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } - - // 2.拿到当前所处机关单位信息 - Result currAgencyRst = govOrgFeignClient.getAgencyById(currAgencyId); - CustomerAgencyDTO currAgencyDto = currAgencyRst.getData(); - if (!currAgencyRst.success() || currAgencyDto == null) { - logger.error("根据当前机构id[{}]查询pids失败:{}", currAgencyId, currAgencyRst.getMsg()); + ListOpePermsFormDTO listOpePermsFormDTO = new ListOpePermsFormDTO(); + listOpePermsFormDTO.setStaffId(staffId); + listOpePermsFormDTO.setCurrAgencyId(currAgencyId); + Result> result = govAccessFeignClient.listOperationPermissions(listOpePermsFormDTO); + if (!result.success()) { + logger.error("调用GovAccess服务查询功能权限列表失败,StaffId:{},错误信息:{}", staffId, result.getMsg()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); } - // 拿到该用户所属的组织机构的orgIdPath,拿到当前组织机构的orgIdPath,看当前组织机构的orgIdPath是否在用户所属的组织机构的orgIdPath下 - - // 查询机关单位中的角色 - List roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId()); - - // 拼装操作key列表 - //Set opeKeys = new HashSet<>(); - // 角色ID列表 - //Set roleIds = new HashSet<>(); - - // 当前组织和所属组织的orgId路径,以及他们的上下级关系 - String belongOrgIdPath = getOrgIdPath(belongAgency); - String currOrgIdPath = getOrgIdPath(currAgencyDto); - String currOrgRelation = getCurrOrgRelation(belongOrgIdPath, currOrgIdPath); - - HashSet filtedOps = new HashSet<>(); - roleDTOS.forEach(roleDto -> { - String roleId = roleDto.getId(); - // 找出该角色的所有功能操作列表 - Result> result = govAccessFeignClient.listRoleAllOperationScopesByRoleId(roleId); - if (!result.success()) { - // 获取operation异常 - logger.error("调用GovAccess,根据RoleId查询Operation列表失败:{}", result.getMsg()); - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } - List roleOperations = result.getData(); - filtedOps.addAll(filterOpesByScope(currOrgRelation, roleOperations)); - }); - return filtedOps; - } - - /** - * 根据上下级关系过滤出要返回的权限列表 - * - * @param currOrgRelation - * @param roleOperations - * @return - */ - private HashSet filterOpesByScope(String currOrgRelation, List roleOperations) { - HashSet opeKeys = new HashSet<>(); - for (RoleOpeScopeResultDTO opeScope : roleOperations) { - String scopeKey = opeScope.getScopeKey(); - if (OpeScopeConstant.ORG_ALL.equals(scopeKey)) { - // 如果该操作的范围是org_all,那就具有所有范围的该操作权限,不需要根据上下级关系判断 - opeKeys.add(opeScope.getOperationKey()); - continue; - } - switch (currOrgRelation) { - case ORG_RELATION_SAME:// 就在所在机构下 - if (OpeScopeConstant.ORG_CURR.equals(scopeKey) - || OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey) - || OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) { - opeKeys.add(opeScope.getOperationKey()); - } - break; - case ORG_RELATION_SUB:// 所在机构的子级 - if (OpeScopeConstant.ORG_CURR_SUB.equals(scopeKey) - || OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey)) { - opeKeys.add(opeScope.getOperationKey()); - } - break; - case ORG_RELATION_SUP:// 所在机构的上级 - if (OpeScopeConstant.ORG_CURR_SUP.equals(scopeKey) - || OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) { - opeKeys.add(opeScope.getOperationKey()); - } - break; - } - } - return opeKeys; - } - - /** - * 获取当前所处机关与所属机关的关系 - */ - private String getCurrOrgRelation(String belongOrgPath, String currAgencyPath) { - if (belongOrgPath.equals(currAgencyPath)) { - // 当前机关即该人员所属机关 - return ORG_RELATION_SAME; - } else if (currAgencyPath.indexOf(belongOrgPath.concat(":")) > -1) { - // 说明当前所在机关是人员所属机关子级,只取出scope为sub的 - return ORG_RELATION_SUB; - } else if (belongOrgPath.indexOf(currAgencyPath.concat(":")) > -1) { - // 说明当前所在机关是人员所属机关的上级 - return ORG_RELATION_SUP; - } - return belongOrgPath; - } - - /** - * 获取组织的orgId路径 - */ - public String getOrgIdPath(CustomerAgencyDTO agency) { - // 拼接单位ID全路径 - if ("0".equals(agency.getPid())) { - // 顶级组织 - return agency.getId(); - } else { - return agency.getPids().concat(":").concat(agency.getId()); - } - } - - //private boolean filterCurrOrgKeysByScope(Set roleIds, String opeKey) { - // for (String roleId : roleIds) { - // Result> result = govAccessFeignClient.listRoleAllOperationScopesByRoleId(roleId); - // if (!result.success()) { - // continue; - // } - // Set scopeDTOS = result.getData(); - // Set scopeKeys = scopeDTOS.stream() - // .filter(scope -> scope.getScopeKey().equals(opeKey)) - // .map(scope -> scope.getScopeKey()) - // .collect(Collectors.toSet()); - // if (scopeKeys.contains(OpeScopeConstant.ORG_CURR) - // || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUB) - // || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUP)) { - // return true; - // } - // } - // return false; - //} - - //private boolean filterSubOrgKeysByScope(Set roleIds, String opeKey) { - // for (String roleId : roleIds) { - // OperationScopeFormDTO opeScopeFormDTO = new OperationScopeFormDTO(); - // opeScopeFormDTO.setRoleId(roleId); - // opeScopeFormDTO.setOperationKey(opeKey); - // Result> result = govAccessFeignClient.getOperationScopesByRoleId(opeScopeFormDTO); - // if (!result.success()) { - // continue; - // } - // - // Set scopeDTOS = result.getData(); - // Set scopeKeys = scopeDTOS.stream().map(scope -> scope.getScopeKey()).collect(Collectors.toSet()); - // if (scopeKeys.contains(OpeScopeConstant.ORG_CURR_SUB) - // || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUB)) { - // return true; - // } - // } - // return false; - //} - - //private boolean filterSupOrgKeysByScope(Set roleIds, String opeKey) { - // for (String roleId : roleIds) { - // OperationScopeFormDTO opeScopeFormDTO = new OperationScopeFormDTO(); - // opeScopeFormDTO.setRoleId(roleId); - // opeScopeFormDTO.setOperationKey(opeKey); - // Result> result = govAccessFeignClient.getOperationScopesByRoleId(opeScopeFormDTO); - // if (!result.success()) { - // continue; - // } - // - // Set scopeDTOS = result.getData(); - // Set scopeKeys = scopeDTOS.stream().map(scope -> scope.getScopeKey()).collect(Collectors.toSet()); - // if (scopeKeys.contains(OpeScopeConstant.ORG_CURR_SUP) - // || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUP)) { - // return true; - // } - // } - // return false; - //} - - /** - * 过滤有效范围 - * - * @param scopeDTOS - * @return - */ - private HashSet filteScopes(Set scopeDTOS) { - HashMap filtedScopes = new HashMap<>(); - - for (OperationScopeDTO scope : scopeDTOS) { - String scopeIndex = scope.getScopeIndex(); - if (StringUtils.isBlank(scopeIndex)) { - continue; - } - String[] currArr = scopeIndex.split("_"); - if ("0".equals(currArr[1])) { - // 为0,说明没有包含关系,直接放入 - filtedScopes.put(scopeIndex, scope); - continue; - } - - OperationScopeDTO tempScope = filtedScopes.get(currArr[0]); - if (tempScope != null) { - // 已经有ac开头的了 - String tempScopeIndex = tempScope.getScopeIndex(); - if (Integer.valueOf(currArr[1]) < Integer.valueOf(tempScopeIndex.split("_")[1])) { - filtedScopes.put(currArr[0], scope); - } - } else { - filtedScopes.put(currArr[0], scope); - } - } - HashSet scopeStrs = new HashSet<>(); - Set> entries = filtedScopes.entrySet(); - for (Map.Entry entry : entries) { - scopeStrs.add(entry.getValue().getScopeKey()); - } - return scopeStrs; + return result.getData(); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index 6cc44ea483..b0babab2fc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -22,7 +22,6 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.AgencyDeptGridFormDTO; -import com.epmet.dto.form.CanTickStaffListFormDTO; import com.epmet.dto.form.StaffOrgFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity;