| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.vci.client.common.providers.ServiceProvider; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.framework.data.FunctionInfo; |
| | | import com.vci.corba.framework.data.RoleRightInfo; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.corba.portal.data.PLUILayout; |
| | | import com.vci.frameworkcore.compatibility.ISmFunctionQueryService; |
| | | import com.vci.frameworkcore.enumpck.ResourceControlTypeEnum; |
| | | import com.vci.frameworkcore.model.SmFunctionForPlatform1; |
| | | import com.vci.frameworkcore.model.SmRoleForPlatform1; |
| | | import com.vci.frameworkcore.pagemodel.MenuVO; |
| | | import com.vci.frameworkcore.pagemodel.SmFunctionVO; |
| | | import com.vci.model.SmFunctionForPlatform1; |
| | | import com.vci.model.SmRoleForPlatform1; |
| | | import com.vci.pagemodel.MenuVO; |
| | | import com.vci.pagemodel.SmFunctionVO; |
| | | import com.vci.omd.utils.ObjectTool; |
| | | import com.vci.pagemodel.SmFunctionVO; |
| | | 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.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.pageModel.UIContentVO; |
| | | import com.vci.pagemodel.UIContentVO; |
| | | import com.vci.web.service.UIEngineServiceI; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | 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; |
| | |
| | | @Autowired |
| | | private UIEngineServiceI uiEngineServiceI; |
| | | |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | @Autowired |
| | | RightControlUtil rightControlUtil; |
| | | /** |
| | | * 查询所有的功能 |
| | | * |
| | |
| | | return functionVO; |
| | | } |
| | | |
| | | // /** |
| | | // * 获取当前角色的菜单 |
| | | // * |
| | | // * @param treeQueryObject 属性查询对象 |
| | | // * @param resourceControlTypeEnum 角色控制区域,也是功能控制的区域 |
| | | // * @return 菜单,包含上下级 |
| | | // */ |
| | | // @Override |
| | | // public List<Tree> treeCurrentUserMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) { |
| | | // SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); |
| | | // if(sessionInfo == null || CollectionUtils.isEmpty(sessionInfo.getFunctionOids())){ |
| | | // return new ArrayList<Tree>(); |
| | | // } |
| | | // if(resourceControlTypeEnum == null){ |
| | | // resourceControlTypeEnum = ResourceControlTypeEnum.BS; |
| | | // } |
| | | // Map<String, SmFunctionVO> functionVOMap = selectAllFunctionMap(); |
| | | // List<SmFunctionVO> functionVOList = new ArrayList<>(); |
| | | // for(String oid : sessionInfo.getFunctionOids()) { |
| | | // SmFunctionVO functionVO = functionVOMap.get(oid); |
| | | // if(functionVO !=null && resourceControlTypeEnum.getValue().equals(functionVO.getResourceControlType()) && functionVO.isDisplayFlag()) { |
| | | // functionVOList.add(functionVO); |
| | | // } |
| | | // } |
| | | // return dos2Trees(functionVOList.stream().sorted(Comparator.comparing(s -> s.getOrderNum())).collect(Collectors.toList()),treeQueryObject == null?null:treeQueryObject.getParentOid()); |
| | | // } |
| | | |
| | | /** |
| | | * 获取当前角色的菜单 |
| | | * |
| | |
| | | @Override |
| | | public List<MenuVO> treeCurrentUserMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException { |
| | | SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); |
| | | // if(sessionInfo == null || CollectionUtils.isEmpty(sessionInfo.getFunctionOids())){ |
| | | // return new ArrayList<Tree>(); |
| | | // } |
| | | if(resourceControlTypeEnum == null){ |
| | | resourceControlTypeEnum = ResourceControlTypeEnum.BS; |
| | | } |
| | | // PortalServicePrx uiService = ServiceProvider.getUIService(); |
| | | // FrameworkServicePrx frameService = ServiceProvider.getFrameService(); |
| | | FunctionInfo[] menus = ServiceProvider.getFrameService().getModuleListByParentId("modelManagmentNode", true); |
| | | // FunctionInfo[] menus = ServiceProvider.getFrameService().("modelManagmentNode", true); |
| | | String parentId; |
| | | |
| | | // PLAction[] allPLAction = uiService.getAllPLAction(); |
| | | if (rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId())) { |
| | | // 系统菜单 |
| | | parentId = "systemManagmentNode" ; |
| | | } else if (rightControlUtil.isThreeAdminCurUser()) { |
| | | parentId = "systemManagmentNode" ; |
| | | } else { |
| | | parentId = "modelManagmentNode" ; |
| | | } |
| | | RoleRightInfo[] userRoleRights = rightControlUtil.getRoleRightByUserName(sessionInfo.getUserId()); |
| | | Map<String, List<FunctionInfo>> map = rightControlUtil.getAllChildrenFunctionsByUserName( |
| | | parentId, sessionInfo.getUserId(), userRoleRights); |
| | | List<MenuVO> functionVOList = new ArrayList<>(); |
| | | // Map<String, SmFunctionVO> functionVOMap = selectAllFunctionMap(); |
| | | for (FunctionInfo menu : menus) { |
| | | if(CollectionUtils.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); |
| | | // if(menu.resourceB.contains("type=") || menu.resourceB.contains("context=")){ |
| | | // String[] split = menu.resourceB.split("\\?")[0].split("="); |
| | | // functionVO.setPath((split.length>1 && split[1].equals("test") ? "/custom-ui/" :"/base/UIContentViewer") + menu.resourceB.substring(3)); |
| | | // }else{ |
| | | // functionVO.setPath("/views/" + menu.id); |
| | | //// functionVO.setPath("/" + menu.resourceB + menu.aliasName); |
| | | // 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",false); |
| | | functionVO.setSort((int) menu.seq); |
| | | functionVO.setChildren(findChildFunctionVO(menu.id)); |
| | | functionVO.setChildren(findChildFunctionVO(menu.id, map)); |
| | | if(functionVO.getChildren().size() > 0){ |
| | | functionVO.setHasChildren(true); |
| | | }else { |
| | |
| | | } |
| | | functionVOList.add(functionVO); |
| | | } |
| | | // return dos2Trees(functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList()),treeQueryObject == null?null:treeQueryObject.getParentOid()); |
| | | return functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public List<MenuVO> findChildFunctionVO(String parentOid) throws PLException { |
| | | FunctionInfo[] menus = ServiceProvider.getFrameService().getModuleListByParentId(parentOid, true); |
| | | public List<MenuVO> findChildFunctionVO(String parentOid,Map<String, List<FunctionInfo>> map) throws PLException { |
| | | List<FunctionInfo> menus = map.get(parentOid); |
| | | List<MenuVO> 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); |
| | | if(StringUtils.isBlank(menu.resourceB) ){ |
| | | continue; |
| | | } |
| | | functionVO.setPath(menu.resourceB); |
| | | // if(menu.resourceB.contains("type=") || menu.resourceB.contains("context=")){ |
| | | // String[] split = menu.resourceB.split("\\?")[0].split("="); |
| | | // functionVO.setPath((split.length>1 && split[1].equals("test") ? "/custom-ui/" :"/base/UIContentViewer") + menu.resourceB.substring(3)); |
| | | // }else{ |
| | | // functionVO.setPath("/views/" + menu.id); |
| | | //// functionVO.setPath("/" + menu.resourceB + menu.aliasName); |
| | | // if(StringUtils.isBlank(menu.resourceB) ){ |
| | | // continue; |
| | | // } |
| | | functionVO.setPath(menu.resourceB); |
| | | functionVO.setCode(menu.aliasName); |
| | | functionVO.setAlias(menu.aliasName); |
| | | functionVO.setParentId(menu.parentId); |
| | | functionVO.setName(menu.name); |
| | | functionVO.getMeta().put("keepAlive",false); |
| | | functionVO.setSort((int) menu.seq); |
| | | functionVO.setChildren(findChildFunctionVO(menu.id)); |
| | | functionVO.setChildren(findChildFunctionVO(menu.id,map)); |
| | | if(functionVO.getChildren().size() > 0){ |
| | | functionVO.setHasChildren(true); |
| | | }else { |
| | |
| | | @Override |
| | | public UIContentVO getUIContentByBtmTypeAndId(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException { |
| | | SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); |
| | | // if(sessionInfo == null || CollectionUtils.isEmpty(sessionInfo.getFunctionOids())){ |
| | | // return new ArrayList<Tree>(); |
| | | // } |
| | | if(resourceControlTypeEnum == null){ |
| | | resourceControlTypeEnum = ResourceControlTypeEnum.BS; |
| | | } |
| | | for (PLUILayout allPLUILayout : ServiceProvider.getUIService().getAllPLUILayouts()) { |
| | | 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); |
| | |
| | | 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); |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmRoleForPlatform1.class); |
| | | List<SmFunctionForPlatform1> functionForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmFunctionForPlatform1.class); |
| | | if(!CollectionUtils.isEmpty(functionForPlatform1s)){ |
| | | functions.addAll(functionForPlatform1s); |
| | |
| | | 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<com.vci.client.bof.ClientBusinessObject> cbos = boService.queryBySql(sql, null); |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | if(!CollectionUtils.isEmpty(cbos)){ |
| | | cbos.stream().forEach(cbo->{ |
| | | String roleOid = cbo.getAttributeValue("plroleoid"); |
| | | String roleOid = ObjectTool.getBOAttributeValue(cbo,"plroleoid"); |
| | | List<String> functionOids = roleFunctionOidMap.getOrDefault(roleOid,new ArrayList<>()); |
| | | functionOids.add(cbo.getAttributeValue("plfuncoid")); |
| | | functionOids.add(ObjectTool.getBOAttributeValue(cbo,"plfuncoid")); |
| | | roleFunctionOidMap.put(roleOid,functionOids); |
| | | }); |
| | | } |