Windchill API 培训
- 格式:ppt
- 大小:144.00 KB
- 文档页数:34
W i n d c h i l l二次开发常用A P I1.1.根据零件名称/编码得到该零件2.wt.clients.prodmgmt.WTPartHelper.findPartByName(name) ;3.wt.clients.prodmgmt.WTPartHelper.findPartByNumber(number);4.2.根据WTpart得到WTparMaster5.WtPart wtpart;6.WTPartMaster wtmaster=(WTPartMster)part.getMaster();7.3.获取codebase下配置文件wt.properties属性信息8.WTProperties wtproperties = WTProperties.getLocalProperties();9.String wthome = wtproperties.getProperty("wt.home", "");//codebase的文件夹路径10.4.获取part被借用的所有父部件11.QueryResult qr=wt.part.WTPartHelper.service.getUsedByWTParts(WTPartMsterwtMaster);12.注:此方法得到的结果为该part被使用情况的全部父部件,包括了Design视图及Manufacturing视图更包括了父部件使用part的所有修订版本,打印出来可以看到会有相同的部件编号,不同的修订版本.13.5.根据OID 获取Wtpart14.wt.fc.WTReference partRef = newwt.fc.ReferenceFactory().getReference( oid );15.WTPart wtpart=(WTPart)partRef;16.6.得到零件最新版本17.WTPart wtpart= (WTPart)VersionControlHelper.getLatestIteration(part);18.7.通过过滤得到零件最新版本19.QuerySpec querysearch = new QuerySpec(WTPartMaster.class);20.//查询所有的WTPartMaster21.QueryResult queryresult =PersistenceHelper.manager.find(querysearch);testConfigSpec latestconfigspec = newLatestConfigSpec();23.//根据WTPartMaster查询所有最新版本的零部件24.QueryResult allWTPart =ConfigHelper.service.filteredIterationsOf(queryresult,latestc onfigspec)25.8.查询某用户某段时间范围内创建的零件26.QuerySpec qs = new QuerySpec(WTPart.class);27.qs.appendSearchCondition(newSearchCondition(WTPart.class,WTPart.CREATE_TIMESTAMP, true,new AttributeRange(begintime, endtime)));//删选条件时间范围内28.qs.appendAnd();//一定要加上不然下一个条件不能删选29.qs.appendSearchCondition(new SearchCondition(WTPart.class,30."iterationInfo.creator.key",SearchCondition.EQUAL,PersistenceHelper.getObjectIdentifier(n ame)));//删选条件用户31.QueryResult qr = PersistenceHelper.manager.find(qs);32.//今后持续更新if (enumUser.hasMoreElements())user = (WTUser) enumUser.nextElement();}if (user == null) {throw new WTException("系统中不存在用户名为'" + name + "'的用户!");}return user;}}10.windchill 中查询,高级查询,基本查询QuerySpec qs = new QuerySpec();//构造Int index = qs.appendClassList(WTPart.class,true);//添加查询类型,获取类型索引,第2个参数表示“要查询的类型、表”WhereExpression where = new SearchCondition(WTPart.class, WTPart.xx, “=”, xx);//泛型在WC API中的使用//获取查询条件数目If(qs.getConditionCount()>0 && qs.getWhere().endsWith(“")){qs.appendAnd();}//添加查询条件qs.appendWhere(where, new int[]{index});//** 以下是联合查询的API范例。
Windchill DTS(Defect Tracking System)/ CMVC(Configuration Management Version Control)系统培训1、进入Windchill系统正式系统 /Windchill/2、输入用户名及密码正式系统用户名:xxxx@密码:123456(初始)3、修改密码Home->Utility->Profile->Actions->Edit Password4、进入DFSProduct->Products-> Defect Tracking System5、归入收藏夹(建议)6、进入Windchill测试系统(培训用)测试系统 /Windchill/注:1)、配置系统的hosts(C:\WINDOWS\system32\drivers\etc)文件,增加一行:10.96.13.235 2)、IE中要去掉代理7、输入测试系统的用户名及密码(培训用)测试系统用户名:xxxx@密码:18、进入测试系统的DFSProduct->Products-> Defect Tracking System9、ECR(Engineering Change Request)流程介绍10、Release中Component与开发工程师ID的关系Release:项目/机型名称Component:故障部件分类对应表Board_Front_Panel Test Board_Front_Panel_Test chengla@ Board_HDD_BP Test Board_HDD_BP_Test duxin@ Board_Mainboard Test Board_Mainboard_Test chengla@ Board_Middle_Plane Test Board_Middle_Plane_Test duxin@ Board_RiserCard Test Board_RiserCard_Test duxin@ Manual_System Test Manual_System_Test longhp@ Manual_Mechanical Test Manual_Mechanical_Test chenllb@ Manual_BIOS Test Manual_BIOS_Test chengla@ Manual_OS_Install Test Manual_OS_Install_Test sunlp@ Mech_Cable Test Mech_Cable_Test xuwy@ Mech_Chasiss Test Mech_Chasiss_Test chenllb@ 注意:一定不能把bug提交到其他机型中去!!!11、在一个“Test”的release项目中,提交一个ECR。
1.Windchill自定义Windchill自带的客制化:站点->实用程序->首选项管理器->展开" Client Customization"->将" Client Customization"选项卡的"否"改为"是"->重新打开浏览器->会出现"自定义"图标,如下图所示:2.定制菜单定制主菜单1)复制navigation-actionModels.xml中的main navigation段代码到custom-actionModels.xml文件中<model name="main navigation" id="browseActions"resourceBundle="com.ptc.core.ui.navigationRB"><description>Main navigation (tabs)</description><action name="recentContexts" type="navigation"/><action name="product" type="navigation"/><action name="library" type="navigation"/><action name="project" type="navigation"/><action name="program" type="navigation"/><action name="change" type="navigation"/><action name="supplier" type="navigation"/><action name="qms" type="navigation"/><action name="org" type="navigation"/><action name="site" type="navigation"/><action name="search" type="navigation"/><!-- entry for customization tab --><action name="customization" type="navigation"/><action name="test" type="navigation"/>//这里是添加的</model><model name="test navigation" defaultActionName="subtest1" defaultActionType="test"><description>Sub tabs under the product main tab</description><action name="subtest1" type="test"/><action name="subtest2" type="test"/></model>2)在custom-actions.xml文件中增加如下代码:<objecttype name="navigation" class="" resourceBundle="ext.corilead.resource.ActionLableResourceRB"><action name="test" renderType="GENERAL"><command class="netmarkets" method="servlet/Navigation?tab=test" windowType="page"/></action></objecttype><objecttype name="test" class="wt.inf.container.ExchangeContainer" resourceBundle=" ext.corilead.resource.ActionLableResourceRB "><action name="subtest1" enabledwhensuspended="true"><command windowType="page"/><includeFilter name="hideNonSiteAdmin"/></action><action name="subtest2" enabledwhensuspended="true"><command windowType="page"/><includeFilter name="hideNonSiteAdmin"/></action></objecttype>3)修改资源文件ActionLableResourceRB文件内容如下:package ext.corilead.resource;import wt.util.resource.RBEntry;import wt.util.resource.RBUUID;import wt.util.resource.WTListResourceBundle;@RBUUID("ext.corilead.resource.ActionLableResourceRB")public class ActionLableResourceRB extends WTListResourceBundle { @RBEntry("定制主菜单")public static final String NAVIGATION_TEST_TITLE ="navigation.test.title";@RBEntry("定制主菜单")public static final String NAVIGATION_TEST_DESCRIPTION = "navigation.test.description";@RBEntry("定制主菜单")public static final String NAVIGATION_TEST_TOOLTIP ="navigation.test.tooltip";@RBEntry("子菜单一")public static final String TEST_SUBTEST1_TITLE ="test.subtest1.title";@RBEntry("子菜单一")public static final String TEST_SUBTEST1_DESCRIPTION ="test.subtest1.description";@RBEntry("子菜单一")public static final String TEST_SUBTEST1_TOOLTIP ="test.subtest1.tooltip";@RBEntry("子菜单二")public static final String TEST_SUBTEST2_TITLE ="test.subtest2.title";@RBEntry("子菜单二")public static final String TEST_SUBTEST2_DESCRIPTION ="test.subtest2.description";@RBEntry("子菜单二")public static final String TEST_SUBTEST2_TOOLTIP ="test.subtest2.tooltip";}ActionLableResourceRB_zh_CN内容如下:package ext.corilead.resource;import wt.util.resource.RBEntry;import wt.util.resource.RBUUID;import wt.util.resource.WTListResourceBundle;@RBUUID("ext.corilead.resource.ActionLableResourceRB")public class ActionLableResourceRB_zh_CN extends WTListResourceBundle { @RBEntry("定制主菜单")public static final String NAVIGATION_TEST_TITLE ="navigation.test.title";@RBEntry("定制主菜单")public static final String NAVIGATION_TEST_DESCRIPTION ="navigation.test.description";@RBEntry("定制主菜单")public static final String NAVIGATION_TEST_TOOLTIP = "navigation.test.tooltip";@RBEntry("子菜单一")public static final String TEST_SUBTEST1_TITLE = "test.subtest1.title";@RBEntry("子菜单一")public static final String TEST_SUBTEST1_DESCRIPTION = "test.subtest1.description";@RBEntry("子菜单一")public static final String TEST_SUBTEST1_TOOLTIP = "test.subtest1.tooltip";@RBEntry("子菜单二")public static final String TEST_SUBTEST2_TITLE = "test.subtest2.title";@RBEntry("子菜单二")public static final String TEST_SUBTEST2_DESCRIPTION = "test.subtest2.description";@RBEntry("子菜单二")public static final String TEST_SUBTEST2_TOOLTIP = "test.subtest2.tooltip";}4)在netmarkets下新建文件夹test并在test下新建jsp文件subtest1.jsp和subtest2.jsp注意:这里的文件名和文件夹名都不能错5)重启服务器6)效果如下:使用jca Table1)修改subtest1.jsp修改subtest1.jsp内容如下:<%@taglib uri="/windchill/taglib/components"prefix="jca"%><%@taglib uri="/windchill/taglib/fmt"prefix="fmt"%><%@page import="ext.corilead.report.GetProductList"%><%@include file="/netmarkets/jsp/util/begin.jspf"%><fmt:setLocale value="${localeBean.locale}"/><fmt:message var="name"key="name"/><fmt:message var="creator"key="creator"/><fmt:message var="container"key="container"/><jca:describeTable var="tableDescriptor"id="allproduct"label="All Product"><jca:describeColumn id="name"label = "Name"sortable="true"/><jca:describeColumn id="creator"label="Creator"sortable="true"/><jca:describeColumn id="container"label="Container"sortable="true"/></jca:describeTable><jca:getModel var="tableModel"descriptor="${tableDescriptor}" serviceName="ext.corilead.report.GetProductList"methodName="getAllProduct"></jca:getModel><jca:renderTable showCustomViewLink="false"model="${tableModel}" showCount="true"showPagingLinks="false"/><%@include file="/netmarkets/jsp/util/end.jspf"%>2)修改java文件package ext.corilead.report;import java.util.HashMap;import java.util.Vector;import wt.fc.QueryResult;import wt.method.RemoteAccess;import wt.pdmlink.PDMLinkProduct;import wt.pds.StatementSpec;import wt.query.QuerySpec;public class GetProductList implements RemoteAccess {private GetProductList(){}public static GetProductList newGetProductList(){return new GetProductList();}public static Vector getAllProduct(){Vector v=new Vector();QuerySpec qs=null;QueryResult qr=null;try{qs=new QuerySpec(PDMLinkProduct.class);if(qs instanceof StatementSpec){qr = wt.fc.PersistenceHelper.manager.find((StatementSpec)qs);//查询所有产品列表while(qr.hasMoreElements()){Object object = qr.nextElement();if(object instanceof PDMLinkProduct){HashMap map=new HashMap();PDMLinkProduct pro=(PDMLinkProduct)object;String name=pro.getName();String creator=pro.getCreator().getName();String container=pro.getContainerName();map.put("name", name);map.put("creator", creator);map.put("container", container);map.put("pro", pro);v.add(map);}}}}catch(Exception e){e.printStackTrace();}HashMap map=new HashMap();return v;}}3)将生成的class文件拷贝到系统codebase目录下,重启服务器4)点击子菜单一,显示结果如下:使用DataUtility1)修改jsp修改jsp文件<jca:describeColumn id="container" label="Container" sortable="true" />为<jca:describeColumn id="container" label="Container" sortable="true"dataUtilityId="containerDdetail"/>2)修改java文件package ext.corilead.dataUtilities;import java.io.IOException;import java.io.Serializable;import java.util.HashMap;import org.apache.log4j.Logger;import wt.fc.ReferenceFactory;import wt.inf.container.WTContainer;import wt.log4j.LogR;import wt.method.RemoteAccess;import wt.pdmlink.PDMLinkProduct;import wt.pom.PersistenceException;import wt.util.WTException;import wt.util.WTProperties;import ponents.descriptor.ModelContext;import ponents.factory.AbstractDataUtility;import ponents.rendering.guicomponents.UrlDisplayComponent;public class SearchDetail extends AbstractDataUtility implements RemoteAccess,Serializable {private static Logger logger = LogR.getLogger(SearchDetail.class.getName());public Object getDataValue(String col_id, Object obj, ModelContext modelcontext) throws WTException {UrlDisplayComponent goPartNumberButton = new UrlDisplayComponent();if(obj instanceof HashMap){HashMap map=(HashMap)obj;String container=(String)map.get("container");WTContainer org=((PDMLinkProduct)map.get("pro")).getContainer();if (org != null) {String url2 = getURLByWTContainer(org);goPartNumberButton.setLink(url2);goPartNumberButton.setLabelForTheLink(container);goPartNumberButton.setTarget("_blank");}}return goPartNumberButton;}//构造url地址public static String getURLByWTContainer(WTContainer org) throws PersistenceException, WTException {String url = "";ReferenceFactory referenceFactory = new ReferenceFactory();if (org != null) {String ufid = referenceFactory.getReferenceString(org);try {WTProperties properties = WTProperties.getLocalProperties();String urlbase = properties.getProperty("java.rmi.server.hostname");String webport = properties.getProperty("wt.webserver.port");url = "http://" + urlbase + ":" + webport + "/Windchill/app/#ptc1/comp/Page?oid=" + ufid + "&u8=1";logger.debug("url==========="+url);} catch (IOException e) {e.printStackTrace();}}return url;}}3)注册dataUtility在site.xconf文件里添加如下内容:<Propertyname="wt.services/svc/default/ponents.descriptor.DataUtility/contai nerDdetail/ng.Object/0"overridable="true"targetFile="codebase/com/ptc/core/components/components.dataUtilities.properties"value="ext.corilead.dataUtilities.SearchDetail/singleton" />4)拷贝class文件及jsp文件到对应路径下5)在Windchill shell下执行xconfmanager –p 命令,重启服务6)点击组织链接,弹出界面如下:添加操作菜单1)custom-actionModels.xml文件拷贝DocumentManagement-actionmodels文件下的:<model name="docs row actions toolbar" menufor="wt.doc.WTDocument"><action name="view" type="object"/> <!-- Info page --><action name="separator" type="separator"/><action name="download_primary_attachment" type="attachments"/><action name="redirect_primary_attachment" type="attachments"/><action name="separator" type="separator"/><submodel name="docs row actions open"/><action name="separator" type="separator"/><action name="checkin" type="wip"/> <!--Check In --><action name="checkin" type="clashDefinition"/> <!--Enabled only if Clash Definition (replaces wip version) --><action name="checkout" type="object"/> <!--Check Out --><action name="checkout_and_download" type="wip"/> <!-- Check Out and Download --><action name="checkoutAndEdit" type="document"/> <!--Check Out and Edit --><action name="checkoutAndEditClashJobDefinition" type="clashDefinition"/> <!-- Check Out and Edit a Clash --><action name="undocheckout" type="object"/> <!--Undo Checkout --><action name="edit" type="document"/> <!-- Edit --><action name="editClashJobDefinition" type="clashDefinition"/> <!-- Edit a Clash --><action name="viewClashJobDefinition" type="clashDefinition"/> <!-- View a Clash --><action name="submitClashJobDefinition" type="clashDefinition"/><action name="replace_content" type="wip"/> <!-- Replace Content --><action name="REVISEITEMS" type="pdmObject"/> <!-- Revise --><action name="separator" type="separator"/><submodel name="docs row actions new"/><action name="separator" type="separator"/><action name="copy" type="object"/> <!--Copy --><action name="renameDocumentWizard" type="document"/> <!--doc specific Rename --><action name="route" type="workflow"/> <!--Route ProjectLink --><action name="CONTAINERMOVE" type="pdmObject"/> <!--Move --><action name="setState" type="lifecycle"/> <!--Set State --><action name="export" type="object"/> <!--Export ProjectLink --><action name="EXPORT" type="pdmObject"/> <!--Export PDMLink --><action name="MULTI_OBJ_DELETE" type="pdmObject"/> <!--Delete --><action name="MULTI_OBJ_DELETE_DETAILS" type="pdmObject"/> <!--Delete --><action name="deleteIterations" type="object"/> <!-- Delete all old iterations --><action name="reassignLC" type="lifecycle"/> <!--Reassign Life Cycle --><action name="resetTeam" type="team"/> <!--Reset Team --><action name="disable" type="document"/> <!--Disable template --><action name="enable" type="document"/> <!--Enable template --><action name="userInitiatedReplication" type="replication"/> <!-- Use Initiated Replication --><action name="separator" type="separator"/><submodel name="docs row actions add"/><action name="separator" type="separator"/><action name="SBSendToPdm" type="sandbox"/> <!--Send to PDM --><action name="sandboxUndoCheckoutDetails" type="object"/> <!--Undo PDM Checkout Details --><action name="sandboxCheckoutShare" type="object"/> <!--PDM Checkout when shared --><action name="convertToShare" type="sandbox"/> <!--Convert to Share --><action name="removeShare" type="object"/> <!--Remove Share --><action name="separator" type="separator"/><submodel name="docs row actions compare"/><action name="separator" type="separator"/><action name="DISPLAYRELATEDMANUFACTURINGITEMS" type="object"/> <!-- MPMLink Display Related Manufacturing items report --><action name="batchPrint" type="wvs"/><action name="separator" type="separator"/><action name="markLinkAsSuspect" type="requirement"/><action name="separator" type="separator"/><action name="RefreshAssociationsDB" type="SoftwareBuild"/> <!-- Update Defect Associations --><action name="ManageSecurity" type="accessPermission"/> <!--Security --><action name="createSubscription" type="subscription"/> <!--Subscribe --><action name="separator" type="separator"/> <!--===================================== --><action name="associateDistributionTarget" type="tgt"/> <!--ESI Associate Distribution Targets (JCA action) --><action name="sendToDistributionTarget" type="tgt"/> <!--ESI Send toDistribution Target --><action name="separator" type="separator"/> <!--===================================== --></model>到custom-actionModels.xml文件内添加行:<action name="submitReview" type="doc"/>2)custom-actions.xml文件增加如下内容:<objecttype name="doc" class="wt.doc.WTDocument"resourceBundle="ext.iecas.resource.ActionLableResourceRB"><action name="submitReview" ajax="page"><command windowType="normal" class="ext.iecas.util.SetStateUtil"method="doSetState"onClick="JCAConfirm(event,'ext.iecas.resource.ActionLableResourceRB.CONFORM_SU BMIT_REVIEW')"/></action></objecttype>3)在资源文件ActionLableResourceRB和ActionLableResourceRB_zh_CN里增加如下内容:@RBEntry("提交审阅")public static final String DOC_SUBMITREVIEW_TITLE = "doc.submitReview.title";@RBEntry("提交审阅")public static final String DOC_SUBMITREVIEW_TOOLTIP = "doc.submitReview.tooltip";@RBEntry("提交审阅")public static final String DOC_SUBMITREVIEW_DESCRIPTION = "doc.submitReview.description";@RBEntry("您确认要提交审阅吗?")public static final String CONFORM_SUBMIT_REVIEW = "CONFORM_SUBMIT_REVIEW";@RBEntry("height=200,width=300")@RBPseudo(false)public static final String DOC_SUBMITREVIEW_MOREURLINFO = "doc.submitReview.moreurlinfo";@RBEntry("提交审阅完成。