| | |
| | | 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.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; |
| | |
| | | /** |
| | | * 菜单的根节点主键,这个是平台定义的 |
| | | */ |
| | | private final String ROOT_MENU_ID = "modelManagmentNode"; |
| | | private final String ROOT_MENU_ID = "business"; |
| | | |
| | | /** |
| | | * 管理功能模块菜单根节点 |
| | | */ |
| | | private final String SYSTEMMANAGMENTNODE = "systemManagmentNode"; |
| | | private final String SYSTEMMANAGMENTNODE = "system"; |
| | | |
| | | /** |
| | | * 操作类型管理菜单根节点 |
| | |
| | | private ISmFunctionQueryService self; |
| | | |
| | | @Autowired |
| | | private UIEngineServiceI uiEngineServiceI; |
| | | private UIEngineServiceI uiEngineServiceI; |
| | | |
| | | @Autowired |
| | | private UIManagerServiceI uiManagerServiceI; |
| | | |
| | | @Autowired |
| | | private RightControlUtil rightControlUtil; |
| | | |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | @Autowired |
| | | RightControlUtil rightControlUtil; |
| | | |
| | | /** |
| | | * 查询所有的功能 |
| | |
| | | String controlType = resourceControlTypeEnum.getValue(); |
| | | List<SmFunctionVO> functionVOS = functionForPlatform1ToFunctionDOs(functions); |
| | | return functionVOS.stream().filter(s->controlType.equalsIgnoreCase(s.getResourceControlType())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户返回所有菜单下的按钮(树形结构) |
| | | * |
| | | * @param treeQueryObject |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MenuVO> 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<FunctionInfo> menuList = rightControlUtil.getMenusByPIdAndPermission(parentId, sessionInfo.getUserId(),userRoleRights); |
| | | Map<String, List<FunctionInfo>> map = rightControlUtil.getAllChildrenFunctionsByUserName( |
| | | parentId, sessionInfo.getUserId(), userRoleRights); |
| | | List<MenuVO> 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<MenuVO> menuVOList = new ArrayList<>(); |
| | | recursionFunction(functionVOList,menuVOList); |
| | | // 5、处理每一个菜单下需要返回的按钮 |
| | | menuVOList.stream().forEach(menuVO -> { |
| | | try { |
| | | //6、获取当前菜单下的按钮 |
| | | Map<String, Long> 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<MenuVO> sourceList, List<MenuVO> 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<MenuVO> getButtonsByAuth(String parentOid,boolean adminOrDeveloperOrRoot,Map<String, Long> authMap) throws PLException { |
| | | List<MenuVO> buttonList = new ArrayList<>(); |
| | | if(Func.isBlank(parentOid)){ |
| | | return buttonList; |
| | | } |
| | | FuncOperationInfo[] funcOperates = platformClientUtil.getFrameworkService().getFuncOperationByModule(parentOid, "", true); |
| | | List<FuncOperationInfo> 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | functionVO.setBtmname("function"); |
| | | functionVO.setBtmName("function"); |
| | | //老的数据里创建人,最后修改人等都没有 |
| | | return functionVO; |
| | | } |
| | |
| | | //} |
| | | functionVO.setPath(menu.resourceB); |
| | | functionVO.setParentId(menu.parentId); |
| | | functionVO.setCode(menu.aliasName); |
| | | //functionVO.setCode(menu.aliasName); |
| | | functionVO.setAlias(menu.aliasName); |
| | | functionVO.setName(menu.name); |
| | | functionVO.getMeta().put("keepAlive",false); |
| | | functionVO.getMeta().put("keepAlive",true); |
| | | functionVO.setSort((int) menu.seq); |
| | | try { |
| | | functionVO.setChildren(findChildFunctionVO(menu.id, map)); |
| | |
| | | } |
| | | functionVOList.add(functionVO); |
| | | } |
| | | //如果是开发或者测试用户,需哟获取系统模块配置菜单 |
| | | //如果是开发或者测试用户,需要获取系统模块配置菜单 |
| | | if(adminOrDeveloperOrRoot){ |
| | | //获取首页系统模块配置菜单 |
| | | MenuVO menuVO = JsonConfigReader.getSysModuleConf().getSysModuleNode(); |
| | |
| | | return menuVOList; |
| | | } |
| | | boolean isFunctionObject = Func.isNotBlank(modeType) && modeType.equalsIgnoreCase("FunctionObject"); |
| | | if(parentId.equals("systemManagmentNode") || parentId.equals("modelManagmentNode") || isFunctionObject){ |
| | | if(parentId.equals("system") || parentId.equals("business") || isFunctionObject){ |
| | | int childType = this.checkChildObject(parentId); |
| | | if(isFunctionObject){ |
| | | try { |
| | |
| | | if(childType == 2){ |
| | | try{ |
| | | FuncOperationInfo[] infos = platformClientUtil.getFrameworkService().getFuncOperationByModule(parentId, "", false); |
| | | if(Func.isNotEmpty(infos.length)){ |
| | | if(Func.isNotEmpty(infos)){ |
| | | childType = this.checkChildObject(infos[0].id); //都是同一层所以取第一个即可查询是什么类型 |
| | | for(int i = 0;i < infos.length ;i++){ |
| | | FuncOperationInfo info = infos[i]; |
| | |
| | | menuVO.setIsValid(info.isValid); |
| | | menuVO.setHasChildren(false); |
| | | menuVO.setCategory(1); |
| | | menuVO.setFunctionType(2); |
| | | menuVO.setFunctionType(3); |
| | | menuVO.setSource(info.image); |
| | | menuVOList.add(menuVO); |
| | | } |
| | | } |
| | |
| | | try{ |
| | | MenuVO parentNode = null; |
| | | //将返回的节点外层套上当前父节点 |
| | | if("systemManagmentNode".equals(parentId)){ |
| | | if("system".equals(parentId)){ |
| | | parentNode = JsonConfigReader.getSysModuleConf().getSystemManagmentNode(); |
| | | }else if("modelManagmentNode".equals(parentId)){ |
| | | }else if("business".equals(parentId)){ |
| | | parentNode = JsonConfigReader.getSysModuleConf().getModelManagmentNode(); |
| | | } |
| | | //如果查询的是第一层节点就需要直接返回systemManagmentNode或modelManagmentNode节点 |
| | |
| | | menuVO.setFunctionType(2); |
| | | menuVO.setChildType(0); |
| | | menuVO.setRemark(operateInfo.desc); |
| | | menuVO.getMeta().put("keepAlive",false); |
| | | 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) { |
| | |
| | | * @param funcInfo |
| | | * @return |
| | | */ |
| | | private MenuVO functionInfoToMenuVO(FunctionInfo funcInfo) |
| | | { |
| | | private MenuVO functionInfoToMenuVO(FunctionInfo funcInfo) { |
| | | MenuVO menuVO = new MenuVO(); |
| | | menuVO.setId(funcInfo.id); |
| | | menuVO.setIsValid(funcInfo.isValid); |
| | |
| | | menuVO.setResourceMobile(funcInfo.resourceMobile); |
| | | menuVO.setPath(funcInfo.resourceB); |
| | | menuVO.setParentId(funcInfo.parentId); |
| | | menuVO.setCode(funcInfo.aliasName); |
| | | //menuVO.setCode(funcInfo.aliasName); |
| | | menuVO.setAlias(funcInfo.aliasName); |
| | | menuVO.setName(funcInfo.name); |
| | | menuVO.getMeta().put("keepAlive",false); |
| | | menuVO.getMeta().put("keepAlive",true); |
| | | menuVO.setSort((int) funcInfo.seq); |
| | | menuVO.setRemark(funcInfo.desc); |
| | | if(this.checkChildObject(menuVO.getId()) == 0){ |
| | | menuVO.setHasChildren(false); |
| | | }else{ |
| | |
| | | functionVO.setId(menu.id); |
| | | functionVO.setSource(menu.image); |
| | | functionVO.setFunctionType(menu.functionType); |
| | | // if(StringUtils.isBlank(menu.resourceB) ){ |
| | | // continue; |
| | | // } |
| | | functionVO.setIsValid(menu.isValid); |
| | | functionVO.setPath(menu.resourceB); |
| | | functionVO.setCode(menu.aliasName); |
| | | //functionVO.setCode(menu.aliasName); |
| | | functionVO.setAlias(menu.aliasName); |
| | | functionVO.setParentId(menu.parentId); |
| | | functionVO.setName(menu.name); |
| | | functionVO.getMeta().put("keepAlive",false); |
| | | 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); |
| | |
| | | menuVO.setParentId(funcObj.parentId); |
| | | menuVO.setChildType((int) type); |
| | | menuVO.setName(funcObj.name); |
| | | menuVO.getMeta().put("keepAlive",false); |
| | | menuVO.getMeta().put("keepAlive",true); |
| | | menuVO.setSort((int) funcObj.seq); |
| | | menuVO.setRemark(funcObj.desc); |
| | | findChildAuthFunctionVO(menuVO, isAll); |
| | | functionVO.getChildren().add(menuVO); |
| | | functionVO.setHasChildren(true); |
| | |
| | | @Override |
| | | public UIContentVO getUIContentByBtmTypeAndId(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException { |
| | | SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); |
| | | if(resourceControlTypeEnum == null){ |
| | | /* if(resourceControlTypeEnum == null){ |
| | | resourceControlTypeEnum = ResourceControlTypeEnum.BS; |
| | | } |
| | | }*/ |
| | | Map<String, List<RoleRightVO>> 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); |
| | | return uiEngineServiceI.UIContentDO2VO(allPLUILayout,true,roleRightMap); |
| | | } |
| | | } |
| | | return null; |
| | |
| | | List<String> authList = new ArrayList<>(); |
| | | for (FunctionInfo functionInfo : moduleListByParentId) { |
| | | if(authMap.containsKey(functionInfo.id)){ |
| | | // authList.add(functionInfo.id); |
| | | // authList.add(functionInfo.id); |
| | | getChildAuthNode(functionInfo, authMap, authList); |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过模块ID获取子级列表 |
| | | * @param isAll 是否包括无效的模块,true则包括 |
| | |
| | | return functionVOList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过模块ID获取子级列表 |
| | | * @param parentId |
| | |
| | | funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(parentId, isAll); |
| | | return funcInfos; |
| | | } |
| | | |
| | | } |