From c826afb6dbc2c1d4433b3c127c5f30f9f72fb2dc Mon Sep 17 00:00:00 2001 From: xiejun <xiejun@vci-tech.com> Date: 星期一, 09 九月 2024 17:18:37 +0800 Subject: [PATCH] 属性加UI类型字段 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java | 156 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 149 insertions(+), 7 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java index 302d878..038360c 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java @@ -7,14 +7,14 @@ import com.vci.client.mw.ClientSessionUtility; import com.vci.corba.common.PLException; import com.vci.corba.omd.atm.AttributeDef; +import com.vci.corba.omd.ltm.LinkType; import com.vci.corba.omd.vrm.VersionRule; import com.vci.dto.OsAttributeDTO; import com.vci.dto.OsEnumDTO; import com.vci.dto.OsEnumItemDTO; import com.vci.omd.dataType.VTDataType; -import com.vci.pagemodel.OsEnumItemVO; -import com.vci.pagemodel.OsEnumVO; -import com.vci.pagemodel.OsUsedAttributeVO; +import com.vci.omd.objects.OtherInfo; +import com.vci.pagemodel.*; import com.vci.po.OsAttributePO; import com.vci.po.OsEnumPO; import com.vci.starter.poi.bo.ReadExcelOption; @@ -25,12 +25,11 @@ import com.vci.starter.web.annotation.log.VciUnLog; import com.vci.starter.web.enumpck.VciFieldTypeEnum; 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.starter.web.pagemodel.*; import com.vci.starter.web.util.*; import com.vci.model.OsAttributeDO; -import com.vci.pagemodel.OsAttributeVO; +import com.vci.web.enumpck.ItemTypeEnum; +import com.vci.web.enumpck.PortalVITypeFlag; import com.vci.web.properties.UsedNames; import com.vci.web.service.OsAttributeServiceI; import com.vci.web.service.OsBaseServiceI; @@ -135,6 +134,101 @@ * 榛樿灞炴�х殑鏄犲皠锛宬ey鏄皬鍐� */ private static Map<String,OsAttributeVO> defaultAttributeVOMap = new HashMap<>(); + + @Override + public List<Tree> getTreeAttributesByBtmName(TreeQueryObject treeQueryObject) { + List<Tree> rootTreeList=new ArrayList<>(); + + Map<String, String> conditionMap = treeQueryObject.getConditionMap(); + if (conditionMap == null) { + conditionMap = new HashMap<>(); + } + String typeName = StringUtils.isBlank(conditionMap.get("typeName")) ? "" : conditionMap.get("typeName"); + if (StringUtils.isBlank(typeName)) { + VciBaseUtil.alertNotNull(typeName,"涓氬姟绫诲瀷鍚嶇О"); + } + try { + String typeFlag=StringUtils.isBlank(conditionMap.get("typeFlag"))?"":conditionMap.get("typeFlag"); + PortalVITypeFlag portalVITypeFlag= PortalVITypeFlag.getByName(typeFlag); + Short viTypeFlag=-1; + if(portalVITypeFlag!=null){ + viTypeFlag=portalVITypeFlag.getIntVal(); + } + boolean isDefault =Boolean.parseBoolean(conditionMap.get("isDefault")); + Tree tree = new Tree("root", "銆�" + typeName + "銆戝睘鎬т俊鎭�", "root"); + tree.setLevel(0); + rootTreeList.add(tree); + getChildTree(rootTreeList,typeName, viTypeFlag,isDefault); + }catch (Throwable e){ + e.printStackTrace(); + } + return rootTreeList; + } + + /** + * 澶熺潃灞炴�ф爲鑺傜偣 + * @param parentTreeList + * @param refTypeName + * @param refFlag + * @param isDefault + * @throws Exception + */ + private void getChildTree(List<Tree> parentTreeList,String refTypeName,int refFlag,boolean isDefault) throws Exception { + for (Tree pTree : parentTreeList) { + if (pTree.getLevel()>= 3) { + continue; + } + Object o= pTree.getData(); + String pName=pTree.getText(); + boolean isOsAttributeVO=false; + if(o instanceof OsAttributeVO){ + isOsAttributeVO=true; + OsAttributeVO osAttributeVO=(OsAttributeVO)o; + String other = osAttributeVO.getOther(); + OtherInfo otherInfo = OtherInfo.getOtherInfoByText(other); + refFlag = otherInfo.getRefFlag(); + refTypeName = otherInfo.getRefTypeName(); + } + List<OsAttributeVO> childOsAttributeVOList=new ArrayList<>(); + if (refFlag != -1) { + // pName: 涓哄弬鐓у睘鎬у悕鍔犱笂璺緞 + childOsAttributeVOList=getOsAttributeVOSByBtName(refTypeName,refFlag,isDefault); + if(!CollectionUtils.isEmpty(childOsAttributeVOList)) { + List<Tree> childTreeList= new ArrayList<>(); + boolean finalIsOsAttributeVO = isOsAttributeVO; + childOsAttributeVOList.stream().forEach(childOsAttributeVO->{ + Tree childTree = new Tree(childOsAttributeVO.getOid(), childOsAttributeVO.getId(), childOsAttributeVO); + childTree.setOid(childOsAttributeVO.getOid()); + childTree.setParentName(pTree.getText()); + childTree.setParentId(pTree.getOid()); + childTree.setLevel(pTree.getLevel()+1); + childTree.setLeaf(true); + if(finalIsOsAttributeVO) { + childTree.setText(pName + "." + childOsAttributeVO.getId()); + }else{ + childTree.setText(childOsAttributeVO.getId()); + } + if (childTree.getLevel()>= 3) { + childTree.setLeaf(true); + } + childTreeList.add(childTree); + }); + if(childTreeList.size()>0){ + pTree.setChildren(childTreeList); + pTree.setExpanded(false); + getChildTree(childTreeList,refTypeName,refFlag,isDefault); + }else{ + pTree.setLeaf(true); + pTree.setExpanded(true); + } + + } + }else{ + pTree.setExpanded(true); + } + } + + } /** * 鑾峰彇榛樿鐨勫睘鎬� @@ -254,6 +348,10 @@ attributeVO.setDescription(attribItem.description); attributeVO.setAttributeDataType(attribItem.vtDataType); attributeVO.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(attribItem.vtDataType)); + //鑾峰彇UI灞炴�х被鍨� + attributeVO.setAttributeUIType(ItemTypeEnum.convertAttributeTypeTOUITypeTextByValue(attribItem.vtDataType,false)); + //鑾峰彇UI灞炴�х被鍨嬫枃鏈� + attributeVO.setAttributeUITypeText(ItemTypeEnum.convertAttributeTypeTOUITypeTextByValue(attribItem.vtDataType,true)); attributeVO.setDefaultValue(attribItem.defValue); if(Func.isNotBlank(attribItem.rage)){ attributeVO.setRange(attribItem.rage.replace("<","<")); @@ -1136,6 +1234,50 @@ } /** + * 鏍规嵁涓氬姟绫诲瀷鑾峰彇灞炴�т俊鎭� + * @param btName 涓氬姟绫诲瀷/閾炬帴绫诲瀷 + * @param typeFlag 0:涓氬姟绫诲瀷,1:閾炬帴绫诲瀷 + * @return + */ + @Override + public List<OsAttributeVO> getOsAttributeVOSByBtName(String btName, int typeFlag,boolean isDefault) throws Exception{ + VciBaseUtil.alertNotNull(btName,"鍙傛暟涓嶅厑璁镐负绌�",typeFlag,"鍙傛暟涓嶅厑璁镐负绌�"); + List<OsAttributeVO> attributeVOS=new ArrayList<>(); + + try { + List<AttributeDef> attributeDefList=new ArrayList<>(); + if(typeFlag==0){ + AttributeDef [] attributeDefs= platformClientUtil.getBtmService().getAttributeDefs(btName); + if(attributeDefs!=null){ + attributeDefList.addAll(Arrays.stream(attributeDefs).collect(Collectors.toList())); + } + if(isDefault){ + AttributeDef [] sysAttributeDefs=platformClientUtil.getBtmService().getSysAttributeDefs(); + if(sysAttributeDefs!=null){ + attributeDefList.addAll(Arrays.stream(sysAttributeDefs).collect(Collectors.toList())); + } + } + }else{ + AttributeDef [] attributeDefs=platformClientUtil.getLinkTypeService().getAttributes(btName); + if(attributeDefs!=null){ + attributeDefList.addAll(Arrays.stream(attributeDefs).collect(Collectors.toList())); + } + if(isDefault){ + AttributeDef[] sysAbItems = platformClientUtil.getLinkTypeService().getSysAttributeDefs(); + if(sysAbItems!=null){ + attributeDefList.addAll(Arrays.stream(sysAbItems).collect(Collectors.toList())); + } + } + } + attributeVOS=attributeDO2VOs(attributeDefList); + }catch (PLException e){ + throw new Exception("鏍规嵁涓氬姟绫诲瀷鑾峰彇灞炴�у紓甯�"+e.getMessage()); + } + + return attributeVOS; + } + + /** * 鏄惁涓哄弬鐓у睘鎬� * @param other 閰嶇疆鐨勫叾浠� * @return true 鏄弬鐓� -- Gitblit v1.9.3