|
|
|
@ -10,7 +10,11 @@ import java.awt.ScrollPane;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
@ -28,6 +32,7 @@ import com.connor.jd.plm.table.MyCellEditor4;
|
|
|
|
|
import com.connor.jd.plm.table.TCTableUtil;
|
|
|
|
|
import com.connor.jd.plm.utils.DBUtil;
|
|
|
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
@ -36,35 +41,27 @@ import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.db.Db;
|
|
|
|
|
import cn.hutool.db.Entity;
|
|
|
|
|
|
|
|
|
|
public class ComponentTestFrame extends JFrame {
|
|
|
|
|
private CTMap model;
|
|
|
|
|
private CTable table;
|
|
|
|
|
private List<Entity> list;
|
|
|
|
|
private int bottom;
|
|
|
|
|
private Container container;
|
|
|
|
|
private TCComponentForm form;
|
|
|
|
|
private TCSession session;
|
|
|
|
|
private MyCallBack callBack;
|
|
|
|
|
private String itemId;
|
|
|
|
|
private String[] colNames = new String[] { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syzq", "jd2_syts", "jd2_syfy",
|
|
|
|
|
"jd2_sycs" };
|
|
|
|
|
private TCComponentForm testForm;
|
|
|
|
|
|
|
|
|
|
private static ComponentTestFrame instance;
|
|
|
|
|
|
|
|
|
|
public static ComponentTestFrame getInstance(TCComponentForm form, MyCallBack callBack) {
|
|
|
|
|
if (instance == null) {
|
|
|
|
|
instance = new ComponentTestFrame(form);
|
|
|
|
|
instance.callBack = callBack;
|
|
|
|
|
} else {
|
|
|
|
|
instance.bottom = 0;
|
|
|
|
|
instance.form = form;
|
|
|
|
|
instance.callBack = callBack;
|
|
|
|
|
instance.init();
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ComponentTestFrame(TCComponentForm form) {
|
|
|
|
|
public ComponentTestFrame(Object itemId, TCComponentForm form, MyCallBack callBack) {
|
|
|
|
|
this.itemId = StrUtil.toString(itemId);
|
|
|
|
|
this.callBack = callBack;
|
|
|
|
|
this.form = form;
|
|
|
|
|
this.session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
|
|
|
|
this.init();
|
|
|
|
@ -82,7 +79,7 @@ public class ComponentTestFrame extends JFrame {
|
|
|
|
|
container.setPreferredSize(new Dimension(600, 400));
|
|
|
|
|
|
|
|
|
|
model = new CTMap(10, 7);
|
|
|
|
|
model.setValueAt("ÐòºÅ", 0, 0);
|
|
|
|
|
model.setValueAt("编号", 0, 0);
|
|
|
|
|
model.setValueAt("部品类型", 0, 1);
|
|
|
|
|
model.setValueAt("试验项目", 0, 2);
|
|
|
|
|
model.setValueAt("试验时间", 0, 3);
|
|
|
|
@ -142,23 +139,18 @@ public class ComponentTestFrame extends JFrame {
|
|
|
|
|
table.getColumnModel().getColumn(6).setCellEditor(new MyCellEditor4(new JTextField()));
|
|
|
|
|
|
|
|
|
|
// 填写数据
|
|
|
|
|
Map<String, String[]> dataMap = new LinkedHashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
list = Db.use(DBUtil.getDataSource(session)).findAll("JD2_COMPONENT");
|
|
|
|
|
bottom = list.size();
|
|
|
|
|
for (int i = 0; i < bottom; i++) {
|
|
|
|
|
if (i > model.getRowCount() - 2) {
|
|
|
|
|
model.addRow();
|
|
|
|
|
}
|
|
|
|
|
int row = i + 1;
|
|
|
|
|
model.setValueAt(row, row, 0);
|
|
|
|
|
model.setValueAt(list.get(i).getStr("TEST_TYPE"), row, 1);
|
|
|
|
|
model.setValueAt(list.get(i).getStr("TEST_PROJECT"), row, 2);
|
|
|
|
|
model.setValueAt(list.get(i).getStr("TEST_TIME"), row, 3);
|
|
|
|
|
model.setValueAt(list.get(i).getInt("TEST_NUM"), row, 4);
|
|
|
|
|
model.setValueAt(list.get(i).getInt("TEST_COST"), row, 5);
|
|
|
|
|
model.setValueAt(new JCheckBox(), row, 6);
|
|
|
|
|
|
|
|
|
|
System.out.println(list.get(i).toString());
|
|
|
|
|
List<Entity> list = Db.use(DBUtil.getDataSource(session)).findAll("JD2_COMPONENT");
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
String[] rowData = new String[6];
|
|
|
|
|
rowData[0] = list.get(i).getStr("TEST_ID");
|
|
|
|
|
rowData[1] = list.get(i).getStr("TEST_TYPE");
|
|
|
|
|
rowData[2] = list.get(i).getStr("TEST_PROJECT");
|
|
|
|
|
rowData[3] = list.get(i).getStr("TEST_TIME");
|
|
|
|
|
rowData[4] = list.get(i).getInt("TEST_NUM") + "";
|
|
|
|
|
rowData[5] = list.get(i).getInt("TEST_COST") == null ? "0" : list.get(i).getInt("TEST_COST") + "";
|
|
|
|
|
dataMap.put(rowData[0], rowData);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
@ -166,10 +158,57 @@ public class ComponentTestFrame extends JFrame {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
List<String> checkedId = new ArrayList<>();
|
|
|
|
|
if (StrUtil.isNotBlank(itemId)) {
|
|
|
|
|
try {
|
|
|
|
|
TCComponent[] res = session.search("Item ID", new String[] { "零组件 ID" }, new String[] { itemId });
|
|
|
|
|
if (ArrayUtil.isNotEmpty(res) && "JD2_GTCSJH".equals(res[0].getType())) {
|
|
|
|
|
TCComponentItemRevision resRev = ((TCComponentItem) res[0]).getLatestItemRevision();
|
|
|
|
|
TCComponent[] forms = resRev.getRelatedComponents("IMAN_master_form_rev");
|
|
|
|
|
testForm = (TCComponentForm) forms[0];
|
|
|
|
|
String[][] rowDatas = TCTableUtil.getTableRows(testForm, "jd2_csjh", colNames);
|
|
|
|
|
for (int i = 0; i < rowDatas.length; i++) {
|
|
|
|
|
checkedId.add(rowDatas[i][0]);
|
|
|
|
|
String[] rowData = new String[6];
|
|
|
|
|
rowData[0] = rowDatas[i][0];
|
|
|
|
|
rowData[1] = "自定义测试项";
|
|
|
|
|
rowData[2] = rowDatas[i][2];
|
|
|
|
|
rowData[3] = rowDatas[i][3];
|
|
|
|
|
rowData[4] = rowDatas[i][4];
|
|
|
|
|
rowData[5] = rowDatas[i][5];
|
|
|
|
|
dataMap.put(rowDatas[i][0], rowData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bottom = dataMap.size();
|
|
|
|
|
int row = 1;
|
|
|
|
|
for (Entry<String, String[]> entry : dataMap.entrySet()) {
|
|
|
|
|
if (row > model.getRowCount() - 1) {
|
|
|
|
|
model.addRow();
|
|
|
|
|
}
|
|
|
|
|
model.setValueAt(entry.getValue()[0], row, 0);
|
|
|
|
|
model.setValueAt(entry.getValue()[1], row, 1);
|
|
|
|
|
model.setValueAt(entry.getValue()[2], row, 2);
|
|
|
|
|
model.setValueAt(entry.getValue()[3], row, 3);
|
|
|
|
|
model.setValueAt(entry.getValue()[4], row, 4);
|
|
|
|
|
model.setValueAt(entry.getValue()[5], row, 5);
|
|
|
|
|
if (checkedId.contains(entry.getValue()[0])) {
|
|
|
|
|
JCheckBox tempCheck = new JCheckBox();
|
|
|
|
|
tempCheck.setSelected(true);
|
|
|
|
|
model.setValueAt(tempCheck, row, 6);
|
|
|
|
|
} else {
|
|
|
|
|
model.setValueAt(new JCheckBox(), row, 6);
|
|
|
|
|
}
|
|
|
|
|
row++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 按钮
|
|
|
|
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
|
|
|
|
JButton createTest = new JButton("´´½¨²âÊԼƻ®");
|
|
|
|
|
JButton createTest = new JButton("创建/更新测试计划");
|
|
|
|
|
createTest.addActionListener(createTest());
|
|
|
|
|
JButton addTestItem = new JButton("新增测试项");
|
|
|
|
|
addTestItem.addActionListener(addTestItem());
|
|
|
|
@ -195,31 +234,77 @@ public class ComponentTestFrame extends JFrame {
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
try {
|
|
|
|
|
TCComponentItemRevision rev = (TCComponentItemRevision) form.whereReferenced()[0].getComponent();
|
|
|
|
|
if (testForm != null) {// 更新
|
|
|
|
|
String[] propNames = new String[] { "jd2_no", "jd2_syxh", "jd2_symd", "jd2_wtry", "jd2_syxm",
|
|
|
|
|
"jd2_syts", "jd2_syzq", "jd2_syfy", "jd2_jhrc", "jd2_jhrc1", "jd2_sjrc", "jd2_sjrc1",
|
|
|
|
|
"jd2_syzt", "jd2_syjg", "jd2_sycs", "jd2_syry", "jd2_csbg", "jd2_bz" };
|
|
|
|
|
List<Map<String, String>> oldRowData = TCTableUtil.getTableMapList(testForm, "jd2_csjh",
|
|
|
|
|
propNames);
|
|
|
|
|
List<String> selectedNo = new ArrayList<>();
|
|
|
|
|
for (int i = 1; i <= bottom; i++) {
|
|
|
|
|
JCheckBox jb = (JCheckBox) model.getValueAt(i, 6);
|
|
|
|
|
if (jb.isSelected()) {
|
|
|
|
|
String no = model.getValueAt(i, 0).toString();
|
|
|
|
|
selectedNo.add(no);
|
|
|
|
|
boolean isInclude = false;
|
|
|
|
|
for (int ii = 0; ii < oldRowData.size(); ii++) {// 修改
|
|
|
|
|
if (no.equals(oldRowData.get(ii).get("jd2_no"))) {
|
|
|
|
|
isInclude = true;
|
|
|
|
|
oldRowData.get(ii).put("jd2_syxm", model.getValueAt(i, 2).toString());
|
|
|
|
|
oldRowData.get(ii).put("jd2_syzq", model.getValueAt(i, 3).toString());
|
|
|
|
|
oldRowData.get(ii).put("jd2_syts", model.getValueAt(i, 4).toString());
|
|
|
|
|
oldRowData.get(ii).put("jd2_syfy", model.getValueAt(i, 5).toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isInclude) {// 新增
|
|
|
|
|
Map<String, String> tempMap = new HashMap<String, String>();
|
|
|
|
|
tempMap.put("jd2_no", no);
|
|
|
|
|
tempMap.put("jd2_wtry", form.getTCProperty("owning_user").getUIFValue());
|
|
|
|
|
tempMap.put("jd2_syxm", model.getValueAt(i, 2).toString());
|
|
|
|
|
tempMap.put("jd2_syzq", model.getValueAt(i, 3).toString());
|
|
|
|
|
tempMap.put("jd2_syts", model.getValueAt(i, 4).toString());
|
|
|
|
|
tempMap.put("jd2_syfy", model.getValueAt(i, 5).toString());
|
|
|
|
|
oldRowData.add(tempMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < oldRowData.size(); i++) {// 删除
|
|
|
|
|
if (!selectedNo.contains(oldRowData.get(i).get("jd2_no"))) {
|
|
|
|
|
oldRowData.remove(i);
|
|
|
|
|
i--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
TCTableUtil.setTableMapList(testForm, "jd2_csjh", "JD2_CSJHTABLE", oldRowData);
|
|
|
|
|
callBack.execute(itemId);
|
|
|
|
|
} else {// 创建
|
|
|
|
|
TCComponentItemRevision rev = (TCComponentItemRevision) form.whereReferenced()[0]
|
|
|
|
|
.getComponent();
|
|
|
|
|
|
|
|
|
|
TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Item");
|
|
|
|
|
TCComponentItem item = type.create(null, null, "JD2_GTCSJH", "²âÊԼƻ®", "", null);
|
|
|
|
|
rev.add("JD2_CSJH", item);
|
|
|
|
|
TCComponentItemRevision rev1 = item.getLatestItemRevision();
|
|
|
|
|
TCComponentForm form1 = (TCComponentForm) rev1.getRelatedComponents("IMAN_master_form_rev")[0];
|
|
|
|
|
String[] colNames = new String[] { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq",
|
|
|
|
|
"jd2_syfy", "jd2_sycs" };
|
|
|
|
|
List<String[]> list = new ArrayList<String[]>();
|
|
|
|
|
String[] row = new String[7];
|
|
|
|
|
for (int i = 1; i <= bottom; i++) {
|
|
|
|
|
JCheckBox jb = (JCheckBox) model.getValueAt(i, 6);
|
|
|
|
|
if (jb.isSelected()) {
|
|
|
|
|
for (int ii = 2; ii < 6; ii++) {
|
|
|
|
|
row[ii - 2] = model.getValueAt(i, ii) == null ? "" : model.getValueAt(i, ii).toString();
|
|
|
|
|
TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Item");
|
|
|
|
|
TCComponentItem item = type.create(null, null, "JD2_GTCSJH", "测试计划", "", null);
|
|
|
|
|
rev.add("JD2_CSJH", item);
|
|
|
|
|
TCComponentItemRevision rev1 = item.getLatestItemRevision();
|
|
|
|
|
TCComponentForm form1 = (TCComponentForm) rev1.getRelatedComponents("IMAN_master_form_rev")[0];
|
|
|
|
|
|
|
|
|
|
List<String[]> list = new ArrayList<String[]>();
|
|
|
|
|
String[] row = new String[7];
|
|
|
|
|
for (int i = 1; i <= bottom; i++) {
|
|
|
|
|
JCheckBox jb = (JCheckBox) model.getValueAt(i, 6);
|
|
|
|
|
if (jb.isSelected()) {
|
|
|
|
|
for (int ii = 2; ii < 6; ii++) {
|
|
|
|
|
row[ii - 2] = model.getValueAt(i, ii) == null ? ""
|
|
|
|
|
: model.getValueAt(i, ii).toString();
|
|
|
|
|
}
|
|
|
|
|
// TCComponentPerson p = (TCComponentPerson) session.getUser().getUserInformation().get(0);
|
|
|
|
|
list.add(new String[] { model.getValueAt(i, 0).toString(),
|
|
|
|
|
form.getTCProperty("owning_user").getUIFValue(), row[0], row[1], row[2], row[3],
|
|
|
|
|
"1" });
|
|
|
|
|
}
|
|
|
|
|
// TCComponentPerson p = (TCComponentPerson) session.getUser().getUserInformation().get(0);
|
|
|
|
|
list.add(new String[] { i + "", form.getTCProperty("owning_user").getUIFValue(), row[0],
|
|
|
|
|
row[2], row[1], row[3], "1" });
|
|
|
|
|
}
|
|
|
|
|
String[][] data = list.toArray(new String[list.size()][7]);
|
|
|
|
|
TCTableUtil.setTableRows(form1, "jd2_csjh", "JD2_CSJHTABLE", colNames, data);
|
|
|
|
|
callBack.execute(item.getProperty("item_id"));
|
|
|
|
|
}
|
|
|
|
|
String[][] data = list.toArray(new String[list.size()][7]);
|
|
|
|
|
TCTableUtil.setTableRows(form1, "jd2_csjh", "JD2_CSJHTABLE", colNames, data);
|
|
|
|
|
callBack.execute(item.getProperty("item_id"));
|
|
|
|
|
dispose();
|
|
|
|
|
} catch (TCException e1) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
@ -238,10 +323,7 @@ public class ComponentTestFrame extends JFrame {
|
|
|
|
|
if (bottom > model.getRowCount() - 2) {
|
|
|
|
|
model.addRow();
|
|
|
|
|
}
|
|
|
|
|
int num = 1;
|
|
|
|
|
if (bottom > 0) {
|
|
|
|
|
num = Integer.parseInt(model.getValueAt(bottom, 0).toString());
|
|
|
|
|
}
|
|
|
|
|
int num = Math.max(Integer.parseInt(model.getValueAt(bottom, 0).toString()), 10000);
|
|
|
|
|
model.setValueAt(num + 1, ++bottom, 0);
|
|
|
|
|
model.setValueAt(new JCheckBox(), bottom, 6);
|
|
|
|
|
}
|
|
|
|
|