mpart commit

main
李建辉 7 months ago
parent 56cde5eaed
commit abc24fee89

@ -15,7 +15,7 @@ public class DialogFrame extends JDialog {
private JComboBox<String> comboBox; private JComboBox<String> comboBox;
private Object syncObject; private Object syncObject;
public DialogFrame(JFrame owner,JComboBox<String> comboBox,ArrayList<String> list) { public DialogFrame(JFrame owner,JComboBox<String> comboBox,ArrayList<String> list) {
super(owner, "Dialog Window", true); // 模态对话框 super(owner, "选择已有M", true); // 模态对话框
this.comboBox = comboBox; this.comboBox = comboBox;
this.syncObject = syncObject; this.syncObject = syncObject;
JButton button = new JButton("È·¶¨"); JButton button = new JButton("È·¶¨");

@ -62,8 +62,6 @@ import com.teamcenter.rac.util.PropertyLayout;
import k.util.KOrgDialog; import k.util.KOrgDialog;
public class MpartDialog extends JFrame implements ActionListener { public class MpartDialog extends JFrame implements ActionListener {
private TCSession session; private TCSession session;
@ -78,12 +76,12 @@ public class MpartDialog extends JFrame implements ActionListener {
private JTable t_part; private JTable t_part;
private JComboBox<String> gsdwComboBox = new JComboBox<String>(); private JComboBox<String> gsdwComboBox = new JComboBox<String>();
protected DefaultTableModel tm_part; protected DefaultTableModel tm_part;
public static final String[] HEADER = new String[] { "","序号", "ID", "名称", "件号", "是否自制", "是否存在M", "归属单位", "工艺小组", "责任人"}; public static final String[] HEADER = new String[] { "", "序号", "ID", "名称", "件号", "是否自制", "是否存在M", "归属单位","责任人" };
public static final int[] HEADERWIDTH = new int[] { 30,40, 60, 120, 100, 60, 60, 60, 60, 100}; public static final int[] HEADERWIDTH = new int[] { 30, 40, 60, 120, 100, 60, 60, 60, 100 };
private JTable t_part2; private JTable t_part2;
protected DefaultTableModel tm_part2; protected DefaultTableModel tm_part2;
public static final String[] HEADER2 = new String[] { "序号", "对象" }; public static final String[] HEADER2 = new String[] { "序号", "对象" };
public static final int[] HEADERWIDTH2 = new int[] {10, 60}; public static final int[] HEADERWIDTH2 = new int[] { 10, 100 };
private ArrayList<ArrayList<Object>> valueList = new ArrayList<ArrayList<Object>>(); private ArrayList<ArrayList<Object>> valueList = new ArrayList<ArrayList<Object>>();
private HashMap<String, TCComponentItemRevision> objectMap = new HashMap<String, TCComponentItemRevision>(); private HashMap<String, TCComponentItemRevision> objectMap = new HashMap<String, TCComponentItemRevision>();
private ArrayList<TCComponentItemRevision> table2RevList = new ArrayList<TCComponentItemRevision>(); private ArrayList<TCComponentItemRevision> table2RevList = new ArrayList<TCComponentItemRevision>();
@ -92,10 +90,10 @@ public class MpartDialog extends JFrame implements ActionListener {
TCComponentItemType type; TCComponentItemType type;
private String[] groupSplit; private String[] groupSplit;
private HashMap<String, String> fieldsMap = new HashMap<String, String>(); private HashMap<String, String> fieldsMap = new HashMap<String, String>();
private HashMap<String, String> typesMap = new HashMap<String, String>();
static TCComponentGroup group; private boolean isInitialized = false;
static TCComponentUser user; //static TCComponentGroup group;
//static TCComponentUser user;
public MpartDialog(TCSession session, ArrayList<TCComponentItemRevision> list) throws TCException { public MpartDialog(TCSession session, ArrayList<TCComponentItemRevision> list) throws TCException {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
@ -103,7 +101,6 @@ public class MpartDialog extends JFrame implements ActionListener {
this.list = list; this.list = list;
viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
view = viewType.create(null); view = viewType.create(null);
type = (TCComponentItemType) session.getTypeComponent("LY6_ProductM");
initUI(); initUI();
} }
@ -111,29 +108,40 @@ public class MpartDialog extends JFrame implements ActionListener {
// TODO Auto-generated method stub // TODO Auto-generated method stub
try { try {
String[] fields = session.getPreferenceService().getStringValues("LY6_EPartToMPartType"); String[] fields = session.getPreferenceService().getStringValues("LY6_EPartToMPartType");
for (int i = 0; i < fields.length; i++) {
String[] split = fields[i].split("=");
fieldsMap.put(split[0], split[1]);
String[] split2 = split[0].split(":");
typesMap.put(split2[0], split2[1]);
}
gsdwComboBox.addItemListener(new ItemListener() { gsdwComboBox.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (!isInitialized) {
// 如果还没有初始化完成,则直接返回,不执行后续代码
return;
}
if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getStateChange() == ItemEvent.SELECTED) {
String selectedItem = (String) gsdwComboBox.getSelectedItem(); String selectedItem = (String) gsdwComboBox.getSelectedItem();
System.out.println("Selected Item: " + selectedItem); System.out.println("Selected Item: " + selectedItem);
// 在这里可以执行其他操作 // 在这里可以执行其他操作
int count = 0; int count = 0;
System.out.println("==========tm_part.getRowCount()=========="+tm_part.getRowCount());
for (int i = 0; i < tm_part.getRowCount(); i++) { for (int i = 0; i < tm_part.getRowCount(); i++) {
System.out.println("tm_part.getValueAt(i, 0).toString()========"+tm_part.getValueAt(i, 0).toString());
if (tm_part.getValueAt(i, 0).toString().equals("1")) { if (tm_part.getValueAt(i, 0).toString().equals("1")) {
tm_part.setValueAt(selectedItem, i, 7); tm_part.setValueAt(selectedItem, i, 7);
count++; count++;
} }
}
if (count == 0) { if (count == 0) {
MessageBox.post("请勾选数据!", "提示 ", MessageBox.INFORMATION); MessageBox.post("请勾选数据!", "提示 ", MessageBox.INFORMATION);
return; return;
} }
} }
} }
}
}); });
find.setPreferredSize(new Dimension(200, 30)); find.setPreferredSize(new Dimension(200, 30));
replace.setPreferredSize(new Dimension(200, 30)); replace.setPreferredSize(new Dimension(200, 30));
@ -172,7 +180,6 @@ public class MpartDialog extends JFrame implements ActionListener {
factory = split[1]; factory = split[1];
} }
} }
gsdwComboBox.addItem(""); gsdwComboBox.addItem("");
if (factory != null && !factory.isEmpty()) { if (factory != null && !factory.isEmpty()) {
@ -183,13 +190,11 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
// this.setAlwaysOnTop(true); // this.setAlwaysOnTop(true);
// 塞值 // 塞值
// 获取当前组 // 获取当前组
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
ArrayList<Object> tempList = new ArrayList<Object>(); ArrayList<Object> tempList = new ArrayList<Object>();
tempList.add(0); tempList.add(0);
@ -210,7 +215,8 @@ public class MpartDialog extends JFrame implements ActionListener {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
TCComponent[] search = session.search("_SearchMFKProperties", new String[] { "ID","工厂" }, new String[] { revId,split[j] }); TCComponent[] search = session.search("_SearchMFKProperties", new String[] { "ID", "工厂" },
new String[] { revId, split[j] });
if (search.length > 0) { if (search.length > 0) {
for (int k = 0; k < search.length; k++) { for (int k = 0; k < search.length; k++) {
@ -244,15 +250,10 @@ public class MpartDialog extends JFrame implements ActionListener {
for (int j = 0; j < valueList.size(); j++) { for (int j = 0; j < valueList.size(); j++) {
ArrayList<Object> arrayList = valueList.get(j); ArrayList<Object> arrayList = valueList.get(j);
tm_part.addRow(new Object[] {arrayList.get(0),arrayList.get(1),arrayList.get(2), tm_part.addRow(new Object[] { arrayList.get(0), arrayList.get(1), arrayList.get(2), arrayList.get(3),
arrayList.get(3),arrayList.get(4),arrayList.get(5),arrayList.get(6), arrayList.get(4), arrayList.get(5), arrayList.get(6), arrayList.get(7), "", "" });
arrayList.get(7),"",""});
} }
isInitialized = true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return; return;
@ -296,7 +297,7 @@ public class MpartDialog extends JFrame implements ActionListener {
return; return;
} }
if(tm_part.getValueAt(i, 9) == null || tm_part.getValueAt(i, 9).toString().isEmpty()) { if (tm_part.getValueAt(i, 8) == null || tm_part.getValueAt(i, 8).toString().isEmpty()) {
MessageBox.post("请填写第" + (i + 1) + "行责任人!", "提示 ", MessageBox.INFORMATION); MessageBox.post("请填写第" + (i + 1) + "行责任人!", "提示 ", MessageBox.INFORMATION);
return; return;
} }
@ -308,7 +309,6 @@ public class MpartDialog extends JFrame implements ActionListener {
return; return;
} }
for (int i = 0; i < tm_part.getRowCount(); i++) { for (int i = 0; i < tm_part.getRowCount(); i++) {
if (tm_part.getValueAt(i, 0).toString().equals("1")) { if (tm_part.getValueAt(i, 0).toString().equals("1")) {
try { try {
@ -317,12 +317,14 @@ public class MpartDialog extends JFrame implements ActionListener {
TCComponentItem eItem = rev.getItem(); TCComponentItem eItem = rev.getItem();
String eType = eItem.getType(); String eType = eItem.getType();
System.out.println("etype=============" + eType); System.out.println("etype=============" + eType);
type = (TCComponentItemType) session.getTypeComponent(typesMap.get(eType));
TCComponentBOMLine topLine = view.setWindowTopLine(rev.getItem(), rev, null, null); TCComponentBOMLine topLine = view.setWindowTopLine(rev.getItem(), rev, null, null);
int childrenCount = topLine.getChildrenCount(); int childrenCount = topLine.getChildrenCount();
System.out.println("childrenCount========" + childrenCount); System.out.println("childrenCount========" + childrenCount);
TCComponent[] searchLs = session.search("_SearchMFKProperties", new String[] { "ID","工厂" }, new String[] { (String) arrayList.get(2),(String) tm_part.getValueAt(i, 7) }); TCComponent[] searchLs = session.search("_SearchMFKProperties", new String[] { "ID", "工厂" },
new String[] { (String) arrayList.get(2), (String) tm_part.getValueAt(i, 7) });
String ly6_sequenceNum = "01"; String ly6_sequenceNum = "0";
// 去调用查询查看该工厂最大流水 // 去调用查询查看该工厂最大流水
// if(searchLs != null && searchLs.length > 0) { // if(searchLs != null && searchLs.length > 0) {
// TCComponentItem mItem = (TCComponentItem)searchLs[0]; // TCComponentItem mItem = (TCComponentItem)searchLs[0];
@ -345,12 +347,11 @@ public class MpartDialog extends JFrame implements ActionListener {
String newID = (String) arrayList.get(2); String newID = (String) arrayList.get(2);
String newRev = type.getNewRev(null); String newRev = type.getNewRev(null);
TCComponentItem item = type.create(newID, newRev, typesMap.get(eType), "", "", null);
TCComponentItem item = type.create(newID, newRev, "LY6_ProductM", "", "", null);
TCComponentItemRevision mRev = item.getLatestItemRevision(); TCComponentItemRevision mRev = item.getLatestItemRevision();
item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString()); item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString());
System.out.println("itemUid2============" + item.getUid()); System.out.println("itemUid2============" + item.getUid());
if(ly6_sequenceNum.isEmpty()) { if (ly6_sequenceNum.isEmpty() || ly6_sequenceNum.equals("0")) {
item.setProperty("ly6_sequenceNum", "01"); item.setProperty("ly6_sequenceNum", "01");
} else { } else {
item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum)); item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum));
@ -366,7 +367,8 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
TCComponent delItem2 = session.stringToComponent((String) arrayList.get(2)+(String) tm_part.getValueAt(i, 7)); TCComponent delItem2 = session
.stringToComponent((String) arrayList.get(2) + (String) tm_part.getValueAt(i, 7));
if (delItem1 != null) { if (delItem1 != null) {
System.out.println("delItem2.getUid()====" + delItem2.getUid()); System.out.println("delItem2.getUid()====" + delItem2.getUid());
@ -374,34 +376,48 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
// 给属性赋值 // 给属性赋值
String fiedsStr = fieldsMap.get(eType+":LY6_ProductM"); String fiedsStr = fieldsMap.get(eType + ":" + typesMap.get(eType));
System.out.println("fiedsStr===================" + fiedsStr);
if (fiedsStr != null && !fiedsStr.isEmpty()) { if (fiedsStr != null && !fiedsStr.isEmpty()) {
if (fiedsStr.contains(",")) { if (fiedsStr.contains(",")) {
String[] split = fiedsStr.split(","); String[] split = fiedsStr.split(",");
System.out.println("split.length===========" + split.length);
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
// :分割 // :分割
String[] split2 = split[j].split(":"); String[] split2 = split[j].split(":");
System.out.println("split2.length=================" + split2.length);
if (split2.length == 2) { if (split2.length == 2) {
// .分割 // .分割
String[] split3 = split2[0].split("\\."); String[] split3 = split2[0].split("\\.");
System.out.println("split3.length=================" + split3.length);
if (split3.length == 2) { if (split3.length == 2) {
if (split3[0].equals("item")) { if (split3[0].equals("item")) {
String[] split4 = split2[1].split("\\."); String[] split4 = split2[1].split("\\.");
if (split4.length == 2) { if (split4.length == 2) {
if (split4[0].equals("item")) { if (split4[0].equals("item")) {
item.setProperty(split4[1], eItem.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], eItem.getProperty(split3[1]));
} else if (split4[0].equals("rev")) { } else if (split4[0].equals("rev")) {
mRev.setProperty(split4[1], eItem.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], eItem.getProperty(split3[1]));
} }
} }
}else if(split2[0].equals("rev")) { } else if (split3[0].equals("rev")) {
String[] split4 = split2[1].split("\\."); String[] split4 = split2[1].split("\\.");
if (split4.length == 2) { if (split4.length == 2) {
if (split4[0].equals("item")) { if (split4[0].equals("item")) {
item.setProperty(split4[1], rev.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], rev.getProperty(split3[1]));
} else if (split4[0].equals("rev")) { } else if (split4[0].equals("rev")) {
mRev.setProperty(split4[1], rev.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
System.out.println("value==========================="+rev.getProperty(split3[1]));
mRev.setProperty(split4[1], rev.getProperty(split3[1]));
} }
} }
} }
@ -410,30 +426,38 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
} else { } else {
// :分割 // :分割
String[] split2 = fiedsStr.split(":"); String[] split2 = fiedsStr.split(":");
if (split2.length == 2) { if (split2.length == 2) {
// .分割 // .分割
String[] split3 = split2[0].split("\\."); String[] split3 = split2[0].split("\\.");
System.out.println("split3.length=================" + split3.length);
if (split3.length == 2) { if (split3.length == 2) {
if (split3[0].equals("item")) { if (split3[0].equals("item")) {
String[] split4 = split2[1].split("\\."); String[] split4 = split2[1].split("\\.");
if (split4.length == 2) { if (split4.length == 2) {
if (split4[0].equals("item")) { if (split4[0].equals("item")) {
item.setProperty(split4[1], eItem.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], eItem.getProperty(split3[1]));
} else if (split4[0].equals("rev")) { } else if (split4[0].equals("rev")) {
mRev.setProperty(split4[1], eItem.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], eItem.getProperty(split3[1]));
} }
} }
}else if(split2[0].equals("rev")) { } else if (split3[0].equals("rev")) {
String[] split4 = split2[1].split("\\."); String[] split4 = split2[1].split("\\.");
if (split4.length == 2) { if (split4.length == 2) {
if (split4[0].equals("item")) { if (split4[0].equals("item")) {
item.setProperty(split4[1], rev.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
item.setProperty(split4[1], rev.getProperty(split3[1]));
} else if (split4[0].equals("rev")) { } else if (split4[0].equals("rev")) {
mRev.setProperty(split4[1], rev.getProperty(split2[1])); System.out.println("split4[1]========" + split4[1]
+ "split3[1]======" + split3[1]);
mRev.setProperty(split4[1], rev.getProperty(split3[1]));
} }
} }
} }
@ -441,57 +465,65 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
} }
} }
//设置 ly6_homemadeStatus
mRev.setProperty("ly6_homemadeStatus", "自制");
// 添加流程 // 添加流程
if (workflowTemplate != null || !workflowTemplate.isEmpty()) { if (workflowTemplate != null || !workflowTemplate.isEmpty()) {
CreateProcess(session, item, workflowTemplate); CreateProcess(session, item, workflowTemplate);
} }
// 把对象放到管理文件夹下 // 把对象放到管理文件夹下
rev.add("LY6_relatedMPart", item); rev.add("LY6_relatedMPart", item);
item.getLatestItemRevision().refresh(); item.getLatestItemRevision().refresh();
} else { } else {
AIFComponentContext[] children = topLine.getChildren(); AIFComponentContext[] children = topLine.getChildren();
//直接创建对象
String newID = (String) arrayList.get(2);
String newRev = type.getNewRev(null);
ArrayList<TCComponentItemRevision> addList = new ArrayList<TCComponentItemRevision>();// mbom的子
ArrayList<String> childrenList = new ArrayList<String>();// 下拉框选中的值
HashMap<String, TCComponentItemRevision> revMap = new HashMap<String, TCComponentItemRevision>();// object_String
TCComponentItem item = type.create(newID, newRev, "LY6_ProductM", "", "", null); StringBuilder errMsg = new StringBuilder();
item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString()); for (int j = 0; j < children.length; j++) {
if(ly6_sequenceNum.isEmpty()) { TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent();
item.setProperty("ly6_sequenceNum", "01"); // 判断是否自制
}else { TCComponentItemRevision eRev = eLine.getItemRevision();
item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum)); String tcProperty = eRev.getTCProperty("ly6_homemadeStatus").toString();
System.out.println("ly6_homemadeStatus=======" + tcProperty);
String eId = eRev.getStringProperty("item_id");
if (tcProperty.equals("自制")) {
// 判断e下面的m是否唯一
//先循环一遍判断有没有 mpart
ArrayList<TCComponentItemRevision> list = new ArrayList<TCComponentItemRevision>();
for (int k = 0; k < groupSplit.length; k++) {
TCComponent[] search = session.search("_SearchMFKProperties",
new String[] { "ID", "工厂" }, new String[] { eId, groupSplit[k] });
for (int l = 0; l < search.length; l++) {
TCComponentItem tempItem = (TCComponentItem) search[l];
list.add(tempItem.getLatestItemRevision());
}
} }
//删除前两个对象
TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2)); if (list.size() == 0) {
if(delItem1 != null) { errMsg.append(eId + "对象未创建MPart"+System.lineSeparator());
System.out.println("delItem1.getUid()===="+delItem1.getUid());
delItem1.delete();
} }
TCComponent delItem2 = session.stringToComponent((String) arrayList.get(2)+(String) tm_part.getValueAt(i, 7));
if(delItem1 != null) {
System.out.println("delItem2.getUid()===="+delItem2.getUid());
delItem2.delete();
} }
}
if(errMsg.length() > 0) {
MessageBox.post(errMsg.toString(), "提示 ", MessageBox.INFORMATION);
return;
}
//把对象放到管理文件夹下
rev.add("LY6_relatedMPart",item); // 和对应版本
item.getLatestItemRevision().refresh();
//搭建mBOM
TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = viewType.create(null);
TCComponentBOMLine mTopLine = view.setWindowTopLine(item, item.getLatestItemRevision(), null, null);
ArrayList<TCComponentItemRevision> addList = new ArrayList<TCComponentItemRevision>();//mbom的子
ArrayList<String> childrenList = new ArrayList<String>();//下拉框选中的值
HashMap<String, TCComponentItemRevision> revMap = new HashMap<String, TCComponentItemRevision>();//object_String 和对应版本
for (int j = 0; j < children.length; j++) { for (int j = 0; j < children.length; j++) {
TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent(); TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent();
@ -501,11 +533,13 @@ public class MpartDialog extends JFrame implements ActionListener {
System.out.println("ly6_homemadeStatus=======" + tcProperty); System.out.println("ly6_homemadeStatus=======" + tcProperty);
String eId = eRev.getStringProperty("item_id"); String eId = eRev.getStringProperty("item_id");
if (tcProperty.equals("自制")) { if (tcProperty.equals("自制")) {
//判断e下面的m是否唯一
//循环 选择mpart
ArrayList<TCComponentItemRevision> tempMrevList = new ArrayList<TCComponentItemRevision>(); ArrayList<TCComponentItemRevision> tempMrevList = new ArrayList<TCComponentItemRevision>();
for (int k = 0; k < groupSplit.length; k++) { for (int k = 0; k < groupSplit.length; k++) {
TCComponent[] search = session.search("_SearchMFKProperties", new String[] { "ID","工厂" }, new String[] { eId,groupSplit[k] }); TCComponent[] search = session.search("_SearchMFKProperties",
new String[] { "ID", "工厂" }, new String[] { eId, groupSplit[k] });
for (int l = 0; l < search.length; l++) { for (int l = 0; l < search.length; l++) {
TCComponentItem tempItem = (TCComponentItem) search[l]; TCComponentItem tempItem = (TCComponentItem) search[l];
@ -513,10 +547,11 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
} }
if(tempMrevList.size() == 0) { // if (tempMrevList.size() == 0) {
MessageBox.post(eId+"对象未创建MPart", "提示 ", MessageBox.INFORMATION); // MessageBox.post(eId + "对象未创建MPart", "提示 ", MessageBox.INFORMATION);
return; // return;
}else if(tempMrevList.size() == 1) { // } else
if (tempMrevList.size() == 1) {
// 把M放bom下 // 把M放bom下
addList.add(tempMrevList.get(0)); addList.add(tempMrevList.get(0));
} else if (tempMrevList.size() > 1) { } else if (tempMrevList.size() > 1) {
@ -524,14 +559,12 @@ public class MpartDialog extends JFrame implements ActionListener {
JComboBox<String> jComboBox = new JComboBox<String>(); JComboBox<String> jComboBox = new JComboBox<String>();
for (int k = 0; k < tempMrevList.size(); k++) { for (int k = 0; k < tempMrevList.size(); k++) {
String stringProperty = tempMrevList.get(k).getStringProperty("object_string"); String stringProperty = tempMrevList.get(k)
.getStringProperty("object_string");
revMap.put(stringProperty, tempMrevList.get(k)); revMap.put(stringProperty, tempMrevList.get(k));
jComboBox.addItem(stringProperty); jComboBox.addItem(stringProperty);
} }
// 创建并显示模态对话框 // 创建并显示模态对话框
DialogFrame dialog = new DialogFrame(MpartDialog.this, jComboBox, childrenList); DialogFrame dialog = new DialogFrame(MpartDialog.this, jComboBox, childrenList);
dialog.setVisible(true); dialog.setVisible(true);
@ -544,20 +577,59 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
}); });
}
} else {
// 不为自制则直接将EPart搭建进入MBOM中
addList.add(eRev);
}
} }
// 直接创建对象
String newID = (String) arrayList.get(2);
String newRev = type.getNewRev(null);
TCComponentItem item = type.create(newID, newRev, typesMap.get(eType), "", "", null);
item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString());
if (ly6_sequenceNum.isEmpty() || ly6_sequenceNum.equals("0")) {
item.setProperty("ly6_sequenceNum", "01");
} else { } else {
//不为自制则直接将EPart搭建进入MBOM中 item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum));
addList.add(eRev); }
// 删除前两个对象
TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2));
if (delItem1 != null) {
System.out.println("delItem1.getUid()====" + delItem1.getUid());
delItem1.delete();
} }
TCComponent delItem2 = session
.stringToComponent((String) arrayList.get(2) + (String) tm_part.getValueAt(i, 7));
if (delItem1 != null) {
System.out.println("delItem2.getUid()====" + delItem2.getUid());
delItem2.delete();
} }
// 把对象放到管理文件夹下
rev.add("LY6_relatedMPart", item);
item.getLatestItemRevision().refresh();
// 搭建mBOM
TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = viewType.create(null);
TCComponentBOMLine mTopLine = view.setWindowTopLine(item, item.getLatestItemRevision(),
null, null);
System.out.println("childrenList.size()=======" + childrenList.size()); System.out.println("childrenList.size()=======" + childrenList.size());
for (int j = 0; j < childrenList.size(); j++) { for (int j = 0; j < childrenList.size(); j++) {
addList.add(revMap.get(childrenList.get(j))); addList.add(revMap.get(childrenList.get(j)));
@ -588,9 +660,6 @@ public class MpartDialog extends JFrame implements ActionListener {
MessageBox.post("创建成功!", "提示 ", MessageBox.INFORMATION); MessageBox.post("创建成功!", "提示 ", MessageBox.INFORMATION);
} else if (this.viewlButton.equals(source)) { } else if (this.viewlButton.equals(source)) {
// 打开对象到结构管理器 // 打开对象到结构管理器
@ -615,15 +684,13 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
} }
} else if (this.xrButton.equals(source)) { } else if (this.xrButton.equals(source)) {
KOrgDialog kOrgDialog = new KOrgDialog(""); //KOrgDialog kOrgDialog = new KOrgDialog("");
// TCComponentUser user = kOrgDialog.getUser(); TCComponentUser user = new KOrgDialog("").getUser();
// TCComponentGroup group = kOrgDialog.getGroup(); // TCComponentGroup group = kOrgDialog.getGroup();
user = kOrgDialog.getUser(); //user = kOrgDialog.getUser();
group = kOrgDialog.getGroup(); //group = kOrgDialog.getGroup();
System.out.println("Select User: " + user+"group==="+group); //System.out.println("Select User: " + user + "group===" + group);
String userName = ""; String userName = "";
try { try {
userName = user.getUserName(); userName = user.getUserName();
@ -635,17 +702,16 @@ public class MpartDialog extends JFrame implements ActionListener {
int count = 0; int count = 0;
for (int i = 0; i < tm_part.getRowCount(); i++) { for (int i = 0; i < tm_part.getRowCount(); i++) {
if (tm_part.getValueAt(i, 0).toString().equals("1")) { if (tm_part.getValueAt(i, 0).toString().equals("1")) {
tm_part.setValueAt(userName, i, 9); tm_part.setValueAt(userName, i, 8);
count++; count++;
} }
}
if (count == 0) { if (count == 0) {
MessageBox.post("请勾选数据!", "提示 ", MessageBox.INFORMATION); MessageBox.post("请勾选数据!", "提示 ", MessageBox.INFORMATION);
return; return;
} }
} }
}
} }
@ -677,7 +743,6 @@ public class MpartDialog extends JFrame implements ActionListener {
return topPanel; return topPanel;
} }
private JPanel getTablePanel() { private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(1100, 600)); panel.setPreferredSize(new Dimension(1100, 600));
@ -697,8 +762,7 @@ public class MpartDialog extends JFrame implements ActionListener {
if (column == 5) {// 可编辑的列 if (column == 5) {// 可编辑的列
return true; return true;
} } else {
else {
return false; return false;
} }
} else { } else {
@ -706,20 +770,15 @@ public class MpartDialog extends JFrame implements ActionListener {
if (column == 5) {// 可编辑的列 if (column == 5) {// 可编辑的列
return true; return true;
} } else {
else {
return false; return false;
} }
} }
} }
}; };
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
// 添加鼠标监听器 // 添加鼠标监听器
@ -731,8 +790,7 @@ public class MpartDialog extends JFrame implements ActionListener {
int selectColumn = t_part.getTableHeader().columnAtPoint(e.getPoint()); int selectColumn = t_part.getTableHeader().columnAtPoint(e.getPoint());
int selectedRow = t_part.rowAtPoint(e.getPoint()); int selectedRow = t_part.rowAtPoint(e.getPoint());
if(selectColumn != 0) if (selectColumn != 0) {
{
t_part2.removeAll(); t_part2.removeAll();
tm_part2.setRowCount(0); tm_part2.setRowCount(0);
table2RevList.clear(); table2RevList.clear();
@ -749,9 +807,10 @@ public class MpartDialog extends JFrame implements ActionListener {
for (int i = 0; i < tempList.size(); i++) { for (int i = 0; i < tempList.size(); i++) {
TCComponentItemRevision tcComponentItemRevision = tempList.get(i); TCComponentItemRevision tcComponentItemRevision = tempList.get(i);
try { try {
String id = tcComponentItemRevision.getStringProperty("item_id"); // String id = tcComponentItemRevision.getStringProperty("item_id");
System.out.println("item_id======"+id); // System.out.println("item_id======" + id);
String objectName = tcComponentItemRevision.getStringProperty("object_string"); String objectName = tcComponentItemRevision
.getStringProperty("object_string");
tm_part2.addRow(new Object[] { i + 1, objectName }); tm_part2.addRow(new Object[] { i + 1, objectName });
} catch (TCException e1) { } catch (TCException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -777,10 +836,6 @@ public class MpartDialog extends JFrame implements ActionListener {
} }
}); });
// t_part.addMouseListener(new MouseListener() { // t_part.addMouseListener(new MouseListener() {
// //
// @Override // @Override
@ -896,14 +951,6 @@ public class MpartDialog extends JFrame implements ActionListener {
// jComboBox3.addItem(split[0]); // jComboBox3.addItem(split[0]);
// } // }
// //
// // 添加鼠标监听器 // // 添加鼠标监听器
// t_part.addMouseListener(new MouseAdapter() { // t_part.addMouseListener(new MouseAdapter() {
@ -925,28 +972,15 @@ public class MpartDialog extends JFrame implements ActionListener {
// } // }
// }); // });
// this.t_part.getTableHeader().setBackground(Color.blue); // this.t_part.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part); JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll); panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createLoweredBevelBorder()); panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel; return panel;
} }
private JPanel getTablePanel2() { private JPanel getTablePanel2() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(200, 600)); panel.setPreferredSize(new Dimension(200, 600));
@ -956,34 +990,30 @@ public class MpartDialog extends JFrame implements ActionListener {
* *
*/ */
@Override @Override
public boolean isCellEditable(int row, int column) { public boolean isCellEditable(int row, int column) {
if (column == 0) {// 可编辑的列 if (column == 0) {// 可编辑的列
return true; return true;
} } else {
else {
return false; return false;
} }
} }
}; };
tm_part2.setDataVector(null, HEADER2); tm_part2.setDataVector(null, HEADER2);
t_part2.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列) t_part2.getTableHeader().setReorderingAllowed(false); // 设置列不可移动,否则会发生类型转换错误(第三列)
this.t_part2.setRowHeight(23); this.t_part2.setRowHeight(23);
TableColumnModel colModel = this.t_part2.getColumnModel(); TableColumnModel colModel = this.t_part2.getColumnModel();
int colCnt = HEADERWIDTH2.length; int colCnt = HEADERWIDTH2.length;
for (int i = 0; i < colCnt; i++) { for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH2[i]); colModel.getColumn(i).setPreferredWidth(HEADERWIDTH2[i]);
} }
//t_part2.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(t_part2)); // t_part2.getTableHeader().setDefaultRenderer(new
//t_part2.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(t_part2)); // CheckHeaderCellRenderer(t_part2));
// t_part2.getColumnModel().getColumn(0).setCellRenderer(new
// TableCellCheckboxRenderer(t_part2));
// t_part2.addMouseListener(new MouseListener() { // t_part2.addMouseListener(new MouseListener() {
// //
// @Override // @Override
@ -1052,20 +1082,11 @@ public class MpartDialog extends JFrame implements ActionListener {
// } // }
// }); // });
// this.t_part2.getTableHeader().setBackground(Color.blue); // this.t_part2.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part2); JScrollPane scroll = new JScrollPane(t_part2);
panel.add(BorderLayout.CENTER, scroll); panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createLoweredBevelBorder()); panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel; return panel;
} }
@ -1075,13 +1096,12 @@ public class MpartDialog extends JFrame implements ActionListener {
String name = group.getTCProperty("full_name").getStringValue(); String name = group.getTCProperty("full_name").getStringValue();
if (name.contains(".")) { if (name.contains(".")) {
String[] split = name.split("\\."); String[] split = name.split("\\.");
name = split[split.length]; name = split[split.length - 1];
System.out.println("name==============" + name); System.out.println("name==============" + name);
} }
return name; return name;
} }
/** /**
* 1011 * 1011
* *
@ -1109,11 +1129,13 @@ public class MpartDialog extends JFrame implements ActionListener {
public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException { public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException {
try { try {
TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType)session.getTypeComponent("EPMTaskTemplate"); TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session
.getTypeComponent("EPMTaskTemplate");
TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0); TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0);
if (taskTemplate != null) { if (taskTemplate != null) {
String name = target.getProperty("object_string"); String name = target.getProperty("object_string");
TCComponent create = processType.create(processName + "" + name, "", taskTemplate, new TCComponent[]{target}, new int[]{1}); TCComponent create = processType.create(processName + "" + name, "", taskTemplate,
new TCComponent[] { target }, new int[] { 1 });
System.out.println("uid===================" + create.getUid()); System.out.println("uid===================" + create.getUid());
System.out.println("type==" + create.getType()); System.out.println("type==" + create.getType());
System.out.println("type==" + create.getStringProperty("object_type")); System.out.println("type==" + create.getStringProperty("object_type"));

@ -10,6 +10,7 @@ import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentSchedule; import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCComponentScheduleTask; import com.teamcenter.rac.kernel.TCComponentScheduleTask;
@ -62,6 +63,19 @@ public class MpartHandler extends AbstractHandler{
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}else if(component instanceof TCComponentBOMLine) {
TCComponentBOMLine bomLine = (TCComponentBOMLine)component;
try {
TCComponentItemRevision itemRevision = bomLine.getItemRevision();
String type = itemRevision.getType();
System.out.println("type2================"+type);
if(types[0].contains(type)) {
arrayList.add((TCComponentItemRevision)itemRevision);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
} }

Loading…
Cancel
Save