package com.vci.server.query.delegate; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.apache.commons.lang3.ArrayUtils; import com.vci.corba.omd.atm.AttribItem; import com.vci.corba.omd.btm.BtmItem; import com.vci.corba.omd.ltm.LinkType; import com.vci.corba.query.data.RefPath; import com.vci.corba.query.data.RefValue; import com.vci.omd.objects.OtherInfo; import com.vci.server.base.utility.ServerServiceProvider; import com.vci.server.cache.OMCacheProvider; import com.vci.server.query.refquery.objects.FromItem; import com.vci.server.query.refquery.objects.MetaData; import com.vci.server.query.refquery.objects.PLMRefPathInfo; import com.vci.server.query.refquery.objects.PLMRefQueryPath; import com.vci.server.query.refquery.utils.PLMRefSQLHelper; import com.vci.server.query.refquery.utils.RefQueryUtils; import com.vci.common.exception.VciExceptionTool; import com.vci.common.log.ServerWithLog4j; import com.vci.corba.common.VCIError; public class RefQueryDelegate { public static final String Other_Key = "btm"; public static final String Root_key = "A_1_OID"; public static final String ToOid = "t_oid"; public static final String FromOid = "f_oid"; /** * 依据数据库最大的限制OID的数目做分割查询 * * @param RefPath * [] 参照路径数组 * @return RefPath [] 参照路径数组 * @throws Exception * */ public RefPath[] limitNumQuery(RefPath[] paths, int limit) throws Throwable { List results = new ArrayList(); // parse path PLMRefQueryPath[] refPaths = toQueryPath(paths); // to mode(a subtree of type tree ) Map> queryConditions = toQuerymode(refPaths); results = queryEachMode(queryConditions, limit); return results.toArray(new RefPath[results.size()]); } public RefPath[] limitNumQuery(RefPath[] paths, String toType, int limit) throws Throwable { // 结果集合 List results = new ArrayList(); // 生成查询路径 parse path PLMRefQueryPath[] refPaths = toQueryPath(paths, toType); // 分割查询模式 to mode(a subtree of type tree ) Map> queryConditions = toQuerymode(refPaths); // 查询每一个模式 results = queryEachMode(queryConditions, limit); // 返回结果集合 return results.toArray(new RefPath[results.size()]); } public RefPath[] limitNumQuery(RefPath[] paths, String[] toTypes, int limit) throws Throwable { // 结果集合 List results = new ArrayList(); // 查询每一个模式 results = mulTypeQueury(paths, toTypes, limit); // 返回结果集合 return results.toArray(new RefPath[results.size()]); } private List mulTypeQueury(RefPath[] paths, String[] toTypes, int limit) throws Throwable { RefValue[] rvs = paths[0].values; HashMap> map = new LinkedHashMap>(); HashMap> seqMap = new LinkedHashMap>(); for (int i = 0; i < rvs.length; i++) { String type = toTypes[i]; List list = map.get(type); if (list == null) { list = new ArrayList(); map.put(type, list); } list.add(rvs[i]); List seqList = seqMap.get(type); if (seqList == null) { seqList = new ArrayList(); seqMap.put(type, seqList); } seqList.add(i); } Iterator itor = map.keySet().iterator(); int count = 0; List> returnList = new ArrayList>(); Map posMap = new LinkedHashMap(); Map, String> queryMap = new LinkedHashMap, String>(); while (itor.hasNext()) { String cType = itor.next(); List cList = map.get(cType); List cSeqList = seqMap.get(cType); ArrayList midList = new ArrayList(); for (int i = 0; i < cList.size(); i++) { midList.add(cList.get(i)); posMap.put(count, cSeqList.get(i)); if (count + 1 % limit == 0) { queryMap.put(midList, cType); returnList.add(multiTypeQuery(queryMap, paths)); queryMap = new HashMap, String>(); midList = new ArrayList(); } count++; } queryMap.put(midList, cType); midList = new ArrayList(); } if (queryMap.size() > 0) { returnList.add(multiTypeQuery(queryMap, paths)); } List wrsList = null; for (int i = 0; i < returnList.size(); i++) { List rsList = returnList.get(i); if (i == 0) { wrsList = rsList; continue; } for (int j = 0; j < rsList.size(); j++) { ArrayUtils.addAll(wrsList.get(i).values, rsList.get(i).values); } } for (int i = 0; i < wrsList.size(); i++) { RefValue[] values = wrsList.get(i).values; RefValue[] newValues = new RefValue[values.length]; for (int j = 0; j < values.length; j++) { newValues[posMap.get(j)] = values[j]; newValues[posMap.get(j)].row = posMap.get(j); } wrsList.get(i).values = newValues; } return wrsList; } public List multiTypeQuery(Map, String> queryMap, RefPath[] paths) throws Throwable { List list = null; Iterator> itor = queryMap.keySet().iterator(); String allSql = ""; boolean isFirst = true; PLMRefQueryPath[] crefPaths = null; while (itor.hasNext()) { ArrayList next = itor.next(); String type = queryMap.get(next); RefPath[] cpaths = new RefPath[paths.length]; for (int i = 0; i < paths.length; i++) { RefPath cPath = new RefPath(); cPath.path = paths[i].path; cPath.values = copyRefValues(next.toArray(new RefValue[next.size()])); cpaths[i] = cPath; } PLMRefQueryPath[] refPaths = toQueryPath(cpaths, type); String sql = PLMRefSQLHelper.generateSQL(refPaths); if (isFirst) { allSql = sql; crefPaths = refPaths; isFirst = false; } else { allSql += " union " + sql; for (int i = 0; i < crefPaths.length; i++) { RefValue[] rfs1 = crefPaths[i].getPath().values; RefValue[] rfs2 = refPaths[i].getPath().values; RefValue[] trfs = new RefValue[rfs1.length + rfs2.length]; System.arraycopy(rfs1, 0, trfs, 0, rfs1.length); System.arraycopy(rfs2, 0, trfs, rfs1.length, rfs2.length); crefPaths[i].getPath().values = trfs; } } } list = getMultiQueryResult(crefPaths, allSql); return list; } private RefValue[] copyRefValues(RefValue[] refValues) { RefValue[] copyRefValues = new RefValue[refValues.length]; for (int i = 0; i < refValues.length; i++) { RefValue copyRefValue = new RefValue(); copyRefValue.row = refValues[i].row; copyRefValue.value = refValues[i].value; copyRefValues[i] = copyRefValue; } return copyRefValues; } private List getMultiQueryResult(PLMRefQueryPath[] refpaths, String sql) throws SQLException { // reference SQL String[] cnames = PLMRefSQLHelper.generateResultSetMetaData(refpaths); // reference data Map datas = RefQueryUtils.executeQuery(sql, cnames); //如果没有查到,判断是否为业务类型,判读是否有继承关系的属性。如果有继承的业务对象,则继续查找。 try { if(datas == null || datas.isEmpty()){ datas = queryAllChildBtmData(refpaths, cnames); } } catch (Exception e) { //子查询时出现异常 e.printStackTrace(); } List returnRefPaths = new ArrayList(); for (PLMRefQueryPath o : refpaths) { // root node if (o.getSelectKey() == null) { returnRefPaths.add(o.getPath()); continue; } // 查询数据库,数据不存在 List values = (List) datas.get(o.getSelectKey() .toUpperCase()); RefValue[] refValues = (RefValue[]) o.getPath().values; for (int i = 0; i < refValues.length; i++) { if (values == null || values.size() == 0) { // 非主键 if (!o.getSelectKey().toUpperCase().equals(Root_key)) { refValues[i].value = ""; continue; } } int real = mapToDbIndex(refValues[i].value, datas); if (real == -1) { // 非主键 if (!o.getSelectKey().toUpperCase().equals(Root_key)) { refValues[i].value = ""; } } else { refValues[i].value = values.get(real) instanceof String ? (String) values .get(real) : String.valueOf(values.get(real)); } } returnRefPaths.add(o.getPath()); } return returnRefPaths; } /** * 将二次查询的属性进行分组 * eg. gpr.usepart.id * gpr.usepart.code * gpr.usepart.name * gpr.useppart.id * gpr.useppart.code * gpr.useppart.name * @param refPaths * @return Map> * > */ private Map> toQuerymode( PLMRefQueryPath[] refPaths) { Map> queryItems = new HashMap>(); for (int i = 0; i < refPaths.length; i++) { MetaData firstLevelO = refPaths[i].getLevel(1); if (queryItems.get(firstLevelO.getAttributeDef().name) == null) { List levelRefPaths = new ArrayList(); levelRefPaths.add(refPaths[i]); queryItems.put(firstLevelO.getAttributeDef().name, levelRefPaths); } else { List levelRefPaths = queryItems .get(firstLevelO.getAttributeDef().name); levelRefPaths.add(refPaths[i]); } } return queryItems; } private List queryEachMode( Map> queryConditions, int limit) throws VCIError { List results = new ArrayList(); // query each of mode Iterator>> itrator = queryConditions .entrySet().iterator(); while (itrator.hasNext()) { List refPathLists = itrator.next().getValue(); try { // 限制数目是1000 int maxNum = 0; // 所有的Id if (refPathLists != null && refPathLists.size() != 0) { maxNum = refPathLists.get(0).getPath().values.length; } if (maxNum < limit) { results.addAll(query(refPathLists)); results.toArray(new RefPath[results.size()]); } else { results.addAll(splitValuesQuery(maxNum, refPathLists, limit)); } } catch (SQLException e) { ServerWithLog4j.logger.error(e.getMessage(), e); throw new VCIError(RefQueryDelegate.class.getName(), new String[]{VciExceptionTool.getExceptionStr(e), VciExceptionTool.getExceptionDetail(e)}); } } return results; } private List splitValuesQuery(int maxNum, List refPathLists, int limit) throws SQLException { List results = new ArrayList(); // 保存一份数据 RefValue[] valuesCopy = new RefValue[maxNum]; RefValue[] valuesNew = new RefValue[maxNum]; System.arraycopy(refPathLists.get(0).getPath().values, 0, valuesNew, 0, maxNum); getCopy(maxNum, valuesCopy, valuesNew); // 分批次查询 Map> rsMaps = new HashMap>(); for (int i = 0; i < (maxNum / limit) + 1; i++) { int length = (maxNum - ((i) * (limit - 1))); if (length < (limit - 1)) { // 重新赋值 for (int j = 0; j < refPathLists.size(); j++) { refPathLists.get(j).getPath().values = getEachSplitValueCopy( length, (limit - 1), i, valuesNew); } } else { // 重新赋值 for (int j = 0; j < refPathLists.size(); j++) { refPathLists.get(j).getPath().values = getEachSplitValueCopy( (limit - 1), (limit - 1), i, valuesNew); } } // 执行查询 query(refPathLists); // 分段查询结束 getEachSplitResult(refPathLists, rsMaps); }// end for // 全部查询结束 for (int n = 0; n < refPathLists.size(); n++) { RefPath key = refPathLists.get(n).getPath(); // 非主键 if (refPathLists.get(n).getLevel() != 1) { key.values = rsMaps.get(key).toArray(new RefValue[maxNum]); } else { refPathLists.get(n).getPath().values = valuesCopy; } // 返回结果 results.add(refPathLists.get(n).getPath()); } return results; } @SuppressWarnings("unchecked") private List query(List refPathLists) throws SQLException { PLMRefQueryPath[] refpaths = refPathLists .toArray(new PLMRefQueryPath[refPathLists.size()]); // reference SQL String sql = PLMRefSQLHelper.generateSQL(refpaths); String[] cnames = PLMRefSQLHelper.generateResultSetMetaData(refpaths); // reference data Map datas = RefQueryUtils.executeQuery(sql, cnames); //如果没有查到,判断是否为业务类型,判读是否有继承关系的属性。如果有继承的业务对象,则继续查找。 try { if(datas == null || datas.isEmpty()){ datas = queryAllChildBtmData(refpaths, cnames); } } catch (Exception e) { //子查询时出现异常 e.printStackTrace(); } List returnRefPaths = new ArrayList(); for (PLMRefQueryPath o : refpaths) { // root node if (o.getSelectKey() == null) { returnRefPaths.add(o.getPath()); continue; } // 查询数据库,数据不存在 List values = (List) datas.get(o.getSelectKey() .toUpperCase()); RefValue[] refValues = (RefValue[]) o.getPath().values; for (int i = 0; i < refValues.length; i++) { if (values == null || values.size() == 0) { // 非主键 if (!o.getSelectKey().toUpperCase().equals(Root_key)) { refValues[i].value = ""; continue; } } int real = mapToDbIndex(refValues[i].value, datas); if (real == -1) { // 非主键 if (!o.getSelectKey().toUpperCase().equals(Root_key)) { refValues[i].value = ""; } } else { refValues[i].value = values.get(real) instanceof String ? (String) values .get(real) : String.valueOf(values.get(real)); } } returnRefPaths.add(o.getPath()); } return returnRefPaths; } /** * 获得传入数组的备份 * */ private RefValue[] getCopy(int maxNum, RefValue[] valuesCopy, RefValue[] valuesNew) { int b = 0; for (RefValue v : valuesNew) { RefValue temp = new RefValue(); temp.row = v.row; temp.value = v.value; valuesCopy[b] = temp; ++b; } return valuesCopy; } /** * 分割后,每一个批次的result * */ private Map> getEachSplitResult( List refPathLists, Map> rsMaps) { for (int n = 0; n < refPathLists.size(); n++) { RefPath key = refPathLists.get(n).getPath(); if (rsMaps.get(key) == null) { List valueObjects = new ArrayList(); valueObjects.addAll(Arrays.asList(key.values)); rsMaps.put(key, valueObjects); } else { rsMaps.get(key).addAll(Arrays.asList(key.values)); } } return rsMaps; } /** * 分割后,每一个批次的Value * */ private RefValue[] getEachSplitValueCopy(int length, int limit, int batch, RefValue[] valuesNew) { RefValue[] eachbatch = new RefValue[(length)]; for (int c = 0; c < (length); c++) { RefValue temp = new RefValue(); temp.row = valuesNew[batch * (limit - 1) + c].row; temp.value = valuesNew[batch * (limit - 1) + c].value; eachbatch[c] = temp; } return eachbatch; } @SuppressWarnings("unchecked") private int mapToDbIndex(String oid, Map dbdatas) { List dbvalues = (List) dbdatas.get(Root_key); return dbvalues.indexOf(oid); } private PLMRefPathInfo generatePathInfo(RefPath path, Map toFromTypes) throws Throwable { // 根类型的所有的属性信息 AttribItem[] leveloneattrs = getAllAttributeByTypeName(path.path .split("\\.")[0]); PLMRefPathInfo pathInfo = new PLMRefPathInfo(); List metas = new ArrayList(); String[] cascade = path.path.split("\\."); for (int i = 0; i < cascade.length; i++) { if (i == 0 || (i > 1 && i == cascade.length - 1)) { continue; } AttribItem currentAttribute = null; if (i == 1) { for (AttribItem a : leveloneattrs) { if (a.name.equals(cascade[i])) { currentAttribute = a; break; } } } if (i > 1) { currentAttribute = getCurrentAttribute(cascade[i]); } // 查询类型 getCurrentType(currentAttribute, null, path, toFromTypes, i, metas); // generateMetaData(metas, currentAttribute, currentType, i); } pathInfo.setMd(metas.toArray(new MetaData[metas.size()])); return pathInfo; } private void generateMetaData(List metas, AttribItem currentAttr, Object type, int level, OtherInfo info) { MetaData meta = new MetaData(); meta.setAttribItem(currentAttr); if (type instanceof BtmItem) { meta.setRefType((BtmItem) type); meta.setType(true); } else { if (info != null) { meta.setQueryEnum(info.getRefFlag()); } meta.setRefLink((LinkType) type); meta.setType(false); } meta.setLevel(level); metas.add(meta); } /** * 生成查询路径 * * @param RefPath * 参照的路径信息 ,String 链接的to端类型 * */ private PLMRefPathInfo generatePathInfo(RefPath path, String toType, Map toFromTypes) throws Throwable { PLMRefPathInfo pathInfo = new PLMRefPathInfo(); List metas = new ArrayList(); String[] cascade = path.path.split("\\."); for (int i = 0; i < cascade.length; i++) { if (i == 0 || (i > 1 && i == cascade.length - 1)) { continue; } AttribItem currentAttr = null; // 得到属性定义信息 currentAttr = getCurrentAttribute(cascade[i]); getCurrentType(currentAttr, toType, path, toFromTypes, i, metas); // generateMetaData(metas, currentAttr, type, i); } pathInfo.setMd(metas.toArray(new MetaData[metas.size()])); return pathInfo; } /** * 生成查询路径集合 * * @param RefPath * [] 参照的路径信息 ,String 链接的to端类型 * */ private PLMRefQueryPath[] toQueryPath(RefPath[] paths, String toType) throws Throwable { List refPaths = new ArrayList(); // 收集to\from端类型 Map toFromTypes = new HashMap(); for (RefPath path : paths) { int level = path.path.split("\\.").length; PLMRefQueryPath refPath = new PLMRefQueryPath(); refPath.setPath(path); refPath.setLevel(level - 1); PLMRefPathInfo info = generatePathInfo(path, toType, toFromTypes); refPath.setPathInfo(info); refPaths.add(refPath); } return refPaths.toArray(new PLMRefQueryPath[refPaths.size()]); } // private PLMRefQueryPath[] toQueryPath(RefPath[] paths, String[] toTypes) // throws Throwable { // List refPaths = new ArrayList(); // // 收集to\from端类型 // Map toFromTypes = new HashMap(); // for (int i = 0; i < paths.length; i++) { // RefPath path = paths[i]; // int level = path.path.split("\\.").length; // PLMRefQueryPath refPath = new PLMRefQueryPath(); // refPath.setPath(path); // refPath.setLevel(level - 1); // PLMRefPathInfo info = generatePathInfo(path, toTypes[i], toFromTypes); // refPath.setPathInfo(info); // refPaths.add(refPath); // } // return refPaths.toArray(new PLMRefQueryPath[refPaths.size()]); // // } private PLMRefQueryPath[] toQueryPath(RefPath[] paths) throws Throwable { List refPaths = new ArrayList(); // 收集to\from端类型 Map toFromTypes = new HashMap(); for (RefPath path : paths) { int level = path.path.split("\\.").length; PLMRefQueryPath refPath = new PLMRefQueryPath(); refPath.setPath(path); refPath.setLevel(level - 1); PLMRefPathInfo info = generatePathInfo(path, toFromTypes); refPath.setPathInfo(info); refPaths.add(refPath); } return refPaths.toArray(new PLMRefQueryPath[refPaths.size()]); } /** * 查询路径在指定的层次的业务类型定义 * * @param AttribItem * 属性定义 ,String 链接的to端类型 * */ private Object getCurrentType(AttribItem attribute, String toType, RefPath path, Map toFromTypes, int level, List metas) throws VCIError { Object retrun = null; BtmItem btmItem = null; LinkType linkItem = null; try { if (attribute.name.toLowerCase().trim().equals(ToOid) || attribute.name.toLowerCase().trim().equals(FromOid)) { // t_oid or f_oid 处于第一层 if (toType != null && !toType.equals("")) { // query reference type //btmItem = ServerServiceProvider.getOMDService().getBTMService().getBtmItemByName(toType); btmItem = OMCacheProvider.getBizType(toType); retrun = btmItem; generateMetaData(metas, attribute, retrun, level, null); } else { // t_oid or f_oid 处于非第一层 String key = getIndentifier((level), path); if (toFromTypes.get(key) != null) { //btmItem = ServerServiceProvider.getOMDService().getBTMService().getBtmItemByName(toFromTypes.get(key)); btmItem = OMCacheProvider.getBizType(toFromTypes.get(key)); retrun = btmItem; generateMetaData(metas, attribute, retrun, level, null); return retrun; } String linkTypeName = path.path.split("\\.")[level - 1];// AttribItem attributeItem = getCurrentAttribute(linkTypeName); OtherInfo info = OtherInfo.getOtherInfoByText(attributeItem.other); String oid = path.values[0].value; String typeName = attribute.name.toLowerCase().trim() .equals(FromOid) ? searchType(info.getRefTypeName(), oid, false) : searchType(info.getRefTypeName(), oid, true); //btmItem = ServerServiceProvider.getOMDService().getBTMService().getBtmItemByName(typeName); btmItem = OMCacheProvider.getBizType(typeName); toFromTypes.put(key, typeName); retrun = btmItem; generateMetaData(metas, attribute, retrun, level, info); } } else { // 普通属性:分为业务类型与链接类型 // is reference Attribute OtherInfo info = OtherInfo.getOtherInfoByText(attribute.other); // 业务类型 if (info.getRefFlag() == 0) { btmItem = ServerServiceProvider.getOMDService().getBTMService().getBtmItemByName( info.getRefTypeName()); retrun = btmItem; } else { linkItem = ServerServiceProvider.getOMDService().getLinkTypeService().getLinkType( info.getRefTypeName()); retrun = linkItem; } generateMetaData(metas, attribute, retrun, level, null); } } catch (Throwable e) { throw new VCIError("", new String[]{VciExceptionTool.getExceptionStr(e), VciExceptionTool.getExceptionDetail(e)}); // TODO: handle exception } return retrun; } private String getIndentifier(int i, RefPath path) { String[] s = path.path.split("\\."); String results = ""; for (int j = 0; j <= i; j++) { results += s[j]; results += "."; } return results.substring(0, results.lastIndexOf(".")); } private String searchType(String link, String oid, boolean to) throws SQLException { StringBuilder searchSQL = new StringBuilder(); Object o = null; if (to) { searchSQL.append(" select t_btwname from ").append("platformlt_") .append(link).append(" where oid in ('").append(oid) .append("')"); Map toTypes = RefQueryUtils.executeQuery( searchSQL.toString(), new String[] { "t_btwname" }); o = toTypes.get("t_btwname"); } else { searchSQL.append(" select f_btwname from ").append("platformlt_") .append(link).append(" where oid in ('").append(oid) .append("')"); Map toTypes = RefQueryUtils.executeQuery( searchSQL.toString(), new String[] { "f_btwname" }); o = toTypes.get("f_btwname"); } return o.toString(); } /** * 查询路径在指定的层次的属性定义 * * @param String * 属性名称 * */ private AttribItem getCurrentAttribute(String name) throws Throwable { AttribItem currentAttr = null; if (name.toLowerCase().trim().equals(ToOid) || name.toLowerCase().trim().equals(FromOid)) { AttribItem attribute = new AttribItem(); attribute.name = name.toLowerCase().trim().equals(ToOid) ? ToOid : FromOid; currentAttr = attribute; } else { currentAttr = getAttributeByName(name); } return currentAttr; } private AttribItem getAttributeByName(String name) throws Throwable { return OMCacheProvider.getAttribute(name); // AttribItem[] arrays = ServerServiceProvider.getOMDService().getAttributeService().getAttribItemsByNames(new String[0]); // for (AttribItem a : arrays) { // if (a.name.equals(name)) { // return a; // } // } // return null; } /** * 依据业务类型的名称,获取所有的属性定义信息 * * @param String * 业务类型名称 * */ private AttribItem[] getAllAttributeByTypeName(String typeName) throws Throwable { //BtmItem typeItem = ServerServiceProvider.getOMDService().getBTMService().getBtmItemByName(typeName); BtmItem typeItem = OMCacheProvider.getBizType(typeName); String[] attributeNames = typeItem.apNameArray; List attributes = new ArrayList(); for (String s : attributeNames) { attributes.add(getAttributeByName(s)); } return attributes.toArray(new AttribItem[attributes.size()]); } /** * 一次从子业务类型中查找数据 * 知道找到为止,如果全不包含返回空Map * @param refpaths * @param cnames * @return */ private Map queryAllChildBtmData(PLMRefQueryPath[] refpaths, String[] cnames){ Map datas = new HashMap(); try { //得到所有子业务类型 List fromItemList = PLMRefSQLHelper.generateFromItemList(refpaths); BtmItem[] bits = getChildBtm(fromItemList); if(bits != null && bits.length > 0){ for(BtmItem bit : bits) { //重新设置refPaths和FormItem的信息 for(FromItem fi : fromItemList){ fi.getMeta().setRefType(bit); } //设置查询语句 String sql = PLMRefSQLHelper.generateSQL(refpaths, fromItemList); //执行查询 datas = RefQueryUtils.executeQuery(sql, cnames); if(datas == null || !datas.isEmpty()){ break; } } } } catch (Exception e) { //System.out.println("二次查询时发生异常!"); //e.printStackTrace(); ServerWithLog4j.logger.error("二次查询时发生异常!", e); } return datas; } /** * 获得所有子业务类型 * @return */ /** * 得到业务对象名称 * @param fromitems * @return */ private static BtmItem[] getChildBtm(List fromitems) { String btmName = ""; for (FromItem item : fromitems) { if (item.getLevel() == 1) { // 判断是业务对象还是link对象 if (item.getMeta().isType()) { btmName = item.getMeta().getRefType().name; } else { btmName = item.getMeta().getRefLink().name; } break; } } try { BtmItem[] a1 = ServerServiceProvider.getOMDService().getBTMService().getChildrenBtms(btmName); return a1; } catch (Throwable e) { //System.out.println("查询子对象异常!"); //e.printStackTrace(); ServerWithLog4j.logger.error("查询子对象异常!", e); return null; } } }