|
|
@ -6,6 +6,8 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package com.connor.kwc.createBom;
|
|
|
|
package com.connor.kwc.createBom;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
|
|
|
import java.awt.Toolkit;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.awt.event.ItemEvent;
|
|
|
|
import java.awt.event.ItemEvent;
|
|
|
@ -32,12 +34,16 @@ import javax.swing.LayoutStyle;
|
|
|
|
import javax.swing.WindowConstants;
|
|
|
|
import javax.swing.WindowConstants;
|
|
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
|
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMView;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentFolder;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentFolder;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentGDE;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
@ -79,6 +85,7 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
private String[] sxxdate;
|
|
|
|
private String[] sxxdate;
|
|
|
|
private TCComponent component;
|
|
|
|
private TCComponent component;
|
|
|
|
private List<String> tempList;
|
|
|
|
private List<String> tempList;
|
|
|
|
|
|
|
|
private List<String> tempIdList;
|
|
|
|
private Map<String, CheckBoxTreeNode> itemMapIsSel = new HashMap<>();
|
|
|
|
private Map<String, CheckBoxTreeNode> itemMapIsSel = new HashMap<>();
|
|
|
|
private Map<String, TCComponentBOMLine> itemMapBoMap = new HashMap<>();
|
|
|
|
private Map<String, TCComponentBOMLine> itemMapBoMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
@ -146,8 +153,11 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
|
|
|
|
|
|
|
|
jLabel3.setText("类型:");
|
|
|
|
jLabel3.setText("类型:");
|
|
|
|
|
|
|
|
|
|
|
|
List typeList = (ArrayList) dataMap.get("typeList");
|
|
|
|
ArrayList<String> typeList = (ArrayList<String>) dataMap.get("typeList");
|
|
|
|
String[] typeArray = (String[]) typeList.toArray();
|
|
|
|
for(String tyString : typeList) {
|
|
|
|
|
|
|
|
System.out.println("tyString:"+tyString);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] typeArray = typeList.stream().toArray(String[]::new);
|
|
|
|
jComboBox2.setModel(new DefaultComboBoxModel<>(typeArray));
|
|
|
|
jComboBox2.setModel(new DefaultComboBoxModel<>(typeArray));
|
|
|
|
jComboBox2.setSelectedIndex(0);
|
|
|
|
jComboBox2.setSelectedIndex(0);
|
|
|
|
|
|
|
|
|
|
|
@ -155,9 +165,11 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
String template = templateMap.get(jComboBox2.getSelectedItem());
|
|
|
|
String template = templateMap.get(jComboBox2.getSelectedItem());
|
|
|
|
String[] split = template.split(";");
|
|
|
|
String[] split = template.split(";");
|
|
|
|
tempList = new ArrayList<String>();
|
|
|
|
tempList = new ArrayList<String>();
|
|
|
|
|
|
|
|
tempIdList = new ArrayList<String>();
|
|
|
|
// 根据UID找模板信息
|
|
|
|
// 根据UID找模板信息
|
|
|
|
for (String uid : split) {
|
|
|
|
for (String uid : split) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
tempIdList.add(uid);
|
|
|
|
TCComponent component = session.stringToComponent(uid);
|
|
|
|
TCComponent component = session.stringToComponent(uid);
|
|
|
|
tempList.add(component.getStringProperty("object_name"));
|
|
|
|
tempList.add(component.getStringProperty("object_name"));
|
|
|
|
} catch (TCException e1) {
|
|
|
|
} catch (TCException e1) {
|
|
|
@ -166,13 +178,14 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String[] array = (String[]) tempList.toArray();
|
|
|
|
String[] array = tempList.stream().toArray(String[]::new);
|
|
|
|
jComboBox3.setModel(new DefaultComboBoxModel<>(array));
|
|
|
|
jComboBox3.setModel(new DefaultComboBoxModel<>(array));
|
|
|
|
jComboBox3.setSelectedIndex(0);
|
|
|
|
jComboBox3.setSelectedIndex(0);
|
|
|
|
jLabel4.setText("模板:");
|
|
|
|
jLabel4.setText("模板:");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 根据模板创建树结构,给用户选择
|
|
|
|
// 根据模板创建树结构,给用户选择
|
|
|
|
component = session.stringToComponent(tempList.get(0));
|
|
|
|
System.out.println("tempId:"+tempIdList.get(0));
|
|
|
|
|
|
|
|
component = session.stringToComponent(tempIdList.get(0));
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindow view = winType.create(null);
|
|
|
|
TCComponentBOMWindow view = winType.create(null);
|
|
|
|
if (component instanceof TCComponentItemRevision) {
|
|
|
|
if (component instanceof TCComponentItemRevision) {
|
|
|
@ -192,11 +205,8 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
e1.printStackTrace();
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jComboBox2.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jComboBox3.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jLabel4.setText("模板:");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jLabel5.setText("专业:");
|
|
|
|
jLabel5.setText("专业:");
|
|
|
|
|
|
|
|
|
|
|
@ -324,7 +334,17 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
|
GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
|
|
|
|
|
|
|
|
|
pack();
|
|
|
|
pack();
|
|
|
|
|
|
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
|
|
|
|
|
|
|
|
int screenWidth = screenSize.width; // 获取屏幕宽度
|
|
|
|
|
|
|
|
int screenHeight = screenSize.height; // 获取屏幕高度
|
|
|
|
|
|
|
|
int x = (screenWidth - this.getWidth()) / 2; // 计算Frame的左上角x坐标
|
|
|
|
|
|
|
|
int y = (screenHeight - this.getHeight()) / 2; // 计算Frame的左上角y坐标
|
|
|
|
|
|
|
|
this.setLocation(x, y); // 设置Frame的位置
|
|
|
|
|
|
|
|
this.setDefaultCloseOperation(2);
|
|
|
|
|
|
|
|
|
|
|
|
jTextField1.setText(target.getStringProperty("item_id"));
|
|
|
|
jTextField1.setText(target.getStringProperty("item_id"));
|
|
|
|
|
|
|
|
// jTextField2.setText(target.getStringProperty("object_name"));
|
|
|
|
|
|
|
|
// jTextField1.setEditable(false);
|
|
|
|
jTextField2.setEditable(false);
|
|
|
|
jTextField2.setEditable(false);
|
|
|
|
// 类型下拉框监听,更新模板下拉框
|
|
|
|
// 类型下拉框监听,更新模板下拉框
|
|
|
|
jComboBox2.addItemListener(new ItemListener() {
|
|
|
|
jComboBox2.addItemListener(new ItemListener() {
|
|
|
@ -334,10 +354,11 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
Map<String, String> templateMap = (HashMap<String, String>) dataMap.get("templateMap");
|
|
|
|
Map<String, String> templateMap = (HashMap<String, String>) dataMap.get("templateMap");
|
|
|
|
String template = templateMap.get(jComboBox2.getSelectedItem());
|
|
|
|
String template = templateMap.get(jComboBox2.getSelectedItem());
|
|
|
|
String[] split = template.split(";");
|
|
|
|
String[] split = template.split(";");
|
|
|
|
List<String> tempList = new ArrayList<String>();
|
|
|
|
tempList = new ArrayList<String>();
|
|
|
|
// 根据UID找模板信息
|
|
|
|
// 根据UID找模板信息
|
|
|
|
for (String uid : split) {
|
|
|
|
for (String uid : split) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
tempIdList.add(uid);
|
|
|
|
TCComponent component = session.stringToComponent(uid);
|
|
|
|
TCComponent component = session.stringToComponent(uid);
|
|
|
|
tempList.add(component.getStringProperty("object_name"));
|
|
|
|
tempList.add(component.getStringProperty("object_name"));
|
|
|
|
} catch (TCException e1) {
|
|
|
|
} catch (TCException e1) {
|
|
|
@ -345,8 +366,8 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
e1.printStackTrace();
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] array = tempList.stream().toArray(String[]::new);
|
|
|
|
String[] array = (String[]) tempList.toArray();
|
|
|
|
//String[] array = (String[]) tempList.toArray();
|
|
|
|
jComboBox3.setModel(new DefaultComboBoxModel<>(array));
|
|
|
|
jComboBox3.setModel(new DefaultComboBoxModel<>(array));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -357,7 +378,7 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
public void itemStateChanged(ItemEvent e) {
|
|
|
|
public void itemStateChanged(ItemEvent e) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int selectedIndex = jComboBox3.getSelectedIndex();
|
|
|
|
int selectedIndex = jComboBox3.getSelectedIndex();
|
|
|
|
String uid = tempList.get(selectedIndex);
|
|
|
|
String uid = tempIdList.get(selectedIndex);
|
|
|
|
component = session.stringToComponent(uid);
|
|
|
|
component = session.stringToComponent(uid);
|
|
|
|
|
|
|
|
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
@ -387,28 +408,56 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
// 必填判定
|
|
|
|
// 必填判定
|
|
|
|
String field1 = jTextField1.getText();
|
|
|
|
String field1 = jTextField1.getText();
|
|
|
|
String field2 = jTextField2.getText();
|
|
|
|
if (field1 == null || "".equals(field1.trim())) {
|
|
|
|
if (field1 == null || "".equals(field1.trim()) || field2 == null || "".equals(field2.trim())) {
|
|
|
|
MessageBox.post("产品代号必填,请检查", "提示", MessageBox.INFORMATION);
|
|
|
|
MessageBox.post("产品代号和产品名称必填,请检查", "提示", MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 开始复制对象
|
|
|
|
// 开始复制对象
|
|
|
|
TCComponentItemRevision revision = (TCComponentItemRevision) component;
|
|
|
|
TCComponentItemRevision revision = (TCComponentItemRevision) component;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (itemMapIsSel.get(revision.getStringProperty("object_string")).isSelected) {
|
|
|
|
if (itemMapIsSel.get(revision.getStringProperty("object_name")).isSelected) {
|
|
|
|
TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A", jTextField2.getText(),
|
|
|
|
TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A");
|
|
|
|
"", true, null);
|
|
|
|
// TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A", revision.getStringProperty("object_name"),"", true, null);
|
|
|
|
TCComponentItemRevision newRevision = newItem.getLatestItemRevision();
|
|
|
|
TCComponentItemRevision newRevision = newItem.getLatestItemRevision();
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session
|
|
|
|
.getTypeComponent("BOMWindow");
|
|
|
|
.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindow view = winType.create(null);
|
|
|
|
TCComponentBOMWindow view = winType.create(null);
|
|
|
|
TCComponentBOMLine line = view.setWindowTopLine(revision.getItem(), revision, null, null);
|
|
|
|
TCComponentBOMLine line = view.setWindowTopLine(newItem, newRevision, null, null);
|
|
|
|
// 根据首选项的值复制对象属性
|
|
|
|
// 根据首选项的值复制对象属性
|
|
|
|
for (String attrStr : sxxdate) {
|
|
|
|
for (String attrStr : sxxdate) {
|
|
|
|
if (attrStr.startsWith(line.getItemRevision().getItem().getStringProperty("object_type"))) {
|
|
|
|
if (attrStr.startsWith(line.getItemRevision().getItem().getStringProperty("object_type"))) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
replaceAttribute(line, newRevision, attrStr);
|
|
|
|
String[] replaces = attrStr.split("=")[1].split(";");
|
|
|
|
} catch (ParseException e1) {
|
|
|
|
for(String replace : replaces) {
|
|
|
|
|
|
|
|
String[] getValues = replace.split("\\.");
|
|
|
|
|
|
|
|
Object val = "";
|
|
|
|
|
|
|
|
if(getValues[0].equals("item")) {
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(revision.getItem(), getValues[1]);
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(newRevision.getItem(), getValues[1], val);
|
|
|
|
|
|
|
|
//val = item.getProperty(getValues[1]);
|
|
|
|
|
|
|
|
}else if(getValues[0].equals("rev")) {
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(revision, getValues[1]);
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(newRevision, getValues[1], val);
|
|
|
|
|
|
|
|
//val = rev.getProperty(getValues[1]);
|
|
|
|
|
|
|
|
}else if(getValues[0].equals("rm")) {
|
|
|
|
|
|
|
|
TCComponent[] oldreferenceListProperty = revision.getReferenceListProperty("IMAN_master_form_rev");
|
|
|
|
|
|
|
|
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(oldform, getValues[1]);
|
|
|
|
|
|
|
|
TCComponent[] newreferenceListProperty = newRevision.getReferenceListProperty("IMAN_master_form_rev");
|
|
|
|
|
|
|
|
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(newform, getValues[1], val);
|
|
|
|
|
|
|
|
//val = form.getProperty(getValues[1]);
|
|
|
|
|
|
|
|
}else if(getValues[0].equals("bom")) {
|
|
|
|
|
|
|
|
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
|
|
|
|
TCComponentBOMWindow view1 = winType1.create(null);
|
|
|
|
|
|
|
|
TCComponentBOMLine line1 = view1.setWindowTopLine(revision.getItem(), revision, null, null);
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(line1, getValues[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(line, getValues[1], val);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e1.printStackTrace();
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -416,10 +465,18 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 递归BOM结构,删除未选中的对象
|
|
|
|
// 递归BOM结构,删除未选中的对象
|
|
|
|
collectAllBomLine(line, jTextField1.getText(), winType, view, false);
|
|
|
|
collectAllBomLine(line, jTextField1.getText(), winType, line.getBOMView(), true);
|
|
|
|
TCComponentItemRevision itemRevision = line.getItemRevision();
|
|
|
|
AIFComponentContext[] children = line.getChildren();
|
|
|
|
target.add("", itemRevision);
|
|
|
|
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
|
|
|
|
TCComponentBOMWindow view1 = winType1.create(null);
|
|
|
|
|
|
|
|
TCComponentBOMLine revLine = view1.setWindowTopLine(target.getItem(), target, null, null);
|
|
|
|
|
|
|
|
for(AIFComponentContext line2 : children) {
|
|
|
|
|
|
|
|
TCComponentBOMLine bomLine = (TCComponentBOMLine)line2.getComponent();
|
|
|
|
|
|
|
|
revLine.add(bomLine.getItem(), bomLine.getItemRevision(), null, false, "");
|
|
|
|
|
|
|
|
view1.save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageBox.post("创建成功", "提示", MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -443,7 +500,7 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
* @throws TCException
|
|
|
|
* @throws TCException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void collectAllBomLine(TCComponentBOMLine bomLine, String newId, TCComponentBOMWindowType winType,
|
|
|
|
public void collectAllBomLine(TCComponentBOMLine bomLine, String newId, TCComponentBOMWindowType winType,
|
|
|
|
TCComponentBOMWindow newview, Boolean flag) throws TCException {
|
|
|
|
TCComponentBOMView newview, Boolean flag) throws TCException {
|
|
|
|
String objectName = bomLine.getItemRevision().getStringProperty("object_name");
|
|
|
|
String objectName = bomLine.getItemRevision().getStringProperty("object_name");
|
|
|
|
boolean selected = itemMapIsSel.get(objectName).isSelected();
|
|
|
|
boolean selected = itemMapIsSel.get(objectName).isSelected();
|
|
|
|
// 判断界面是否选中
|
|
|
|
// 判断界面是否选中
|
|
|
@ -461,15 +518,48 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 当不是第一次递归的时候,每次递归另存一个对象,把要同步的数据同步过去,然后将对象替换到新的bomview上去
|
|
|
|
// 当不是第一次递归的时候,每次递归另存一个对象,把要同步的数据同步过去,然后将对象替换到新的bomview上去
|
|
|
|
TCComponentItem saveAsItem = bomLine.getItemRevision().saveAsItem(jTextField1.getText(), "A",
|
|
|
|
String itemId = bomLine.getItemRevision().getStringProperty("item_id");
|
|
|
|
bomLine.getItemRevision().getStringProperty("object_name"), "", true, null);
|
|
|
|
System.out.println("itemID:"+itemId);
|
|
|
|
|
|
|
|
System.out.println(bomLine.getItemRevision().getStringProperty("object_string"));
|
|
|
|
|
|
|
|
String newItemId = itemId.replaceFirst(itemId.split("-")[0], jTextField1.getText());
|
|
|
|
|
|
|
|
System.out.println("newItemId:"+newItemId);
|
|
|
|
|
|
|
|
TCComponentItem saveAsItem = bomLine.getItemRevision().saveAsItem(newItemId, "A");
|
|
|
|
|
|
|
|
//TCComponentItem saveAsItem = bomLine.getItemRevision().saveAsItem(jTextField1.getText(), "A",bomLine.getItemRevision().getStringProperty("object_name"), "", true, null);
|
|
|
|
TCComponentItemRevision latestItemRevision = saveAsItem.getLatestItemRevision();
|
|
|
|
TCComponentItemRevision latestItemRevision = saveAsItem.getLatestItemRevision();
|
|
|
|
// 替换属性
|
|
|
|
// 替换属性
|
|
|
|
for (String attrStr : sxxdate) {
|
|
|
|
for (String attrStr : sxxdate) {
|
|
|
|
if (attrStr.startsWith(bomLine.getItemRevision().getItem().getStringProperty("object_type"))) {
|
|
|
|
if (attrStr.startsWith(bomLine.getItemRevision().getItem().getStringProperty("object_type"))) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
replaceAttribute(itemMapBoMap.get(objectName), latestItemRevision, attrStr);
|
|
|
|
//Util.replaceAttribute(itemMapBoMap.get(objectName), latestItemRevision, attrStr);
|
|
|
|
} catch (ParseException e1) {
|
|
|
|
String[] replaces = attrStr.split("=")[1].split(";");
|
|
|
|
|
|
|
|
for(String replace : replaces) {
|
|
|
|
|
|
|
|
String[] getValues = replace.split("\\.");
|
|
|
|
|
|
|
|
Object val = "";
|
|
|
|
|
|
|
|
if(getValues[0].equals("item")) {
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItem(), getValues[1]);
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(latestItemRevision.getItem(), getValues[1], val);
|
|
|
|
|
|
|
|
//val = item.getProperty(getValues[1]);
|
|
|
|
|
|
|
|
}else if(getValues[0].equals("rev")) {
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItemRevision(), getValues[1]);
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(latestItemRevision, getValues[1], val);
|
|
|
|
|
|
|
|
//val = rev.getProperty(getValues[1]);
|
|
|
|
|
|
|
|
}else if(getValues[0].equals("rm")) {
|
|
|
|
|
|
|
|
TCComponent[] oldreferenceListProperty = itemMapBoMap.get(objectName).getItemRevision().getReferenceListProperty("IMAN_master_form_rev");
|
|
|
|
|
|
|
|
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(oldform, getValues[1]);
|
|
|
|
|
|
|
|
TCComponent[] newreferenceListProperty = latestItemRevision.getReferenceListProperty("IMAN_master_form_rev");
|
|
|
|
|
|
|
|
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(newform, getValues[1], val);
|
|
|
|
|
|
|
|
//val = form.getProperty(getValues[1]);
|
|
|
|
|
|
|
|
}else if(getValues[0].equals("bom")) {
|
|
|
|
|
|
|
|
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName), getValues[1]);
|
|
|
|
|
|
|
|
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
|
|
|
|
TCComponentBOMWindow view1 = winType1.create(null);
|
|
|
|
|
|
|
|
TCComponentBOMLine line1 = view1.setWindowTopLine(latestItemRevision.getItem(), latestItemRevision, null, null);
|
|
|
|
|
|
|
|
Util.setTCPropertyValue(line1, getValues[1], val);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e1.printStackTrace();
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -478,8 +568,14 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 替换分类属性
|
|
|
|
// 替换分类属性
|
|
|
|
|
|
|
|
|
|
|
|
// 替换bom行
|
|
|
|
//添加属性
|
|
|
|
bomLine.replace(saveAsItem, latestItemRevision, newview);
|
|
|
|
latestItemRevision.setStringProperty("kwc6_ProductID", jTextField1.getText());
|
|
|
|
|
|
|
|
// 添加bom行
|
|
|
|
|
|
|
|
String stringProperty = bomLine.getItemRevision().getStringProperty("object_string");
|
|
|
|
|
|
|
|
System.out.println("要替换的老行:"+stringProperty);
|
|
|
|
|
|
|
|
String stringProperty2 = latestItemRevision.getStringProperty("object_string");
|
|
|
|
|
|
|
|
System.out.println("要替换的新行:"+stringProperty2);
|
|
|
|
|
|
|
|
bomLine.replace(saveAsItem, latestItemRevision, null);
|
|
|
|
if (bomLine.hasChildren()) {
|
|
|
|
if (bomLine.hasChildren()) {
|
|
|
|
for (AIFComponentContext aifComponentContext : bomLine.getChildren()) {
|
|
|
|
for (AIFComponentContext aifComponentContext : bomLine.getChildren()) {
|
|
|
|
TCComponentBOMLine line = (TCComponentBOMLine) aifComponentContext.getComponent();
|
|
|
|
TCComponentBOMLine line = (TCComponentBOMLine) aifComponentContext.getComponent();
|
|
|
@ -489,6 +585,7 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 从bomview中删除对象
|
|
|
|
// 从bomview中删除对象
|
|
|
|
|
|
|
|
bomLine.cut();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -516,108 +613,5 @@ public class NewJFrame1 extends JFrame {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void replaceAttribute(TCComponentBOMLine oldLine, TCComponentItemRevision newLine, String attrStr)
|
|
|
|
|
|
|
|
throws TCException, ParseException {
|
|
|
|
|
|
|
|
String[] attrs = attrStr.split("=")[1].split(";");
|
|
|
|
|
|
|
|
for (String attr : attrs) {
|
|
|
|
|
|
|
|
String[] p1 = attr.split("\\.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (p1[0].equals("item")) {
|
|
|
|
|
|
|
|
// pitem.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
String val = oldLine.getItem().getStringProperty(p1[1]);
|
|
|
|
|
|
|
|
TCComponentItem pitem = newLine.getItem();
|
|
|
|
|
|
|
|
TCProperty property = (TCProperty) pitem.getTCProperty(p1[1]);
|
|
|
|
|
|
|
|
switch (property.getPropertyType()) {
|
|
|
|
|
|
|
|
case TCProperty.PROP_string:
|
|
|
|
|
|
|
|
case TCProperty.PROP_long_string:
|
|
|
|
|
|
|
|
pitem.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_short:
|
|
|
|
|
|
|
|
case TCProperty.PROP_int:
|
|
|
|
|
|
|
|
pitem.setIntProperty(p1[1], Integer.parseInt(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_double:
|
|
|
|
|
|
|
|
case TCProperty.PROP_float:
|
|
|
|
|
|
|
|
pitem.setDoubleProperty(p1[1], Double.parseDouble(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_date:
|
|
|
|
|
|
|
|
if (!val.equals("")) {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
|
|
|
|
|
|
|
Date date = sdf.parse(p1[1]);
|
|
|
|
|
|
|
|
if (date != null) {
|
|
|
|
|
|
|
|
pitem.setDateProperty(p1[1], date);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
pitem.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (p1[0].equals("rev")) {
|
|
|
|
|
|
|
|
String val = oldLine.getItemRevision().getStringProperty(p1[1]);
|
|
|
|
|
|
|
|
TCComponentItemRevision prev = newLine;
|
|
|
|
|
|
|
|
TCProperty property = (TCProperty) prev.getTCProperty(p1[1]);
|
|
|
|
|
|
|
|
// prev.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
switch (property.getPropertyType()) {
|
|
|
|
|
|
|
|
case TCProperty.PROP_string:
|
|
|
|
|
|
|
|
case TCProperty.PROP_long_string:
|
|
|
|
|
|
|
|
prev.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_short:
|
|
|
|
|
|
|
|
case TCProperty.PROP_int:
|
|
|
|
|
|
|
|
prev.setIntProperty(p1[1], Integer.parseInt(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_double:
|
|
|
|
|
|
|
|
case TCProperty.PROP_float:
|
|
|
|
|
|
|
|
prev.setDoubleProperty(p1[1], Double.parseDouble(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_date:
|
|
|
|
|
|
|
|
if (!val.equals("")) {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
|
|
|
|
|
|
|
Date date = sdf.parse(p1[1]);
|
|
|
|
|
|
|
|
if (date != null) {
|
|
|
|
|
|
|
|
prev.setDateProperty(p1[1], date);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
prev.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (p1[0].equals("bom")) {
|
|
|
|
|
|
|
|
String val = oldLine.getStringProperty(p1[1]);
|
|
|
|
|
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
|
|
|
|
TCComponentBOMWindow view = winType.create(null);
|
|
|
|
|
|
|
|
TCComponentBOMLine line = view.setWindowTopLine(newLine.getItem(), newLine, null, null);
|
|
|
|
|
|
|
|
TCProperty property = (TCProperty) line.getTCProperty(p1[1]);
|
|
|
|
|
|
|
|
switch (property.getPropertyType()) {
|
|
|
|
|
|
|
|
case TCProperty.PROP_string:
|
|
|
|
|
|
|
|
case TCProperty.PROP_long_string:
|
|
|
|
|
|
|
|
line.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_short:
|
|
|
|
|
|
|
|
case TCProperty.PROP_int:
|
|
|
|
|
|
|
|
line.setIntProperty(p1[1], Integer.parseInt(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_double:
|
|
|
|
|
|
|
|
case TCProperty.PROP_float:
|
|
|
|
|
|
|
|
line.setDoubleProperty(p1[1], Double.parseDouble(val));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCProperty.PROP_date:
|
|
|
|
|
|
|
|
if (!val.equals("")) {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
|
|
|
|
|
|
|
Date date = sdf.parse(p1[1]);
|
|
|
|
|
|
|
|
if (date != null) {
|
|
|
|
|
|
|
|
line.setDateProperty(p1[1], date);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
line.setStringProperty(p1[1], val);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|