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;
    /**
     * 查询所有的功能
     *
@@ -199,7 +211,7 @@
                functionVO.setDescription(functionForPlatform1.getPldesc());
            }
        }
        functionVO.setBtmname("function");
        //老的数据里创建人,最后修改人等都没有
        return functionVO;
@@ -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())) {
            // 系统菜单
            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)) {
@@ -239,9 +254,9 @@
            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);
@@ -249,7 +264,14 @@
            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 {
@@ -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();
@@ -310,9 +431,6 @@
        return null;
    }
    /**
     * 获取所有的功能菜单
     *
@@ -324,7 +442,7 @@
    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());
    }
@@ -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);
@@ -385,7 +503,7 @@
    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());
    }
@@ -401,12 +519,12 @@
    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());
    }