Windchill二次开发-查询篇-部件查询
今天给大家介绍如何查询系统中的WTPart对象
?
public static WTPart getPart(String num){ if(num == null || num.trim().length()==0){ return null ; } WTPart part = null ; try { QuerySpec qs = new QuerySpec(WTPart.class) ; qs.appendWhere(new SearchCondition(WTPart.class,WTPart.NUMBER,SearchCondition.EQUAL,num),new int[] {0}) ; QueryResult qr = PersistenceHelper.manager.find((StatementSpec)qs) ; //过滤最新版本 LatestConfigSpec ls = new LatestConfigSpec() ; QueryResult qrLs; qrLs = ls.process(qr); System.out.println(qrLs.hasMoreElements()) ; while(qrLs.hasMoreElements()){ part = (WTPart) qrLs.nextElement() ; } } catch (WTException e) { // TODO Auto-generated catch block e.printStackTrace(); } return part ; }
?
?