From 787eeb2b2880490bcf2705dc8d35c9dd230dba35 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 04 十二月 2024 10:44:39 +0800 Subject: [PATCH] 本地代码提交 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java | 110 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 83 insertions(+), 27 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 4b60a12..cf129dd 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); }); @@ -244,6 +245,7 @@ vo.setTableName(VciBaseUtil.getTableName(vo.getId())); vo.setInputRevisionFlag(btmItem.revInput); vo.setDelimiter(btmItem.delimiter); + vo.setImageName(btmItem.imageName); vo.setfName(btmItem.fName); vo.setVersionRule(String.valueOf(btmItem.verRuleName)); if (StringUtils.isNotBlank(vo.getRevisionRuleId()) || vo.isInputRevisionFlag()) { @@ -290,12 +292,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 +309,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); } /** @@ -443,9 +446,10 @@ if (attrVOs == null) { attrVOs = new ArrayList<>(); } - if (!CollectionUtils.isEmpty(attributeService.getDefaultAttributeVOs())) { + List<OsAttributeVO> defaultAttributeVOs = attributeService.getDefaultAttributeVOs(); + if (!CollectionUtils.isEmpty(defaultAttributeVOs)) { List<OsBtmTypeAttributeVO> finalAttrVOs = attrVOs; - attributeService.getDefaultAttributeVOs().stream().forEach(attr -> { + defaultAttributeVOs.stream().forEach(attr -> { OsBtmTypeAttributeVO attributeVO = new OsBtmTypeAttributeVO(); BeanUtil.convert(attr, attributeVO); attributeVO.setAttributeDataType(attr.getAttributeDataType()); @@ -456,7 +460,8 @@ }); attrVOs = finalAttrVOs; } - return attrVOs; + // TODO: 2024/12/2 Ludc 杩斿洖鍊兼帓搴� + return attrVOs.stream().sorted(Comparator.comparing(o->o.getId(),String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList()); } /** @@ -622,7 +627,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}); @@ -636,7 +641,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<>(); @@ -657,7 +662,7 @@ * @return 鎵ц缁撴灉 */ @Override - public OsERVO createERUsed(String btmId) { + public OsERVO createERUsed(String btmId) throws PLException { VciBaseUtil.alertNotNull(btmId, "涓氬姟绫诲瀷缂栧彿"); OsBtmTypeVO btmTypeVO = getBtmById(btmId); //鑾峰彇浣跨敤褰撳墠绫诲瀷鐨勫睘鎬� @@ -712,6 +717,7 @@ tree.setParentName(null); tree.setParentId(null); tree.setLeaf(true); + tree.setIcon(osBtmTypeVO.getImageName()); tree.setId(osBtmTypeVO.getId()); tree.setText(osBtmTypeVO.getDescription()); tree.setAttributes(WebUtil.objectToMapString(osBtmTypeVO)); @@ -719,7 +725,7 @@ rootTreeList.add(tree); } } - + rootTreeList = rootTreeList.stream().sorted((o1, o2) -> o1.getId().compareTo(o2.getId())).collect(Collectors.toList()); return rootTreeList; } @@ -808,6 +814,7 @@ bizType.label = dto.getName(); bizType.fName = dto.getfName(); bizType.implClass = dto.getImplClass(); + bizType.imageName = dto.getImageName(); bizType.shape = ""; bizType.lifeCycle = dto.getLifeCycleId(); List<String> lcList = Arrays.asList(dto.getSubLifeCycleId().split(",")); @@ -820,14 +827,9 @@ bizType.revLevel = dto.getRevLevel(); bizType.revRuleName = dto.getRevisionRuleId(); bizType.revInput = dto.isInputRevisionFlag(); - bizType.delimiter = (dto.getDelimiter() == null ? "" : dto.getDelimiter()); - bizType.verRuleName = Func.isBlank(dto.getVersionRule()) ? 0 : Short.parseShort(dto.getVersionRule()); - - //bizType.imageName = dto.get; //List<String> attrIdList = dto.getAttributesDTOList().stream().map(OsBtmTypeLinkAttributesDTO::getId).collect(Collectors.toList()); - bizType.apNameArray = dto.getApNameArray().split(",");//attrIdList.toArray(new String[attrIdList.size()]); String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); long timeMillis = System.currentTimeMillis(); @@ -1403,7 +1405,7 @@ //璁剧疆鍒楀悕 List<String> columns = new ArrayList<>( Arrays.asList("绫诲瀷鍚嶇О", "鏍囩", "缁ф壙鑷�", "瀹炵幇绫�", "鎻忚堪", "鐗堟湰瑙勫垯", "鐗堟湰鍙疯鍒�", - "鏄惁鎵嬪伐杈撳叆", "鍒嗛殧绗�", "鐗堟鍙疯鍒�", "鐢熷懡鍛ㄦ湡", "澶囬�夌敓鍛藉懆鏈熷垪琛�", "灞炴�у垪琛�") + "鏄惁鎵嬪伐杈撳叆", "鍒嗛殧绗�", "鐗堟鍙疯鍒�","鍥炬爣", "鐢熷懡鍛ㄦ湡", "澶囬�夌敓鍛藉懆鏈熷垪琛�", "灞炴�у垪琛�") ); try { new File(excelPath).createNewFile(); @@ -1427,9 +1429,10 @@ excelDataList.add(new WriteExcelData(i + 1, 7, bizType.revInput)); excelDataList.add(new WriteExcelData(i + 1, 8, bizType.delimiter)); excelDataList.add(new WriteExcelData(i + 1, 9, bizType.verRuleName)); - excelDataList.add(new WriteExcelData(i + 1, 10, bizType.lifeCycle)); - excelDataList.add(new WriteExcelData(i + 1, 11, String.join(",", bizType.lifeCycles))); - excelDataList.add(new WriteExcelData(i + 1, 12, String.join(",", bizType.apNameArray))); + excelDataList.add(new WriteExcelData(i + 1, 10, bizType.imageName)); + excelDataList.add(new WriteExcelData(i + 1, 11, bizType.lifeCycle)); + excelDataList.add(new WriteExcelData(i + 1, 12, String.join(",", bizType.lifeCycles))); + excelDataList.add(new WriteExcelData(i + 1, 13, String.join(",", bizType.apNameArray))); attributes.addAll(Arrays.asList(bizType.apNameArray)); i++; } @@ -1546,6 +1549,7 @@ bizType.revInput = Boolean.parseBoolean(osBtmTypePO.getRevInput().toLowerCase(Locale.ROOT)); bizType.delimiter = osBtmTypePO.getDelimiter(); bizType.verRuleName = osBtmTypePO.getVerRuleName(); + bizType.imageName = osBtmTypePO.getImageName(); bizType.lifeCycle = osBtmTypePO.getLifeCycle(); bizType.lifeCycles = osBtmTypePO.getLifeCycles().split(","); bizType.apNameArray = osBtmTypePO.getApNameArray().split(","); @@ -1619,6 +1623,7 @@ tree.setParentName(parentBIzType.getfName()); tree.setParentId(parentBIzType.getOid()); tree.setLeaf(true); + tree.setIcon(bizType.getImageName()); tree.setText(bizType.getDescription()); tree.setAttributes(WebUtil.objectToMapString(bizType)); tree.setChildren(getChildren(osBtmTypeVOS, bizType)); @@ -1653,7 +1658,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); @@ -1669,7 +1681,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()); @@ -1758,7 +1770,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); @@ -1833,7 +1852,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()); @@ -2084,4 +2103,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