|
|
@ -1,16 +1,25 @@
|
|
|
|
package com.chint.plm.SearchSapResult;
|
|
|
|
package com.chint.plm.SearchSapResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.chint.plm.createEcn.Util;
|
|
|
|
import com.connor.chint.sap2.util.ChintPreferenceUtil;
|
|
|
|
import com.connor.chint.sap2.util.ChintPreferenceUtil;
|
|
|
|
import com.connor.chint.sap2.util.SqlUtil;
|
|
|
|
import com.connor.chint.sap2.util.SqlUtil;
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
|
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javafx.application.Platform;
|
|
|
|
import javafx.beans.property.SimpleIntegerProperty;
|
|
|
|
import javafx.beans.property.SimpleIntegerProperty;
|
|
|
|
import javafx.beans.property.SimpleStringProperty;
|
|
|
|
import javafx.beans.property.SimpleStringProperty;
|
|
|
|
import javafx.beans.value.ChangeListener;
|
|
|
|
import javafx.beans.value.ChangeListener;
|
|
|
@ -18,6 +27,7 @@ import javafx.beans.value.ObservableValue;
|
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
|
|
|
|
import javafx.event.EventHandler;
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.CheckBox;
|
|
|
|
import javafx.scene.control.CheckBox;
|
|
|
@ -27,6 +37,8 @@ import javafx.scene.control.TableColumn;
|
|
|
|
import javafx.scene.control.TableView;
|
|
|
|
import javafx.scene.control.TableView;
|
|
|
|
import javafx.scene.control.TextField;
|
|
|
|
import javafx.scene.control.TextField;
|
|
|
|
import javafx.scene.control.cell.PropertyValueFactory;
|
|
|
|
import javafx.scene.control.cell.PropertyValueFactory;
|
|
|
|
|
|
|
|
import javafx.scene.input.KeyCode;
|
|
|
|
|
|
|
|
import javafx.scene.input.KeyEvent;
|
|
|
|
import javafx.scene.layout.FlowPane;
|
|
|
|
import javafx.scene.layout.FlowPane;
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
import javafx.scene.layout.StackPane;
|
|
|
|
import javafx.scene.layout.StackPane;
|
|
|
@ -62,8 +74,8 @@ public class DetailsController {
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
private TableColumn<DetailsBean, String> tc_batch;
|
|
|
|
private TableColumn<DetailsBean, String> tc_batch;
|
|
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
private TextField pageNumTxt;
|
|
|
|
private TextField pageNumTxt;
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
private TableColumn<DetailsBean, String> tc_wbs;
|
|
|
|
private TableColumn<DetailsBean, String> tc_wbs;
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
@ -92,7 +104,10 @@ public class DetailsController {
|
|
|
|
private Button bt_all;
|
|
|
|
private Button bt_all;
|
|
|
|
|
|
|
|
|
|
|
|
int pageNum = 0;
|
|
|
|
int pageNum = 0;
|
|
|
|
List<List<DetailsBean>> tableBeans;
|
|
|
|
List<List<DetailsBean>> tableBeans; // 记录表格里面的数据
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<List<DetailsBean>> errMsgBeans; // 记录错误的数据
|
|
|
|
|
|
|
|
List<List<DetailsBean>> allMsgBeans; // 记录全部数据
|
|
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
void firstAction(ActionEvent event) {
|
|
|
|
void firstAction(ActionEvent event) {
|
|
|
@ -155,23 +170,41 @@ public class DetailsController {
|
|
|
|
protected AbstractAIFApplication app;
|
|
|
|
protected AbstractAIFApplication app;
|
|
|
|
private TCSession session;
|
|
|
|
private TCSession session;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param event
|
|
|
|
* @param event
|
|
|
|
* @function 导出
|
|
|
|
* @function 导出EXCEL
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
void outputAction(ActionEvent event) {
|
|
|
|
void outputAction(ActionEvent event) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取首选项的文件
|
|
|
|
|
|
|
|
File tempFile = Util.getFile(session, "CHINT_BOM_RESULT_TEMPLATE", "MSExcelX");
|
|
|
|
|
|
|
|
if (tempFile == null) {
|
|
|
|
|
|
|
|
MessageBox.post("未找到excel模板,请检查CHINT_BOM_RESULT_TEMPLATE.", "失败", MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
FileInputStream in = new FileInputStream(tempFile);
|
|
|
|
|
|
|
|
XSSFWorkbook wb = new XSSFWorkbook(in);
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XSSFSheet sheetAt = wb.getSheet("SAP传递结果导出");
|
|
|
|
|
|
|
|
for (List<DetailsBean> detailList : tableBeans) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private StringBuilder sqlTotal;
|
|
|
|
private StringBuilder sqlTotal;
|
|
|
|
|
|
|
|
|
|
|
|
public void initData(Stage primaryStage, boolean onlyError,
|
|
|
|
public void initData(Stage primaryStage, boolean onlyError, StringBuilder sqlTotal) {
|
|
|
|
StringBuilder sqlTotal) {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
this.sqlTotal = sqlTotal;
|
|
|
|
this.sqlTotal = sqlTotal;
|
|
|
|
|
|
|
|
|
|
|
|
this.app = AIFUtility.getCurrentApplication();
|
|
|
|
this.app = AIFUtility.getCurrentApplication();
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
|
// 表格列绑定bean对象
|
|
|
|
// 表格列绑定bean对象
|
|
|
@ -200,7 +233,7 @@ public class DetailsController {
|
|
|
|
tc_returnTime.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("returnTime"));
|
|
|
|
tc_returnTime.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("returnTime"));
|
|
|
|
tc_plm.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("plmStatus"));
|
|
|
|
tc_plm.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("plmStatus"));
|
|
|
|
|
|
|
|
|
|
|
|
//绑定列宽
|
|
|
|
// 绑定列宽
|
|
|
|
tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.05));
|
|
|
|
tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.05));
|
|
|
|
tc_batch.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
|
|
|
|
tc_batch.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
|
|
|
|
tc_material.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
|
|
|
|
tc_material.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
|
|
|
@ -212,8 +245,8 @@ public class DetailsController {
|
|
|
|
tc_returnDate.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
|
|
|
|
tc_returnDate.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
|
|
|
|
tc_returnTime.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
|
|
|
|
tc_returnTime.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
|
|
|
|
tc_plm.prefWidthProperty().bind(tableView.widthProperty().multiply(0.07));
|
|
|
|
tc_plm.prefWidthProperty().bind(tableView.widthProperty().multiply(0.07));
|
|
|
|
|
|
|
|
|
|
|
|
//触发查询,默认错误数据
|
|
|
|
// 触发查询,默认错误数据
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
cb_errBtn.setSelected(true);
|
|
|
|
cb_errBtn.setSelected(true);
|
|
|
|
searchErrMsg();
|
|
|
|
searchErrMsg();
|
|
|
@ -224,10 +257,10 @@ public class DetailsController {
|
|
|
|
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
|
|
|
|
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
|
|
|
|
tableView.getItems().clear();
|
|
|
|
tableView.getItems().clear();
|
|
|
|
tableView.setItems(data);
|
|
|
|
tableView.setItems(data);
|
|
|
|
lb_page.setText("/"+tableBeans.size());
|
|
|
|
lb_page.setText("/" + tableBeans.size());
|
|
|
|
// this.tableBeans = tableBeans;
|
|
|
|
// this.tableBeans = tableBeans;
|
|
|
|
|
|
|
|
|
|
|
|
//最大化绑定
|
|
|
|
// 最大化绑定
|
|
|
|
primaryStage.widthProperty().addListener(new ChangeListener<Number>() {
|
|
|
|
primaryStage.widthProperty().addListener(new ChangeListener<Number>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
|
|
|
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
|
|
@ -242,71 +275,109 @@ public class DetailsController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
primaryStage.setMaximized(true);
|
|
|
|
primaryStage.setMaximized(true);
|
|
|
|
|
|
|
|
cb_errBtn.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
|
|
|
|
|
|
|
// just show results
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (flagEdit) {
|
|
|
|
|
|
|
|
flagEdit = false;
|
|
|
|
|
|
|
|
searchErrMsg();
|
|
|
|
|
|
|
|
Platform.runLater(() -> {
|
|
|
|
|
|
|
|
flagEdit = true;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
System.out.println("END" + sqlTotal.toString());
|
|
|
|
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pageNumTxt.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handle(KeyEvent event) {
|
|
|
|
|
|
|
|
if (event.getCode() == KeyCode.ENTER) {
|
|
|
|
|
|
|
|
// showHistoryWords(querybox.getText());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean flagEdit = true;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param event
|
|
|
|
* @param event
|
|
|
|
* @function 只显示错误数据
|
|
|
|
* @function 只显示错误数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@FXML
|
|
|
|
// @FXML
|
|
|
|
void errBtnAction(ActionEvent event) {
|
|
|
|
// void errBtnAction(ActionEvent event) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
cb_errBtn.setDisable(true);
|
|
|
|
|
|
|
|
searchErrMsg();
|
|
|
|
|
|
|
|
cb_errBtn.setDisable(false);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
System.out.println("END" + sqlTotal.toString());
|
|
|
|
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
* @throws Exception
|
|
|
|
* @function 显示错误数据
|
|
|
|
* @function 显示错误数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void searchErrMsg() throws Exception {
|
|
|
|
private void searchErrMsg() throws Exception {
|
|
|
|
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
|
|
|
|
|
|
|
|
// 单个BOM具体信息 : 全部状态.
|
|
|
|
// 单个BOM具体信息 : 全部状态.
|
|
|
|
List<List<DetailsBean>> tableBeans = new ArrayList<List<DetailsBean>>();
|
|
|
|
List<List<DetailsBean>> tableBeans = new ArrayList<List<DetailsBean>>();
|
|
|
|
SqlUtil.getTCDataConnection(prefs);
|
|
|
|
if (cb_errBtn.isSelected() && errMsgBeans.size() > 0) {
|
|
|
|
String sqlDetail = "";
|
|
|
|
tableBeans = errMsgBeans;
|
|
|
|
if (cb_errBtn.isSelected()) {
|
|
|
|
} else if (!cb_errBtn.isSelected() && allMsgBeans.size() > 0) {
|
|
|
|
sqlDetail = sqlTotal.toString() + " and status = 'E' ";
|
|
|
|
tableBeans = allMsgBeans;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sqlDetail = sqlTotal.toString();// + " and status = 'S' ";
|
|
|
|
String sqlDetail = "";
|
|
|
|
}
|
|
|
|
if (cb_errBtn.isSelected()) {
|
|
|
|
ResultSet read = SqlUtil.read(sqlDetail);
|
|
|
|
sqlDetail = sqlTotal.toString() + " and status = 'E' ";
|
|
|
|
int i = 1;
|
|
|
|
} else {
|
|
|
|
List<DetailsBean> beanList = null;
|
|
|
|
sqlDetail = sqlTotal.toString();// + " and status = 'S' ";
|
|
|
|
while (read.next()) {
|
|
|
|
}
|
|
|
|
// 分页 20 查询结果放入表格
|
|
|
|
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
|
|
|
|
DetailsBean sumBean = new DetailsBean(new SimpleIntegerProperty(i),
|
|
|
|
SqlUtil.getTCDataConnection(prefs);
|
|
|
|
new SimpleStringProperty(read.getString(1)), new SimpleStringProperty(read.getString(2)),
|
|
|
|
System.out.println("cb_errBtn" + cb_errBtn.isSelected());
|
|
|
|
new SimpleStringProperty(read.getString(3)), new SimpleStringProperty(read.getString(4)),
|
|
|
|
System.out.println("sqlDetail" + sqlDetail.toString());
|
|
|
|
new SimpleStringProperty(read.getString(5)), new SimpleStringProperty(read.getString(6)),
|
|
|
|
ResultSet read = SqlUtil.read(sqlDetail);
|
|
|
|
new SimpleStringProperty(read.getString(7)), new SimpleStringProperty(read.getString(8)),
|
|
|
|
int i = 1;
|
|
|
|
new SimpleStringProperty(read.getString(9)), new SimpleStringProperty(read.getString(10)));
|
|
|
|
List<DetailsBean> beanList = null;
|
|
|
|
if (i % 20 == 1) {
|
|
|
|
while (read.next()) {
|
|
|
|
|
|
|
|
// 分页 20 查询结果放入表格
|
|
|
|
|
|
|
|
DetailsBean sumBean = new DetailsBean(new SimpleIntegerProperty(i),
|
|
|
|
|
|
|
|
new SimpleStringProperty(read.getString(1)), new SimpleStringProperty(read.getString(2)),
|
|
|
|
|
|
|
|
new SimpleStringProperty(read.getString(3)), new SimpleStringProperty(read.getString(4)),
|
|
|
|
|
|
|
|
new SimpleStringProperty(read.getString(5)), new SimpleStringProperty(read.getString(6)),
|
|
|
|
|
|
|
|
new SimpleStringProperty(read.getString(7)), new SimpleStringProperty(read.getString(8)),
|
|
|
|
|
|
|
|
new SimpleStringProperty(read.getString(9)), new SimpleStringProperty(read.getString(10)));
|
|
|
|
|
|
|
|
if (i % 40 == 1) {
|
|
|
|
|
|
|
|
beanList = new ArrayList<DetailsBean>();
|
|
|
|
|
|
|
|
tableBeans.add(beanList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
beanList.add(sumBean);
|
|
|
|
|
|
|
|
i = i + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
|
|
|
|
if (tableBeans.size() == 0) {
|
|
|
|
beanList = new ArrayList<DetailsBean>();
|
|
|
|
beanList = new ArrayList<DetailsBean>();
|
|
|
|
tableBeans.add(beanList);
|
|
|
|
tableBeans.add(beanList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
beanList.add(sumBean);
|
|
|
|
if (errMsgBeans.size() == 0 && cb_errBtn.isSelected()) {
|
|
|
|
i = i + 1;
|
|
|
|
errMsgBeans = tableBeans;
|
|
|
|
}
|
|
|
|
} else if (allMsgBeans.size() == 0 && !cb_errBtn.isSelected()) {
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
allMsgBeans = tableBeans;
|
|
|
|
if (tableBeans.size() == 0) {
|
|
|
|
}
|
|
|
|
beanList = new ArrayList<DetailsBean>();
|
|
|
|
|
|
|
|
tableBeans.add(beanList);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
|
|
|
|
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
|
|
|
|
tableView.getItems().clear();
|
|
|
|
tableView.getItems().clear();
|
|
|
|
tableView.setItems(data);
|
|
|
|
tableView.setItems(data);
|
|
|
|
pageNum = 0;
|
|
|
|
pageNum = 0;
|
|
|
|
this.tableBeans = tableBeans;
|
|
|
|
this.tableBeans = tableBeans;
|
|
|
|
lb_page.setText("/"+tableBeans.size());
|
|
|
|
lb_page.setText("/" + tableBeans.size());
|
|
|
|
|
|
|
|
pageNumTxt.setText("1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|