|
|
|
@ -0,0 +1,467 @@
|
|
|
|
|
package com.connor.jd.plm.form;
|
|
|
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
import java.awt.GridBagConstraints;
|
|
|
|
|
import java.awt.GridBagLayout;
|
|
|
|
|
import java.awt.Insets;
|
|
|
|
|
import java.awt.event.MouseAdapter;
|
|
|
|
|
import java.awt.event.MouseEvent;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.swing.DefaultCellEditor;
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
|
import javax.swing.JComboBox;
|
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
|
import javax.swing.JTable;
|
|
|
|
|
import javax.swing.filechooser.FileFilter;
|
|
|
|
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
|
|
|
import javax.swing.table.DefaultTableModel;
|
|
|
|
|
|
|
|
|
|
import com.connor.jd.plm.beans.ComponentBean;
|
|
|
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
|
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentDataset;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentDatasetType;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemType;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
import com.teamcenter.rac.stylesheet.AbstractRendering;
|
|
|
|
|
import com.teamcenter.services.rac.core.DataManagementService;
|
|
|
|
|
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
|
|
|
|
|
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
|
|
|
|
|
|
|
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
|
|
|
|
|
|
public class CSJHForm extends AbstractRendering {
|
|
|
|
|
|
|
|
|
|
TCComponent form;
|
|
|
|
|
DefaultTableModel model;
|
|
|
|
|
TCSession session;
|
|
|
|
|
TCComponentItemRevision itemR;
|
|
|
|
|
private static Connection con = null;
|
|
|
|
|
private static PreparedStatement ps = null;
|
|
|
|
|
private static ResultSet rs = null;
|
|
|
|
|
private ObservableList<ComponentBean> componentData = FXCollections.observableArrayList();
|
|
|
|
|
String[] propNames = new String[] { "jd2_syxh", "jd2_symd", "jd2_wtry", "jd2_syxm", "jd2_syts", "jd2_syzq",
|
|
|
|
|
"jd2_syfy", "jd2_jhrc", "jd2_sjrc", "jd2_syzt", "jd2_syjg", "jd2_sycs", "jd2_syry", "jd2_csbg", "jd2_bz" };
|
|
|
|
|
|
|
|
|
|
public CSJHForm(TCComponent form) throws Exception {
|
|
|
|
|
super();
|
|
|
|
|
this.form = form;
|
|
|
|
|
session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
|
|
|
|
System.out.println("加载");
|
|
|
|
|
loadRendering();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = 1;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void loadRendering() throws TCException {
|
|
|
|
|
// try {
|
|
|
|
|
// con = DBConnectionUtil.dbConn("infodba", "infodba");
|
|
|
|
|
// String sqlString = "select * from JD2_Component";
|
|
|
|
|
// if (con == null) {
|
|
|
|
|
// Alert alert = new Alert(AlertType.ERROR, "连接失败");
|
|
|
|
|
// alert.show();
|
|
|
|
|
// } else {
|
|
|
|
|
// ps = con.prepareStatement(sqlString);
|
|
|
|
|
// rs = ps.executeQuery();
|
|
|
|
|
// while (rs.next()) {
|
|
|
|
|
// ComponentBean comBean = new ComponentBean();
|
|
|
|
|
// // System.out.println("第一列内容:" + rs.getString(1));
|
|
|
|
|
// comBean.setType(rs.getString(1));
|
|
|
|
|
// comBean.setProject(rs.getString(2));
|
|
|
|
|
// comBean.setTime(rs.getString(3));
|
|
|
|
|
// comBean.setNumber(String.valueOf(rs.getInt(4)));
|
|
|
|
|
// comBean.setCost(String.valueOf(rs.getDouble(5)));
|
|
|
|
|
// comBean.setCompId(rs.getInt(6));
|
|
|
|
|
// comBean.setAddId(0);
|
|
|
|
|
// comBean.setStage(0);// 刚从数据库取出
|
|
|
|
|
// componentData.add(comBean);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// } finally {
|
|
|
|
|
// if (rs != null) {
|
|
|
|
|
// try {
|
|
|
|
|
// rs.close();
|
|
|
|
|
// } catch (SQLException e1) {
|
|
|
|
|
// e1.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (ps != null) {
|
|
|
|
|
// try {
|
|
|
|
|
// ps.close();
|
|
|
|
|
// } catch (SQLException e1) {
|
|
|
|
|
// e1.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (con != null) {
|
|
|
|
|
// try {
|
|
|
|
|
// con.close();
|
|
|
|
|
// } catch (SQLException e1) {
|
|
|
|
|
// e1.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
this.setPreferredSize(new Dimension(1000, 250));
|
|
|
|
|
TCComponent[] tables = form.getTCProperty("jd2_csjh").getReferenceValueArray();
|
|
|
|
|
AIFComponentContext[] contexts = form.whereReferenced();
|
|
|
|
|
for (int i = 0; i < contexts.length; i++) {
|
|
|
|
|
if (contexts[i].getComponent() instanceof TCComponentItemRevision) {
|
|
|
|
|
try {
|
|
|
|
|
itemR = (TCComponentItemRevision) contexts[i].getComponent();
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String[] info = new String[] { "NO", "实验型号", "实验目的", "委托人员", "实验项目", "实验台数", "实验周期", "试验费用", "计划日期", "实际日期",
|
|
|
|
|
"实验状态", "实验结果", "第_次实验", "实验人员", "测试报告", "备注" };
|
|
|
|
|
model = new DefaultTableModel(info, 0);
|
|
|
|
|
JComboBox<String> testStage = new JComboBox();
|
|
|
|
|
JComboBox<String> testResult = new JComboBox();
|
|
|
|
|
String[] stageInfo = { "待测", "进行中", "完成" };
|
|
|
|
|
for (int i = 0; i < stageInfo.length; i++) {
|
|
|
|
|
testStage.addItem(stageInfo[i]);
|
|
|
|
|
}
|
|
|
|
|
testResult.addItem("不合格");
|
|
|
|
|
testResult.addItem("合格");
|
|
|
|
|
for (int i = 0; i < tables.length; i++) {
|
|
|
|
|
String[] temp = new String[16];
|
|
|
|
|
temp[0] = Integer.toString(index++);
|
|
|
|
|
String[] props = tables[i].getProperties(propNames);
|
|
|
|
|
for (int j = 0; j < props.length; j++) {
|
|
|
|
|
temp[j + 1] = props[j];
|
|
|
|
|
}
|
|
|
|
|
model.addRow(temp);
|
|
|
|
|
}
|
|
|
|
|
// for (int i = 0; i < componentData.size(); i++) {
|
|
|
|
|
// // for (int j = 0; j < tables.length; j++) {
|
|
|
|
|
// String project = componentData.get(i).getProject();
|
|
|
|
|
// String number = componentData.get(i).getNumber();
|
|
|
|
|
// String time = componentData.get(i).getTime();
|
|
|
|
|
// String cost = componentData.get(i).getCost();
|
|
|
|
|
//// if (!project.equals(tables[j].getProperty("jd2_syxm"))
|
|
|
|
|
//// && !number.equals(tables[j].getProperty("jd2_syts"))
|
|
|
|
|
//// && !time.equals(tables[j].getProperty("jd2_syzq"))
|
|
|
|
|
//// && !cost.equals(tables[j].getProperty("jd2_syfy"))) {
|
|
|
|
|
// String[] temp = new String[16];
|
|
|
|
|
// temp[0] = Integer.toString(index++);
|
|
|
|
|
// temp[4] = componentData.get(i).getProject();
|
|
|
|
|
// temp[5] = componentData.get(i).getNumber();
|
|
|
|
|
// temp[6] = componentData.get(i).getTime();
|
|
|
|
|
// temp[7] = componentData.get(i).getCost();
|
|
|
|
|
// model.addRow(temp);
|
|
|
|
|
//// }
|
|
|
|
|
//// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
final JTable table = new JTable(model) {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isCellEditable(int row, int column) {
|
|
|
|
|
if (column == 3 || column == 4 || column == 5 || column == 6 || column == 7 || column == 14)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
table.addPropertyChangeListener(e -> {
|
|
|
|
|
if (e.getPropertyName().equals("tableCellEditor")) {
|
|
|
|
|
// System.out.println("change");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
|
table.getColumn(table.getColumnName(i)).setMinWidth(60);
|
|
|
|
|
}
|
|
|
|
|
table.getColumn(table.getColumnName(10)).setCellEditor(new DefaultCellEditor(testStage));
|
|
|
|
|
table.getColumn(table.getColumnName(11)).setCellEditor(new DefaultCellEditor(testResult));
|
|
|
|
|
JPanel panelLable = new JPanel();
|
|
|
|
|
JLabel label = new JLabel("试验费用总计:");
|
|
|
|
|
JLabel label2 = new JLabel();
|
|
|
|
|
Double allcost = 0.0;
|
|
|
|
|
for (int i = 0; i < model.getRowCount(); i++) {
|
|
|
|
|
String value = (String) model.getValueAt(i, 7);
|
|
|
|
|
if (value.equals(""))
|
|
|
|
|
value = "0";
|
|
|
|
|
allcost += Double.valueOf(value);
|
|
|
|
|
}
|
|
|
|
|
label2.setText(allcost + "元");
|
|
|
|
|
panelLable.add(label);
|
|
|
|
|
panelLable.add(label2);
|
|
|
|
|
JPanel panel = new JPanel();
|
|
|
|
|
JScrollPane pane = new JScrollPane(table);
|
|
|
|
|
GridBagLayout gbl = new GridBagLayout();
|
|
|
|
|
JPanel bottom = new JPanel(gbl);
|
|
|
|
|
GridBagConstraints gbs = new GridBagConstraints();
|
|
|
|
|
gbs.anchor = GridBagConstraints.SOUTHEAST;
|
|
|
|
|
gbs.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
|
gbs.insets = new Insets(10, 20, 5, 10);
|
|
|
|
|
gbs.weighty = 0.2;
|
|
|
|
|
gbs.gridheight = 1;
|
|
|
|
|
gbs.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
|
|
gbs.weightx = 1;
|
|
|
|
|
JButton testButton = new JButton("测试报告上传");
|
|
|
|
|
gbl.setConstraints(testButton, gbs);
|
|
|
|
|
JButton huizongButton = new JButton("汇总结论上传");
|
|
|
|
|
gbl.setConstraints(huizongButton, gbs);
|
|
|
|
|
JButton againButton = new JButton("再次试验");
|
|
|
|
|
gbl.setConstraints(againButton, gbs);
|
|
|
|
|
bottom.add(testButton);
|
|
|
|
|
bottom.add(huizongButton);
|
|
|
|
|
bottom.add(againButton);
|
|
|
|
|
|
|
|
|
|
setLayout(new BorderLayout());
|
|
|
|
|
panel.add(pane, BorderLayout.CENTER);
|
|
|
|
|
add(bottom, BorderLayout.EAST);
|
|
|
|
|
add(panelLable, BorderLayout.SOUTH);
|
|
|
|
|
add(pane, BorderLayout.CENTER);
|
|
|
|
|
testButton.addActionListener(e -> {
|
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
|
chooser.setDialogTitle("选择上传的测试报告");
|
|
|
|
|
FileFilter filter = new FileNameExtensionFilter("Excel工作簿(.xlsx)", "xlsx");// 设置文件过滤器,只列出JPG或GIF格式的图片
|
|
|
|
|
chooser.setFileFilter(filter);
|
|
|
|
|
chooser.showOpenDialog(null);
|
|
|
|
|
File file = chooser.getSelectedFile();
|
|
|
|
|
if (file != null) {
|
|
|
|
|
String filePath = file.getPath();
|
|
|
|
|
String fileName = file.getName();
|
|
|
|
|
String[] filename = fileName.split(".");
|
|
|
|
|
System.out.println(filePath);
|
|
|
|
|
System.out.println(fileName);
|
|
|
|
|
int row = table.getSelectedRow();
|
|
|
|
|
String value = (String) model.getValueAt(row, 14);
|
|
|
|
|
if (value.equals("")) {
|
|
|
|
|
try {
|
|
|
|
|
TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG");
|
|
|
|
|
String itemId = itemtype.getNewID();
|
|
|
|
|
String itemRev = itemtype.getNewRev(null);
|
|
|
|
|
TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "描述", null);
|
|
|
|
|
itemR.add("JD2_CSBG", item);
|
|
|
|
|
TCComponentDatasetType datasetType = (TCComponentDatasetType) session
|
|
|
|
|
.getTypeComponent("Dataset");
|
|
|
|
|
String msType = "";
|
|
|
|
|
if (filePath.endsWith(".xls")) {
|
|
|
|
|
msType = "MSExcel";
|
|
|
|
|
} else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) {
|
|
|
|
|
msType = "MSExcelX";
|
|
|
|
|
}
|
|
|
|
|
TCComponentDataset datasetMSExcelX = datasetType.create(filename[0], "", msType);
|
|
|
|
|
datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text)
|
|
|
|
|
item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX);
|
|
|
|
|
model.setValueAt(item.getProperty("current_id"), row, 14);
|
|
|
|
|
} catch (TCException e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 添加到数据集
|
|
|
|
|
try {
|
|
|
|
|
TCComponent[] tcc = itemR.getTCProperty("JD2_CSBG").getReferenceValueArray();
|
|
|
|
|
for (int i = 0; i < tcc.length; i++) {
|
|
|
|
|
if (value.equals(tcc[i].getProperty("current_id"))) {
|
|
|
|
|
TCComponentItem item = (TCComponentItem) tcc[i];
|
|
|
|
|
TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification")
|
|
|
|
|
.getReferenceValueArray();
|
|
|
|
|
TCComponentDataset dataset = (TCComponentDataset) tccitem[0];
|
|
|
|
|
dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (TCException e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
huizongButton.addActionListener(e -> {
|
|
|
|
|
int row = table.getSelectedRow();
|
|
|
|
|
String value = (String) model.getValueAt(row, 14);
|
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
|
chooser.setDialogTitle("选择上传的汇总结论");
|
|
|
|
|
FileFilter filter = new FileNameExtensionFilter("Excel工作簿(.xlsx)", "xlsx");// 设置文件过滤器,只列出JPG或GIF格式的图片
|
|
|
|
|
chooser.setFileFilter(filter);
|
|
|
|
|
chooser.showOpenDialog(null);
|
|
|
|
|
File file = chooser.getSelectedFile();
|
|
|
|
|
if (file != null) {
|
|
|
|
|
String filePath = file.getPath();
|
|
|
|
|
String fileName = file.getName();
|
|
|
|
|
String[] filename = fileName.split(".");
|
|
|
|
|
System.out.println(filePath);
|
|
|
|
|
System.out.println(fileName);
|
|
|
|
|
if (value.equals("")) {
|
|
|
|
|
try {
|
|
|
|
|
TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("JD2_GTCSBG");
|
|
|
|
|
String itemId = itemtype.getNewID();
|
|
|
|
|
String itemRev = itemtype.getNewRev(null);
|
|
|
|
|
TCComponentItem item = itemtype.create(itemId, itemRev, "JD2_GTCSBG", fileName, "描述", null);
|
|
|
|
|
itemR.add("JD2_CSBGHZ", item);
|
|
|
|
|
TCComponentDatasetType datasetType = (TCComponentDatasetType) session
|
|
|
|
|
.getTypeComponent("Dataset");
|
|
|
|
|
String msType = "";
|
|
|
|
|
if (filePath.endsWith(".xls")) {
|
|
|
|
|
msType = "MSExcel";
|
|
|
|
|
} else if (filePath.endsWith(".xlsx") || filePath.endsWith(".xlsm")) {
|
|
|
|
|
msType = "MSExcelX";
|
|
|
|
|
}
|
|
|
|
|
TCComponentDataset datasetMSExcelX = datasetType.create(filename[0], "", msType);
|
|
|
|
|
datasetMSExcelX.setFiles(new String[] { filePath }, new String[] { "excel" });// 两参:文件路径,命名应用(text)
|
|
|
|
|
item.getLatestItemRevision().add("IMAN_specification", datasetMSExcelX);
|
|
|
|
|
model.setValueAt(item.getProperty("current_id"), row, 14);
|
|
|
|
|
} catch (TCException e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 添加到数据集
|
|
|
|
|
try {
|
|
|
|
|
TCComponent[] tcc = itemR.getTCProperty("JD2_CSBGHZ").getReferenceValueArray();
|
|
|
|
|
for (int i = 0; i < tcc.length; i++) {
|
|
|
|
|
if (value.equals(tcc[i].getProperty("current_id"))) {
|
|
|
|
|
TCComponentItem item = (TCComponentItem) tcc[i];
|
|
|
|
|
TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification")
|
|
|
|
|
.getReferenceValueArray();
|
|
|
|
|
TCComponentDataset dataset = (TCComponentDataset) tccitem[0];
|
|
|
|
|
dataset.setFiles(new String[] { file.getPath() }, new String[] { "excel" });
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (TCException e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
againButton.addActionListener(e -> {
|
|
|
|
|
String[] temp = new String[16];
|
|
|
|
|
int num = Integer.valueOf((String) model.getValueAt(table.getSelectedRow(), 0)) + 1;
|
|
|
|
|
// temp[0] = String.valueOf(num);
|
|
|
|
|
temp[1] = (String) model.getValueAt(table.getSelectedRow(), 1);
|
|
|
|
|
temp[2] = (String) model.getValueAt(table.getSelectedRow(), 2);
|
|
|
|
|
temp[3] = (String) model.getValueAt(table.getSelectedRow(), 3);
|
|
|
|
|
temp[4] = (String) model.getValueAt(table.getSelectedRow(), 4);
|
|
|
|
|
temp[5] = (String) model.getValueAt(table.getSelectedRow(), 5);
|
|
|
|
|
temp[6] = (String) model.getValueAt(table.getSelectedRow(), 6);
|
|
|
|
|
temp[7] = (String) model.getValueAt(table.getSelectedRow(), 7);
|
|
|
|
|
String chishu = (String) model.getValueAt(table.getSelectedRow(), 12);
|
|
|
|
|
if ("".equals(chishu)) {
|
|
|
|
|
chishu = "0";
|
|
|
|
|
System.out.println(chishu);
|
|
|
|
|
}
|
|
|
|
|
if (chishu == null) {
|
|
|
|
|
chishu = "0";
|
|
|
|
|
}
|
|
|
|
|
temp[12] = String.valueOf(Integer.valueOf(chishu) + 1);
|
|
|
|
|
temp[14] = (String) model.getValueAt(table.getSelectedRow(), 14);
|
|
|
|
|
temp[15] = (String) model.getValueAt(table.getSelectedRow(), 15);
|
|
|
|
|
model.insertRow(table.getSelectedRow() + 1, temp);
|
|
|
|
|
for (int i = table.getSelectedRow() + 1; i < model.getRowCount(); i++) {
|
|
|
|
|
|
|
|
|
|
model.setValueAt(String.valueOf(num++), i, 0);
|
|
|
|
|
}
|
|
|
|
|
Double allcost2 = 0.0;
|
|
|
|
|
for (int i = 0; i < model.getRowCount(); i++) {
|
|
|
|
|
String value = (String) model.getValueAt(i, 7);
|
|
|
|
|
if (value.equals(""))
|
|
|
|
|
value = "0";
|
|
|
|
|
allcost2 += Double.valueOf(value);
|
|
|
|
|
}
|
|
|
|
|
label2.setText(allcost2 + "元");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
table.addMouseListener(new MouseAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
if (table.getSelectedColumn() == 14) {
|
|
|
|
|
if (e.getClickCount() == 2) {
|
|
|
|
|
System.out.println("双击了");
|
|
|
|
|
int selectedRow = table.getSelectedRow(); // 获得选中行索引
|
|
|
|
|
String value = (String) model.getValueAt(selectedRow, 14);
|
|
|
|
|
if (value == null)
|
|
|
|
|
value = "";
|
|
|
|
|
if (!value.equals("")) {
|
|
|
|
|
try {
|
|
|
|
|
TCComponent[] result = session.search("零组件 ID", new String[] { "零组件 ID" },
|
|
|
|
|
new String[] { value });
|
|
|
|
|
TCComponentItem item = (TCComponentItem) result[0];
|
|
|
|
|
TCComponent[] tccitem = item.getLatestItemRevision().getTCProperty("IMAN_specification")
|
|
|
|
|
.getReferenceValueArray();
|
|
|
|
|
TCComponentDataset dataset = (TCComponentDataset) tccitem[0];
|
|
|
|
|
dataset.open();
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveRendering() {
|
|
|
|
|
try {
|
|
|
|
|
List<TCComponent> c = new ArrayList<TCComponent>();
|
|
|
|
|
|
|
|
|
|
// TCComponent[] com = form.getTCProperty("sf6_EplanBOMLineTable").getReferenceValueArray();
|
|
|
|
|
// for (int j = 0; j < com.length; j++) {
|
|
|
|
|
// c.add(com[j]);
|
|
|
|
|
// }
|
|
|
|
|
DataManagementService service = DataManagementService
|
|
|
|
|
.getService((TCSession) AIFUtility.getCurrentApplication().getSession());
|
|
|
|
|
CreateIn[] newIn = new CreateIn[model.getRowCount()];
|
|
|
|
|
for (int i = 0; i < model.getRowCount(); i++) {
|
|
|
|
|
CreateIn in = new CreateIn();
|
|
|
|
|
Map<String, String> propMap = new HashMap<String, String>();
|
|
|
|
|
for (int j = 0; j < propNames.length; j++) {
|
|
|
|
|
propMap.put(propNames[j],
|
|
|
|
|
model.getValueAt(i, j + 1) == null ? "" : model.getValueAt(i, j + 1).toString());
|
|
|
|
|
}
|
|
|
|
|
// System.out.println("prop:" + propMap);
|
|
|
|
|
in.data.boName = "JD2_CSJHTABLE";
|
|
|
|
|
in.data.stringProps = propMap;
|
|
|
|
|
newIn[i] = in;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
CreateResponse response = service.createObjects(newIn);
|
|
|
|
|
System.out.println(response.serviceData.sizeOfCreatedObjects());
|
|
|
|
|
if (response.serviceData.sizeOfCreatedObjects() > 0) {
|
|
|
|
|
// System.out.println("创建CreateResponse");
|
|
|
|
|
int length = response.serviceData.sizeOfCreatedObjects();
|
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
|
c.add(response.output[i].objects[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
form.getTCProperty("jd2_csjh").setReferenceValueArray(c.toArray(new TCComponent[c.size()]));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|