1、如果描述不必填,采用胖客户端的创建方式
newItem = itemType.create(newItemId, "", targetTypeComp.getTypeName(), item_name,
// "test1", null, null
2、如果描述必填,则需要采用SOA的创建方式
DataManagementService service = DataManagementService.getService(session);
CreateIn createInput = new CreateIn();
createInput.clientId = "createItemTest";
CreateInput itemInput = new CreateInput();
createInput.data = itemInput;
itemInput.boName = itemType;
Calendar now = Calendar.getInstance();itemInput.stringProps.put("item_id", "");
itemInput.stringProps.put("object_name", itemName);
itemInput.stringProps.put("object_desc", "物料描述测试");CreateInput itemRevInput = new CreateInput();
itemRevInput.boName = itemType + "Revision";
itemRevInput.stringProps.put("item_revision_id", itemType.getNewRev(null));itemInput.compoundCreateInput.put("revision", new CreateInput[] { itemRevInput });CreateIn[] var1 = new CreateIn[] { createInput };
CreateResponse createObjects = service.createObjects(var1);
SoaUtil.checkPartialErrors(createObjects.serviceData);
if (CustomArrayUtil.isNotEmpty(createObjects.output)) {TCComponent[] results = createObjects.output[0].objects;for (TCComponent t : results) {if (t instanceof TCComponentItem) {newItem = (TCComponentItem) t;}}
}
感兴趣的朋友可以关注下,一起交流PLM开发知识!