From aecacfb404d19749260189ab1d4ee90efc92ae24 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期二, 15 十月 2024 14:46:52 +0800
Subject: [PATCH] UI授权树查询接口优化。添加按角色查询已授权UI接口。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/utility/UIDataFetcher.java                               |  178 +++++++++++++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java                      |   21 ++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java |    7 
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java                           |   13 +
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java                   |  298 +++++++++++++++++++++-----------
 5 files changed, 407 insertions(+), 110 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java
index 3357a53..8aae3cd 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmUserQueryServiceImpl.java
@@ -357,6 +357,7 @@
 		}else {
 			smRoleVOList = smRoleQueryService.listRoleByUserOid(userInfo.id,null);
 		}
+
 		smUserVO.setPkPerson(
 				Func.isEmpty(smRoleVOList) ?
 						null:smRoleVOList.stream().map(SmRoleVO::getOid).collect(Collectors.joining(","))
@@ -541,7 +542,11 @@
 			smRoleVOMap = smRoleQueryService.batchListRoleByUserOids(idList,null);
 			smPwdStrategyVOMap = smPwdStrategyQueryService.batchSmPwdStrategyByUserOids(idList);
 			dataGrid.setData(userInfoArr2VO(userInfos));
-			//TODO: 杩欎釜缁熻鎬绘暟鏈夐棶棰橈紝甯﹁繃鍘荤殑鍙傛暟涓嶈兘鍍忎笂闈㈤偅涓猣etchUserInfoByCondition鏌ヨ涓�鏍风粺璁″鍗寸殑鎬绘暟
+			//鐢ㄥ畬浜嗘竻绌�
+			orgDepartmentVOMap = null;
+			smRoleVOMap = null;
+			smPwdStrategyVOMap = null;
+			//TODO: 杩欎釜缁熻鎬绘暟鏈夐棶棰橈紝甯﹁繃鍘荤殑鍙傛暟涓嶈兘鍍忎笂闈㈤偅涓猣etchUserInfoByCondition鏌ヨ涓�鏍风粺璁$殑鍗寸殑鎬绘暟
 			dataGrid.setTotal(
 					platformClientUtil.getFrameworkService().getUserTotalByCondition(
 						conditionMap.get("name"),
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java
index ce4cb2d..9e8b201 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java
@@ -607,7 +607,7 @@
     @VciBusinessLog(operateName = "UI鎺堟潈锛堟爲褰㈢粨鏋勶級")
     public BaseResult getUIAuthor(BaseQueryObject baseQueryObject){
         try {
-            return BaseResult.dataList( uiManagerService.getUIAuthor(baseQueryObject));
+            return BaseResult.dataList(uiManagerService.getUIAuthor(baseQueryObject));
         }catch (Throwable e) {
             e.printStackTrace();
             String exceptionMessage = "UI鎺堟潈鍔犺浇鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
@@ -616,6 +616,25 @@
         }
     }
 
+    /**
+     * 鏍规嵁瑙掕壊涓婚敭鑾峰彇宸叉巿鏉冪殑淇℃伅
+     * @param roleId
+     * @return
+     * @throws PLException
+     */
+    @GetMapping( "/getRightListByRoleId")
+    @VciBusinessLog(operateName = "鏍规嵁瑙掕壊涓婚敭鑾峰彇宸叉巿鏉冪殑UI涓婚敭闆嗗悎")
+    public BaseResult getRightListByRoleId(String roleId){
+        try {
+            return BaseResult.dataList(uiManagerService.getRightListByRoleId(roleId));
+        }catch (Throwable e) {
+            e.printStackTrace();
+            String exceptionMessage = "鑾峰彇宸叉巿鏉冧俊鎭椂閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
     /***
      * @param uiAuthorDTO 鍕鹃�夌殑闇�瑕佷繚瀛樼殑鏁版嵁瀵硅薄
      * @return
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java
index 88b5f2c..e08db6d 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java
@@ -7,16 +7,13 @@
 import com.vci.corba.portal.data.PLUILayout;
 import com.vci.corba.portal.data.PLTabPage;
 import com.vci.corba.portal.data.PortalVI;
-import com.vci.pagemodel.PLTabButtonVO;
-import com.vci.pagemodel.PLUILayoutCloneVO;
-import com.vci.pagemodel.UICloneVO;
+import com.vci.pagemodel.*;
 import com.vci.starter.web.exception.VciBaseException;
 import com.vci.starter.web.pagemodel.BaseQueryObject;
 import com.vci.starter.web.pagemodel.BaseResult;
 import com.vci.starter.web.pagemodel.DataGrid;
 import com.vci.dto.UIAuthorDTO;
 import com.vci.starter.web.pagemodel.Tree;
-import com.vci.pagemodel.PLDefinationVO;
 import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
@@ -210,6 +207,14 @@
     List<Tree> getUIAuthor(BaseQueryObject baseQueryObject)throws Exception;
 
     /**
+     * 鏍规嵁瑙掕壊涓婚敭鑾峰彇宸叉巿鏉冪殑淇℃伅
+     * @param roleId
+     * @return
+     * @throws PLException
+     */
+    List<RoleRightVO> getRightListByRoleId(String roleId) throws PLException;
+
+    /**
      * UI鎺堟潈
      * @param uiAuthorDTO
      * @return
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java
index dd92d2d..bbca258 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java
@@ -27,6 +27,7 @@
 import com.vci.web.service.UIManagerServiceI;
 import com.vci.web.util.*;
 import com.vci.web.util.BeanUtil;
+import com.vci.web.utility.UIDataFetcher;
 import org.apache.commons.lang3.StringUtils;
 import com.vci.web.util.Func;
 import com.vci.web.util.PlatformClientUtil;
@@ -89,9 +90,9 @@
     private final String IMPORTUIKEY = "importUIKey:";
 
     /**
-     * 褰撳墠鐧诲綍鐢ㄦ埛鐨勪俊鎭�
+     * ui瀹氫箟鏁版嵁寮曟搸
      */
-    private SessionInfo sessionInfo = null;
+    private UIDataFetcher uiDataFetcher = null;
 
     /**
      * 鎺掑簭姣旇緝鍣�
@@ -100,16 +101,6 @@
         @Override
         public int compare(PLUILayout o1, PLUILayout o2) {
             return o1.plCode.compareTo(o2.plCode);
-        }
-    };
-
-    /**
-     * 鎺掑簭姣旇緝鍣�
-     */
-    private Comparator<PLDefinationVO> pageDefinationComparator = new Comparator<PLDefinationVO>() {
-        @Override
-        public int compare(PLDefinationVO o1, PLDefinationVO o2) {
-            return new Integer(o1.getSeq()).compareTo(new Integer(o2.getSeq()));
         }
     };
 
@@ -162,7 +153,7 @@
             contextList.add("");
         }
         contextList.stream().forEach(code->{
-            PLUILayout[]  pluiLayouts= new PLUILayout[0];
+            PLUILayout[] pluiLayouts= new PLUILayout[0];
             try {
                 pluiLayouts = platformClientUtil.getUIService().getPLUILayoutEntityByTypeAndCode(btemName,code);
             } catch (PLException e) {
@@ -1453,6 +1444,7 @@
      */
     private void saveButtonParams(LinkedHashMap<String, String> buttonParams,String tabButtonOid) throws VciBaseException{
         if(Func.isNotEmpty(buttonParams)) {
+            SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
             Iterator<Map.Entry<String, String>> iterator = buttonParams.entrySet().iterator();
             while(iterator.hasNext()){
                 Map.Entry<String, String> next = iterator.next();
@@ -1701,17 +1693,17 @@
         if (conditionMap == null) {
             conditionMap = new HashMap<>();
         }
-        String roleId = StringUtils.isBlank(conditionMap.get("roleId")) ? "" : conditionMap.get("roleId");
+        //String roleId = StringUtils.isBlank(conditionMap.get("roleId")) ? "" : conditionMap.get("roleId");
         String type = StringUtils.isBlank(conditionMap.get("type")) ? "" : conditionMap.get("type");
-        String context = StringUtils.isBlank(conditionMap.get("context")) ? "" : conditionMap.get("context");
+        //String context = StringUtils.isBlank(conditionMap.get("context")) ? "" : conditionMap.get("context");
         boolean showCheckBox = Boolean.parseBoolean(conditionMap.get("showCheckBox"));
-       Map<String,RoleRightVO> roleRightVOMap=new HashMap<>();
+        /*Map<String,RoleRightVO> roleRightVOMap=new HashMap<>();
         if(StringUtils.isNotBlank(roleId)){
-          String userName= WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+            String userName = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
             RoleRightInfo[] rightInfos= platformClientUtil.getFrameworkService().getRoleRightList(roleId,userName);
-            List<RoleRightVO>  roleRightVOList=roleRightDOO2VOS(Arrays.asList(rightInfos));
-            roleRightVOMap=roleRightVOList.stream().collect(Collectors.toMap(RoleRightVO::getFuncId,roleRightVO ->roleRightVO,(oldValue,newOldValue)->oldValue));
-        }
+            List<RoleRightVO> roleRightVOList = roleRightDOO2VOS(Arrays.asList(rightInfos));
+            roleRightVOMap = roleRightVOList.stream().collect(Collectors.toMap(RoleRightVO::getFuncId,roleRightVO ->roleRightVO,(oldValue,newOldValue)->oldValue));
+        }*/
         BizType[] bizTypes=osBtmServiceI.getBizTypes(type);
         List<Tree> treeList=new ArrayList<>();
         Tree rootNode =new Tree("root","鍔熻兘妯″潡","root");
@@ -1719,23 +1711,47 @@
         rootNode.setShowCheckbox(true);
         rootNode.setExpanded(true);
         List<Tree> childList=new ArrayList<>();
+
+        //long startTime = System.currentTimeMillis();
+        uiDataFetcher = new UIDataFetcher();
         for (int i = 0; i < bizTypes.length; i++) {
             Tree bizTypeTree = new Tree(bizTypes[i].oid,bizTypes[i].name,bizTypes[i]);//(btmItems[i].label+" ["+ btmItems[i].name+"]", btmItems[i]);
             bizTypeTree.setLevel(1);
             bizTypeTree.setShowCheckbox(true);
             bizTypeTree.setParentId(rootNode.getOid());
             bizTypeTree.setParentName(rootNode.getText());
-            bizTypeTree.setShowCheckbox(true);
             bizTypeTree.setParentBtmName(bizTypes[i].name);
-            childList.add(bizTypeTree);
-            List<PLUILayout>contextList=getUIContextDataByBtName(bizTypes[i].name,context);
-            List<Tree> btmChildList=new ArrayList<>();
+
+            //long startTime1 = System.currentTimeMillis();
+            List<PLUILayout> contextList = uiDataFetcher.getContext(bizTypes[i].name);
+            //long endTime1 = System.currentTimeMillis();
+            //System.out.println("============================================鑾峰彇UI瀹氫箟鏁版嵁寮曟搸鑰楁椂锛�"+((endTime1-startTime1)/1000)+"s");
+
+            List<Tree> btmChildList = new ArrayList<>();
             btmChildList.add(bizTypeTree);
-            setChildNode(btmChildList,contextList,roleRightVOMap,showCheckBox);
+            setChildNode(btmChildList,contextList/*,roleRightVOMap*/,showCheckBox);
+            childList.add(bizTypeTree);
         }
+        //long endTime = System.currentTimeMillis();
+        //System.out.println("============================================UI瀹氫箟鏍戣绠楀畬姣曡�楁椂锛�"+((endTime-startTime)/1000)+"s");
         rootNode.setChildren(childList);
         treeList.add(rootNode);
         return treeList;
+    }
+
+    /**
+     * 鏍规嵁瑙掕壊涓婚敭鑾峰彇宸叉巿鏉冪殑淇℃伅
+     * @param roleId
+     * @return
+     * @throws PLException
+     */
+    @Override
+    public List<RoleRightVO> getRightListByRoleId(String roleId) throws PLException {
+        VciBaseUtil.alertNotNull(roleId,"鏌ヨ鏉′欢瑙掕壊涓婚敭");
+        String userName = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+        RoleRightInfo[] rightInfos= platformClientUtil.getFrameworkService().getRoleRightList(roleId,userName);
+        List<RoleRightVO> roleRightVOList = roleRightDOO2VOS(Arrays.asList(rightInfos));
+        return roleRightVOList;
     }
 
     /***
@@ -2001,22 +2017,21 @@
         });
     }
 
-    /***
+    /**
      * 閬嶅巻瀛愯妭鐐�
      * @param parentTree
      * @param contextList
      * @param roleRightVOMap
      * @param isShowCheckBox
      */
-    private void setChildNode(List<Tree> parentTree, List<PLUILayout>contextList,Map<String,RoleRightVO> roleRightVOMap,boolean isShowCheckBox){
-        Optional.ofNullable(parentTree).orElseGet(()->new ArrayList<Tree>()).stream().forEach(pTree -> {
-            Object funcObj=  pTree.getData();
-            List<Tree> chiledTreeList=new ArrayList<>();
+    private void setChildNode_old(List<Tree> parentTree, List<PLUILayout>contextList,Map<String,RoleRightVO> roleRightVOMap,boolean isShowCheckBox){
+        Optional.ofNullable(parentTree).orElseGet(()->new ArrayList<>()).stream().forEach(pTree -> {
+            Object funcObj = pTree.getData();
+            List<Tree> chiledTreeList = new ArrayList<>();
             if (funcObj instanceof BizType) {//涓氬姟绫诲瀷
-                BizType bizType = (BizType) funcObj;
                 if(!CollectionUtil.isEmpty(contextList)) {
                     contextList.stream().forEach(context->{
-                        Tree childTree=new Tree(context.plOId,context.plName+"("+context.plCode+")",context);
+                        Tree childTree = new Tree(context.plOId,context.plName+"("+context.plCode+")",context);
                         childTree.setParentName(pTree.getText());
                         childTree.setParentBtmName(pTree.getParentBtmName());
                         childTree.setParentId(pTree.getOid());
@@ -2027,19 +2042,13 @@
                     pTree.setChildren(chiledTreeList);
                 }
                 if(!CollectionUtil.isEmpty(chiledTreeList)) {
-                    setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
+                    setChildNode_old(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
                 }
             }else  if (funcObj instanceof PLUILayout){//UI
                 PLUILayout context = (PLUILayout) funcObj;
-                PLTabPage[] pages = new PLTabPage[0];
-                try {
-                    pages = platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(context.plOId);
-                } catch (PLException e) {
-                    e.printStackTrace();
-                }
-                if(pages!=null&&pages.length>0){
-                    List<PLTabPage> plTabPageList= Arrays.stream(pages).collect(Collectors.toList());
-                    plTabPageList.stream().forEach(plTabPage -> {
+                List<PLTabPage> pageList = uiDataFetcher.getTabs(context.plOId);
+                if(Func.isNotEmpty(pageList)){
+                    pageList.stream().forEach(plTabPage -> {
                         Tree childTree=new Tree(plTabPage.plOId,plTabPage.plName,plTabPage);
                         childTree.setParentName(pTree.getText());
                         childTree.setParentId(pTree.getOid());
@@ -2048,66 +2057,51 @@
                         childTree.setShowCheckbox(isShowCheckBox);
                         chiledTreeList.add(childTree);
                     });
+                }
+                if(!CollectionUtil.isEmpty(chiledTreeList)) {
+                    setChildNode_old(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
+                }
+                pTree.setChildren(chiledTreeList);
+            }else if (funcObj instanceof PLTabPage) {//涓婁笅鏂�
+                PLTabPage plTabPage = (PLTabPage) funcObj;
+                List<PLPageDefination> pageDefinationList = uiDataFetcher.getComopnent(plTabPage.plOId);
+                if(Func.isNotEmpty(pageDefinationList)){
+                    pageDefinationList.stream().forEach(plPageDefination -> {
+                        Tree childTree=new Tree(plPageDefination.plOId,plPageDefination.name,plPageDefination);
+                        childTree.setParentName(pTree.getText());
+                        childTree.setParentId(pTree.getOid());
+                        childTree.setParentBtmName(pTree.getParentBtmName());
+                        childTree.setLevel(pTree.getLevel()+1);
+                        childTree.setShowCheckbox(isShowCheckBox);
+                        chiledTreeList.add(childTree);
+                    });
                     pTree.setChildren(chiledTreeList);
                 }
                 if(!CollectionUtil.isEmpty(chiledTreeList)) {
-                    setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
+                    setChildNode_old(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
                 }
-
-            }else if (funcObj instanceof PLTabPage) {//涓婁笅鏂�
-                PLTabPage plTabPage = (PLTabPage) funcObj;
-                List<PLPageDefination>plPageDefinationList=new ArrayList<>();
-                try {
-                    PLPageDefination[] pLPageDefinations = platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(plTabPage.plOId);
-                    if(pLPageDefinations!=null&&pLPageDefinations.length>0){
-                        plPageDefinationList= Arrays.stream(pLPageDefinations).collect(Collectors.toList());
-                        plPageDefinationList.stream().forEach(plPageDefination -> {
-                            Tree childTree=new Tree(plPageDefination.plOId,plPageDefination.name,plPageDefination);
-                            childTree.setParentName(pTree.getText());
-                            childTree.setParentId(pTree.getOid());
-                            childTree.setParentBtmName(pTree.getParentBtmName());
-                            childTree.setLevel(pTree.getLevel()+1);
-                            childTree.setShowCheckbox(isShowCheckBox);
-                            chiledTreeList.add(childTree);
-                        });
-                        pTree.setChildren(chiledTreeList);
-                    }
-                    if(!CollectionUtil.isEmpty(chiledTreeList)) {
-                        setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
-                    }
-                } catch (PLException e) {
-                    e.printStackTrace();
-                }
-
-            }else if (funcObj instanceof PLPageDefination) {//
+            }else if (funcObj instanceof PLPageDefination) {
                 PLPageDefination plPageDefination = (PLPageDefination) funcObj;
-                try {
-                    List<PLTabButton>plTabButtonList=new ArrayList<>();
-                    PLTabButton[] pLTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(plPageDefination.plOId);
-                    if(pLTabButtons!=null&&pLTabButtons.length>0){
-                        plTabButtonList= Arrays.stream(pLTabButtons).collect(Collectors.toList());
-                        plTabButtonList.stream().forEach(plTabButton -> {
-                            Tree childTree=new Tree(plTabButton.plOId,plTabButton.plLabel,plTabButton);
-                            childTree.setParentName(pTree.getText());
-                            childTree.setParentId(pTree.getOid());
-                            childTree.setParentBtmName(pTree.getParentBtmName());
-                            childTree.setLevel(pTree.getLevel()+1);
-                            childTree.setShowCheckbox(isShowCheckBox);
-                            childTree.setLeaf(true);
-                            chiledTreeList.add(childTree);
-                        });
-                        pTree.setChildren(chiledTreeList);
-                    }
-                    if(!CollectionUtil.isEmpty(chiledTreeList)) {
-                        setChildNode(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
-                    }
-                } catch (PLException e) {
-                    e.printStackTrace();
+                List<PLTabButton> pLTabButtonList = uiDataFetcher.getButtons(plPageDefination.plOId);
+                if(Func.isNotEmpty(pLTabButtonList)){
+                    pLTabButtonList.stream().forEach(plTabButton -> {
+                        Tree childTree=new Tree(plTabButton.plOId,plTabButton.plLabel,plTabButton);
+                        childTree.setParentName(pTree.getText());
+                        childTree.setParentId(pTree.getOid());
+                        childTree.setParentBtmName(pTree.getParentBtmName());
+                        childTree.setLevel(pTree.getLevel()+1);
+                        childTree.setShowCheckbox(isShowCheckBox);
+                        childTree.setLeaf(true);
+                        chiledTreeList.add(childTree);
+                    });
+                    pTree.setChildren(chiledTreeList);
                 }
-
+                if(!CollectionUtil.isEmpty(chiledTreeList)) {
+                    setChildNode_old(chiledTreeList, contextList, roleRightVOMap, isShowCheckBox);
+                }
             }else if (funcObj instanceof PLTabButton) {//鎸夐挳
-                PLTabButton plTabButton= (PLTabButton) funcObj;
-                String id =plTabButton.plTableOId;
+                PLTabButton plTabButton = (PLTabButton) funcObj;
+                String id = plTabButton.plTableOId;
                 if(roleRightVOMap.containsKey(id)){
                     RoleRightVO roleRightVO = roleRightVOMap.get(id);
                     Long rightValue =  roleRightVO.getRightValue();
@@ -2122,6 +2116,107 @@
                     pTree.setChecked(false);
                 }
             }
+        });
+    }
+
+    /**
+     * 閬嶅巻瀛愯妭鐐�
+     * @param parentTree
+     * @param contextList
+     * @param isShowCheckBox
+     */
+    private void setChildNode(List<Tree> parentTree, List<PLUILayout>contextList, boolean isShowCheckBox){
+        Optional.ofNullable(parentTree).orElseGet(()->new ArrayList<>()).stream().forEach(pTree -> {
+            Object funcObj = pTree.getData();
+            List<Tree> chiledTreeList = new ArrayList<>();
+            if (funcObj instanceof BizType) {//涓氬姟绫诲瀷
+                if(!CollectionUtil.isEmpty(contextList)) {
+                    contextList.stream().forEach(context->{
+                        Tree childTree = new Tree(context.plOId,context.plName+"("+context.plCode+")",context);
+                        childTree.setParentName(pTree.getText());
+                        childTree.setParentBtmName(pTree.getParentBtmName());
+                        childTree.setParentId(pTree.getOid());
+                        childTree.setLevel(pTree.getLevel()+1);
+                        childTree.setShowCheckbox(isShowCheckBox);
+                        chiledTreeList.add(childTree);
+                    });
+                    pTree.setChildren(chiledTreeList);
+                }
+                if(!CollectionUtil.isEmpty(chiledTreeList)) {
+                    setChildNode(chiledTreeList, contextList, isShowCheckBox);
+                }
+            }else  if (funcObj instanceof PLUILayout){//UI
+                PLUILayout context = (PLUILayout) funcObj;
+                List<PLTabPage> pageList = uiDataFetcher.getTabs(context.plOId);
+                if(Func.isNotEmpty(pageList)){
+                    pageList.stream().forEach(plTabPage -> {
+                        Tree childTree=new Tree(plTabPage.plOId,plTabPage.plName,plTabPage);
+                        childTree.setParentName(pTree.getText());
+                        childTree.setParentId(pTree.getOid());
+                        childTree.setParentBtmName(pTree.getParentBtmName());
+                        childTree.setLevel(pTree.getLevel()+1);
+                        childTree.setShowCheckbox(isShowCheckBox);
+                        chiledTreeList.add(childTree);
+                    });
+                }
+                if(!CollectionUtil.isEmpty(chiledTreeList)) {
+                    setChildNode(chiledTreeList, contextList, isShowCheckBox);
+                }
+                pTree.setChildren(chiledTreeList);
+            }else if (funcObj instanceof PLTabPage) {//涓婁笅鏂�
+                PLTabPage plTabPage = (PLTabPage) funcObj;
+                List<PLPageDefination> pageDefinationList = uiDataFetcher.getComopnent(plTabPage.plOId);
+                if(Func.isNotEmpty(pageDefinationList)){
+                    pageDefinationList.stream().forEach(plPageDefination -> {
+                        Tree childTree=new Tree(plPageDefination.plOId,plPageDefination.name,plPageDefination);
+                        childTree.setParentName(pTree.getText());
+                        childTree.setParentId(pTree.getOid());
+                        childTree.setParentBtmName(pTree.getParentBtmName());
+                        childTree.setLevel(pTree.getLevel()+1);
+                        childTree.setShowCheckbox(isShowCheckBox);
+                        chiledTreeList.add(childTree);
+                    });
+                    pTree.setChildren(chiledTreeList);
+                }
+                if(!CollectionUtil.isEmpty(chiledTreeList)) {
+                    setChildNode(chiledTreeList, contextList, isShowCheckBox);
+                }
+            }else if (funcObj instanceof PLPageDefination) {
+                PLPageDefination plPageDefination = (PLPageDefination) funcObj;
+                List<PLTabButton> pLTabButtonList = uiDataFetcher.getButtons(plPageDefination.plOId);
+                if(Func.isNotEmpty(pLTabButtonList)){
+                    pLTabButtonList.stream().forEach(plTabButton -> {
+                        Tree childTree=new Tree(plTabButton.plOId,plTabButton.plLabel,plTabButton);
+                        childTree.setParentName(pTree.getText());
+                        childTree.setParentId(pTree.getOid());
+                        childTree.setParentBtmName(pTree.getParentBtmName());
+                        childTree.setLevel(pTree.getLevel()+1);
+                        childTree.setShowCheckbox(isShowCheckBox);
+                        childTree.setLeaf(true);
+                        chiledTreeList.add(childTree);
+                    });
+                    pTree.setChildren(chiledTreeList);
+                }
+                if(!CollectionUtil.isEmpty(chiledTreeList)) {
+                    setChildNode(chiledTreeList, contextList, isShowCheckBox);
+                }
+            }/*else if (funcObj instanceof PLTabButton) {//鎸夐挳
+                PLTabButton plTabButton = (PLTabButton) funcObj;
+                String id = plTabButton.plTableOId;
+                if(roleRightVOMap.containsKey(id)){
+                    RoleRightVO roleRightVO = roleRightVOMap.get(id);
+                    Long rightValue =  roleRightVO.getRightValue();
+                    int nodeValue = plTabButton.plSeq;
+                    if (nodeValue >= 0 && nodeValue <= 63) {
+                        long preValue = (rightValue >> nodeValue) & 1;
+                        if (preValue == 1) {
+                            pTree.setChecked(true);
+                        }
+                    }
+                }else{
+                    pTree.setChecked(false);
+                }
+            }*/
         });
     }
 
@@ -2759,9 +2854,7 @@
         tabPage.plName = copyObjName;
         tabPage.plCode = copyObjCode;
         tabPage.plSeq = Short.parseShort(copyObjSeq);
-        if(Func.isEmpty(sessionInfo)){
-            sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
-        }
+        SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
         tabPage.plCreateUser = sessionInfo.getUserId();
         tabPage.plModifyUser = sessionInfo.getUserId();
         long currentTimeMillis = System.currentTimeMillis();
@@ -2888,9 +2981,7 @@
             return BaseResult.success("椤甸潰瀹氫箟鍏嬮殕鎴愬姛锛侊紒");
         }
         //鍒濆鍖杝essionInfo灞炴��
-        if(Func.isEmpty(sessionInfo)){
-            sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
-        }
+        SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
         //寰幆鍏嬮殕鎸夐挳锛堝悓鏃朵細瀵规寜閽殑鐖跺瓙绾у叧绯诲拰鎸夐挳涓嬬殑鍙傛暟杩涜淇濆瓨锛�
         tabButtonVOS.stream().forEach(buttonVO->{
             try {
@@ -2934,9 +3025,7 @@
         if(Func.isEmpty(filterTabButton)){
             return BaseResult.fail("鏍规嵁婧愬璞′富閿湭鏌ヨ鍒版簮瀵硅薄锛岃鍒锋柊鍚庨噸璇曪紒锛�");
         }
-        if(Func.isEmpty(sessionInfo)){
-            sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
-        }
+        SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
 
         //鏀瑰彉button瀵硅薄鐨刼id鍜宲arentOId
         this.modifyButtonOIdsAndCopy(filterTabButton,toOId,ObjectUtility.getNewObjectID36());
@@ -2958,6 +3047,7 @@
 
         // 淇敼褰撳墠鑺傜偣鐨刼Id
         button.setOId(newOId);
+        SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
         //寮�濮嬩繚瀛樻寜閽拰鍙傛暟
         button.setCreateUser(sessionInfo.getUserId());
         button.setModifyUser(sessionInfo.getUserId());
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/utility/UIDataFetcher.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/utility/UIDataFetcher.java
new file mode 100644
index 0000000..a3c0088
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/utility/UIDataFetcher.java
@@ -0,0 +1,178 @@
+package com.vci.web.utility;
+
+import com.vci.corba.common.PLException;
+import com.vci.corba.portal.data.PLPageDefination;
+import com.vci.corba.portal.data.PLTabButton;
+import com.vci.corba.portal.data.PLTabPage;
+import com.vci.corba.portal.data.PLUILayout;
+import com.vci.web.util.UITools;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author ludc
+ * @date 2024/10/15 10:32
+ */
+public class UIDataFetcher {
+
+    //涓婁笅鏂噈ap
+    private Map<String, List<PLUILayout>> contextMap = new HashMap<String, List<PLUILayout>>();
+
+    //tab椤电map
+    private Map<String, List<PLTabPage>> tabMap = new HashMap<String, List<PLTabPage>>();
+
+    //缁勪欢map
+    private Map<String, List<PLPageDefination>> defMap = new HashMap<String, List<PLPageDefination>>();
+
+    //鎸夐挳map
+    private Map<String, List<PLTabButton>> buttonMap = new HashMap<String, List<PLTabButton>>();
+
+
+
+    public UIDataFetcher() {
+        initUIDefination();
+    }
+
+    public static void main(String[] args) {
+        new UIDataFetcher();
+    }
+
+    /**
+     * 鍒濆鍖栨墍鏈塙I瀹氫箟淇℃伅
+     */
+    private void initUIDefination() {
+        try {
+            //鍒濆鍖栨墍鏈夌殑涓婁笅鏂�
+            //long s = System.currentTimeMillis();
+            PLUILayout[] allContext = UITools.getService().getAllPLUILayouts();
+            //long e = System.currentTimeMillis();
+            //System.out.println(allContext.length + " 1: " + (e - s));
+            //s = System.currentTimeMillis();
+            List<PLUILayout> contextList = null;
+            for (PLUILayout context : allContext) {
+                if (contextMap.get(context.plRelatedType) == null) {
+                    contextList = new ArrayList<PLUILayout>();
+                    contextMap.put(context.plRelatedType, contextList);
+                } else {
+                    contextList = contextMap.get(context.plRelatedType);
+                }
+                contextList.add(context);
+            }
+            //e = System.currentTimeMillis();
+            //System.out.println("2: " + (e - s));
+            //鍒濆鍖栨墍鏈夌殑椤电
+            //s = System.currentTimeMillis();
+            PLTabPage[] allTabs = UITools.getService().getAllPLTabPages();
+            //e = System.currentTimeMillis();
+            //System.out.println(allTabs.length + " 3: " + (e - s));
+            //s = System.currentTimeMillis();
+            List<PLTabPage> tabList = null;
+            for (PLTabPage tab : allTabs) {
+                if (tabMap.get(tab.plContextOId) == null) {
+                    tabList = new ArrayList<PLTabPage>();
+                    tabMap.put(tab.plContextOId, tabList);
+                } else {
+                    tabList = tabMap.get(tab.plContextOId);
+                }
+                tabList.add(tab);
+            }
+            //e = System.currentTimeMillis();
+            //System.out.println("4: " + (e - s));
+            //s = System.currentTimeMillis();
+            //鍒濆鍖栫粍寤哄畾涔�
+            PLPageDefination[] allDefinations = UITools.getService().getAllPLPageDefinationsWithNoConf();
+            //e = System.currentTimeMillis();
+            //System.out.println(allDefinations.length + " 5: " + (e - s));
+            //s = System.currentTimeMillis();
+            List<PLPageDefination> defList = null;
+            for (PLPageDefination def : allDefinations) {
+                if (defMap.get(def.plTabPageOId) == null) {
+                    defList = new ArrayList<PLPageDefination>();
+                    defMap.put(def.plTabPageOId, defList);
+                } else {
+                    defList = defMap.get(def.plTabPageOId);
+                }
+                defList.add(def);
+            }
+            //e = System.currentTimeMillis();
+            //System.out.println("6: " + (e - s));
+            //鍒濆鍖朾utton
+            //s = System.currentTimeMillis();
+            PLTabButton[] allButtons = UITools.getService().getAllPLTabButtons();
+            //e = System.currentTimeMillis();
+            //System.out.println(allButtons.length + " 7: " + (e - s));
+            //s = System.currentTimeMillis();
+            List<PLTabButton> allButtonList = Arrays.stream(allButtons).filter(item -> item.show.equals("0")).collect(Collectors.toList());
+            List<PLTabButton> buttonList = null;
+            for (PLTabButton button : allButtonList) {
+                if (buttonMap.get(button.plTableOId) == null) {
+                    buttonList = new ArrayList<PLTabButton>();
+                    buttonMap.put(button.plTableOId, buttonList);
+                } else {
+                    buttonList = buttonMap.get(button.plTableOId);
+                }
+                buttonList.add(button);
+            }
+            //e = System.currentTimeMillis();
+            //System.out.println("8: " + (e - s));
+        } catch (PLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 鑾峰彇涓氬姟绫诲瀷涓嬬殑涓婁笅鏂囦俊鎭�
+     * @param btmType
+     * @return
+     */
+    public List<PLUILayout> getContext(String btmType) {
+        return contextMap.get(btmType);
+    }
+
+    /**
+     * 鑾峰彇涓婁笅鏂囦欢涓嬬殑tab椤电淇℃伅
+     * @param contextId
+     * @return
+     */
+    public List<PLTabPage> getTabs(String contextId) {
+        return tabMap.get(contextId);
+    }
+
+    /**
+     * 鑾峰彇tab椤电涓嬬殑缁勪欢淇℃伅
+     * @param tabId
+     * @return
+     */
+    public List<PLPageDefination> getComopnent(String tabId) {
+        return defMap.get(tabId);
+    }
+
+    /**
+     * 鑾峰彇缁勪欢涓嬬殑鎸夐挳淇℃伅
+     * @param componentId
+     * @return
+     */
+    public List<PLTabButton> getButtons(String componentId) {
+        List<PLTabButton> buttons = this.buttonMap.get(componentId);
+        if (buttons != null) {
+            sort(buttons);
+        }
+        return buttons;
+    }
+
+    /**
+     * 鎸夐挳椤哄簭濂芥帓搴廱utton
+     * @param buttons
+     */
+    private void sort(List<PLTabButton> buttons) {
+        Collections.sort(buttons, new Comparator<PLTabButton>(){
+
+            @Override
+            public int compare(PLTabButton o1, PLTabButton o2) {
+                return new Integer(o1.plSeq).compareTo(new Integer(o2.plSeq));
+            }
+        });
+    }
+
+}

--
Gitblit v1.9.3