parent
5d53268c37
commit
ae8d2915bc
@ -0,0 +1,2 @@
|
||||
/cn/
|
||||
/com/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,190 @@
|
||||
package com.connor.jk.plm.MESreport;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class DataBaseControl {
|
||||
|
||||
/** ************************数据库类调用:声明部分*********************************** */
|
||||
/**
|
||||
* kelsen声明部分 ....
|
||||
*/
|
||||
Connection conn;
|
||||
|
||||
ResultSet rs;
|
||||
|
||||
PreparedStatement pstmt;
|
||||
|
||||
Statement stmt;
|
||||
|
||||
String strUrl, strUserName, strPassword, strSQLQuery, strDriver;
|
||||
|
||||
public String str_Information = "";
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*/
|
||||
public DataBaseControl(String strDriver, String strUrl, String strUserName,
|
||||
String strPassword) {
|
||||
this.strDriver = strDriver; // "oracle.jdbc.driver.OracleDriver";//驱动
|
||||
this.strUrl = strUrl; // "jdbc:oracle:thin:@127.0.0.1:1521:tceng";//连接路径
|
||||
this.strUserName = strUserName; // "infodba";//数据库用户
|
||||
this.strPassword = strPassword; // "infodba";//数据库密码
|
||||
// strSQLQuery="select * from LABELID";//查询语句
|
||||
|
||||
// 加载驱动
|
||||
try {
|
||||
Class.forName(strDriver);// 通过反射加载驱动到内存
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
cnfe.printStackTrace();
|
||||
}
|
||||
// try {
|
||||
// Class.forName("org.objectweb.rmijdbc.Driver").newInstance();
|
||||
// } catch (InstantiationException e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// } catch (ClassNotFoundException e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 表更新
|
||||
*
|
||||
* @param strSQLQuery
|
||||
*/
|
||||
public void dbModify(String strSQLQuery) throws Exception{
|
||||
|
||||
openDataBase();
|
||||
|
||||
// try {
|
||||
stmt = conn.createStatement();
|
||||
stmt.executeUpdate(strSQLQuery);
|
||||
// } catch (SQLException sqle2) {
|
||||
// sqle2.printStackTrace();
|
||||
// }
|
||||
|
||||
closeDataBase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 表查询
|
||||
*
|
||||
* @param strSQLQuery
|
||||
* @return
|
||||
*/
|
||||
public ResultSet dbQuery(String strSQLQuery) throws Exception{
|
||||
ResultSet rs_result = null;
|
||||
// try {
|
||||
if (conn == null) {
|
||||
openDataBase();
|
||||
}
|
||||
stmt = conn.createStatement();
|
||||
rs_result = stmt.executeQuery(strSQLQuery);
|
||||
|
||||
// } catch (SQLException sqle2) {
|
||||
// sqle2.printStackTrace();
|
||||
// }
|
||||
return rs_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回list
|
||||
*/
|
||||
public List<String[]> doQuery2(String strSQLQuery,int count) throws Exception{
|
||||
List<String[]> list = new ArrayList<String[]>();
|
||||
openDataBase();
|
||||
try {
|
||||
rs = dbQuery(strSQLQuery);
|
||||
if(rs!=null) {
|
||||
while(rs.next()) {
|
||||
String [] arr = new String[count];
|
||||
for(int i = 1;i<=count;i++) {
|
||||
arr[i-1] = rs.getString(i);
|
||||
}
|
||||
list.add(arr);
|
||||
}
|
||||
}
|
||||
|
||||
}finally {
|
||||
closeDataBase();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开启链接
|
||||
*
|
||||
*/
|
||||
public void openDataBase() throws Exception{
|
||||
// try {
|
||||
// this.strUrl="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.29)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=tcprod)))";
|
||||
if (conn == null || conn.isClosed())
|
||||
conn = DriverManager.getConnection(strUrl, strUserName,
|
||||
strPassword);
|
||||
// }catch (SQLException sqle) {
|
||||
// sqle.printStackTrace();
|
||||
//// ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
//// sqle.printStackTrace(new PrintStream(baos));
|
||||
//// String exception = baos.toString();
|
||||
//// MessageBox.post(exception,"",MessageBox.INFORMATION);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭数据库链接
|
||||
*
|
||||
*/
|
||||
public void closeDataBase() {
|
||||
try {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException sqlec) {
|
||||
sqlec.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (SQLException sqlec) {
|
||||
sqlec.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (conn != null && !conn.isClosed()) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException sqlecon) {
|
||||
sqlecon.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,345 @@
|
||||
package com.connor.jk.plm.MESreport;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.PropertyLayout;
|
||||
|
||||
public class MESreportDialog extends AbstractAIFDialog implements ActionListener{
|
||||
private AbstractAIFUIApplication app;
|
||||
private TCSession session;
|
||||
private JTable table;
|
||||
private DefaultTableModel model;
|
||||
private JButton exportButton;
|
||||
private JButton closeButton;
|
||||
private final static String PREF = "TX_MESReport";
|
||||
private JButton searchButton;
|
||||
private JTextField from_date;
|
||||
private JTextField to_date;
|
||||
private JTextField th_text;
|
||||
private JTextField jsy_text;
|
||||
private JTextField dth_text;
|
||||
private JTextField dxlx_text;
|
||||
private List<String> colomuns = new ArrayList<String>();
|
||||
private Map<String,String> map = new HashMap<String,String>();
|
||||
private DataBaseControl databaseControl;
|
||||
private String export_path ="";
|
||||
private DateChooser dateChooser1 = DateChooser.getInstance("yyyy-MM-dd");
|
||||
private DateChooser dateChooser2 = DateChooser.getInstance("yyyy-MM-dd");
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
public MESreportDialog(AbstractAIFUIApplication app){
|
||||
this.app = app;
|
||||
session = (TCSession) app.getSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
init();
|
||||
String[] stringValues = session.getPreferenceService().getStringValues("TX_DATABASE");
|
||||
if(stringValues == null || stringValues.length<1) {
|
||||
MessageBox.post("未配置首选项TX_DATABASE","",MessageBox.INFORMATION);
|
||||
throw new Exception("未配置首选项TX_DATABASE");
|
||||
}
|
||||
databaseControl = new DataBaseControl("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@"+stringValues[0], stringValues[1], stringValues[2]);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
e.printStackTrace(new PrintStream(baos));
|
||||
String exception = baos.toString();
|
||||
MessageBox.post(exception,"",MessageBox.INFORMATION);
|
||||
}
|
||||
}
|
||||
|
||||
private void init() throws Exception{
|
||||
setTitle("MES中间表导出");
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
mainPanel.add(getConditionPanel(),BorderLayout.NORTH);
|
||||
mainPanel.add(getTablePanel(),BorderLayout.CENTER);
|
||||
mainPanel.add(getButtonPanel(),BorderLayout.SOUTH);
|
||||
|
||||
add(mainPanel);
|
||||
pack();
|
||||
setAlwaysOnTop(true);
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
private JPanel getConditionPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
|
||||
|
||||
from_date = new JTextField(20);
|
||||
to_date = new JTextField(20);
|
||||
dateChooser1.register(from_date);
|
||||
dateChooser2.register(to_date);
|
||||
JPanel panel1 = new JPanel();
|
||||
panel1.add(new JLabel("发放日期"));
|
||||
panel1.add(from_date);
|
||||
panel1.add(new JLabel("-"));
|
||||
panel1.add(to_date);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
panel2.add(new JLabel("图号"));
|
||||
th_text = new JTextField(10);
|
||||
panel2.add(th_text);
|
||||
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(new JLabel("技术员"));
|
||||
jsy_text = new JTextField(10);
|
||||
panel3.add(jsy_text);
|
||||
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(new JLabel("底图号"));
|
||||
dth_text = new JTextField(10);
|
||||
panel4.add(dth_text);
|
||||
|
||||
JPanel panel5 = new JPanel();
|
||||
panel5.add(new JLabel("对象类型"));
|
||||
dxlx_text = new JTextField(10);
|
||||
panel5.add(dxlx_text);
|
||||
|
||||
|
||||
panel.add(panel1);
|
||||
panel.add(panel2);
|
||||
panel.add(panel3);
|
||||
panel.add(panel4);
|
||||
panel.add(panel5);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JScrollPane getTablePanel() throws Exception {
|
||||
JScrollPane panel = new JScrollPane();
|
||||
table = new JTable() {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
String[] stringValues = session.getPreferenceService().getStringValues(PREF);
|
||||
if(stringValues == null || stringValues.length<1) {
|
||||
MessageBox.post("未配置首选项"+PREF,"",MessageBox.INFORMATION);
|
||||
throw new Exception("未配置首选项"+PREF);
|
||||
}
|
||||
for(String s:stringValues) {
|
||||
String[] split = s.split(":");
|
||||
colomuns.add(split[0]);
|
||||
map.put(split[0], split[1]);
|
||||
}
|
||||
model = new DefaultTableModel(null,colomuns.toArray(new String[colomuns.size()]));
|
||||
table.setModel(model);
|
||||
table.getTableHeader().setReorderingAllowed(false);//设置表头固定
|
||||
model.addRow((Vector)null);
|
||||
panel.setViewportView(table);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel getButtonPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
exportButton = new JButton("导出");
|
||||
searchButton = new JButton("查询");
|
||||
closeButton = new JButton("关闭");
|
||||
exportButton.addActionListener(this);
|
||||
searchButton.addActionListener(this);
|
||||
closeButton.addActionListener(this);
|
||||
panel.add(searchButton);
|
||||
panel.add(new JLabel(" "));
|
||||
panel.add(exportButton);
|
||||
panel.add(new JLabel(" "));
|
||||
panel.add(closeButton);
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void search() throws Exception {
|
||||
System.out.println("开始查询");
|
||||
System.out.println("清空表格");
|
||||
updateTable(null);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
System.out.println("拼接sql");
|
||||
sb.append("Select ");
|
||||
for(int i = 0;i<colomuns.size();i++) {
|
||||
String string = map.get(colomuns.get(i));
|
||||
if(string.toUpperCase().equals("PDATE")||string.toUpperCase().equals("PMESDATE")) {
|
||||
sb.append("to_char(");
|
||||
sb.append(string);
|
||||
sb.append(",'yyyy-MM-dd') ");
|
||||
}else {
|
||||
sb.append(string).append(" ");
|
||||
}
|
||||
if(i!=colomuns.size() -1)sb.append(", ");
|
||||
}
|
||||
sb.append("From PTX_TCTOMES ");
|
||||
boolean isfirst = true;
|
||||
if(dxlx_text.getText()!=null&&dxlx_text.getText().trim().length()>0) {
|
||||
if(isfirst) {
|
||||
sb.append("WHERE PTYPE1 like '%");
|
||||
sb.append(dxlx_text.getText());
|
||||
sb.append("%' ");
|
||||
}
|
||||
isfirst = false;
|
||||
}
|
||||
if(th_text.getText()!=null&&th_text.getText().trim().length()>0) {
|
||||
if(isfirst) {
|
||||
sb.append("WHERE PCODE1 like '%");
|
||||
sb.append(th_text.getText());
|
||||
sb.append("%' ");
|
||||
}else {
|
||||
sb.append("AND PCODE1 like '%");
|
||||
sb.append(th_text.getText());
|
||||
sb.append("%' ");
|
||||
}
|
||||
isfirst = false;
|
||||
}
|
||||
if(dth_text.getText()!=null&&dth_text.getText().trim().length()>0) {
|
||||
if(isfirst) {
|
||||
sb.append("WHERE PITEMID1 like '%");
|
||||
sb.append(dth_text.getText());
|
||||
sb.append("%' ");
|
||||
}else {
|
||||
sb.append("AND PITEMID1 like '%");
|
||||
sb.append(dth_text.getText());
|
||||
sb.append("%' ");
|
||||
}
|
||||
isfirst = false;
|
||||
}
|
||||
if(jsy_text.getText()!=null&&jsy_text.getText().trim().length()>0) {
|
||||
if(isfirst) {
|
||||
sb.append("WHERE POWNER1 like '%");
|
||||
sb.append(jsy_text.getText());
|
||||
sb.append("%' ");
|
||||
}else {
|
||||
sb.append("AND POWNER1 like '%");
|
||||
sb.append(jsy_text.getText());
|
||||
sb.append("%' ");
|
||||
}
|
||||
isfirst = false;
|
||||
}
|
||||
if (from_date.getText() != null && from_date.getText().trim().length() > 0) {
|
||||
if (isfirst) {
|
||||
sb.append("WHERE PDATE >= to_date('");
|
||||
sb.append(sdf.format(dateChooser1.getDate()).trim());
|
||||
sb.append("','yyyy-MM-dd')");
|
||||
} else {
|
||||
sb.append("AND PDATE >= to_date('");
|
||||
sb.append(sdf.format(dateChooser1.getDate()).trim());
|
||||
sb.append("','yyyy-MM-dd')");
|
||||
}
|
||||
isfirst = false;
|
||||
}
|
||||
if (to_date.getText() != null && to_date.getText().trim().length() > 0) {
|
||||
if (isfirst) {
|
||||
sb.append("WHERE PDATE <= to_date('");
|
||||
sb.append(sdf.format(dateChooser2.getDate()).trim());
|
||||
sb.append("','yyyy-MM-dd')");
|
||||
} else {
|
||||
sb.append("AND PDATE <= to_date('");
|
||||
sb.append(sdf.format(dateChooser2.getDate()).trim());
|
||||
sb.append("','yyyy-MM-dd')");
|
||||
}
|
||||
isfirst = false;
|
||||
}
|
||||
String sql = sb.toString();
|
||||
System.out.println("sql:"+sql);
|
||||
// MessageBox.post("sql:"+sql,"",MessageBox.INFORMATION);
|
||||
List<String[]> result = databaseControl.doQuery2(sql, colomuns.size());
|
||||
System.out.println("开始更新表格");
|
||||
updateTable(result.toArray(new String[result.size()][colomuns.size()]));
|
||||
}
|
||||
|
||||
public void export() throws Exception{
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
FileOutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream(export_path);
|
||||
int rowCount = model.getRowCount();
|
||||
Row toprow = sheet.createRow(0);
|
||||
for(int i = 0;i<colomuns.size();i++) {
|
||||
Cell cell = toprow.createCell(i);
|
||||
cell.setCellValue(colomuns.get(i));
|
||||
}
|
||||
for(int i = 0;i<rowCount;i++) {
|
||||
Row row = sheet.createRow(i+1);
|
||||
|
||||
for(int j = 0;j<colomuns.size();j++) {
|
||||
Cell cell = row.createCell(j);
|
||||
cell.setCellValue(model.getValueAt(i, j)!=null?model.getValueAt(i, j).toString():"");
|
||||
}
|
||||
}
|
||||
wb.write(out);
|
||||
}finally {
|
||||
if(out !=null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTable(String [][]data) {
|
||||
model = new DefaultTableModel(data,colomuns.toArray(new String[colomuns.size()]));
|
||||
table.setModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object source = e.getSource();
|
||||
if(source == searchButton) {
|
||||
MESreportOperation operation = new MESreportOperation(app,session,"查询",MESreportDialog.this);
|
||||
session.queueOperation(operation);
|
||||
}else if(source == exportButton) {
|
||||
JFileChooser jfc = new JFileChooser();
|
||||
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);// 设定只能选择到文件夹
|
||||
int state = jfc.showOpenDialog(MESreportDialog.this);// 此句是打开文件选择器界面的触发语句
|
||||
if (state == 1) {
|
||||
return;
|
||||
} else {
|
||||
File f = jfc.getSelectedFile();// f为选择到的目录
|
||||
String dirPath = f.getAbsolutePath();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");//设置格式
|
||||
String filePah = dirPath + File.separator+"MEX导出报表"+simpleDateFormat.format(date)+".xlsx";
|
||||
export_path = filePah;
|
||||
MESreportOperation operation = new MESreportOperation(app,session,"导出",MESreportDialog.this);
|
||||
session.queueOperation(operation);
|
||||
}
|
||||
|
||||
}else if(source == closeButton) {
|
||||
MESreportDialog.this.dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.connor.jk.plm.MESreport;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class MESreportHandler extends AbstractHandler{
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
MESreportDialog dialog = new MESreportDialog(app);
|
||||
new Thread(dialog).start();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.connor.jk.plm.MESreport;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Label;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class MESreportOperation extends AbstractAIFOperation{
|
||||
private String exeType;
|
||||
private AbstractAIFUIApplication app;
|
||||
private TCSession session;
|
||||
private String errInfo = "";
|
||||
private MESreportDialog dialog;
|
||||
public MESreportOperation(AbstractAIFUIApplication app, TCSession session,String exeType,MESreportDialog dialog) {
|
||||
this.app = app;
|
||||
this.session = session;
|
||||
this.exeType = exeType;
|
||||
this.dialog = dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOperation() throws Exception {
|
||||
new Thread() {
|
||||
public void run() {
|
||||
WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在"+exeType);
|
||||
dia.setVisible(true);
|
||||
// dialog.setAlwaysOnTop(false);
|
||||
dia.setAlwaysOnTop(true);
|
||||
boolean flag = false;
|
||||
try {
|
||||
switch (exeType) {
|
||||
case "查询":
|
||||
flag = search();
|
||||
|
||||
break;
|
||||
case "导出":
|
||||
flag = export();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (flag) {
|
||||
dia.setVisible(false);
|
||||
if(exeType.equals("导出"))
|
||||
MessageBox.post(dialog,exeType+"成功!", "", MessageBox.INFORMATION);
|
||||
} else {
|
||||
dia.setVisible(false);
|
||||
MessageBox.post(dialog,exeType+"失败!\n"+errInfo, "", MessageBox.INFORMATION);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
// dialog.setAlwaysOnTop(true);
|
||||
}
|
||||
};
|
||||
}.start();
|
||||
}
|
||||
|
||||
private boolean search() throws Exception{
|
||||
try {
|
||||
dialog.search();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errInfo+=e.getMessage();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private boolean export() throws Exception{
|
||||
try {
|
||||
dialog.export();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errInfo+=e.getMessage();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public JPanel panel;
|
||||
JProgressBar progressBar = null;
|
||||
|
||||
public WaitingDialog(Frame arg0, String title, String message) {
|
||||
super(arg0, title);
|
||||
this.setModal(false);
|
||||
|
||||
panel = new JPanel(new BorderLayout());
|
||||
|
||||
/*
|
||||
* JLabel label = new JLabel(message); System.out.println("message:"+message);
|
||||
* System.out.println("label:"+label); panel.add(label);
|
||||
*/
|
||||
|
||||
progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
|
||||
progressBar.setVisible(true);
|
||||
progressBar.setIndeterminate(true);
|
||||
|
||||
panel.add(BorderLayout.CENTER, new Label(message));
|
||||
panel.add(BorderLayout.SOUTH, progressBar);
|
||||
|
||||
panel.setPreferredSize(new Dimension(350, 60));
|
||||
|
||||
this.getContentPane().add(panel);
|
||||
|
||||
centerToScreen();
|
||||
|
||||
pack();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package com.connor.jk.plm.MESreport;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
|
||||
public class Test extends JDialog implements ActionListener{
|
||||
private JTable table;
|
||||
private DefaultTableModel model;
|
||||
private JButton exportButton;
|
||||
private JButton closeButton;
|
||||
private JButton searchButton;
|
||||
private JTextField from_date;
|
||||
private JTextField to_date;
|
||||
private JTextField th_text;
|
||||
private JTextField jsy_text;
|
||||
private JTextField dth_text;
|
||||
private JTextField dxlx_text;
|
||||
|
||||
|
||||
public Test() {
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Test test = new Test();
|
||||
try {
|
||||
test.init();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void init() throws Exception{
|
||||
setTitle("MES中间表导出");
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
mainPanel.add(getConditionPanel(),BorderLayout.NORTH);
|
||||
mainPanel.add(getTablePanel(),BorderLayout.CENTER);
|
||||
mainPanel.add(getButtonPanel(),BorderLayout.SOUTH);
|
||||
|
||||
add(mainPanel);
|
||||
pack();
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private JPanel getConditionPanel() {
|
||||
DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d");
|
||||
DateChooser dateChooser2 = DateChooser.getInstance("yyyy-M-d");
|
||||
from_date = new JTextField(20);
|
||||
to_date = new JTextField(20);
|
||||
dateChooser1.register(from_date);
|
||||
dateChooser2.register(to_date);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
|
||||
JPanel panel1 = new JPanel();
|
||||
panel1.add(new JLabel("发放日期"));
|
||||
panel1.add(from_date);
|
||||
panel1.add(new JLabel("-"));
|
||||
panel1.add(to_date);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
panel2.add(new JLabel("图号"));
|
||||
th_text = new JTextField(10);
|
||||
panel2.add(th_text);
|
||||
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(new JLabel("技术员"));
|
||||
jsy_text = new JTextField(10);
|
||||
panel3.add(jsy_text);
|
||||
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(new JLabel("底图号"));
|
||||
dth_text = new JTextField(10);
|
||||
panel4.add(dth_text);
|
||||
|
||||
JPanel panel5 = new JPanel();
|
||||
panel5.add(new JLabel("对象类型"));
|
||||
dxlx_text = new JTextField(10);
|
||||
panel5.add(dxlx_text);
|
||||
|
||||
|
||||
panel.add(panel1);
|
||||
panel.add(panel2);
|
||||
panel.add(panel3);
|
||||
panel.add(panel4);
|
||||
panel.add(panel5);
|
||||
|
||||
return panel;
|
||||
}
|
||||
private JScrollPane getTablePanel() {
|
||||
JScrollPane panel = new JScrollPane();
|
||||
table = new JTable() {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
model = new DefaultTableModel(null,new String[] {"1","2","3","4","5","6"});
|
||||
table.setModel(model);
|
||||
table.getTableHeader().setReorderingAllowed(false);//设置表头固定
|
||||
model.addRow((Vector)null);
|
||||
panel.setViewportView(table);
|
||||
return panel;
|
||||
}
|
||||
private JPanel getButtonPanel() {
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
exportButton = new JButton("导出");
|
||||
searchButton = new JButton("查询");
|
||||
closeButton = new JButton("关闭");
|
||||
exportButton.addActionListener(this);
|
||||
searchButton.addActionListener(this);
|
||||
closeButton.addActionListener(this);
|
||||
panel.add(searchButton);
|
||||
panel.add(new JLabel(" "));
|
||||
panel.add(exportButton);
|
||||
panel.add(new JLabel(" "));
|
||||
panel.add(closeButton);
|
||||
return panel;
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object source = e.getSource();
|
||||
if(source == searchButton) {
|
||||
|
||||
}else if(source == exportButton) {
|
||||
|
||||
}else if(source == closeButton) {
|
||||
Test.this.dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.net.connor.ld.plm.ld05;
|
||||
import javax.swing.*;
|
||||
|
||||
import com.sun.scenario.effect.impl.hw.d3d.D3DShaderSource;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class DialogFrame extends JDialog {
|
||||
|
||||
private JComboBox<String> comboBox;
|
||||
private Object syncObject;
|
||||
public DialogFrame(JFrame owner,JComboBox<String> comboBox,HashMap<String, String> map,String key) {
|
||||
super(owner, key, true); // 模态对话框
|
||||
this.comboBox = comboBox;
|
||||
this.syncObject = syncObject;
|
||||
JButton button = new JButton("确定");
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String selectedItem =(String) comboBox.getSelectedItem();
|
||||
if(selectedItem == null || selectedItem.isEmpty()) {
|
||||
MessageBox.post("请选择数据!", "提示 ", MessageBox.INFORMATION);
|
||||
}else {
|
||||
|
||||
System.out.println("Selected Item: " + selectedItem);
|
||||
map.put(key,selectedItem);
|
||||
dispose(); // 关闭对话框
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
this.setPreferredSize(new Dimension(700,140));
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new FlowLayout());
|
||||
panel.add(new JLabel("请选择:"));
|
||||
panel.add(comboBox);
|
||||
panel.add(button);
|
||||
|
||||
this.add(panel);
|
||||
this.pack();
|
||||
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
this.setLocationRelativeTo(owner); // 居中显示
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.net.connor.ld.plm.ld05;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentSchedule;
|
||||
import com.teamcenter.rac.kernel.TCComponentScheduleTask;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class ECSelectHandler extends AbstractHandler{
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
try {
|
||||
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
InterfaceAIFComponent targetComponent = app.getTargetComponent();
|
||||
|
||||
|
||||
try {
|
||||
new ECSelectDialog(session,app);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}.start();
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/** * @Title: test1.java
|
||||
* @Package com.net.connor.ld.plm.ld05
|
||||
* @Description: TODO(用一句话描述该文件做什么)
|
||||
* @author admin * @date 2024年8月14日
|
||||
* @version V1.0
|
||||
*/
|
||||
package com.net.connor.ld.plm.ld05;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* @ClassName: test1
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author admin
|
||||
* @date 2024年8月14日
|
||||
*
|
||||
*/
|
||||
public class test1 {
|
||||
public static void main(String[] args) {
|
||||
String dateString = "Sat Aug 03 00:00:00 GMT+08:00 2024";
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy",Locale.US);
|
||||
TimeZone tz = TimeZone.getTimeZone("GMT+8");
|
||||
|
||||
sdf.setTimeZone(tz);
|
||||
Date s = null;
|
||||
String da = null;
|
||||
Date strToDate = null;
|
||||
try {
|
||||
s = sdf.parse(dateString);
|
||||
System.out.println(s); // Sun Oct 22 00:00:00 CST 2017
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
da = sdf.format(s);
|
||||
System.out.println(da); // 2017-10-22
|
||||
strToDate = sdf.parse(da);
|
||||
} catch (ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue