使用案例 9:透過根據兩個屬性略過零件來產生下游結構
請考慮這樣一種情境:即 BOM 轉換器中存在以下結構:
• Upstream Parent Part (Design) 與 Downstream Parent Part (Manufacturing) 之間存在對等連結。
• Part C1 (Design)、Part C4 (Design)、Part C5 (Design)、Part C6 (Design) 與 Part C7 (Design) 的零件使用關係屬性 Attribute1 設定為 true。
| Attribute1 是類型為布林值的屬性。在 Windchill 中,此屬性的值為 Yes 與 No。true 與 false 分別同步到 Yes 與 No。 |
• 結構中所有零件的零件類型均為 wt.part.WTPart。
欲透過根據兩個屬性略過零件產生下游結構,您可以使用規則檔案或內容檔案來指定轉換與重新建構規則。
使用規則檔案
{
"transformRules": [
{
"sourceType": "wt.part.WTPart",
"newAttributeMappings": [
[
"source.usage.Attribute1:true",
"target.part.CustomAttribute1:String1",
"doAndValidationForAttr": "true"
]
],
"targetType": "wt.part.WTPart",
"transformOption": "newPart",
"skipAttributes":
[
"source:buy",
"Attribute2":"true"
]
}
]
}
使用內容檔案
1. 存取位於 Windchill/codebase/com/ptc/core/foundation/associativity 中的 associativity.properties.xconf 檔案。
2. 在 Windchill/codebase/com/ptc/core/foundation/associativity 檔案中新增下列重新建構規則:
<Property name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" multivalued="," default=""/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="transformOption=newPart"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="targetType=wt.part.WTPart"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="attributeMapping.rule1=Attribute1:true:CustomAttribute1:String1"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="skipAttribute.Source=buy"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="skipAttribute.Attribute2=true"/>
<AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="doAndValidationForAttr=true"/>
針對上游中的所選零件啟動
動作後,Windchill 系統會遍歷所選零件下方的結構。此組態可確保:
• 如果 Windchill 系統偵測到上游存在零件屬性 Attribute1 設定為 true 的零件,則會在下游中屬性 CustomAttribute1 設定為 String1 的零件下轉換它。將其轉換為新零件。
• 如果 Windchill 系統偵測到上游存在零件屬性 Attribute2 設定為 true 且屬性 Source 設定為 buy 的零件,則會跳過該零件,且不會將其新增至下游。但是,會遍歷偵測到的零件之下的結構。
下列結構會顯示在 BOM 轉換器中:
• 會略過 Part C2 (Design),因為它符合指定的條件:
◦ <AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="skipAttribute.Source=buy"/>
◦ <AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="skipAttribute.Attribute2=true"/>
◦ <AddToProperty name="com.ptc.windchill.associativity.reconciliation.addusage.wt.part.WTPart" value="doAndValidationForAttr=true"/>
但是,系統會遍歷其下方的結構。
• Part C1 (Design)、Part C4 (Design)、Part C5 (Design)、Part C6 (Design) 與 Part C7 (Design) 的零件屬性 Attribute1 設定為 true。因此,會將其新增為 Part T1 (Manufacturing) 下的新零件。Part T1 (Manufacturing) 零件屬性 CustomAttribute1 設定為 String1。
• 不會在 Part T2 (Manufacturing) 下新增零件。這是因為,其零件屬性 CustomAttribute1 設定為 String2。