From 2d7cef859d28aaf01b9871c595f5bee4f1b4d1b4 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 18 十一月 2024 16:22:08 +0800
Subject: [PATCH] 业务类型树查询添加排序

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java |   83 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 68 insertions(+), 15 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
index 325921d..ce3999a 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
@@ -22,6 +22,7 @@
 import com.vci.corba.omd.ltm.LinkType;
 import com.vci.corba.omd.stm.StatePool;
 import com.vci.corba.omd.vrm.VersionRule;
+import com.vci.corba.portal.data.PLUILayout;
 import com.vci.dto.OsBtmTypeDTO;
 import com.vci.dto.OsBtmTypeLinkAttributesDTO;
 import com.vci.model.IndexObject;
@@ -203,7 +204,7 @@
     @Override
     public List<OsBtmTypeVO> btmDO2VOs(Collection<BizType> btmItems,Map<String, OsAttributeVO> attributeVOMap) {
         List<OsBtmTypeVO> VOS = new ArrayList<>();
-        Optional.ofNullable(btmItems).orElseGet(() -> new ArrayList<>()).stream().forEach(btmItem -> {
+        Optional.ofNullable(btmItems).orElseGet(() -> new ArrayList<>()).parallelStream().forEach(btmItem -> {
             OsBtmTypeVO vo = btmDO2VO(btmItem,attributeVOMap);
             VOS.add(vo);
         });
@@ -290,12 +291,12 @@
         if (CollectionUtils.isEmpty(btmIds)) {
             return null;
         }
-        Map<String, OsBtmTypeVO> btmTypeVOMap = self.selectAllBtmMap();
+        //Map<String, OsBtmTypeVO> btmTypeVOMap = self.selectAllBtmMap();
+        BtmDataFetcher btmDataFetcher = new BtmDataFetcher();
         List<OsBtmTypeVO> btmTypeVOS = new ArrayList<>();
         btmIds.stream().forEach(id -> {
-            if (btmTypeVOMap.containsKey(id.toLowerCase())) {
-                btmTypeVOS.add(btmTypeVOMap.get(id.toLowerCase()));
-            }
+            OsBtmTypeVO btmType = btmDataFetcher.getBtmType(id);
+            btmTypeVOS.add(btmType);
         });
         return btmTypeVOS;
     }
@@ -307,11 +308,12 @@
      * @return 涓氬姟绫诲瀷
      */
     @Override
-    public OsBtmTypeVO getBtmById(String id) {
+    public OsBtmTypeVO getBtmById(String id) throws PLException {
         if (StringUtils.isBlank(id)) {
             return null;
         }
-        return self.selectAllBtmMap().getOrDefault(id.toLowerCase(), null);
+        BizType bizType = platformClientUtil.getBtmService().getBizTypeByName(id);
+        return btmDO2VO(bizType,null);
     }
 
     /**
@@ -623,7 +625,7 @@
      * @return 鏋氫妇鐨勫悕绉�
      */
     @Override
-    public String getNameById(String id) {
+    public String getNameById(String id) throws PLException {
         OsBtmTypeVO btmTypeVO = getBtmById(id);
         if (btmTypeVO == null) {
             throw new VciBaseException("涓氬姟绫诲瀷[{0}]鍦ㄧ郴缁熼噷涓嶅瓨鍦�", new String[]{id});
@@ -637,7 +639,7 @@
      * @param btmId 涓氬姟绫诲瀷涓婚敭
      */
     @Override
-    public OsERVO createERDiagram(String btmId) {
+    public OsERVO createERDiagram(String btmId) throws PLException {
         VciBaseUtil.alertNotNull(btmId, "涓氬姟绫诲瀷缂栧彿");
         OsBtmTypeVO btmTypeVO = getBtmById(btmId);
         List<OsERNodeVO> nodeVOList = new ArrayList<>();
@@ -658,7 +660,7 @@
      * @return 鎵ц缁撴灉
      */
     @Override
-    public OsERVO createERUsed(String btmId) {
+    public OsERVO createERUsed(String btmId) throws PLException {
         VciBaseUtil.alertNotNull(btmId, "涓氬姟绫诲瀷缂栧彿");
         OsBtmTypeVO btmTypeVO = getBtmById(btmId);
         //鑾峰彇浣跨敤褰撳墠绫诲瀷鐨勫睘鎬�
@@ -720,7 +722,7 @@
                 rootTreeList.add(tree);
             }
         }
-
+        rootTreeList = rootTreeList.stream().sorted((o1, o2) -> o1.getId().compareTo(o2.getId())).collect(Collectors.toList());
         return rootTreeList;
     }
 
@@ -1654,7 +1656,14 @@
             itemList.add(nodePropertyVO);
             //鍒ゆ柇鍙傜収
             if (hasRefer) {
-                selectReferenceBtmType(attribute, btmTypeVO, nodeVOList, relationVOList);
+                try {
+                    selectReferenceBtmType(attribute, btmTypeVO, nodeVOList, relationVOList);
+                } catch (PLException e) {
+                    e.printStackTrace();
+                    String exceptionMessage = "鍒ゆ柇涓氬姟绫诲瀷鐨勫睘鎬ф槸涓嶆槸鍙傜収绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�"+VciBaseUtil.getExceptionMessage(e);
+                    logger.error(exceptionMessage);
+                    throw new VciBaseException(exceptionMessage);
+                }
             }
         });
         nodeVO.setItems(itemList);
@@ -1670,7 +1679,7 @@
      * @param relationVOList 鍏崇郴淇℃伅
      */
     private void selectReferenceBtmType(OsBtmTypeAttributeVO attribute, OsBtmTypeVO btmTypeVO,
-                                        List<OsERNodeVO> nodeVOList, List<OsERRelationVO> relationVOList) {
+                                        List<OsERNodeVO> nodeVOList, List<OsERRelationVO> relationVOList) throws PLException {
         if (StringUtils.isNotBlank(attribute.getReferBtmTypeId())) {
             //鏄弬鐓х被鍨嬬殑
             OsBtmTypeVO referenceBtmType = getBtmById(attribute.getReferBtmTypeId());
@@ -1759,7 +1768,14 @@
                 items.add(nodePropertyVO);
                 //鍒ゆ柇鍙傜収
                 if (!used) {
-                    selectReferenceLinkType(attr, link, nodeVOList, relationVOList);
+                    try {
+                        selectReferenceLinkType(attr, link, nodeVOList, relationVOList);
+                    } catch (PLException e) {
+                        e.printStackTrace();
+                        String exceptionMessage = "鏂摼鎺ョ被鍨嬬殑灞炴�ф槸涓嶆槸鍙傜収绫诲瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�"+VciBaseUtil.getExceptionMessage(e);
+                        logger.error(exceptionMessage);
+                        throw new VciBaseException(exceptionMessage);
+                    }
                 }
             });
             nodeVO.setItems(items);
@@ -1834,7 +1850,7 @@
      * @param nodeVOList     鑺傜偣瀵硅薄
      * @param relationVOList 鍏崇郴瀵硅薄
      */
-    private void selectReferenceLinkType(OsLinkTypeAttributeVO attr, OsLinkTypeVO linkTypeVO, List<OsERNodeVO> nodeVOList, List<OsERRelationVO> relationVOList) {
+    private void selectReferenceLinkType(OsLinkTypeAttributeVO attr, OsLinkTypeVO linkTypeVO, List<OsERNodeVO> nodeVOList, List<OsERRelationVO> relationVOList) throws PLException {
         if (StringUtils.isNotBlank(attr.getReferBtmTypeId())) {
             //鏄弬鐓х被鍨嬬殑
             OsBtmTypeVO referenceBtmType = getBtmById(attr.getReferBtmTypeId());
@@ -2085,4 +2101,41 @@
 
     }
 
+    private class BtmDataFetcher {
+
+        //涓氬姟绫诲瀷
+        private Map<String, BizType> btmTypeVOMap = new HashMap<String, BizType>();
+
+        public BtmDataFetcher() {
+            initBtmDataFetcher();
+        }
+
+        private void initBtmDataFetcher(){
+            try {
+                BizType[] bizTypes = platformClientUtil.getBtmService().getBizTypes("");
+                //List<OsBtmTypeVO> osBtmTypeVOS = btmDO2VOs(Arrays.asList(bizTypes), null);
+                if(Func.isNotEmpty(bizTypes)){
+                    btmTypeVOMap = Arrays.stream(bizTypes).collect(Collectors.toMap(btm -> btm.name, btm -> btm));
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }
+
+        /**
+         * 鑾峰彇涓氬姟绫诲瀷
+         * @param id
+         * @return
+         */
+        public OsBtmTypeVO getBtmType(String id) {
+            BizType bizType = btmTypeVOMap.get(id);
+            if(Func.isEmpty(bizType)){
+                return null;
+            }
+            //鑾峰彇鐨勬椂鍊欐墠璧歏O瀵硅薄锛岃繖鏍烽伩鍏嶄竴娆℃�у叏閮˙tm杞琕O澶參鐨勯棶棰�
+            return btmDO2VO(bizType,null);
+        }
+
+    }
+
 }

--
Gitblit v1.9.3