From f49622515192a11878628b8eecbc7315671ae562 Mon Sep 17 00:00:00 2001 From: yuxc <yuxc@vci-tech.com> Date: 星期四, 09 一月 2025 15:25:25 +0800 Subject: [PATCH] 在获取相关业务类型下的属性时,未在属性中定义的数据直接跳过 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java | 445 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 370 insertions(+), 75 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java index 83fd63d..666d847 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java @@ -1,11 +1,8 @@ package com.vci.web.service.impl; import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ZipUtil; import com.alibaba.fastjson.JSONObject; -import com.vci.client.ClientSession; import com.vci.client.common.oq.OQTool; -import com.vci.client.common.providers.ClientServiceProvider; import com.vci.common.qt.object.*; import com.vci.constant.FrameWorkLangCodeConstant; import com.vci.corba.common.PLException; @@ -16,44 +13,35 @@ import com.vci.corba.omd.ltm.LinkType; import com.vci.corba.omd.qtm.QTD; import com.vci.corba.omd.qtm.QTInfo; -import com.vci.dto.QTInfoDTO; +import com.vci.dto.*; +import com.vci.omd.constants.SystemAttribute; import com.vci.omd.objects.OtherInfo; -import com.vci.po.OsLinkTypePO; -import com.vci.starter.poi.bo.ReadExcelOption; -import com.vci.starter.poi.bo.WriteExcelData; -import com.vci.starter.poi.bo.WriteExcelOption; -import com.vci.starter.poi.constant.ExcelLangCodeConstant; -import com.vci.starter.poi.util.ExcelUtil; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; -import com.vci.starter.web.pagemodel.Tree; -import com.vci.starter.web.util.*; +import com.vci.starter.web.util.ControllerUtil; +import com.vci.starter.web.util.Lcm.DateUtil; +import com.vci.starter.web.util.Lcm.Func; +import com.vci.starter.web.util.LocalFileUtil; +import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.other.BtmQTExportData; import com.vci.web.other.LinkQTExportData; -import com.vci.web.service.*; -import com.vci.web.util.DateUtil; -import com.vci.web.util.Func; +import com.vci.web.service.OsQuereyTemplateServiceI; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; +import com.vci.web.utility.AttributeDataFetcher; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; -import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; -import org.jdesktop.swingx.JXDatePicker; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; -import javax.swing.*; -import java.awt.*; import java.io.*; import java.util.*; -import java.util.List; import java.util.stream.Collectors; /** @@ -97,7 +85,8 @@ }else { qtdArray = platformClientUtil.getQTDService().getBizTypeQTDs(btmName); } - return BaseResult.dataList(Arrays.asList(qtdArray)); + List<QTD> qtdList = Arrays.asList(qtdArray).stream().sorted(Comparator.comparing(s -> s.name,String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList()); + return BaseResult.dataList(qtdList); } /** @@ -121,6 +110,7 @@ throw new PLException("500", new String[]{"澧炲姞涓氬姟绫诲瀷鏌ヨ妯℃澘澶辫触"}); } } + /** * 淇敼鏌ヨ妯℃澘 * @param qtd 鏌ヨ妯℃澘瀹炰綋绫� @@ -160,6 +150,7 @@ return BaseResult.fail("鍒犻櫎鏌ヨ妯℃澘澶辫触"); } } + /** * @param qtInfoDTO 浼犺緭鐨勬暟鎹璞★細 * linkTypeName 閾炬帴绫诲瀷銆� @@ -192,7 +183,13 @@ public BaseResult getObjTypeQTs(String btName) throws PLException, DocumentException { VciBaseUtil.alertNotNull(btName,"绫诲瀷鍚�"); QTInfo[] objTypeQTs = platformClientUtil.getQTDService().getObjTypeQTs(btName); + if(Func.isEmpty(objTypeQTs)){ + return BaseResult.success(); + } List<QTInfoDTO> dtos = new ArrayList<>(); + Map<String, AttributeDef> allSysAttr = Arrays.stream(platformClientUtil.getBtmService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e)); + allSysAttr.putAll(Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e))); + for (QTInfo obj : objTypeQTs) { QTInfoDTO qtInfoDTO = new QTInfoDTO(); qtInfoDTO.setCreator(obj.creator); @@ -203,13 +200,92 @@ qtInfoDTO.setQtUIText(obj.qtUIText); if(StringUtils.isNotBlank(obj.qtUIText)){ //灏嗙粰瀹氱殑String鏂囨湰瑙f瀽涓篨ML鏂囨。骞惰繑鍥炴柊鍒涘缓鐨刣ocument - qtInfoDTO.setTree(analysisXml(obj)); + qtInfoDTO.setTree(analysisXml(obj, allSysAttr)); } - qtInfoDTO.setQueryTemplate(OQTool.getQTByDoc(DocumentHelper.parseText(obj.qtText), obj.qtName)); + QueryTemplate qtByDoc = OQTool.getQTByDoc(DocumentHelper.parseText(obj.qtText), obj.qtName); + qtInfoDTO.setQueryTemplate(queryTemplateToDto(qtByDoc, allSysAttr)); qtInfoDTO.setCreateTimeText(DateFormatUtils.format(new Date(obj.createTime), DateUtil.PATTERN_DATETIME)); dtos.add(qtInfoDTO); } + // TODO: 2024/12/2 Ludc 杩斿洖鍊兼帓搴� + dtos = dtos.stream().sorted(Comparator.comparing(QTInfoDTO::getQtName,String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList()); return BaseResult.dataList(dtos); + } + + /** + * 瀵硅薄杞崲 + * @param qtByDoc 妯℃澘瀵硅薄 + * @param allSysAttr 鎵�鏈夌郴缁熷睘鎬� + * @return 妯℃澘浼犺緭瀵硅薄 + * @throws PLException + */ + private QueryTemplateDTO queryTemplateToDto(QueryTemplate qtByDoc, Map<String, AttributeDef> allSysAttr) throws PLException { + QueryTemplateDTO dto = new QueryTemplateDTO(); + dto.setId(qtByDoc.getId()); + dto.setBtmType(qtByDoc.getBtmType()); + dto.setDirection(qtByDoc.getDirection()); + dto.setLevel(qtByDoc.getLevel()); + dto.setQueryChildrenFlag(qtByDoc.isQueryChildren()); + dto.setQueryISLeaf(qtByDoc.isQueryISLeaf()); + dto.setClauseList(qtByDoc.getClauseList()); + dto.setPageInfo(qtByDoc.getPageInfo()); + dto.setLinkType(qtByDoc.getLinkType()); + dto.setVersion(qtByDoc.getVersion()); + dto.setType(qtByDoc.getType()); + dto.setSecretFlag(qtByDoc.isSecretFlag()); + dto.setRightFlag(qtByDoc.isRightFlag()); + dto.setOrderInfoList(qtByDoc.getOrderInfoList()); + dto.setRecReturnMode(qtByDoc.getRecReturnMode()); + Condition con = qtByDoc.getCondition(); + if(con != null){ + ConditionDTO conDto = new ConditionDTO(); + conDto.setRootCIName(con.getRootCIName()); + Map<String, ConditionItem> ciMap = con.getCIMap(); + Map<String, ConditionItemDTO> ciMapDto = new HashMap<>(); + for (String key : ciMap.keySet()) { + ConditionItem item = ciMap.get(key); + LeafInfo leafInfo = item.getLeafInfo(); + ConditionItemDTO itemDTO = new ConditionItemDTO(); + itemDTO.setChildrenInfo(item.getChildrenInfo()); + itemDTO.setId(item.getId()); + itemDTO.setLeafFlag(item.isLeaf()); + ciMapDto.put(key, itemDTO); + if(leafInfo == null){ + continue; + } + LeafInfoDTO leafInfoDTO = new LeafInfoDTO(); + itemDTO.setLeafInfo(leafInfoDTO); + //澶勭悊鏌ヨ瀛楁绫诲瀷 + String column = leafInfo.getClause(); + if(column.contains(".")){ + column = StringUtils.substringAfterLast(column, "."); + } + if(column.contains(" ")){ + column = StringUtils.substringBefore(column, " "); + } + AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(column); + if(att == null || "".equals(att.oid)){ + att = allSysAttr.get(column.toLowerCase()); + } + if(att == null){ + throw new PLException("500", new String[]{"灞炴�у瓧娈碉細" + column + "鍦ㄥ睘鎬ф睜涓湭鏌ヨ鍒帮紝璇风‘璁わ紒锛�"}); + } + leafInfoDTO.setClause(leafInfo.getClause()); + + leafInfoDTO.setOperator(leafInfo.getOperator()); + leafInfoDTO.setType(att.vtDataType); + if(leafInfo.getValue() != null ){ + LeafValueDto valueDto = new LeafValueDto(); + valueDto.setOrdinaryValue(leafInfo.getValue().getOrdinaryValue()); + valueDto.setQueryTemplate(leafInfo.getValue().getQueryTemplate() != null ? queryTemplateToDto(leafInfo.getValue().getQueryTemplate(),allSysAttr) : null); + leafInfoDTO.setValue(valueDto); + } + + } + conDto.setCIMap(ciMapDto); + dto.setCondition(conDto); + } + return dto; } /** @@ -218,14 +294,13 @@ * @return * @throws DocumentException */ - private HashMap<String,Object> analysisXml(QTInfo obj) throws DocumentException { + private HashMap<String,Object> analysisXml(QTInfo obj, Map<String, AttributeDef> allSysAttr) throws DocumentException, PLException { org.dom4j.Document document = DocumentHelper.parseText(obj.qtUIText); if(document == null){ return null; } //鑾峰彇鏍硅妭鐐�,鍦ㄤ緥瀛愪腑灏辨槸responsedata鑺傜偣 Element root = document.getRootElement(); - List<HashMap<String,Object>> treeList = new ArrayList<>(); HashMap<String,Object> treeMap = new HashMap<>(); treeMap.put("connector",root.getText()); List<Element> children = root.elements(); @@ -233,9 +308,21 @@ for(Iterator<Element> i = children.iterator(); i.hasNext();){ Element child = i.next(); if(AND.equals(child.getText()) || OR.equals(child.getText())){ - childList.add(addDefaultMutableTree(child)); + childList.add(addDefaultMutableTree(child, allSysAttr)); }else { - childList.add(child.getText().trim()); + String column = StringUtils.substringBefore(child.getText().trim(), " "); + + if(column.contains(".")){ + column = StringUtils.substringAfterLast(column, "."); + } + AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(column); + if(att == null || "".equals(att.oid)){ + att = allSysAttr.get(column.toLowerCase()); + } + HashMap<String, String> data = new HashMap<>(); + data.put("column",child.getText().trim()); + data.put("type",att.vtDataType); + childList.add(data); } } treeMap.put("child",childList); @@ -246,7 +333,7 @@ * 灏嗗瓙鑺傜偣杞负map缁撴瀯 * @param element */ - public Map<String, Object> addDefaultMutableTree(Element element){ + public Map<String, Object> addDefaultMutableTree(Element element, Map<String, AttributeDef> allSysAttr) throws PLException { List<Object> childList = new ArrayList<>(); List<Element> children = element.elements(); HashMap<String,Object> treeMap = new HashMap<>(); @@ -254,9 +341,21 @@ for(Iterator<Element> i = children.iterator(); i.hasNext();){ Element child = i.next(); if(AND.equals(child.getText()) || OR.equals(child.getText())){ - childList.add(addDefaultMutableTree(child)); + childList.add(addDefaultMutableTree(child, allSysAttr)); }else { - childList.add(child.getText().trim()); + String column = StringUtils.substringBefore(child.getText().trim(), " "); + + if(column.contains(".")){ + column = StringUtils.substringAfterLast(column, "."); + } + AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(column); + if(att == null || "".equals(att.oid)){ + att = allSysAttr.get(column.toLowerCase()); + } + HashMap<String, String> data = new HashMap<>(); + data.put("column",child.getText().trim()); + data.put("type",att.vtDataType); + childList.add(data); } } treeMap.put("child",childList); @@ -336,7 +435,7 @@ //娣诲姞涓氬姟绫诲瀷鏍硅妭鐐� for (LinkType plAction : linkTypes) { HashMap<String,Object> childTree = new HashMap(); - childTree.put("text", plAction.tag + "/" +plAction.name); + childTree.put("text", plAction.label + "/" +plAction.name); childTree.put("oid", plAction.oid); // tree.put("children", childTree); addExportTreeNode(plAction, qts, childTree); @@ -683,6 +782,7 @@ } return ciMap; } + /** * 鏍戝寲涓�涓煡璇㈡潯浠剁粍鑺傜偣 * @param children @@ -755,6 +855,7 @@ } return ciList; } + /** * 楂樼骇鏌ヨ * 鎶奛ode鍐呭瑙f瀽鎴怌onditionItem @@ -840,8 +941,6 @@ return ci; } - - /** * 鑾峰彇鍙傜収鐨勬煡璇㈡ā鏉� * @param refAbName: 鍙傜収灞炴�у悕 @@ -901,35 +1000,6 @@ return qt; } -// /** -// * 缁勮鏌ヨ妯℃澘 -// * @return -// */ -// public QueryTemplate getQT(HashMap<String,Object> dataMap){ -// QueryTemplate qt = new QueryTemplate(); -// qt.setType(QTConstants.TYPE_LINK); -// //TODO String qtId = -// qt.setLinkType((String) dataMap.get("linkTypeName")); -// qt.setDirection( (Boolean)dataMap.get("rdPositive") ? QTConstants.DIRECTION_POSITIVE : QTConstants.DIRECTION_OPPOSITE); -// qt.setBtmType((String) dataMap.get("btmName")); -// if("鎵�鏈夌被鍨�".equals(dataMap.get("combRelaType"))){ -// qt.setBtmType("*"); -// } -// qt.setVersion(getVersion((String) dataMap.get("versionValue"))); -// qt.setQueryISLeaf((Boolean) dataMap.get("isQueryIsLeaf")); -// qt.setLevel(StringUtils.isBlank((CharSequence) dataMap.get("level")) ? 1 : Integer.valueOf(String.valueOf(dataMap.get("level")))); -// List<String> clauseList = new ArrayList<String>(); -// //TODO 鏌ヨ鍒� 鏄剧ず鍒� -// clauseList.add("*"); -// qt.setClauseList(clauseList); -// Condition con = new Condition(); -// qt.setCondition(con); -// HashMap<String, ConditionItem> ciMap = getCIMap(); -// con.setCIMap(ciMap); -// con.setRootCIName(con.getRootCINameByCIMap(ciMap)); -// return qt; -// } - /** * 杩斿洖鏌ヨ鐨勭増鏈� * @return @@ -977,11 +1047,12 @@ * @return */ @Override - public void expLinkTemplate(List<String> names, HttpServletResponse response) throws PLException, IOException { + public void expLinkTemplate(String names, HttpServletResponse response) throws PLException, IOException { String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); String vciqtmfFileName = defaultTempFolder + File.separator + "LinkTemplateExp" + new Date().getTime() + ".vciqtf"; LinkQTExportData exportData = new LinkQTExportData(); - for (String name : names) { + String[] splits = names.split(","); + for (String name : splits) { QTInfo qt = platformClientUtil.getQTDService().getQT(name); exportData.getAllQTs().put(qt.qtName,qt); LinkType linkType = platformClientUtil.getLinkTypeService().getLinkType(qt.btmName); @@ -1009,6 +1080,7 @@ ControllerUtil.writeFileToResponse(response,vciqtmfFileName); FileUtil.del(defaultTempFolder + File.separator); } + /** * 瀵煎叆閾炬帴绫诲瀷鏌ヨ妯℃澘 * @param file 涓婁紶鐨勬枃浠� @@ -1039,7 +1111,7 @@ //娣诲姞涓氬姟绫诲瀷鏍硅妭鐐� for (LinkType plAction : ltsNew) { HashMap<String,Object> childTree = new HashMap(); - childTree.put("text", plAction.tag + "/" +plAction.name); + childTree.put("text", plAction.label + "/" +plAction.name); childTree.put("oid", plAction.oid); addExportTreeNode(plAction, qts, childTree); childList.add(childTree); @@ -1332,12 +1404,16 @@ } /** * 鏌ヨ鏂规鍒犻櫎 - * @param templateNames 鏌ヨ鏂规鍚� + * @param names 鏌ヨ鏂规鍚� * @return 鎿嶄綔缁撴灉 */ @Override - public BaseResult deleteLinkTemplate(List<String> templateNames) throws PLException { - boolean b = platformClientUtil.getQTDService().deleteQTs(templateNames.toArray(new String[0])); + public BaseResult deleteLinkTemplate(String names) throws PLException { + if(StringUtils.isBlank(names)){ + return BaseResult.fail("璇烽�夋嫨鏌ヨ鏂规锛�"); + } + String[] nameSplit = names.split(","); + boolean b = platformClientUtil.getQTDService().deleteQTs(nameSplit); if(!b){ return BaseResult.fail("鍒犻櫎澶辫触锛侊紒锛�"); } @@ -1363,8 +1439,13 @@ throw new PLException("500", new String[]{checkInfo}); } qt.setId("qt1"); - BusinessObject[] result = platformClientUtil.getQueryService().findBTMObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML()); - return BaseResult.dataList(Arrays.asList(result)); + try { + BusinessObject[] result = platformClientUtil.getQueryService().findBTMObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML()); + return BaseResult.dataList(Arrays.asList(result)); + }catch (Exception e){ + String errorLog = "鏌ヨ鏃跺嚭鐜伴棶棰橈紝璇锋鏌ラ厤缃殑鏉′欢鏄惁瀛樺湪闂锛屽叿浣撳師鍥狅細"+VciBaseUtil.getExceptionMessage(e); + throw new VciBaseException(errorLog); + } } /** @@ -1398,6 +1479,7 @@ if(!checkInfo.equals("OK")){ throw new PLException("500", new String[]{checkInfo}); } + qt.setId(qtInfoDTO.getQtName()); //璁剧疆鎺掑簭淇℃伅 qt.setOrderInfoList(qtInfoDTO.getQueryTemplate().getOrderInfoList()); QTInfo qtWrapper = new QTInfo(); @@ -1478,9 +1560,10 @@ * @return */ @Override - public void expBtmQTTemplate(List<String> names, HttpServletResponse response) throws PLException, IOException { + public String expBtmQTTemplate(String qtNames) throws PLException, IOException { String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); String vciqtmfFileName = defaultTempFolder + File.separator + "BtmTemplateExp" + new Date().getTime() + ".vciqtf"; + String[] names = qtNames.split(","); BtmQTExportData exportData = new BtmQTExportData(); for (String name : names) { QTInfo qt = platformClientUtil.getQTDService().getQT(name); @@ -1510,8 +1593,9 @@ throw new PLException("500",new String[]{"瀵煎嚭娴佸叧闂紓甯革紒"}); } } - ControllerUtil.writeFileToResponse(response,vciqtmfFileName); - FileUtil.del(defaultTempFolder + File.separator); + //ControllerUtil.writeFileToResponse(response,vciqtmfFileName); + //FileUtil.del(defaultTempFolder + File.separator); + return vciqtmfFileName; } /** @@ -1521,8 +1605,9 @@ @Override public BaseResult getAllQTs() throws PLException { QTInfo[] allQTs = platformClientUtil.getQTDService().getAllQTs(); + List<QTInfo> allQTList = Arrays.stream(allQTs).sorted(Comparator.comparing(o -> o.qtName, String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList()); DataGrid<QTInfo> dataGrid = new DataGrid<>(); - dataGrid.setData(Arrays.asList(allQTs)); + dataGrid.setData(allQTList); dataGrid.setTotal(allQTs.length); return BaseResult.dataGrid(dataGrid); } @@ -1565,6 +1650,216 @@ return BaseResult.success(tree); } + /** + * 鏌ヨ妯℃澘鐨勫垪琛ㄦ坊鍔犱簡瀛楁鐨勭浉鍏冲睘鎬� + * @param btmName 绫诲瀷 + * @param linkFlag 鏄惁閾炬帴绫诲瀷 锛歵rue 閾炬帴绫诲瀷 锛宖alse 涓氬姟绫诲瀷 + * @param direction 姝e弽鏂瑰悜 + * @return 鏌ヨ妯℃澘鐨勫垪琛� + */ + @Override + public BaseResult queryTemplateListByAttr(String btmName, Boolean linkFlag, String direction) throws PLException { + //杩斿洖鐨勭晫闈笅鎷夋鏄剧ず鏍� + List<QTDDTO> qtddtos = new ArrayList<>(); + //灏嗛摼鎺ョ被鍨嬩笌涓氬姟绫诲瀷鐨勬墍鏈夐粯璁ゅ瓧娈垫煡璇㈠嚭鏉ユ斁鍒癿ap閲岄潰鏂逛究鍚庣画璋冪敤 + Map<String, AttributeDef> allSysAttr = Arrays.stream(platformClientUtil.getBtmService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e)); + allSysAttr.putAll(Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e))); + QTD[] qtdArray = null; + //鏌ヨ鐩稿叧绫诲瀷鐨勬煡璇㈡ā鏉胯繘琛屽鐞� + if(linkFlag){ + qtdArray = platformClientUtil.getQTDService().getLinkTypeQTDs(btmName); + }else { + qtdArray = platformClientUtil.getQTDService().getBizTypeQTDs(btmName); + } + //鑾峰彇灞炴�х殑鏁版嵁鍔犺浇绫� + AttributeDataFetcher attrDataFetcher = new AttributeDataFetcher(); + for (QTD qtd : qtdArray) { + QTDDTO qtddto = new QTDDTO(); + qtddto.setName(qtd.name); + qtddto.setCreateTime(qtd.createTime); + qtddto.setLinkTypeName(qtd.linkTypeName); + qtddto.setBtmName(qtd.btmName); + qtddto.setCreator(qtd.creator); + for (String abName : qtd.abNames) { + //AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(abName); + AttributeDef att = attrDataFetcher.getAttributeDef(abName); + //濡傛灉鍦ㄥ睘鎬ф帴鍙d腑娌℃湁鏌ュ埌鐩稿叧瀛楁搴旇灏卞湪榛樿瀛楁涓� + if(att == null || "".equals(att.oid)){ + att = allSysAttr.get(abName.toLowerCase()); + } + if(direction != null) { + if (direction.equals(QTConstants.DIRECTION_POSITIVE)) { + if(att == null ){ + continue; +// throw new PLException("500",new String[]{"灞炴�у瓧娈�:"+ abName +"鏈煡璇㈠埌锛岃纭锛�"}); + } + att.name = "T_OID." + abName; + } else if (direction.equals(QTConstants.DIRECTION_OPPOSITE)) { + if(att == null ){ + continue; +// throw new PLException("500",new String[]{"灞炴�у瓧娈�:"+ abName +"鏈煡璇㈠埌锛岃纭锛�"}); + } + att.name = "F_OID." + abName; + } + }else{ + att.name = abName; + } + AttributeDefDTO attrDto = new AttributeDefDTO(); + attrDto.setDescription(att.description); + attrDto.setLabel(att.label); + attrDto.setOid(att.oid); + attrDto.setCreator(att.creator); + attrDto.setName(att.name); + attrDto.setDefValue(att.defValue); + attrDto.setLayersNum(1); + attrDto.setRage(att.rage); + attrDto.setVtDataType(att.vtDataType); + attrDto.setOther(att.other); + qtddto.getAttrs().add(attrDto); + addNode(attrDto, allSysAttr); + } + qtddtos.add(qtddto); + } + return BaseResult.dataList(qtddtos); + } + + /** + * 瀛愯妭鐐瑰鐞� + * @param attributeDefByName 鐖惰妭鐐圭殑灞炴�т俊鎭� + * @param allSysAttr 鎵�鏈夐粯璁ゅ瓧娈� + */ + private void addNode(AttributeDefDTO attributeDefByName, Map<String, AttributeDef> allSysAttr){ + + if(attributeDefByName.getLayersNum() >= 3){ + return; + } + String abName = attributeDefByName.name; + //鍙杗ode涓婄殑鏈�鍚庝竴涓睘鎬у悕 + if(abName.contains(".")){ + abName = abName.substring(abName.lastIndexOf(".") + 1); + } + if(SystemAttribute.sysAttList().contains(abName.toUpperCase())){ + return; + } + AttributeDef abItem = null; + try { + abItem = platformClientUtil.getAttributeService().getAttributeDefByName(abName); + String other = abItem.other; +// String btmName = ApProvider.getInstance().getOtherValueByType(other, BTM); + OtherInfo otherInfo = OtherInfo.getOtherInfoByText(other); + int refFlag = otherInfo.getRefFlag(); + String refTypeName = otherInfo.getRefTypeName(); + if(refFlag != -1){ + //鍙傜収涓氬姟绫诲瀷 + if(refFlag == 0){ + //pName: 涓哄弬鐓у睘鎬у悕鍔犱笂璺緞 + String pName = attributeDefByName.name + "."; + String[] abNames = platformClientUtil.getBtmService().getAttributeNames(refTypeName); + for(int i = 0; i < abNames.length; i++){ + String abName_ = abNames[i]; + AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(abName_); + if(att == null || "".equals(att.oid)){ + att = allSysAttr.get(abName_.toLowerCase()); + if(att == null || "".equals(att.oid)){ + continue; + } + } + att.name = pName + abName_ ; + AttributeDefDTO attrDto = new AttributeDefDTO(); + attrDto.setDescription(att.description); + attrDto.setLabel(att.label); + attrDto.setOid(att.oid); + attrDto.setLayersNum(attributeDefByName.getLayersNum() + 1); + attrDto.setCreator(att.creator); + attrDto.setName(att.name); + attrDto.setDefValue(att.defValue); + attrDto.setRage(att.rage); + attrDto.setVtDataType(att.vtDataType); + attrDto.setOther(att.other); + attributeDefByName.getAttrs().add(attrDto); + addNode(attrDto, allSysAttr); + } + //绯荤粺灞炴�D,NAME,DESCRIPTION + for (int i = 0; i < SystemAttribute.bosysAttList().size(); i++) { + AttributeDef attributeDef = allSysAttr.get(SystemAttribute.bosysAttList().get(i).toLowerCase()); + if(Func.isEmpty(attributeDef)){ + break; + } + AttributeDefDTO attrDto = new AttributeDefDTO(); + attrDto.setDescription(attributeDef.description); + attrDto.setLabel(attributeDef.label); + attrDto.setOid(attributeDef.oid); + attrDto.setLayersNum(attributeDefByName.getLayersNum() + 1); + attrDto.setCreator(attributeDef.creator); + attrDto.setName(pName + SystemAttribute.bosysAttList().get(i)); + attrDto.setDefValue(attributeDef.defValue); + attrDto.setRage(attributeDef.rage); + attrDto.setVtDataType(attributeDef.vtDataType); + attrDto.setOther(attributeDef.other); + attributeDefByName.getAttrs().add(attrDto); + addNode(attrDto, allSysAttr); + } + //鍙傜収閾炬帴绫诲瀷 + }else if(refFlag == 1){ + //pName: 涓哄弬鐓у睘鎬у悕鍔犱笂璺緞 + String pName = attributeDefByName.name + "."; + LinkType link = null; + try { + link = platformClientUtil.getLinkTypeService().getLinkType(refTypeName); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Throwable e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(link != null){ + String[] abNames = link.attributes; + for(int i = 0; i < abNames.length; i++){ + String abName_ = abNames[i]; + AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(abName_); + if(att == null || att.oid.equals("")){ + att = allSysAttr.get(abName_.toLowerCase()); + } + AttributeDefDTO attrDto = new AttributeDefDTO(); + attrDto.setDescription(att.description); + attrDto.setLabel(att.label); + attrDto.setOid(att.oid); + attrDto.setLayersNum(attributeDefByName.getLayersNum() + 1); + attrDto.setCreator(att.creator); + attrDto.setName(pName + abName_); + attrDto.setDefValue(att.defValue); + attrDto.setRage(att.rage); + attrDto.setVtDataType(att.vtDataType); + attrDto.setOther(att.other); + attributeDefByName.getAttrs().add(attrDto); + addNode(attrDto, allSysAttr); + } + //绯荤粺灞炴�D,NAME,DESCRIPTION + for (int i = 0; i < SystemAttribute.losysAttList().size(); i++) { + AttributeDef sysAttributeDefs = allSysAttr.get(SystemAttribute.losysAttList().get(i).toLowerCase()); + AttributeDefDTO attrDto = new AttributeDefDTO(); + attrDto.setDescription(sysAttributeDefs.description); + attrDto.setLabel(sysAttributeDefs.label); + attrDto.setOid(sysAttributeDefs.oid); + attrDto.setLayersNum(attributeDefByName.getLayersNum() + 1); + attrDto.setCreator(sysAttributeDefs.creator); + attrDto.setName(pName + SystemAttribute.losysAttList().get(i)); + attrDto.setDefValue(sysAttributeDefs.defValue); + attrDto.setRage(sysAttributeDefs.rage); + attrDto.setVtDataType(sysAttributeDefs.vtDataType); + attrDto.setOther(sysAttributeDefs.other); + attributeDefByName.getAttrs().add(attrDto); + addNode(attrDto, allSysAttr); + } + } + } + } + } catch (PLException e) { + e.printStackTrace(); + } + } + // 鏁版嵁杩囨护 private void addImportBtmData(BtmQTExportData qtExportData, List<BizType> ltsNew, List<QTInfo> qTWrapperNew, Map<String/* 绫诲瀷鍚嶇О */, QTD[]/* 鏌ヨ妯℃澘瀹氫箟 */> norepQTDs) { -- Gitblit v1.9.3