1、RCP设置uom_tag属性值
private void setItemPropForUomtag(TCComponentItem item,String uom_tag_value) {
System.out.println("enter setItemPropForUomtag...");
System.out.println("uom_tag value:"+uom_tag_value);
if((uom_tag_value!=null) && (!"".equals(uom_tag_value))){
System.out.println("开始设置属性值...");
TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession();
TCTypeService service = session.getTypeService();
try {
System.out.println("搜索所有uom,构建map<uom name,uom TCComponent>");
TCComponentType uom = service.getTypeComponent("UnitOfMeasure");
if(uom!=null){
TCComponent[] uoms = uom.extent();
Map<String, TCComponent> uomMap = new HashMap<String, TCComponent>();
if (uoms != null) {
for (int i = 0; i < uoms.length; i++) {
uomMap.put(uoms[i].toString(), uoms[i]);
}
}
System.out.println("uomMap size:"+uomMap.size());
TCComponent uomCom = uomMap.get(uom_tag_value);
if(uomCom!=null){
System.out.println("找到名为"+uom_tag_value+"的单位对象");
item.lock();
item.setReferenceProperty("uom_tag", uomCom);
item.save();
item.unlock();
}
}else{
System.out.println("未找到UnitOfMeasure类型数据(TCComponentType==null)");
}
} catch (TCException e1) {
e1.printStackTrace();
}
}
System.out.println("setItemPropForUomtag end");
}
2、ITK设置uom_tag属性值
// 设置显示值
tag_t uom_tag = NULLTAG;
UOM_find_by_name(prop_value.c_str(), &uom_tag) :
ITEM_set_unit_of_measure(prop_value.c str,uom_tag);
// 设置真实值
UOM_find_by_symbol(prop_value.c_str(), &uom_tag);
ITEM_set_unit_of_measure(item_tag, uom_tag) :