From af8757f5f6b9c9c215fc09636610fbf3ffc74deb Mon Sep 17 00:00:00 2001 From: yuxc <yuxc@vci-tech.com> Date: 星期二, 07 一月 2025 10:08:28 +0800 Subject: [PATCH] 按钮返回接口增加图标返回数据 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/SmFunctionQueryServicePlatformImpl.java | 218 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 186 insertions(+), 32 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/SmFunctionQueryServicePlatformImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/SmFunctionQueryServicePlatformImpl.java index dc8ea53..42cf760 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/SmFunctionQueryServicePlatformImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/SmFunctionQueryServicePlatformImpl.java @@ -13,6 +13,7 @@ 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; @@ -24,6 +25,7 @@ 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; @@ -56,12 +58,12 @@ /** * 鑿滃崟鐨勬牴鑺傜偣涓婚敭锛岃繖涓槸骞冲彴瀹氫箟鐨� */ - private final String ROOT_MENU_ID = "modelManagmentNode"; + private final String ROOT_MENU_ID = "business"; /** * 绠$悊鍔熻兘妯″潡鑿滃崟鏍硅妭鐐� */ - private final String SYSTEMMANAGMENTNODE = "systemManagmentNode"; + private final String SYSTEMMANAGMENTNODE = "system"; /** * 鎿嶄綔绫诲瀷绠$悊鑿滃崟鏍硅妭鐐� @@ -87,13 +89,16 @@ 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; /** * 鏌ヨ鎵�鏈夌殑鍔熻兘 @@ -147,6 +152,156 @@ 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) { + // 妫�鏌unctionType鏄惁涓�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; } /** @@ -214,7 +369,7 @@ } } - functionVO.setBtmname("function"); + functionVO.setBtmName("function"); //鑰佺殑鏁版嵁閲屽垱寤轰汉锛屾渶鍚庝慨鏀逛汉绛夐兘娌℃湁 return functionVO; } @@ -261,10 +416,10 @@ //} 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)); @@ -281,7 +436,7 @@ } functionVOList.add(functionVO); } - //濡傛灉鏄紑鍙戞垨鑰呮祴璇曠敤鎴凤紝闇�鍝熻幏鍙栫郴缁熸ā鍧楅厤缃彍鍗� + //濡傛灉鏄紑鍙戞垨鑰呮祴璇曠敤鎴凤紝闇�瑕佽幏鍙栫郴缁熸ā鍧楅厤缃彍鍗� if(adminOrDeveloperOrRoot){ //鑾峰彇棣栭〉绯荤粺妯″潡閰嶇疆鑿滃崟 MenuVO menuVO = JsonConfigReader.getSysModuleConf().getSysModuleNode(); @@ -307,7 +462,7 @@ 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 { @@ -315,7 +470,7 @@ 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]; @@ -333,7 +488,8 @@ menuVO.setIsValid(info.isValid); menuVO.setHasChildren(false); menuVO.setCategory(1); - menuVO.setFunctionType(2); + menuVO.setFunctionType(3); + menuVO.setSource(info.image); menuVOList.add(menuVO); } } @@ -368,9 +524,9 @@ 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(); } //濡傛灉鏌ヨ鐨勬槸绗竴灞傝妭鐐瑰氨闇�瑕佺洿鎺ヨ繑鍥瀞ystemManagmentNode鎴杕odelManagmentNode鑺傜偣 @@ -417,10 +573,11 @@ 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) { @@ -436,8 +593,7 @@ * @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); @@ -448,10 +604,10 @@ 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); if(this.checkChildObject(menuVO.getId()) == 0){ menuVO.setHasChildren(false); @@ -493,15 +649,13 @@ 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.setChildren(findChildFunctionVO(menu.id,map)); if(functionVO.getChildren().size() > 0){ @@ -529,7 +683,7 @@ 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); findChildAuthFunctionVO(menuVO, isAll); functionVO.getChildren().add(menuVO); @@ -562,13 +716,14 @@ @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, 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; @@ -600,7 +755,7 @@ 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); } } @@ -1090,7 +1245,6 @@ } - /** * 閫氳繃妯″潡ID鑾峰彇瀛愮骇鍒楄〃 * @param isAll 鏄惁鍖呮嫭鏃犳晥鐨勬ā鍧楋紝true鍒欏寘鎷� @@ -1136,7 +1290,6 @@ return functionVOList; } - /** * 閫氳繃妯″潡ID鑾峰彇瀛愮骇鍒楄〃 * @param parentId @@ -1149,4 +1302,5 @@ funcInfos = platformClientUtil.getFrameworkService().getModuleListByParentId(parentId, isAll); return funcInfos; } + } -- Gitblit v1.9.3