| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.framework.data.FunctionInfo; |
| | |
| | | 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.pagemodel.UIContentVO; |
| | | import com.vci.web.service.UIEngineServiceI; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.RightControlUtil; |
| | | import com.vci.web.util.WebUtil; |
| | |
| | | /** |
| | | * 菜单的根节点主键,这个是平台定义的 |
| | | */ |
| | | private final String ROOT_MENU_Id = "modelManagmentNode"; |
| | | private final String ROOT_MENU_ID = "modelManagmentNode"; |
| | | |
| | | /** |
| | | * 管理功能模块菜单根节点 |
| | | */ |
| | | private final String SYSTEMMANAGMENTNODE = "systemManagmentNode"; |
| | | |
| | | /** |
| | | * 操作类型管理菜单根节点 |
| | | */ |
| | | private final String OPERATENODE = "operateNode"; |
| | | |
| | | /** |
| | | * 使用用户查询 |
| | |
| | | |
| | | @Autowired |
| | | RightControlUtil rightControlUtil; |
| | | |
| | | /** |
| | | * 查询所有的功能 |
| | | * |
| | |
| | | functionVO.setDescription(functionForPlatform1.getPldesc()); |
| | | } |
| | | } |
| | | |
| | | |
| | | functionVO.setBtmname("function"); |
| | | //老的数据里创建人,最后修改人等都没有 |
| | | return functionVO; |
| | |
| | | public List<MenuVO> treeCurrentUserMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException { |
| | | SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); |
| | | String parentId; |
| | | |
| | | if (rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId())) { |
| | | // 系统菜单 |
| | | parentId = "systemManagmentNode" ; |
| | | boolean adminOrDeveloperOrRoot = rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId()); |
| | | if (adminOrDeveloperOrRoot) { |
| | | //系统菜单 |
| | | parentId = SYSTEMMANAGMENTNODE; |
| | | } else if (rightControlUtil.isThreeAdminCurUser()) { |
| | | parentId = "systemManagmentNode" ; |
| | | //三员返回管理功能模块相关的菜单 |
| | | parentId = SYSTEMMANAGMENTNODE; |
| | | } else { |
| | | parentId = "modelManagmentNode" ; |
| | | //普通用户只返回业务功能模块相关的菜单 |
| | | parentId = ROOT_MENU_ID; |
| | | } |
| | | RoleRightInfo[] userRoleRights = rightControlUtil.getRoleRightByUserName(sessionInfo.getUserId()); |
| | | Map<String, List<FunctionInfo>> map = rightControlUtil.getAllChildrenFunctionsByUserName( |
| | | parentId, sessionInfo.getUserId(), userRoleRights); |
| | | |
| | | List<MenuVO> functionVOList = new ArrayList<>(); |
| | | if(CollectionUtils.isEmpty(map.get(parentId))){ |
| | | if(Func.isEmpty(map.get(parentId))) { |
| | | return functionVOList; |
| | | } |
| | | for (FunctionInfo menu : map.get(parentId)) { |
| | |
| | | MenuVO functionVO = new MenuVO(); |
| | | functionVO.setId(menu.id); |
| | | functionVO.setSource(menu.image); |
| | | // if(StringUtils.isBlank(menu.resourceB)){ |
| | | // continue; |
| | | // } |
| | | //if(StringUtils.isBlank(menu.resourceB)){ |
| | | // continue; |
| | | //} |
| | | functionVO.setPath(menu.resourceB); |
| | | functionVO.setParentId(menu.parentId); |
| | | functionVO.setCode(menu.aliasName); |
| | |
| | | functionVO.setName(menu.name); |
| | | functionVO.getMeta().put("keepAlive",false); |
| | | functionVO.setSort((int) menu.seq); |
| | | functionVO.setChildren(findChildFunctionVO(menu.id, map)); |
| | | 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 { |
| | |
| | | } |
| | | functionVOList.add(functionVO); |
| | | } |
| | | if(adminOrDeveloperOrRoot){ |
| | | functionVOList.addAll(this.getSystemMenu()); |
| | | } |
| | | return functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * 获取首页系统模块配置菜单 |
| | | * @return |
| | | */ |
| | | private List<MenuVO> getSystemMenu(){ |
| | | /*如果是测试账号或者开发账号,处理返回systemManagmentNode和modelManagmentNode以外, |
| | | 还需要返回操作类型管理菜单节点(operateNode)和系统配置、系统运行监控节点*/ |
| | | List<MenuVO> functionVOList = new ArrayList<>(); |
| | | String menuJson = "{\n" + |
| | | " \"hasChildren\": true,\n" + |
| | | " \"children\": [\n" + |
| | | " {\n" + |
| | | " \"hasChildren\": true,\n" + |
| | | " \"children\": [],\n" + |
| | | " \"id\": \"systemManagmentNode\",\n" + |
| | | " \"name\": \"管理功能模块\",\n" + |
| | | " \"parentId\": \"VCIBaseTreeNode\",\n" + |
| | | " \"code\": \"systemManagmentNode\",\n" + |
| | | " \"alias\": \"system\",\n" + |
| | | " \"meta\": {\n" + |
| | | " \"keepAlive\": false\n" + |
| | | " },\n" + |
| | | " \"sort\": 2,\n" + |
| | | " \"soruce\": \"\"\n" + |
| | | " },\n" + |
| | | " {\n" + |
| | | " \"hasChildren\": true,\n" + |
| | | " \"children\": [],\n" + |
| | | " \"id\": \"modelManagmentNode\",\n" + |
| | | " \"name\": \"业务功能模块\",\n" + |
| | | " \"parentId\": \"VCIBaseTreeNode\",\n" + |
| | | " \"code\": \"modelManagmentNode\",\n" + |
| | | " \"alias\": \"model\",\n" + |
| | | " \"meta\": {\n" + |
| | | " \"keepAlive\": false\n" + |
| | | " },\n" + |
| | | " \"sort\": 3,\n" + |
| | | " \"soruce\": \"\"\n" + |
| | | " },\n" + |
| | | " {\n" + |
| | | " \"hasChildren\": true,\n" + |
| | | " \"children\": [],\n" + |
| | | " \"id\": \"operateNode\",\n" + |
| | | " \"name\": \"操作类型管理\",\n" + |
| | | " \"parentId\": \"VCIBaseTreeNode\",\n" + |
| | | " \"code\": \"operateNode\",\n" + |
| | | " \"alias\": \"operate\",\n" + |
| | | " \"meta\": {\n" + |
| | | " \"keepAlive\": false\n" + |
| | | " },\n" + |
| | | " \"sort\": 4,\n" + |
| | | " \"soruce\": \"\"\n" + |
| | | " },\n" + |
| | | " {\n" + |
| | | " \"hasChildren\": false,\n" + |
| | | " \"children\": [],\n" + |
| | | " \"id\": \"sysOptionNode\",\n" + |
| | | " \"name\": \"系统配置\",\n" + |
| | | " \"parentId\": \"VCIBaseTreeNode\",\n" + |
| | | " \"code\": \"sysOptionNode\",\n" + |
| | | " \"alias\": \"sysOption\",\n" + |
| | | " \"meta\": {\n" + |
| | | " \"keepAlive\": false\n" + |
| | | " },\n" + |
| | | " \"sort\": 5,\n" + |
| | | " \"soruce\": \"\"\n" + |
| | | " },\n" + |
| | | " {\n" + |
| | | " \"hasChildren\": false,\n" + |
| | | " \"children\": [],\n" + |
| | | " \"id\": \"sysMonitorNode\",\n" + |
| | | " \"name\": \"系统运行监控\",\n" + |
| | | " \"parentId\": \"VCIBaseTreeNode\",\n" + |
| | | " \"code\": \"sysMonitorNode\",\n" + |
| | | " \"alias\": \"sysMonitor\",\n" + |
| | | " \"meta\": {\n" + |
| | | " \"keepAlive\": false\n" + |
| | | " },\n" + |
| | | " \"sort\": 5,\n" + |
| | | " \"soruce\": \"\"\n" + |
| | | " }\n" + |
| | | " ],\n" + |
| | | " \"id\": \"VCIBaseTreeNode\",\n" + |
| | | " \"name\": \"系统模块配置\",\n" + |
| | | " \"parentId\": \"\",\n" + |
| | | " \"code\": \"rootNode\",\n" + |
| | | " \"alias\": \"root\",\n" + |
| | | " \"meta\": {\n" + |
| | | " \"keepAlive\": false\n" + |
| | | " },\n" + |
| | | " \"sort\": 1,\n" + |
| | | " \"soruce\": \"\"\n" + |
| | | "}"; |
| | | functionVOList.add(JSON.parseObject(menuJson, MenuVO.class)); |
| | | return functionVOList; |
| | | } |
| | | |
| | | public List<MenuVO> findChildFunctionVO(String parentOid,Map<String, List<FunctionInfo>> map) throws PLException { |
| | |
| | | return functionVOList.stream().sorted(Comparator.comparing(s -> s.getSort())).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public UIContentVO getUIContentByBtmTypeAndId(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException { |
| | | SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取所有的功能菜单 |
| | | * |
| | |
| | | public List<Tree> treeAllMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) { |
| | | List<SmFunctionVO> 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()); |
| | | 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()); |
| | | } |
| | |
| | | List<Tree> 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())) { |
| | | if (tree.getParentId() == null || tree.getParentId().equals(rootId) || ROOT_MENU_ID.equalsIgnoreCase(tree.getParentId())) { |
| | | rootList.add(tree); |
| | | } else { |
| | | childList.add(tree); |
| | |
| | | public List<Tree> treeFunctionByParent(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) { |
| | | List<SmFunctionVO> 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()); |
| | | functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList()); |
| | | } |
| | | return dos2Trees(functionVOList,treeQueryObject == null?null:treeQueryObject.getParentOid()); |
| | | } |
| | |
| | | public List<Tree> treeCurrentFunctionByParent(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) { |
| | | SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfo(); |
| | | List<SmFunctionVO> functionVOList =self.selectAllFunction().stream().filter(s -> s.isDisplayFlag() |
| | | && resourceControlTypeEnum.getValue().equalsIgnoreCase(s.getResourceControlType()) |
| | | && 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()); |
| | | functionVOList = functionVOList.stream().filter(s->treeQueryObject.getParentOid().equalsIgnoreCase(s.getParentFunctionId())).collect(Collectors.toList()); |
| | | } |
| | | return dos2Trees(functionVOList,treeQueryObject == null?null:treeQueryObject.getParentOid()); |
| | | } |