package com.vci.web.service.impl; import com.alibaba.fastjson.JSONObject; import com.vci.common.exception.VciException; import com.vci.corba.common.PLException; import com.vci.corba.common.data.UserEntityInfo; import com.vci.corba.framework.data.*; import com.vci.corba.omd.data.BusinessObject; import com.vci.corba.portal.data.PLUILayout; import com.vci.dto.RoleInfoDTO; import com.vci.dto.RoleRightParamDTO; import com.vci.model.SmFunctionForPlatform1; import com.vci.model.SmRoleForPlatform1; import com.vci.omd.utils.ObjectTool; import com.vci.pagemodel.MenuVO; import com.vci.pagemodel.RoleRightVO; import com.vci.pagemodel.SmFunctionVO; import com.vci.pagemodel.UIContentVO; import com.vci.starter.web.constant.QueryOptionConstant; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.*; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.wrapper.VciQueryWrapperForDO; import com.vci.web.enumpck.ResourceControlTypeEnum; import com.vci.web.properties.JsonConfigReader; import com.vci.web.service.ISmFunctionQueryService; import com.vci.web.service.UIEngineServiceI; import com.vci.web.service.UIManagerServiceI; import com.vci.web.service.WebBoServiceI; import com.vci.starter.web.util.Lcm.Func; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.RightControlUtil; import com.vci.web.util.WebUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; /** * 老平台的权限服务 * @author weidy * @date 2020/3/1 */ @Service public class SmFunctionQueryServicePlatformImpl implements ISmFunctionQueryService { /** * 日志 */ private Logger logger = LoggerFactory.getLogger(getClass()); /** * 菜单的根节点主键,这个是平台定义的 */ private final String ROOT_MENU_ID = "business"; /** * 管理功能模块菜单根节点 */ private final String SYSTEMMANAGMENTNODE = "system"; /** * 操作类型管理菜单根节点 */ private final String OPERATENODE = "operateNode"; /** * 使用用户查询 */ public static final String QUERY_BY_USER = "select r.PLFUNCOID from plroleright r left join pluserrole u on r.PLROLEOID = u.PLROLEUID "; /** * 业务数据服务 */ @Autowired private WebBoServiceI boService; /** * 加载自身 */ @Autowired(required = false) @Lazy private ISmFunctionQueryService self; @Autowired private UIEngineServiceI uiEngineServiceI; @Autowired private UIManagerServiceI uiManagerServiceI; @Autowired private RightControlUtil rightControlUtil; @Autowired private PlatformClientUtil platformClientUtil; /** * 查询所有的功能 * * @return 功能的显示对象 */ @Override public List selectAllFunction() { VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(null, SmFunctionForPlatform1.class); List functions = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class); return functionForPlatform1ToFunctionDOs(functions); } /** * 查询所有的功能映射 * * @return 功能的显示对象 */ @Override public Map selectAllFunctionMap() { return Optional.ofNullable(self.selectAllFunction()).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t)); } /** * 根据用户查询关联的权限 * * @param userOid 用户的主键 * @param queryMap 查询条件,如果要用用户的属性查询,可以使用pkUser.xxx * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 权限的显示对象,未转化为上下级关系 */ @Override public List listFunctionByUserOid(String userOid, Map queryMap, ResourceControlTypeEnum resourceControlTypeEnum) { if(StringUtils.isBlank(userOid)){ return new ArrayList<>(); } VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,SmFunctionForPlatform1.class); queryWrapper.in("ploid",QUERY_BY_USER + " where u.pluseruid = '" + userOid.trim() + "'"); List functions = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class); if(CollectionUtils.isEmpty(functions)){ return new ArrayList<>(); } //TODO 密级的控制 //超级管理员,一般不让登录,登录后可以看业务的功能,也可以看管理功能 //三员的,只看管理的 //普通的只看业务的 if(resourceControlTypeEnum == null){ resourceControlTypeEnum = ResourceControlTypeEnum.BS; } String controlType = resourceControlTypeEnum.getValue(); List functionVOS = functionForPlatform1ToFunctionDOs(functions); return functionVOS.stream().filter(s->controlType.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList()); } /** * 根据用户返回所有菜单下的按钮(树形结构) * * @param treeQueryObject * @return */ @Override public List buttons(TreeQueryObject treeQueryObject) { //1、先根据session判断当前用户类型 SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); boolean adminOrDeveloperOrRoot = rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId()); String parentId; //2、根据不同用户返回不同的节点下的菜单和按钮 if (adminOrDeveloperOrRoot) { //系统菜单 parentId = SYSTEMMANAGMENTNODE; } else if (rightControlUtil.isThreeAdminCurUser()) { //三员返回管理功能模块相关的菜单 parentId = SYSTEMMANAGMENTNODE; } else { // 普通用户只返回业务功能模块相关的菜单, // 但可能存在普通用户分配系统功能的菜单和按钮权限,不过需要 // 再业务功能模块下创建对应的管理功能模块的菜单并进行授权。 parentId = ROOT_MENU_ID; } RoleRightInfo[] userRoleRights = rightControlUtil.getRoleRightByUserName(sessionInfo.getUserId()); //3、根据角色查询出对应的父节点下的所有的菜单,然后再获取菜单下的所有按钮 //List menuList = rightControlUtil.getMenusByPIdAndPermission(parentId, sessionInfo.getUserId(),userRoleRights); Map> map = rightControlUtil.getAllChildrenFunctionsByUserName( parentId, sessionInfo.getUserId(), userRoleRights); List functionVOList = new ArrayList<>(); //4、先获取parentid对应的菜单,再获取每一层子节点,同时过滤掉按钮未启用的功能模块 for (FunctionInfo menu : map.get(parentId)) { if(!menu.isValid){ continue; } MenuVO functionVO = new MenuVO(); functionVO.setId(menu.id); functionVO.setSource(menu.image); functionVO.setPath(menu.resourceB); functionVO.setParentId(menu.parentId); functionVO.setCode(menu.aliasName); functionVO.setAlias(menu.aliasName); functionVO.setName(menu.name); functionVO.setFunctionType(menu.functionType); functionVO.setIsValid(menu.isValid); functionVO.getMeta().put("keepAlive",false); functionVO.setSort((int) menu.seq); try { functionVO.setChildren(findChildFunctionVO(menu.id, map)); } catch (PLException e) { e.printStackTrace(); String errorMsg = "菜单查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); logger.error(errorMsg); throw new VciBaseException(errorMsg); } if(functionVO.getChildren().size() > 0){ functionVO.setHasChildren(true); }else { functionVO.setHasChildren(false); } functionVOList.add(functionVO); } //6、过滤出实际的菜单节点 List menuVOList = new ArrayList<>(); recursionFunction(functionVOList,menuVOList); // 5、处理每一个菜单下需要返回的按钮 menuVOList.stream().forEach(menuVO -> { try { //6、获取当前菜单下的按钮 Map authMap = Arrays.stream(userRoleRights).collect(Collectors.toMap(e -> e.funcId, e -> e.rightValue, (existing, replacement) -> existing)); menuVO.setChildren(getButtonsByAuth(menuVO.getId(),adminOrDeveloperOrRoot,authMap)); } catch (PLException e) { e.printStackTrace(); String errorMsg = "按钮查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); logger.error(errorMsg); throw new VciBaseException(errorMsg); } }); return menuVOList; } /** * 过滤出菜单只返回菜单节点 * @param sourceList * @param targetList */ private static void recursionFunction(List sourceList, List targetList) { for (MenuVO menu : sourceList) { // 检查functionType是否为0 if (menu.getFunctionType() == 0) { targetList.add(menu); } // 递归处理children recursionFunction(menu.getChildren(), targetList); } } /** * 根据菜单主键和角色权限获取其下的按钮 * @param parentOid * @return * @throws PLException */ private List getButtonsByAuth(String parentOid,boolean adminOrDeveloperOrRoot,Map authMap) throws PLException { List buttonList = new ArrayList<>(); if(Func.isBlank(parentOid)){ return buttonList; } FuncOperationInfo[] funcOperates = platformClientUtil.getFrameworkService().getFuncOperationByModule(parentOid, "", true); List funcOperationList = new ArrayList<>(); if(!adminOrDeveloperOrRoot){ for (int i = 0; i < funcOperates.length; i++) { if(authMap.containsKey(funcOperates[i].funcId)){ long rightValue = authMap.get(funcOperates[i].funcId); long nodeValue = funcOperates[i].number; long preValue = (rightValue >> nodeValue) & 1; //进行位与操作,如果相等则表示具有当前操作的权限 if (preValue == 1) { funcOperationList.add(funcOperates[i]); } } } }else{ funcOperationList = Arrays.asList(funcOperates); } if(Func.isNotEmpty(funcOperationList)){ for(FuncOperationInfo info: funcOperationList){ MenuVO menuVO = new MenuVO(); menuVO.setChildType(0); menuVO.setId(info.id); menuVO.setFuncId(info.funcId); menuVO.setCode(info.operIndentify); menuVO.setOperId(info.operId); menuVO.setName(info.operName); menuVO.setAlias(info.operAlias); menuVO.setRemark(info.operDesc); menuVO.setSort((int) info.number); menuVO.setIsValid(info.isValid); menuVO.setHasChildren(false); menuVO.setCategory(1); menuVO.setFunctionType(2); menuVO.setSource(info.image); buttonList.add(menuVO); } } return buttonList; } /** * 原平台功能转换为新平台的功能 * @param functionForPlatform1List 原平台功能对象列表 * @return 新平台功能对象 */ private List functionForPlatform1ToFunctionDOs(List functionForPlatform1List){ List functionVOList = new ArrayList(); if(!CollectionUtils.isEmpty(functionForPlatform1List)){ for(int i = 0 ; i < functionForPlatform1List.size(); i ++ ) { functionVOList.add(functionForPlatform1ToFunctionVO(functionForPlatform1List.get(i))); } } return functionVOList; } /** * 原平台功能转换为新平台的功能 * * @param functionForPlatform1 原平台功能对象 * @return 新平台功能对象 */ private SmFunctionVO functionForPlatform1ToFunctionVO(SmFunctionForPlatform1 functionForPlatform1){ SmFunctionVO functionVO = new SmFunctionVO(); functionVO.setOid(functionForPlatform1.getPloid()); //functionVO.setId(String.valueOf(functionForPlatform1.getPlmoduleno())); functionVO.setName(functionForPlatform1.getPlname()); functionVO.setLogName(functionForPlatform1.getPlaliasname()); if(StringUtils.isNotBlank(functionForPlatform1.getPlresourceb())){ functionVO.setResourceControlType(ResourceControlTypeEnum.BS.getValue()); functionVO.setUrl(functionForPlatform1.getPlresourceb()); }else if(StringUtils.isNotBlank(functionForPlatform1.getPlresourcedotnet())) { functionVO.setResourceControlType(ResourceControlTypeEnum.DOTNET.getValue()); functionVO.setUrl(functionForPlatform1.getPlresourcedotnet()); }else if(StringUtils.isNotBlank(functionForPlatform1.getPlresourcemobil())) { functionVO.setResourceControlType(ResourceControlTypeEnum.MOBILE.getValue()); functionVO.setUrl(functionForPlatform1.getPlresourcemobil()); }else { functionVO.setResourceControlType(ResourceControlTypeEnum.CS.getValue()); functionVO.setUrl(functionForPlatform1.getPlresourcec()); } functionVO.setResourceControlTypeText(ResourceControlTypeEnum.getTextByValue(functionVO.getResourceControlType())); functionVO.setDisplayFlag((functionForPlatform1.getPlisvalid() !=null&& 1 == functionForPlatform1.getPlisvalid())? true:false); functionVO.setControlRightFlag(true); functionVO.setParentFunctionId(functionForPlatform1.getPlparentid()); functionVO.setOrderNum(functionForPlatform1.getPlmodulesequence()); if(StringUtils.isNotBlank(functionForPlatform1.getPlimage())) { functionVO.setIconCss(functionForPlatform1.getPlimage()); } //以前的老图标没办法转换了,但是支持layui的图标 if(StringUtils.isNotBlank(functionForPlatform1.getPldesc())){ //需要在平台中设置菜单的图标路径,在描述字段中添加 //{iconSrc:xxxx,desc:yyyy} try{ JSONObject jo = JSONObject.parseObject(functionForPlatform1.getPldesc()); if(jo!=null&&jo.containsKey("iconSrc")){ functionVO.setIconCss(jo.getString("iconSrc")); } if(jo!=null&&jo.containsKey("desc")){ functionVO.setDescription(jo.getString("desc")); } }catch(Exception e){ functionVO.setDescription(functionForPlatform1.getPldesc()); } } functionVO.setBtmName("function"); //老的数据里创建人,最后修改人等都没有 return functionVO; } /** * 获取当前角色的菜单 * * @param treeQueryObject 属性查询对象 * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 菜单,包含上下级 */ @Override public List treeCurrentUserMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException { SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); String parentId; boolean adminOrDeveloperOrRoot = rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId()); if (adminOrDeveloperOrRoot) { //系统菜单 parentId = SYSTEMMANAGMENTNODE; } else if (rightControlUtil.isThreeAdminCurUser()) { //三员返回管理功能模块相关的菜单 parentId = SYSTEMMANAGMENTNODE; } else { //普通用户只返回业务功能模块相关的菜单 parentId = ROOT_MENU_ID; } RoleRightInfo[] userRoleRights = rightControlUtil.getRoleRightByUserName(sessionInfo.getUserId()); Map> map = rightControlUtil.getAllChildrenFunctionsByUserName( parentId, sessionInfo.getUserId(), userRoleRights); List functionVOList = new ArrayList<>(); if(Func.isEmpty(map.get(parentId))) { return functionVOList; } for (FunctionInfo menu : map.get(parentId)) { if(!menu.isValid){ continue; } MenuVO functionVO = new MenuVO(); functionVO.setId(menu.id); functionVO.setSource(menu.image); //if(StringUtils.isBlank(menu.resourceB)){ // continue; //} functionVO.setPath(menu.resourceB); functionVO.setParentId(menu.parentId); //functionVO.setCode(menu.aliasName); functionVO.setAlias(menu.aliasName); functionVO.setName(menu.name); functionVO.getMeta().put("keepAlive",true); functionVO.setSort((int) menu.seq); try { functionVO.setChildren(findChildFunctionVO(menu.id, map)); } catch (PLException e) { e.printStackTrace(); String errorMsg = "菜单查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); logger.error(errorMsg); throw new VciBaseException(errorMsg); } if(functionVO.getChildren().size() > 0){ functionVO.setHasChildren(true); }else { functionVO.setHasChildren(false); } functionVOList.add(functionVO); } //如果是开发或者测试用户,需要获取系统模块配置菜单 if(adminOrDeveloperOrRoot){ //获取首页系统模块配置菜单 MenuVO menuVO = JsonConfigReader.getSysModuleConf().getSysModuleNode(); if(Func.isNotEmpty(menuVO)){ functionVOList.add(menuVO); } } return functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList()); } /** * 通过模块ID获取子级列表 * @param parentId * @param modeType 模块类型 * @param isAll 是否包括无效的模块,true则包括 * @return * @throws VciBaseException */ @Override public List getSysModelTreeMenuByPID(String parentId,String modeType,boolean isAll) throws VciBaseException{ List menuVOList = new ArrayList<>(); if(Func.isBlank(parentId)){ return menuVOList; } boolean isFunctionObject = Func.isNotBlank(modeType) && modeType.equalsIgnoreCase("FunctionObject"); if(parentId.equals("system") || parentId.equals("business") || isFunctionObject){ int childType = this.checkChildObject(parentId); if(isFunctionObject){ try { /**判断该模块下子对象是模块还是操作,0表示无子节点,1表示是模块,2表示是操作**/ if(childType == 2){ try{ FuncOperationInfo[] infos = platformClientUtil.getFrameworkService().getFuncOperationByModule(parentId, "", false); if(Func.isNotEmpty(infos)){ childType = this.checkChildObject(infos[0].id); //都是同一层所以取第一个即可查询是什么类型 for(int i = 0;i < infos.length ;i++){ FuncOperationInfo info = infos[i]; MenuVO menuVO = new MenuVO(); menuVO.setChildType(childType); menuVO.setId(info.id); menuVO.setFuncId(info.funcId); menuVO.setCode(info.operIndentify); menuVO.setOperId(info.operId); menuVO.setName(info.operName); menuVO.setAlias(info.operAlias); menuVO.setRemark(info.operDesc); menuVO.setSort((int) info.number); menuVO.setModeType("FunctionObject"); menuVO.setIsValid(info.isValid); menuVO.setHasChildren(false); menuVO.setCategory(1); menuVO.setFunctionType(3); menuVO.setSource(info.image); menuVOList.add(menuVO); } } }catch (PLException e) { e.printStackTrace(); throw new VciBaseException(String.valueOf(e.code), e.messages); } }else if(childType == 1){ try{ FunctionInfo[] funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(parentId, isAll); if(Func.isNotEmpty(funcInfos.length)){ childType = this.checkChildObject(funcInfos[0].id); //都是同一层所以取第一个即可查询是什么类型 for(int i = 0;i < funcInfos.length; i++){ FunctionInfo funcInfo = funcInfos[i]; MenuVO menuVO = this.functionInfoToMenuVO(funcInfo); menuVO.setChildType(childType); menuVO.setModeType("FunctionObject"); menuVO.setCategory(0); menuVOList.add(menuVO); } } }catch (PLException e) { e.printStackTrace(); throw new VciBaseException(String.valueOf(e.code),e.messages); } } } catch (Exception e) { e.printStackTrace(); throw new VciBaseException("模块查询时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e)); } }else{ try{ MenuVO parentNode = null; //将返回的节点外层套上当前父节点 if("system".equals(parentId)){ parentNode = JsonConfigReader.getSysModuleConf().getSystemManagmentNode(); }else if("business".equals(parentId)){ parentNode = JsonConfigReader.getSysModuleConf().getModelManagmentNode(); } //如果查询的是第一层节点就需要直接返回systemManagmentNode或modelManagmentNode节点 if(Func.isNotBlank(modeType) && modeType.equals("firstNode")){ menuVOList.add(parentNode); return menuVOList; } //查询的三级节点 FunctionInfo[] funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(parentId, isAll); for(int i = 0;i < funcInfos.length; i++){ FunctionInfo funcInfo = funcInfos[i]; MenuVO menuVO = this.functionInfoToMenuVO(funcInfo); menuVO.setModeType("FunctionObject"); childType = this.checkChildObject(funcInfos[i].id); menuVO.setChildType(childType); menuVO.setCategory(0); menuVOList.add(menuVO); } return menuVOList; }catch (PLException e) { e.printStackTrace(); throw new VciBaseException(String.valueOf(e.code),e.messages); } } }else if(parentId.equals("operateNode")){ //加载所有操作 try{ //将返回的节点外层套上当前父节点 MenuVO parentNode = JsonConfigReader.getSysModuleConf().getOperateNode(); //如果查询的是第一层节点就需要直接返回sysOptionNode节点 if(Func.isNotBlank(modeType) && modeType.equals("firstNode")){ menuVOList.add(parentNode); return menuVOList; } OperateInfo[] operateInfos = platformClientUtil.getFrameworkService().getOperateTreeList(parentId); for(int i = 0; i < operateInfos.length;i++ ){ OperateInfo operateInfo = operateInfos[i]; MenuVO menuVO = new MenuVO(); menuVO.setId(operateInfo.id); menuVO.setName(operateInfo.name); menuVO.setCode(operateInfo.identify); menuVO.setAlias(operateInfo.alias); menuVO.setCategory(1); menuVO.setFunctionType(2); menuVO.setChildType(0); menuVO.setRemark(operateInfo.desc); menuVO.getMeta().put("keepAlive",true); menuVO.setSort((int) operateInfo.seq); menuVO.setModeType("operateObject"); menuVO.setHasChildren(false); menuVO.setSource(operateInfo.image); menuVOList.add(menuVO); } }catch (PLException e) { e.printStackTrace(); throw new VciBaseException(String.valueOf(e.code),new String[]{VciBaseUtil.getExceptionMessage(e)}); } } return menuVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList()); } /** * functionInfo转VO对象 * @param funcInfo * @return */ private MenuVO functionInfoToMenuVO(FunctionInfo funcInfo) { MenuVO menuVO = new MenuVO(); menuVO.setId(funcInfo.id); menuVO.setIsValid(funcInfo.isValid); menuVO.setSource(funcInfo.image); menuVO.setFunctionType(funcInfo.functionType); menuVO.setPathC(funcInfo.resourceC); menuVO.setResourceDotNet(funcInfo.resourceDotNet); menuVO.setResourceMobile(funcInfo.resourceMobile); menuVO.setPath(funcInfo.resourceB); menuVO.setParentId(funcInfo.parentId); //menuVO.setCode(funcInfo.aliasName); menuVO.setAlias(funcInfo.aliasName); menuVO.setName(funcInfo.name); menuVO.getMeta().put("keepAlive",true); menuVO.setSort((int) funcInfo.seq); menuVO.setRemark(funcInfo.desc); if(this.checkChildObject(menuVO.getId()) == 0){ menuVO.setHasChildren(false); }else{ menuVO.setHasChildren(true); } return menuVO; } /** * 通过模块ID检查该模块子级对象是模块还是操作 * @param moduleId * @return 0表示没有模块也没有操作,1表示有模块,2表示有操作 * @throws VciException */ @Override public int checkChildObject(String moduleId) throws VciBaseException { long res = 0; try{ res = platformClientUtil.getFrameworkService().checkChildObject(moduleId); }catch (PLException e) { e.printStackTrace(); throw new VciBaseException(String.valueOf(e.code),e.messages); } return (int)res; } public List findChildFunctionVO(String parentOid,Map> map) throws PLException { List menus = map.get(parentOid); List functionVOList = new ArrayList<>(); if(menus == null){ return functionVOList; } for (FunctionInfo menu : menus) { if(!menu.isValid){ continue; } MenuVO functionVO = new MenuVO(); functionVO.setId(menu.id); functionVO.setSource(menu.image); functionVO.setFunctionType(menu.functionType); functionVO.setIsValid(menu.isValid); functionVO.setPath(menu.resourceB); //functionVO.setCode(menu.aliasName); functionVO.setAlias(menu.aliasName); functionVO.setParentId(menu.parentId); functionVO.setName(menu.name); functionVO.getMeta().put("keepAlive",true); functionVO.setSort((int) menu.seq); functionVO.setRemark(menu.desc); functionVO.setChildren(findChildFunctionVO(menu.id,map)); if(functionVO.getChildren().size() > 0){ functionVO.setHasChildren(true); }else { functionVO.setHasChildren(false); } functionVOList.add(functionVO); } return functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList()); } public void findChildAuthFunctionVO(MenuVO functionVO, boolean isAll) throws PLException { //0表示没有模块也没有操作,1表示有模块,2表示有操作 long type = platformClientUtil.getFrameworkService().checkChildObject(functionVO.getId()); if(type == 1){ FunctionInfo[] funcObjs = platformClientUtil.getFrameworkService().getModuleListByParentId(functionVO.getId(), isAll); for (FunctionInfo funcObj : funcObjs) { MenuVO menuVO = new MenuVO(); menuVO.setId(funcObj.id); menuVO.setSource(funcObj.image); menuVO.setPath(funcObj.resourceB); menuVO.setCode(funcObj.aliasName); menuVO.setAlias(funcObj.aliasName); menuVO.setParentId(funcObj.parentId); menuVO.setChildType((int) type); menuVO.setName(funcObj.name); menuVO.getMeta().put("keepAlive",true); menuVO.setSort((int) funcObj.seq); menuVO.setRemark(funcObj.desc); findChildAuthFunctionVO(menuVO, isAll); functionVO.getChildren().add(menuVO); functionVO.setHasChildren(true); } }else if(type == 2){ FuncOperationInfo[] infos = platformClientUtil.getFrameworkService().getFuncOperationByModule(functionVO.getId(), "", true); for (FuncOperationInfo info : infos) { MenuVO menuVO = new MenuVO(); menuVO.setChildType((int) type); menuVO.setId(info.id); menuVO.setFuncId(info.funcId); menuVO.setCode(info.operIndentify); menuVO.setOperId(info.operId); menuVO.setName(info.operName); menuVO.setAlias(info.operAlias); menuVO.setRemark(info.operDesc); menuVO.setSort((int) info.number); menuVO.setModeType("FunctionObject"); menuVO.setIsValid(info.isValid); menuVO.setHasChildren(false); functionVO.getChildren().add(menuVO); functionVO.setHasChildren(true); } }else{ functionVO.setHasChildren(false); } } @Override public UIContentVO getUIContentByBtmTypeAndId(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException { SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); /* if(resourceControlTypeEnum == null){ resourceControlTypeEnum = ResourceControlTypeEnum.BS; }*/ Map> roleRightMap = uiManagerServiceI.getRoleRightMap(null); for (PLUILayout allPLUILayout : platformClientUtil.getUIService().getAllPLUILayouts()) { if(treeQueryObject.getConditionMap().getOrDefault("type","").equals(allPLUILayout.plRelatedType) && treeQueryObject.getConditionMap().getOrDefault("context","").equals(allPLUILayout.plCode)){ return uiEngineServiceI.UIContentDO2VO(allPLUILayout,true,roleRightMap); } } return null; } /** * 获取授权的模块 * @param roleId 角色主键 * @return 所具有权限的主键 * @throws PLException */ @Override public List getSysModelAuth(String roleId) throws PLException { RoleRightInfo[] roleRightList = platformClientUtil.getFrameworkService().getRoleRightList(roleId, WebUtil.getCurrentUserId()); Map authMap = Arrays.stream(roleRightList).collect(Collectors.toMap(e -> e.funcId, e -> e.rightValue, (existing, replacement) -> existing)); String parentId; SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); boolean adminOrDeveloperOrRoot = rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId()); if (adminOrDeveloperOrRoot) { //系统菜单 parentId = SYSTEMMANAGMENTNODE; } else { //普通用户只返回业务功能模块相关的菜单 parentId = ROOT_MENU_ID; } FunctionInfo[] moduleListByParentId = getModuleListByParentId(parentId, false); List authList = new ArrayList<>(); for (FunctionInfo functionInfo : moduleListByParentId) { if(authMap.containsKey(functionInfo.id)){ // authList.add(functionInfo.id); getChildAuthNode(functionInfo, authMap, authList); } } return authList; } public BaseResult saveRoleRight(List roleRightDTOS, String roleId) throws PLException { /** * 存储需要保存的权限 */ Map rightMap = new HashMap(); Map> parentMap = roleRightDTOS.stream().collect(Collectors.groupingBy(e -> e.parentId)); for (RoleRightParamDTO dto : roleRightDTOS) { RoleRightInfo obj = null; //判断类型 if(dto.getType() == 1 && !dto.getParentId().equals(ROOT_MENU_ID) && !dto.getParentId().equals(SYSTEMMANAGMENTNODE) && !dto.getParentId().equals(OPERATENODE)){ if(!rightMap.containsKey(dto.getParentId())){ obj = new RoleRightInfo(); obj.funcId = dto.getParentId(); obj.rightType = (short)1; obj.rightValue = 1;//没有操作的模块权限值存储为0 obj.roleId = roleId; obj.createUser = WebUtil.getCurrentUserId(); obj.createTime = new Date().getTime(); obj.modifyUser = WebUtil.getCurrentUserId(); obj.modifyTime = new Date().getTime(); obj.licensor = ""; }else{ obj = rightMap.get(dto.getParentId()); if (obj == null) { obj = new RoleRightInfo(); obj.funcId = dto.getParentId(); obj.rightType = (short)1; obj.rightValue = 1;//没有操作的模块权限值存储为0 obj.roleId = roleId; obj.createUser = WebUtil.getCurrentUserId(); obj.createTime = new Date().getTime(); obj.modifyUser = WebUtil.getCurrentUserId(); obj.modifyTime = new Date().getTime(); obj.licensor = ""; }else { obj.rightValue = 1; } } rightMap.put(dto.getParentId(), obj); }else if (dto.getType() == 2){ // RoleRightInfo roleRightObj = new RoleRightInfo(); if(!rightMap.containsKey(dto.getParentId())) { obj = new RoleRightInfo(); obj.funcId = dto.getParentId(); obj.rightType = (short)1; obj.rightValue = countRightValue(parentMap.get(dto.getParentId()));//没有操作的模块权限值存储为0 obj.roleId = roleId; obj.createUser = WebUtil.getCurrentUserId(); obj.createTime = new Date().getTime(); obj.modifyUser = WebUtil.getCurrentUserId(); obj.modifyTime = new Date().getTime(); obj.licensor = ""; rightMap.put(dto.getParentId(), obj); } } } /**上面处理完成后,循环遍历取出MAP里的对象进行保存**/ RoleRightInfo[] roleRightObjs = new RoleRightInfo[rightMap.size()]; Set objSet = rightMap.keySet(); Iterator it = objSet.iterator(); int i = 0; while(it.hasNext()){ roleRightObjs[i++] = rightMap.get(it.next()); } UserEntityInfo userEntityInfo = new UserEntityInfo(); userEntityInfo.setModules("com.vci.client.framework.rightdistribution.roleRight.RoleRightPanel"); userEntityInfo.setUserName(WebUtil.getCurrentUserId()); boolean res = platformClientUtil.getFrameworkService() .saveRoleRight(roleRightObjs,roleId,WebUtil.getCurrentUserId(), userEntityInfo); if(!res){ throw new PLException("500", new String[]{"功能模块授权失败!"}); } return BaseResult.success(); } /** * 获取所授权的模块权限 * @param roleName 搜索的角色 * @return 角色列表 */ @Override public List getRoleList(String roleName) throws PLException { RoleInfo[] roleInfos = platformClientUtil.getFrameworkService().fetchRoleInfoByUserType(WebUtil.getCurrentUserId()); List dtos = new ArrayList<>(); for (RoleInfo roleInfo : roleInfos) { if(StringUtils.isBlank(roleName) || roleInfo.name.indexOf(roleName) != -1) { RoleInfoDTO dto = new RoleInfoDTO(); dto.setName(roleInfo.name); dto.setDescription(roleInfo.description); dto.setId(roleInfo.id); dto.setGrantor(roleInfo.grantor); dto.setType(roleInfo.type); dto.setCreateTime(roleInfo.createTime); dto.setCreateUser(roleInfo.createUser); dto.setUpdateTime(roleInfo.updateTime); dto.setUpdateUser(roleInfo.updateUser); dtos.add(dto); } } return dtos; } private long countRightValue(List dtos){ long value = 0; for (RoleRightParamDTO dto : dtos) { value += (long)Math.pow(2, dto.getNumber());//累计加上各个操作的权限值 } return value; } /** * * @param funcObj 模块对象 * @param authMap 该角色下所有的权限数据 * @param authList 该角色下所具有的权限 * @throws PLException */ private void getChildAuthNode(FunctionInfo funcObj, Map authMap, List authList) throws PLException { /**0表示该模块下什么都没有,1表示有模块,2表示有操作**/ long funcType = platformClientUtil.getFrameworkService().checkChildObject(funcObj.id); if(funcType == 1){ FunctionInfo[] funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(funcObj.id, false); for(int i=0;i> nodeValue) & 1; //进行位与操作,如果相等则表示具有当前操作的权限 if (preValue == 1) { authList.add(funcOperates[j].id); } } } } } /** * 获取所有的功能菜单 * * @param treeQueryObject 树查询对象 * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 树节点,出现错误会在异常处理器中统一返回Json */ @Override public List treeAllMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) { List functionVOList = self.selectAllFunction().stream().filter(s -> s.isDisplayFlag() && resourceControlTypeEnum.getValue().equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList()); if(!treeQueryObject.isQueryAllLevel() && StringUtils.isNotBlank(treeQueryObject.getParentOid())){ functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList()); } return dos2Trees(functionVOList.stream().sorted(Comparator.comparing(s -> s.getOrderNum())).collect(Collectors.toList()),treeQueryObject == null?null:treeQueryObject.getParentOid()); } /** * 批量将数据对象转换为树节点 * @param functionVOList 数据对象列表 * @param rootId 根节点的主键,最顶层使用null或者"" * @return 树节点列表,不存在数据时返回空列表 */ public List dos2Trees(List functionVOList,String rootId){ if(!CollectionUtils.isEmpty(functionVOList)) { List rootList = new ArrayList<>(); List childList = new ArrayList<>(); functionVOList.stream().forEach(s -> { Tree tree = DO2Tree(s); if (tree.getParentId() == null || tree.getParentId().equals(rootId) || ROOT_MENU_ID.equalsIgnoreCase(tree.getParentId())) { rootList.add(tree); } else { childList.add(tree); } }); return Tree.getChildList(rootList, childList); }else{ return new ArrayList<>(); } } /** * 数据对象转换为树节点 * @param functionVO 数据显示对象 * @return 树节点对象 */ public Tree DO2Tree(SmFunctionVO functionVO){ Tree tree = new Tree(); tree.setOid(functionVO.getOid()); tree.setText(functionVO.getName()); tree.setIndex(functionVO.getOrderNum() + ""); tree.setParentId(functionVO.getParentFunctionId()); tree.setIconCls(functionVO.getIconCss()); tree.setHref(functionVO.getUrl()); try { tree.setAttributes(WebUtil.objectToMapString(functionVO)); } catch (Throwable e) { logger.error("拷贝信息",e); } return tree; } /** * 通过上级节点获取下级的所有的菜单节点 * * @param treeQueryObject 树查询对象 * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 树节点,出现错误会在异常处理器中统一返回Json */ @Override public List treeFunctionByParent(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) { List functionVOList = self.selectAllFunction().stream().filter(s -> s.isDisplayFlag() && resourceControlTypeEnum.getValue().equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList()); if(!treeQueryObject.isQueryAllLevel() && StringUtils.isNotBlank(treeQueryObject.getParentOid())){ functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList()); } return dos2Trees(functionVOList,treeQueryObject == null?null:treeQueryObject.getParentOid()); } /** * 通过上级节点获取当前角色有权限的下级的所有的菜单节点 * * @param treeQueryObject 树查询对象 * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 树节点,出现错误会在异常处理器中统一返回Json */ @Override public List treeCurrentFunctionByParent(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) { SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfo(); List functionVOList =self.selectAllFunction().stream().filter(s -> s.isDisplayFlag() && resourceControlTypeEnum.getValue().equalsIgnoreCase(s.getResourceControlType()) && !CollectionUtils.isEmpty(sessionInfo.getFunctionOids()) && sessionInfo.getFunctionOids().contains(s.getOid()) ).collect(Collectors.toList()); if(!treeQueryObject.isQueryAllLevel() && StringUtils.isNotBlank(treeQueryObject.getParentOid())){ functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList()); } return dos2Trees(functionVOList,treeQueryObject == null?null:treeQueryObject.getParentOid()); } /** * 获取系统功能列表 * * @param queryMap 查询条件 * @param pageHelper 排序和分页对象 * @return DataGrid 系统功能列表 */ @Override public DataGrid dataGrid(Map queryMap, PageHelper pageHelper) { VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(queryMap,SmFunctionForPlatform1.class,pageHelper); List functionForPlatform1s = boService.selectByQueryWrapper(queryWrapperForDO, SmFunctionForPlatform1.class); List functionVOS = functionForPlatform1ToFunctionDOs(functionForPlatform1s); DataGrid dataGrid = new DataGrid(); dataGrid.setData(functionVOS); if(!CollectionUtils.isEmpty(functionVOS)){ dataGrid.setTotal(boService.countByQueryWrapper(queryWrapperForDO,SmFunctionForPlatform1.class)); } return dataGrid; } /** * 根据角色主键获取关联的权限 * * @param roleOid 角色主键 * @param queryMap 查询条件,如果需要使用角色的属性来查询可以使用pkUser.xxxx * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 权限的显示对象 */ @Override public List listFunctionByRoleOid(String roleOid, Map queryMap, ResourceControlTypeEnum resourceControlTypeEnum) { String controlType = resourceControlTypeEnum == null? ResourceControlTypeEnum.BS.getValue(): resourceControlTypeEnum.getValue(); return Optional.ofNullable(listFunctionByRoleOid(roleOid,queryMap,false)).orElseGet(()->new ArrayList<>()).stream().filter(s->controlType.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList()); } /** * 获取未关联某个角色的权限 * * @param roleOid 角色主键 * @param queryMap 查询条件,如果需要使用角色的属性来查询可以使用pkUser.xxxx * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 权限的显示对象 */ @Override public List listFunctionUnInRoleOid(String roleOid, Map queryMap, ResourceControlTypeEnum resourceControlTypeEnum) { String controlType = resourceControlTypeEnum == null? ResourceControlTypeEnum.BS.getValue(): resourceControlTypeEnum.getValue(); return Optional.ofNullable(listFunctionByRoleOid(roleOid,queryMap,true)).orElseGet(()->new ArrayList<>()).stream().filter(s->controlType.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList()); } /** * 使用角色主键查询权限 * @param roleOid 用户主键 * @param queryMap 查询条件 * @param notIn 是否为不包含 * @return 角色的显示对象 */ private List listFunctionByRoleOid(String roleOid, Map queryMap, boolean notIn){ if(StringUtils.isBlank(roleOid)){ return new ArrayList<>(); } if(queryMap == null){ queryMap = new HashMap<>(); } List functions = new ArrayList<>(); if(roleOid.contains(",")){ Map finalQueryMap = queryMap; WebUtil.switchCollectionForOracleIn(WebUtil.str2List(roleOid)).stream().forEach(roleOids->{ Map conditionMap = new HashMap<>(); finalQueryMap.forEach((key,value)->{ conditionMap.put(key,value); }); conditionMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid in (" + WebUtil.toInSql(roleOids.toArray(new String[0])) + ")"); VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmRoleForPlatform1.class); List functionForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class); if(!CollectionUtils.isEmpty(functionForPlatform1s)){ functions.addAll(functionForPlatform1s); } }); }else { queryMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid ='" + roleOid.trim() + "'"); } VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,SmRoleForPlatform1.class); List roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class); if(!CollectionUtils.isEmpty(roleForPlatform1s)){ functions.addAll(roleForPlatform1s); } return functionForPlatform1ToFunctionDOs(functions); } /** * 获取未关联某个角色的权限 * * @param roleOid 角色主键 * @param queryMap 查询条件,如果需要使用角色的属性来查询可以使用pkUser.xxxx * @param pageHelper 分页和排序对象,老平台不支持使用权限编号来排序 * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 权限的显示对象 */ @Override public DataGrid gridFunctionUninRoleOid(String roleOid, Map queryMap, PageHelper pageHelper, ResourceControlTypeEnum resourceControlTypeEnum) { return gridFunctionByRoleOid(roleOid,queryMap,pageHelper,resourceControlTypeEnum,true); } /** * 批量根据角色的主键来获取权限 * * @param roleOidCollection 角色主键集合 * @param queryMap 查询条件,如果需要使用角色的属性来查询可以使用pkRole.xxxx * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 权限的显示对象,key是角色主键,value是这个角色关联的权限 */ @Override public Map> batchListFunctionByRoleOids(Collection roleOidCollection, Map queryMap, ResourceControlTypeEnum resourceControlTypeEnum) { if(CollectionUtils.isEmpty(roleOidCollection)){ return new HashMap<>(); } List functionVOList = new ArrayList<>(); Map> roleFunctionOidMap = new HashMap<>(); String roleContoll = resourceControlTypeEnum == null?ResourceControlTypeEnum.BS.getValue():resourceControlTypeEnum.getValue(); WebUtil.switchCollectionForOracleIn(roleOidCollection).stream().forEach(roleOids->{ List functionVOS = Optional.ofNullable(listFunctionByRoleOid(roleOids.stream().collect(Collectors.joining(",")), queryMap, false)).orElseGet(()->new ArrayList<>()).stream().filter(s->roleContoll.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList()); if(!CollectionUtils.isEmpty(functionVOS)){ functionVOList.addAll(functionVOS); String sql = "select plfuncoid,plroleoid from plroleright where plroleoid in (" + WebUtil.toInSql(roleOids.toArray(new String[0])) + ")"; List cbos = boService.queryBySql(sql, null); if(!CollectionUtils.isEmpty(cbos)){ cbos.stream().forEach(cbo->{ String roleOid = ObjectTool.getBOAttributeValue(cbo,"plroleoid"); List functionOids = roleFunctionOidMap.getOrDefault(roleOid,new ArrayList<>()); functionOids.add(ObjectTool.getBOAttributeValue(cbo,"plfuncoid")); roleFunctionOidMap.put(roleOid,functionOids); }); } } }); if(!CollectionUtils.isEmpty(functionVOList)){ Map functionVOMap = functionVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); Map> roleFunctionVOMap = new HashMap<>(); roleFunctionOidMap.forEach((roleOid,functionOids)->{ List functionVOS = new ArrayList<>(); functionOids.forEach(functionOid->{ if(functionVOMap.containsKey(functionOid)){ functionVOS.add(functionVOMap.get(functionOid)); } }); roleFunctionVOMap.put(roleOid,functionVOS); }); return roleFunctionVOMap; } return new HashMap<>(); } /** * 使用角色查询权限表 * @param roleOid 角色的主键 * @param queryMap 查询条件 * @param pageHelper 分页对象 * @param notIn 不包含 * @return 列表数据 */ private DataGrid gridFunctionByRoleOid(String roleOid,Map queryMap,PageHelper pageHelper,ResourceControlTypeEnum resourceControlTypeEnum,boolean notIn){ if(queryMap == null){ queryMap = new HashMap<>(); } if(StringUtils.isBlank(roleOid)){ return new DataGrid<>(); } if(roleOid.contains(",")){ String[] roleOids = roleOid.trim().split(","); if(roleOids.length>1000){ //这个方法不支持超过1000个的用户查询 throw new VciBaseException("这个方法不支持超过1000个角色的主键来查询"); } queryMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid in (" + WebUtil.toInSql(roleOid) + ")"); }else { queryMap.put("ploid", notIn ? QueryOptionConstant.NOTIN : QueryOptionConstant.IN + "select plfuncoid from plroleright where plroleoid ='" + roleOid.trim() + "'"); } if(resourceControlTypeEnum == null){ resourceControlTypeEnum = ResourceControlTypeEnum.BS; } switch (resourceControlTypeEnum){ case BS: queryMap.put("plresourceb",QueryOptionConstant.ISNOTNULL); break; case DOTNET: queryMap.put("plresourcedotnet",QueryOptionConstant.ISNOTNULL); break; case MOBILE: queryMap.put("plresourcemobil",QueryOptionConstant.ISNOTNULL); break; default: queryMap.put("plsuffixc",QueryOptionConstant.ISNOTNULL); } return dataGrid(queryMap,pageHelper); } /** * 批量根据角色的主键获取关联的权限 * * @param roleOidCollection 角色的主键集合 * @param queryMap 查询条件,如果需要使用角色的属性来查询可以使用pkRole.xxxx * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 权限的显示对象, 会去除重复的项 */ @Override public List listFunctionByRoleOids(Collection roleOidCollection, Map queryMap, ResourceControlTypeEnum resourceControlTypeEnum) { if(CollectionUtils.isEmpty(roleOidCollection)){ return new ArrayList<>(); } return listFunctionByRoleOid(roleOidCollection.stream().collect(Collectors.joining(",")),queryMap,false); } /** * 批量根据角色的主键获取关联的权限 * * @param roleOidCollection 角色的主键集合 * @param queryMap 查询条件,如果需要使用角色的属性来查询可以使用pkRole.xxxx * @param pageHelper 分页对象 * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 * @return 权限的显示对象, 会去除重复的项 */ @Override public DataGrid gridFunctionByRoleOids(Collection roleOidCollection, Map queryMap, PageHelper pageHelper, ResourceControlTypeEnum resourceControlTypeEnum) { if(CollectionUtils.isEmpty(roleOidCollection)){ return new DataGrid<>(); } return gridFunctionByRoleOid(roleOidCollection.stream().collect(Collectors.joining(",")), queryMap,pageHelper,resourceControlTypeEnum,false); } /** * 清除缓存 */ @Override public void clearCache() { } /** * 通过模块ID获取子级列表 * @param isAll 是否包括无效的模块,true则包括 * @return * @throws VciBaseException */ @Override public List getSysModelAuthTreeMenuByPID(boolean isAll) throws VciBaseException, PLException { SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); boolean adminOrDeveloperOrRoot = rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId()); String parentId; if (adminOrDeveloperOrRoot) { //系统菜单 parentId = SYSTEMMANAGMENTNODE; } else { //普通用户只返回业务功能模块相关的菜单 parentId = ROOT_MENU_ID; } List functionVOList = new ArrayList<>(); FunctionInfo[] moduleListByParentId = getModuleListByParentId(parentId, isAll); for (FunctionInfo menu : moduleListByParentId) { if(!menu.isValid){ continue; } MenuVO functionVO = new MenuVO(); functionVO.setId(menu.id); functionVO.setSource(menu.image); functionVO.setPath(menu.resourceB); functionVO.setParentId(menu.parentId); functionVO.setCode(menu.aliasName); functionVO.setAlias(menu.aliasName); functionVO.setName(menu.name); functionVO.getMeta().put("keepAlive",false); functionVO.setSort((int) menu.seq); findChildAuthFunctionVO(functionVO, isAll); if(functionVO.getChildren().size() > 0){ functionVO.setHasChildren(true); }else { functionVO.setHasChildren(false); } functionVOList.add(functionVO); } return functionVOList; } /** * 通过模块ID获取子级列表 * @param parentId * @param isAll 是否包括无效的模块,true则包括 * @return * @throws VciException */ public FunctionInfo[] getModuleListByParentId(String parentId,boolean isAll) throws PLException { FunctionInfo[] funcInfos = null; funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(parentId, isAll); return funcInfos; } }