ludc
2024-08-15 118211ba511524e94952c896bd508ff9baec46c8
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmFunctionQueryServicePlatformImpl.java
@@ -1,5 +1,6 @@
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;
@@ -17,10 +18,12 @@
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;
@@ -51,9 +54,17 @@
    /**
     * 菜单的根节点主键,这个是平台定义的
     */
   private final String ROOT_MENU_Id  = "modelManagmentNode";
   private final String ROOT_MENU_ID  = "modelManagmentNode";
    /**
     * 管理功能模块菜单根节点
     */
    private final String SYSTEMMANAGMENTNODE = "systemManagmentNode";
    /**
     * 操作类型管理菜单根节点
     */
    private final String OPERATENODE = "operateNode";
    /**
     * 使用用户查询
@@ -81,6 +92,7 @@
    @Autowired
    RightControlUtil rightControlUtil;
    /**
     * 查询所有的功能
     *
@@ -216,20 +228,23 @@
    public List<MenuVO> treeCurrentUserMenu(TreeQueryObject treeQueryObject, ResourceControlTypeEnum resourceControlTypeEnum) throws PLException {
        SessionInfo sessionInfo = WebUtil.getCurrentUserSessionInfoNotException();
        String parentId;
        if (rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId())) {
        boolean adminOrDeveloperOrRoot = rightControlUtil.isAdminOrDeveloperOrRoot(sessionInfo.getUserId());
        if (adminOrDeveloperOrRoot) {
            // 系统菜单
            parentId = "systemManagmentNode" ;
            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)) {
@@ -249,7 +264,14 @@
            functionVO.setName(menu.name);
            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 {
@@ -257,7 +279,107 @@
            }
            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 {
@@ -294,7 +416,6 @@
        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();
@@ -309,9 +430,6 @@
        }
        return null;
    }
    /**
     * 获取所有的功能菜单
@@ -341,7 +459,7 @@
            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);