颜色件创建

main
zouxk 6 years ago
parent 62d4db98f9
commit 402512ed1e

@ -0,0 +1,78 @@
package cn.com.origin.autocode.jfom.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
public class TCTableUtil {
public static String[][] getTableRows(TCComponentForm form, String prop, String[] colNames) {
try {
TCProperty tcProperty = form.getTCProperty(prop);
TCComponent[] components = tcProperty.getReferenceValueArray();
String[][] res = new String[components.length][colNames.length];
for (int i = 0; i < components.length; i++) {
for (int ii = 0; ii < colNames.length; ii++) {
res[i][ii] = components[i].getPropertyDisplayableValue(colNames[ii]);
}
}
return res;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static boolean setTableRows(TCComponentForm form, String prop, String refName, String[] colNames,
String[][] rows) {
List<TCComponent> list = new ArrayList<TCComponent>();
DataManagementService service = DataManagementService
.getService((TCSession) AIFUtility.getCurrentApplication().getSession());
CreateIn ci = new CreateIn();
ci.data.boName = refName;
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < rows.length; i++) {
for (int ii = 0; ii < colNames.length; ii++) {
map.put(colNames[ii], rows[i][ii]);
}
System.out.println(map.size());
ci.data.stringProps = map;
try {
CreateResponse response = service.createObjects(new CreateIn[] { ci });
System.out.println("CreateResponse size:" + response.serviceData.sizeOfCreatedObjects());
if (response.serviceData.sizeOfCreatedObjects() > 0) {
list.add(response.output[0].objects[0]);
} else {
String str = String.join(",", response.serviceData.getPartialError(0).getMessages());
System.out.println(str);
}
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
form.getTCProperty(prop).setReferenceValueArray(list.toArray(new TCComponent[list.size()]));
System.out.println("±£´ætable³É¹¦");
return true;
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
}

@ -108,6 +108,7 @@ import cn.com.origin.autocode.jfom.util.JFomLovBean;
import cn.com.origin.autocode.jfom.util.JFomMethodUtil;
import cn.com.origin.autocode.jfom.util.JFomUtil;
import cn.com.origin.autocode.jfom.util.SoaServerUtil;
import cn.com.origin.autocode.jfom.util.TCTableUtil;
import cn.com.origin.autocode.newitem.origin.ORAfterNewItemCustomization;
import cn.com.origin.autocode.newitem.origin.ORCreateICOObject;
import cn.com.origin.autocode.newitem.origin.ORSaveObjectDescOperation;
@ -248,7 +249,13 @@ public class NewCodeItemDialog extends Dialog {
private Boolean isCreateTempItem = false;
private String ksfl = null;
private String selectedType = null;
private TCComponentItemRevision ysjtzRev = null;
private TCComponentForm ysdzbForm = null;
private String[][] ysjTable = null;
private String[] colNames = new String[] { "jd2_bjh", "jd2_cl", "jd2_ys", "jd2_xh" };
private String ys = null;
private String cz = null;
private String xh = null;
public Text getIdLengthText() {
return idLengthText;
@ -2214,8 +2221,6 @@ public class NewCodeItemDialog extends Dialog {
codeDesc = codeDesc + "\n";
}
this.codeRemark = treeData.getPackCodeNodeInfo().getNode_desc();
this.selectedType = treeData.getPackCodeNodeInfo().getNodeComponent().getType();
System.out.println("selectType ===>" + selectedType);
System.out.println("node_desc ===>" + treeData.getPackCodeNodeInfo().getNode_desc());
}
}
@ -3214,6 +3219,7 @@ public class NewCodeItemDialog extends Dialog {
return value;
}
@SuppressWarnings("deprecation")
private void createNewItem(String itemID, String itemRev, String itemType, String itemName, String itemDesc) {
try {
@ -3272,9 +3278,10 @@ public class NewCodeItemDialog extends Dialog {
flag = true;
TCComponent cadTemplate = session.stringToComponent(uid);
TCComponentDataset cadDataset = (TCComponentDataset) cadTemplate;
TCComponentDataset newCad = cadDataset.saveAs(null);
TCComponentItem item = (TCComponentItem) newComp;
item.getLatestItemRevision().add("IMAN_specification", newCad);
TCComponentDataset newCad = cadDataset.saveAs(item.getProperty("item_id"));
item.getLatestItemRevision().add("TC_Attaches", newCad);
System.out.println("cad数据集创建成功");
}
}
if (!flag) {
@ -3293,12 +3300,43 @@ public class NewCodeItemDialog extends Dialog {
new String[] { ksfl, "文件夹" });
if (res.length > 0) {
TCComponentFolder folder = (TCComponentFolder) res[0];
session.getUserService().call("bs_bypass", new Object[] { true });
folder.add("contents", newComp);
folder.refresh();
System.out.println("发送成功");
session.getUserService().call("bs_bypass", new Object[] { false });
}
}
}
if (ysjtzRev != null) {
TCComponentItem item = (TCComponentItem) newComp;
if (ysdzbForm != null) {
if (ysjTable != null) {
// String[][] ysjTable1 = new String[ysjTable.length + 1][colNames.length];
List<String[]> ysjTable1 = new ArrayList<String[]>();
for (String[] arr : ysjTable) {
ysjTable1.add(arr);
}
String[] newRow = new String[] { item.getProperty("item_id"), cz, ys, xh };
ysjTable1.add(newRow);
TCTableUtil.setTableRows(ysdzbForm, "jd2_ysdzb", "JD2_YSDZBTABLE", colNames,
ysjTable1.toArray(new String[ysjTable1.size()][colNames.length]));
}
} else {
TCComponentFormType formType = (TCComponentFormType) session.getTypeComponent("Form");
ysdzbForm = formType.create("颜色对照表", "颜色对照表", "JD2_YSDZB");
ysjTable = new String[][] { { item.getProperty("item_id"), cz, ys, xh } };
TCTableUtil.setTableRows(ysdzbForm, "jd2_ysdzb", "JD2_YSDZBTABLE", colNames, ysjTable);
ysjtzRev.add("IMAN_specification", ysdzbForm);
}
item.getLatestItemRevision().add("TC_Is_Represented_By", ysjtzRev);
ysjtzRev.refresh();
item.refresh();
System.out.println("颜色件创建成功");
}
if (targetObject instanceof TCComponentFolder) {
if (newComp != null) {
@ -4079,6 +4117,8 @@ public class NewCodeItemDialog extends Dialog {
return;
}
// 波轮图纸分类
ksfl = null;
System.out.println("选中类型++++++++++++++++++++++++++++++++++++" + realItemType);
if (realItemType != null && realItemType.equals("JD2_BLXYJTZ")) {
// TableItem tableItems[] = this.propTable.getItems();
@ -4094,6 +4134,7 @@ public class NewCodeItemDialog extends Dialog {
System.out.println(text);
if (text.equals("款式分类:")) {
ksfl = ((Text) generalPropTextList.get(i)).getText();
break;
}
}
@ -4109,6 +4150,74 @@ public class NewCodeItemDialog extends Dialog {
}
}
// 颜色件
String ysjth = null;
ys = null;
cz = null;
xh = null;
for (int i = 0; i < generalPropLabelList.size(); i++) {
String text = generalPropLabelList.get(i).getText();
System.out.println(text);
if (text.equals("颜色件图号:")) {
ysjth = ((Text) generalPropTextList.get(i)).getText();
System.out.println("颜色件图号:" + ysjth);
break;
}
}
for (int i = 0; i < classPropList.size(); i++) {
// System.out.println(" CLASS ID = " + integers[i] + " =" +
// vals[i]);
CNClassPropBean bean = classPropList.get(i);
System.out.println(bean.propDisName);
if ("颜色".equals(bean.propDisName)) {
if (bean.isLov) {
ys = ((Combo) classTextList.get(i)).getText();
ys = bean.lovMapping.get(ys);
} else {
ys = ((Text) classTextList.get(i)).getText();
}
// icspro[i] = new ICSProperty(bean.propID, value);
System.out.println("颜色:" + ys);
break;
}
}
if (ysjth != null && ys == null) {
MessageBox.post("该物料不是颜色件", "错误", MessageBox.ERROR);
return;
}
if (ysjth != null) {
TCComponent comp = null;
try {
comp = session.search("Item ID", new String[] { "零组件 ID" }, new String[] { ysjth })[0];
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (comp != null) {
TCComponentItem item = (TCComponentItem) comp;
ysjtzRev = item.getLatestItemRevision();
TCComponent[] comps = ysjtzRev.getReferenceListProperty("IMAN_specification");
for (int i = 0; i < comps.length; i++) {
if (comps[i].getType().equals("JD2_YSDZB")) {
ysdzbForm = (TCComponentForm) comps[i];
ysjTable = TCTableUtil.getTableRows(ysdzbForm, "jd2_ysdzb", colNames);
for (String[] row : ysjTable) {
if (ys.equals(row[2])) {
MessageBox.post("图号为\"" + ysjth + "\"的颜色件已存在颜色\"" + ys + "\"", "错误",
MessageBox.ERROR);
return;
}
}
break;
}
}
} else {
MessageBox.post("没有找到与\"" + ysjth + "\"对应的图纸信息", "错误", MessageBox.ERROR);
return;
}
}
TCComponentItem oldItem = tccomponentitemtype.find(getJYNewID(newID));
if (oldItem != null) {
MessageBox.post("ID为【" + getJYNewID(newID) + "】的物料已经存在!", "INFO", MessageBox.WARNING);

Loading…
Cancel
Save