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