其中itemUom 为度量单位
/**
* 度量单位的获取
* @Title: getMeasureMap
* @Description: TODO
* @param session
* @Author:wushigao
* @CreateDate:2022 Feb 25 08:29:00
*/
public static Map<String,TCComponentUnitOfMeasure> getMeasureMap(TCSession session) {
Map<String,TCComponentUnitOfMeasure> unitOfMeasureMap = new HashMap<>();
TCComponentType uomType;
try {
uomType = session.getTypeComponent("UnitOfMeasure");
TCComponent[] uoms = uomType.extent();
// System.out.println("UOM Count:" + uoms.length);
for (int i = 0; i < uoms.length; i++) {
TCComponentUnitOfMeasure measure = (TCComponentUnitOfMeasure) uoms[i];
System.out.println(measure);
unitOfMeasureMap.put(measure.toString(), measure);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return unitOfMeasureMap;
}
item版本与itemRevesion创建时必填项的带入
/**
* 20240109 add hzh
* @param session
* @param typeName
* @param itemMap
* @param revesionMaps
* @param itemUom
* @return
* @throws ServiceException
* @throws TCException
* @throws InterruptedException
* @throws ExecutionException
*/
public TCComponent createComponent(TCSession session, String typeName, Map<String, String> itemMap,
Map<String, String> revesionMaps, TCComponent itemUom)
throws ServiceException, TCException, InterruptedException, ExecutionException {
TCComponentItem tcComponentItem = null;
DataManagementService dataManagementService = DataManagementService.getService(session);
CreateInput createInput = new CreateInput();
createInput.boName = typeName;
createInput.stringProps = itemMap;
CreateIn createIn = new CreateIn();
createInput.tagProps.put("uom_tag", itemUom);
createIn.data = createInput;
// revision
CreateInput createRevInput = new CreateInput();
createRevInput.boName = typeName + "Revision";
createRevInput.stringProps = revesionMaps;
List<CreateInput> createInputs = Lists.newArrayList(createRevInput);
createInput.compoundCreateInput.put("revision", createInputs.toArray(new CreateInput[] {}));
List<CreateIn> createIns = Lists.newArrayList(createIn);
CreateResponse createResponse = dataManagementService.createObjects(createIns.toArray(new CreateIn[] {}));
SoaUtil.checkPartialErrors(createResponse.serviceData);
for (CreateOut createOut : createResponse.output) {
for (TCComponent tcComponent : createOut.objects) {
if (tcComponent instanceof TCComponentItem) {
tcComponentItem = (TCComponentItem) tcComponent;
}
}
}
return tcComponentItem;
}
标签:createInput,必填,param,Item,teamcenter,session,new,throws,CreateInput From: https://www.cnblogs.com/huangzuhong/p/18103164