no-bomasyn
陈翼晖 2 years ago
parent b8a133df93
commit c15d8a9833

@ -1,4 +1,5 @@
package com.chint.plm.SearchSapResult;
import java.io.IOException;
import java.util.List;
@ -9,26 +10,28 @@ import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class ChildMessage extends Application {
public class ChildMessage extends Application {
// private List<List<DetailsBean>> tableBeans;
private boolean onlyError;
private StringBuilder sqlTotal;
public ChildMessage(boolean onlyError,StringBuilder sqlTotal) {
super();
private boolean onlyError;
private StringBuilder sqlTotal;
public ChildMessage(boolean onlyError, StringBuilder sqlTotal) {
super();
// this.tableBeans = tableBeans;
this.onlyError = onlyError;
this.sqlTotal = sqlTotal;
}
@Override
this.onlyError = onlyError;
this.sqlTotal = sqlTotal;
}
@Override
public void start(Stage primaryStage) throws IOException {
// StackPane root = new StackPane();
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("SearchSapDetailPanel.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root, 1200.0, 800.0);
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("SearchSapDetailPanel.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root, 1200.0, 800.0);
DetailsController controller = (DetailsController) fxmlLoader.getController();
primaryStage.setTitle("SAP´«µÝ½á¹ûÃ÷ϸ");
controller.initData(primaryStage,onlyError,sqlTotal);
controller.initData(primaryStage, onlyError, sqlTotal);
primaryStage.setScene(scene);
primaryStage.show();
}

@ -7,103 +7,123 @@ public class DetailsBean {
// batchnumber,productmaterialno,status,message,createdate,createtime,returndate,returntime,"
// + "PLMSTATUS
//序号
protected SimpleIntegerProperty num;
protected SimpleStringProperty batchNum;//批次号
protected SimpleStringProperty productMaterialNo; //父物料号
protected SimpleStringProperty wbsNo; //父物料号
protected SimpleStringProperty status;//状态
protected SimpleStringProperty message;//状态
protected SimpleStringProperty createDate;//创建日期
protected SimpleStringProperty createTime;//创建时间
protected SimpleStringProperty returnDate;//回传日期
protected SimpleStringProperty returnTime;//回传时间
protected SimpleStringProperty plmStatus;//回传时间
public Integer getNum() {
return num.get();
}
public void setNum(SimpleIntegerProperty num) {
this.num = num;
}
public String getBatchNum() {
return batchNum.get();
}
public void setBatchNum(SimpleStringProperty batchNum) {
this.batchNum = batchNum;
}
public String getProductMaterialNo() {
return productMaterialNo.get();
}
public void setProductMaterialNo(SimpleStringProperty productMaterialNo) {
this.productMaterialNo = productMaterialNo;
}
public String getStatus() {
return status.get();
}
public void setStatus(SimpleStringProperty status) {
this.status = status;
}
public String getCreateDate() {
return createDate.get();
}
public void setCreateDate(SimpleStringProperty createDate) {
this.createDate = createDate;
}
public String getCreateTime() {
return createTime.get();
}
public void setCreateTime(SimpleStringProperty createTime) {
this.createTime = createTime;
}
public String getReturnDate() {
return returnDate.get();
}
public void setReturnDate(SimpleStringProperty returnDate) {
this.returnDate = returnDate;
}
public String getReturnTime() {
return returnTime.get();
}
public void setReturnTime(SimpleStringProperty returnTime) {
this.returnTime = returnTime;
}
public String getWbsNo() {
return wbsNo.get();
}
public void setWbsNo(SimpleStringProperty wbsNo) {
this.wbsNo = wbsNo;
}
public String getMessage() {
return message.get();
}
public void setMessage(SimpleStringProperty message) {
this.message = message;
}
public String getPlmStatus() {
return plmStatus.get();
}
public void setPlmStatus(SimpleStringProperty plmStatus) {
this.plmStatus = plmStatus;
}
public DetailsBean(SimpleIntegerProperty num, SimpleStringProperty batchNum, SimpleStringProperty productMaterialNo,
SimpleStringProperty wbsNo, SimpleStringProperty status, SimpleStringProperty message,
SimpleStringProperty createDate, SimpleStringProperty createTime, SimpleStringProperty returnDate,
SimpleStringProperty returnTime, SimpleStringProperty plmStatus) {
super();
this.num = num;
this.batchNum = batchNum;
this.productMaterialNo = productMaterialNo;
this.wbsNo = wbsNo;
this.status = status;
this.message = message;
this.createDate = createDate;
this.createTime = createTime;
this.returnDate = returnDate;
this.returnTime = returnTime;
this.plmStatus = plmStatus;
}
// 序号
protected SimpleIntegerProperty num;
protected SimpleStringProperty batchNum;// 批次号
protected SimpleStringProperty productMaterialNo; // 父物料号
protected SimpleStringProperty wbsNo; // 父物料号
protected SimpleStringProperty status;// 状态
protected SimpleStringProperty message;// 状态
protected SimpleStringProperty createDate;// 创建日期
protected SimpleStringProperty createTime;// 创建时间
protected SimpleStringProperty returnDate;// 回传日期
protected SimpleStringProperty returnTime;// 回传时间
protected SimpleStringProperty plmStatus;// 回传时间
public Integer getNum() {
return num.get();
}
public void setNum(SimpleIntegerProperty num) {
this.num = num;
}
public String getBatchNum() {
return batchNum.get();
}
public void setBatchNum(SimpleStringProperty batchNum) {
this.batchNum = batchNum;
}
public String getProductMaterialNo() {
return productMaterialNo.get();
}
public void setProductMaterialNo(SimpleStringProperty productMaterialNo) {
this.productMaterialNo = productMaterialNo;
}
public String getStatus() {
return status.get();
}
public void setStatus(SimpleStringProperty status) {
this.status = status;
}
public String getCreateDate() {
return createDate.get();
}
public void setCreateDate(SimpleStringProperty createDate) {
this.createDate = createDate;
}
public String getCreateTime() {
return createTime.get();
}
public void setCreateTime(SimpleStringProperty createTime) {
this.createTime = createTime;
}
public String getReturnDate() {
return returnDate.get();
}
public void setReturnDate(SimpleStringProperty returnDate) {
this.returnDate = returnDate;
}
public String getReturnTime() {
return returnTime.get();
}
public void setReturnTime(SimpleStringProperty returnTime) {
this.returnTime = returnTime;
}
public String getWbsNo() {
return wbsNo.get();
}
public void setWbsNo(SimpleStringProperty wbsNo) {
this.wbsNo = wbsNo;
}
public String getMessage() {
return message.get();
}
public void setMessage(SimpleStringProperty message) {
this.message = message;
}
public String getPlmStatus() {
return plmStatus.get();
}
public void setPlmStatus(SimpleStringProperty plmStatus) {
this.plmStatus = plmStatus;
}
public DetailsBean(SimpleIntegerProperty num, SimpleStringProperty batchNum, SimpleStringProperty productMaterialNo,
SimpleStringProperty wbsNo, SimpleStringProperty status, SimpleStringProperty message,
SimpleStringProperty createDate, SimpleStringProperty createTime, SimpleStringProperty returnDate,
SimpleStringProperty returnTime, SimpleStringProperty plmStatus) {
super();
this.num = num;
this.batchNum = batchNum;
this.productMaterialNo = productMaterialNo;
this.wbsNo = wbsNo;
this.status = status;
this.message = message;
this.createDate = createDate;
this.createTime = createTime;
this.returnDate = returnDate;
this.returnTime = returnTime;
this.plmStatus = plmStatus;
}
}

@ -2,12 +2,18 @@ package com.chint.plm.SearchSapResult;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.filechooser.FileSystemView;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -44,340 +50,400 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
* @author cyh
*
*/
/**
* @author cyh
*
*/
public class DetailsController {
@FXML
private Button bt_last;
@FXML
private Button bt_next;
@FXML
private TableColumn<DetailsBean, String> tc_cDate;
@FXML
private TableColumn<DetailsBean, String> tc_msg;
@FXML
private TableColumn<DetailsBean, String> tc_cTime;
@FXML
private TableView<DetailsBean> tableView;
@FXML
private TableColumn<DetailsBean, String> tc_returnTime;
@FXML
private TableColumn<DetailsBean, String> tc_batch;
@FXML
private TextField pageNumTxt;
@FXML
private TableColumn<DetailsBean, String> tc_wbs;
@FXML
private TableColumn<DetailsBean, String> tc_SapResult;
@FXML
private TableColumn<DetailsBean, Integer> tc_xh;
@FXML
private TableColumn<DetailsBean, String> tc_material;
@FXML
private TableColumn<DetailsBean, String> tc_returnDate;
@FXML
private TableColumn<DetailsBean, String> tc_plm;
@FXML
private CheckBox cb_errBtn;
@FXML
private Label lb_page;
@FXML
private Button bt_first;
@FXML
private StackPane stackPane;
@FXML
private Button bt_tail;
@FXML
private Button bt_all;
int pageNum = 0;
List<List<DetailsBean>> tableBeans; // 记录表格里面的数据
List<List<DetailsBean>> errMsgBeans; // 记录错误的数据
List<List<DetailsBean>> allMsgBeans; // 记录全部数据
@FXML
void firstAction(ActionEvent event) {
pageNum = 0;
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
}
@FXML
void lastAction(ActionEvent event) {
if (pageNum > 0) {
pageNum = pageNum - 1;
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
@FXML
void nextAction(ActionEvent event) {
if (pageNum < tableBeans.size() - 1) {
pageNum = pageNum + 1;
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
@FXML
void tailAction(ActionEvent event) {
pageNum = tableBeans.size() - 1;
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
@FXML
private FlowPane flowPane;
@FXML
private ScrollPane scrollPane;
@FXML
private GridPane girdPane;
/**
* @param event
* @function
*/
@FXML
void allAction(ActionEvent event) {
List<DetailsBean> allBeans = new ArrayList<DetailsBean>();
for (int i = 0; i < tableBeans.size(); i++) {
allBeans.addAll(tableBeans.get(i));
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(allBeans);
tableView.getItems().clear();
tableView.setItems(data);
}
protected AbstractAIFApplication app;
private TCSession session;
/**
* @param event
* @function EXCEL
*/
@FXML
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;
public void initData(Stage primaryStage, boolean onlyError, StringBuilder sqlTotal) {
// TODO Auto-generated method stub
this.sqlTotal = sqlTotal;
this.app = AIFUtility.getCurrentApplication();
this.session = (TCSession) app.getSession();
// 表格列绑定bean对象
tc_xh.setSortable(false);
tc_cDate.setSortable(false);
tc_msg.setSortable(false);
tc_cTime.setSortable(false);
tc_returnTime.setSortable(false);
tc_batch.setSortable(false);
tc_wbs.setSortable(false);
tc_SapResult.setSortable(false);
tc_plm.setSortable(false);
tc_material.setSortable(false);
tc_returnDate.setSortable(false);
// 列绑定bean对象
tc_xh.setCellValueFactory(new PropertyValueFactory<DetailsBean, Integer>("num"));
tc_batch.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("batchNum"));
tc_material.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("productMaterialNo"));
tc_wbs.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("wbsNo"));
tc_SapResult.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("status"));
tc_msg.setCellValueFactory(new PropertyValueFactory<>("message"));
@FXML
private Button bt_last;
@FXML
private Button bt_next;
@FXML
private TableColumn<DetailsBean, String> tc_cDate;
@FXML
private TableColumn<DetailsBean, String> tc_msg;
@FXML
private TableColumn<DetailsBean, String> tc_cTime;
@FXML
private TableView<DetailsBean> tableView;
@FXML
private TableColumn<DetailsBean, String> tc_returnTime;
@FXML
private TableColumn<DetailsBean, String> tc_batch;
@FXML
private TextField pageNumTxt;
@FXML
private TableColumn<DetailsBean, String> tc_wbs;
@FXML
private TableColumn<DetailsBean, String> tc_SapResult;
@FXML
private TableColumn<DetailsBean, Integer> tc_xh;
@FXML
private TableColumn<DetailsBean, String> tc_material;
@FXML
private TableColumn<DetailsBean, String> tc_returnDate;
@FXML
private TableColumn<DetailsBean, String> tc_plm;
@FXML
private CheckBox cb_errBtn;
@FXML
private Label lb_page;
@FXML
private Button bt_first;
@FXML
private StackPane stackPane;
@FXML
private Button bt_tail;
@FXML
private Button bt_all;
int pageNum = 0;
List<List<DetailsBean>> tableBeans; // 记录表格里面的数据
List<List<DetailsBean>> errMsgBeans = new ArrayList<>(); // 记录错误的数据
List<List<DetailsBean>> allMsgBeans = new ArrayList<>(); // 记录全部数据
/**
* @param event
* @function
*/
@FXML
void firstAction(ActionEvent event) {
pageNum = 0;
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
}
/**
* @param event
* @function
*/
@FXML
void lastAction(ActionEvent event) {
if (pageNum > 0) {
pageNum = pageNum - 1;
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
/**
* @param event
* @function
*/
@FXML
void nextAction(ActionEvent event) {
if (pageNum < tableBeans.size() - 1) {
pageNum = pageNum + 1;
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
/**
* @param event
* @function
*/
@FXML
void tailAction(ActionEvent event) {
pageNum = tableBeans.size() - 1;
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
@FXML
private FlowPane flowPane;
@FXML
private ScrollPane scrollPane;
@FXML
private GridPane girdPane;
/**
* @param event
* @function
*/
@FXML
void allAction(ActionEvent event) {
List<DetailsBean> allBeans = new ArrayList<DetailsBean>();
for (int i = 0; i < tableBeans.size(); i++) {
allBeans.addAll(tableBeans.get(i));
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(allBeans);
tableView.getItems().clear();
tableView.setItems(data);
}
protected AbstractAIFApplication app;
private TCSession session;
/**
* @param event
* @function EXCEL
*/
@FXML
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) {
// 导出excel设置值
for (DetailsBean detailsBean : detailList) {
XSSFRow row1 = Util.getRow(sheetAt, detailsBean.getNum());
Util.setCellValue(row1.getCell(0), 0, row1, detailsBean.getNum() + "");// 序号
Util.setCellValue(row1.getCell(1), 1, row1, detailsBean.getBatchNum());// 批次号
Util.setCellValue(row1.getCell(2), 2, row1, detailsBean.getProductMaterialNo());// 父物料编码
Util.setCellValue(row1.getCell(3), 3, row1, detailsBean.getWbsNo());// WBS
Util.setCellValue(row1.getCell(4), 4, row1, detailsBean.getStatus());// SAP状态
Util.setCellValue(row1.getCell(5), 5, row1, detailsBean.getMessage());// 具体信息
Util.setCellValue(row1.getCell(6), 6, row1, detailsBean.getCreateDate());// BOM创建日期
Util.setCellValue(row1.getCell(7), 7, row1, detailsBean.getCreateTime());// BOM创建时间
Util.setCellValue(row1.getCell(8), 8, row1, detailsBean.getReturnDate());// BOM同步日期
Util.setCellValue(row1.getCell(9), 9, row1, detailsBean.getReturnTime());// BOM同步时间
Util.setCellValue(row1.getCell(9), 9, row1, detailsBean.getPlmStatus());// PLM状态
}
}
// 桌面
File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory();
String desktopPath = desktopDir.getAbsolutePath();
// 文件保存到桌面,名称:结果导出时间戳
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
String pathName = "结果导出" + format.format(new Date()) + ".xlsx";
File file2 = new File(desktopPath + File.separator + pathName);
FileOutputStream os = new FileOutputStream(file2);
wb.write(os);
os.flush();
os.close();
Runtime.getRuntime().exec("cmd /c start "+desktopPath + File.separator + pathName);
// MessageBox.post("导出完成.","提示",2);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private Stage primaryStage;
private StringBuilder sqlTotal;
/**
* @param primaryStage
* @param onlyError
* @param sqlTotal
* @function
*/
public void initData(Stage primaryStage, boolean onlyError, StringBuilder sqlTotal) {
// TODO Auto-generated method stub
this.sqlTotal = sqlTotal;
this.app = AIFUtility.getCurrentApplication();
this.session = (TCSession) app.getSession();
// 表格列绑定bean对象
this.primaryStage = primaryStage;
tc_xh.setSortable(false);
tc_cDate.setSortable(false);
tc_msg.setSortable(false);
tc_cTime.setSortable(false);
tc_returnTime.setSortable(false);
tc_batch.setSortable(false);
tc_wbs.setSortable(false);
tc_SapResult.setSortable(false);
tc_plm.setSortable(false);
tc_material.setSortable(false);
tc_returnDate.setSortable(false);
// 列绑定bean对象
tc_xh.setCellValueFactory(new PropertyValueFactory<DetailsBean, Integer>("num"));
tc_batch.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("batchNum"));
tc_material.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("productMaterialNo"));
tc_wbs.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("wbsNo"));
tc_SapResult.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("status"));
tc_msg.setCellValueFactory(new PropertyValueFactory<>("message"));
// tc_log.setCellValueFactory(new PropertyValueFactory<>("user"));
tc_cDate.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("createDate"));
tc_cTime.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("createTime"));
tc_returnDate.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("returnDate"));
tc_returnTime.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("returnTime"));
tc_plm.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("plmStatus"));
// 绑定列宽
tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.05));
tc_batch.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
tc_material.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
tc_wbs.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_SapResult.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_msg.prefWidthProperty().bind(tableView.widthProperty().multiply(0.35));
tc_cDate.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
tc_cTime.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_plm.prefWidthProperty().bind(tableView.widthProperty().multiply(0.07));
// 触发查询,默认错误数据
try {
cb_errBtn.setSelected(true);
searchErrMsg();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
lb_page.setText("/" + tableBeans.size());
tc_cDate.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("createDate"));
tc_cTime.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("createTime"));
tc_returnDate.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("returnDate"));
tc_returnTime.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("returnTime"));
tc_plm.setCellValueFactory(new PropertyValueFactory<DetailsBean, String>("plmStatus"));
// 绑定列宽
tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.05));
tc_batch.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
tc_material.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
tc_wbs.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_SapResult.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_msg.prefWidthProperty().bind(tableView.widthProperty().multiply(0.35));
tc_cDate.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
tc_cTime.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_plm.prefWidthProperty().bind(tableView.widthProperty().multiply(0.07));
// 触发查询,默认错误数据
try {
cb_errBtn.setSelected(true);
searchErrMsg();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
lb_page.setText("/" + tableBeans.size());
// this.tableBeans = tableBeans;
// 最大化绑定
primaryStage.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
// 更新GUI组件
// Platform.runLater(new Runnable() {
double width = primaryStage.getWidth();
System.out.println("width==>" + width);
girdPane.setPrefWidth(width * 0.98);
flowPane.setPrefWidth(width * 0.98);
scrollPane.setPrefWidth(width * 0.98);
tableView.setPrefWidth(width * 0.98);
}
});
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
* @function
*/
// 最大化绑定
primaryStage.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
// 更新GUI组件
// Platform.runLater(new Runnable() {
double width = primaryStage.getWidth();
double height = primaryStage.getHeight();
System.out.println("width==>" + width);
girdPane.setPrefWidth(width * 0.98);
flowPane.setPrefWidth(width * 0.98);
scrollPane.setPrefWidth(width * 0.98);
tableView.setPrefWidth(width * 0.98);
scrollPane.setPrefHeight(height*0.8);
tableView.setPrefHeight(height*0.8);
}
});
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) {
String text = pageNumTxt.getText();
int num = 0;
try {
int parseInt = Integer.parseInt(text);
num = parseInt;
} catch (Exception e) {
}
if (num > 0 && num <= tableBeans.size()) {
pageNum = num;
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(num - 1));
tableView.getItems().clear();
tableView.setItems(data);
}
}
}
});
}
private boolean flagEdit = true;
/**
* @param event
* @function
*/
// @FXML
// void errBtnAction(ActionEvent event) {
//
// }
/**
* @throws Exception
* @function
*/
private void searchErrMsg() throws Exception {
// 单个BOM具体信息 : 全部状态.
List<List<DetailsBean>> tableBeans = new ArrayList<List<DetailsBean>>();
if (cb_errBtn.isSelected() && errMsgBeans.size() > 0) {
tableBeans = errMsgBeans;
} else if (!cb_errBtn.isSelected() && allMsgBeans.size() > 0) {
tableBeans = allMsgBeans;
} else {
String sqlDetail = "";
if (cb_errBtn.isSelected()) {
sqlDetail = sqlTotal.toString() + " and status = 'E' ";
} else {
sqlDetail = sqlTotal.toString();// + " and status = 'S' ";
}
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
SqlUtil.getTCDataConnection(prefs);
System.out.println("cb_errBtn" + cb_errBtn.isSelected());
System.out.println("sqlDetail" + sqlDetail.toString());
ResultSet read = SqlUtil.read(sqlDetail);
int i = 1;
List<DetailsBean> beanList = null;
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>();
tableBeans.add(beanList);
}
if (errMsgBeans.size() == 0 && cb_errBtn.isSelected()) {
errMsgBeans = tableBeans;
} else if (allMsgBeans.size() == 0 && !cb_errBtn.isSelected()) {
allMsgBeans = tableBeans;
}
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
pageNum = 0;
this.tableBeans = tableBeans;
lb_page.setText("/" + tableBeans.size());
pageNumTxt.setText("1");
}
/**
* @throws Exception
* @function
*/
private void searchErrMsg() throws Exception {
// 单个BOM具体信息 : 全部状态.
List<List<DetailsBean>> tableBeans = new ArrayList<List<DetailsBean>>();
if (cb_errBtn.isSelected() && errMsgBeans.size() > 0) {
tableBeans = errMsgBeans;
} else if (!cb_errBtn.isSelected() && allMsgBeans.size() > 0) {
tableBeans = allMsgBeans;
} else {
String sqlDetail = "";
if (cb_errBtn.isSelected()) {
sqlDetail = sqlTotal.toString() + " and status = 'E' ";
} else {
sqlDetail = sqlTotal.toString();// + " and status = 'S' ";
}
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
SqlUtil.getTCDataConnection(prefs);
System.out.println("cb_errBtn" + cb_errBtn.isSelected());
System.out.println("sqlDetail" + sqlDetail.toString());
ResultSet read = SqlUtil.read(sqlDetail);
int i = 1;
List<DetailsBean> beanList = null;
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>();
tableBeans.add(beanList);
}
if (errMsgBeans.size() == 0 && cb_errBtn.isSelected()) {
errMsgBeans = tableBeans;
} else if (allMsgBeans.size() == 0 && !cb_errBtn.isSelected()) {
allMsgBeans = tableBeans;
}
}
ObservableList<DetailsBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
pageNum = 0;
this.tableBeans = tableBeans;
lb_page.setText("/" + tableBeans.size());
pageNumTxt.setText("1");
}
}

@ -7,20 +7,20 @@ import com.chint.plm.fxUtil.KFrame;
import javafx.embed.swing.JFXPanel;
public class SapResultFrame extends KFrame{
public class SapResultFrame extends KFrame {
public SapResultFrame() {
super();
}
public SapResultFrame() {
super();
}
@Override
protected void initUI() throws Exception {
this.setTitle("SAP´«µÝ½á¹û²éѯ");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1200, 800));
JFXPanel panel = new JFXPanel();
panel.setScene(new SapResultPanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
@Override
protected void initUI() throws Exception {
this.setTitle("SAP´«µÝ½á¹û²éѯ");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1200, 800));
JFXPanel panel = new JFXPanel();
panel.setScene(new SapResultPanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
}

@ -4,10 +4,10 @@ import java.awt.Window;
import com.chint.plm.fxUtil.KFXPanel;
public class SapResultPanel extends KFXPanel{
public class SapResultPanel extends KFXPanel {
public SapResultPanel(Window dialog) {
super(dialog,"SearchSapResultPanel.fxml");
// TODO Auto-generated constructor stub
}
public SapResultPanel(Window dialog) {
super(dialog, "SearchSapResultPanel.fxml");
// TODO Auto-generated constructor stub
}
}

@ -52,475 +52,475 @@ import javafx.scene.layout.StackPane;
public class SearchSapController extends KFXPanelController {
@FXML
private TitledPane tp_result;
@FXML
private Button bt_closeAll;
@FXML
private TitledPane mxtjPane;
@FXML
private GridPane bt_cx; // 按钮的pane
@FXML
private Button bt_close; // 关闭
@FXML
private Button bt_czcx;// 重置查询
@FXML
private StackPane stackPane;
// table的列
@FXML
private TableColumn<SumTableBean, String> tc_xh;
@FXML
private TableColumn<SumTableBean, String> tc_zrws;
@FXML
private TableColumn<SumTableBean, String> tc_rwh;
@FXML
private TableColumn<SumTableBean, String> tc_fqsj;
@FXML
private TableColumn<SumTableBean, String> tc_fqr;
@FXML
private TableColumn<SumTableBean, String> tc_status;
@FXML
private TableColumn<SumTableBean, Object> tc_log;
@FXML
private TableColumn<SumTableBean, String> tc_sapState;
@FXML
private TableColumn<SumTableBean, String> tc_plm;
@FXML
private TableColumn<SumTableBean, Object> tc_result;
@FXML
private TitledPane tp_sxtj;// 筛选条件pane
@FXML
private TitledPane rwtjPane; // 任务条件pane
@FXML
private GridPane gridPane; // 第一个pane插入日期控件
@FXML
private TextField tx_bh; // 文本 任务编号
@FXML
private ComboBox<String> cb_factory; // 工厂下拉
@FXML
private TextField tx_wbs; // wbs号
@FXML
private ComboBox<String> cb_status; // 数据状态
@FXML
private TextField tx_user;// 发起人
@FXML
private ComboBox<String> cb_sapState; // sap处理结果
@FXML
private TextField tx_projectName;// 项目名称
@FXML
private CheckBox bt_errTask;// 查询错误任务
@FXML
private CheckBox bt_errMsg; // 单个BOM错误信息
// 明细条件
@FXML
private ComboBox<String> tx_sapStatus;// sap数据状态
@FXML
private TextField tx_pcode;// 父物料编码
@FXML
private TextField tx_wbsMx;// wbs
@FXML
private TextField tx_sapReturn;// sap返回信息
@FXML
private TextField tx_batchNum;// 批次号
@FXML
private Button bt_wy; // 按钮尾页
@FXML
private Button bt_syy; // 上一页
@FXML
private Button bt_xyy;// 下一页
@FXML
private Button bt_sy;// 首页
@FXML
private Button bt_search;
@FXML
private TableView<SumTableBean> tableView;
// 全部关闭
@FXML
void clossAll(ActionEvent event) {
frame.dispose();
}
String getCombText(Object comb) {
String textVal = "";
if (comb instanceof TextField) {
textVal = ((TextField) comb).getText();
} else if (comb instanceof ComboBox) {
SingleSelectionModel<?> selectionModel = ((ComboBox<?>) comb).getSelectionModel();
if (selectionModel.getSelectedIndex() >= 0) {
textVal = ((ComboBox<?>) comb).getSelectionModel().getSelectedItem().toString();
}
} else if (comb instanceof CheckBox) {
boolean selected = ((CheckBox) comb).isSelected();
}
return textVal;
}
private int pageNum;// 分页显示当前第几页
private List<List<SumTableBean>> tableBeans = new ArrayList<List<SumTableBean>>();
// 查询操作
@FXML
void searchAction(ActionEvent event) {
// 拼接查询语句
StringBuilder sql = new StringBuilder(
"select \"CODE\",\"USER\",STARTTIME,\"NUMBER\",SAPRESULT,DATASTATUS,PLMRESULT,LOGURL from CHINT_BOM_TO_SAP_SUM where 1=1");
String code = getCombText(tx_bh);
if (!code.isEmpty()) {
sql.append(" and \"CODE\" = '").append(code).append("'");
}
String factory = getCombText(cb_factory);
if (!factory.isEmpty()) {
sql.append(" and factory = '").append(factory).append("'");
}
String wbsno = getCombText(tx_wbs);
if (!wbsno.isEmpty()) {
sql.append(" and wbsno = '").append(wbsno).append("'");
}
String datastatus = getCombText(cb_status);
if (!datastatus.isEmpty()) {
sql.append(" and datastatus = '").append(datastatus).append("'");
}
String user = getCombText(tx_user);
System.out.println("user==>" + user);
if (!user.isEmpty()) {
sql.append(" and \"USER\" = '").append(user).append("'");
}
String sapresult = getCombText(cb_sapState);
if (!sapresult.isEmpty()) {
sql.append(" and sapresult = '").append(sapresult).append("'");
}
String projectno = getCombText(tx_projectName);
if (!projectno.isEmpty()) {
sql.append(" and projectno = '").append(projectno).append("'");
}
if (bt_errTask.isSelected()) {
sql.append(" and SAPRESULT = '部分失败' ");
}
ObjectProperty<LocalDateTime> dateTimeProperty = dateTimeStart.dateTimeProperty();
if (dateTimeProperty != null && dateTimeProperty.get() != null) {
String startTime = dateTimeProperty.get().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
sql.append(" and starttime >= to_date('").append(startTime).append("','yyyy-mm-ddhh24:mi:ss') "); // to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("startTime==>" + startTime);
}
ObjectProperty<LocalDateTime> dateTimeProperty2 = dateTimeEnd.dateTimeProperty();
if (dateTimeProperty2 != null && dateTimeProperty2.get() != null) {
String endTime = dateTimeProperty2.get().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
sql.append(" and starttime <= to_date('").append(endTime).append("','yyyy-mm-ddhh24:mi:ss') "); // to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("endTime==>" + endTime);
}
// 拼接DETAILS表的SQL信息
StringBuilder detailSql = new StringBuilder("");
String batchNum = getCombText(tx_batchNum);
if (!batchNum.isEmpty()) {
detailSql.append(" and batchnumber = '").append(batchNum).append("'");
}
String wbsnoDetail = getCombText(tx_wbsMx);
if (!wbsnoDetail.isEmpty()) {
detailSql.append(" and wbsno = '").append(wbsnoDetail).append("'");
}
String message = getCombText(tx_sapReturn);
if (!message.isEmpty()) {
detailSql.append(" and message like '%").append(message).append("%'");
}
String productmaterialno = getCombText(tx_pcode);
if (!productmaterialno.isEmpty()) {
detailSql.append(" and productmaterialno like '%").append(productmaterialno).append("%'");
}
String status = getCombText(tx_sapStatus);
if (!status.isEmpty()) {
if (status.equals("成功")) {
status = "S";
} else {
status = "E";
}
detailSql.append(" and status = '").append(status).append("'");
}
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
SqlUtil.getTCDataConnection(prefs);
try {
tableBeans.clear();
sql.append(" order by \"CODE\" asc ");
System.out.println("read==>" + sql);
ResultSet read = SqlUtil.read(sql.toString());
int i = 1;
List<SumTableBean> beanList = null;
while (read.next()) {
// 分页 20 查询结果放入表格
System.out.println("read==>" + read.getInt(4));
SumTableBean sumBean = new SumTableBean(new SimpleIntegerProperty(i),
new SimpleStringProperty(String.valueOf(read.getInt(1))),
new SimpleStringProperty(read.getString(2)), new SimpleStringProperty(read.getString(3)),
new SimpleStringProperty(String.valueOf(read.getInt(4))),
new SimpleStringProperty(read.getString(5)), new SimpleStringProperty(read.getString(6)),
new SimpleStringProperty(read.getString(7)), bt_errMsg.isSelected(), detailSql, prefs, code,
read.getString(8));
if (i % 20 == 1) {
beanList = new ArrayList<SumTableBean>();
tableBeans.add(beanList);
}
beanList.add(sumBean);
i = i + 1;
}
if (tableBeans.size() == 0) {
MessageBox.post(frame,"未查询到传递记录.", "提示", 2);
beanList = new ArrayList<SumTableBean>();
tableBeans.add(beanList);
}
pageNum = 0;
System.out.println("beanList==>" + beanList.size());
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
} catch (Exception e) {
e.printStackTrace();
} finally {
SqlUtil.freeAll();
}
@FXML
private TitledPane tp_result;
@FXML
private Button bt_closeAll;
@FXML
private TitledPane mxtjPane;
@FXML
private GridPane bt_cx; // 按钮的pane
@FXML
private Button bt_close; // 关闭
@FXML
private Button bt_czcx;// 重置查询
@FXML
private StackPane stackPane;
// table的列
@FXML
private TableColumn<SumTableBean, String> tc_xh;
@FXML
private TableColumn<SumTableBean, String> tc_zrws;
@FXML
private TableColumn<SumTableBean, String> tc_rwh;
@FXML
private TableColumn<SumTableBean, String> tc_fqsj;
@FXML
private TableColumn<SumTableBean, String> tc_fqr;
@FXML
private TableColumn<SumTableBean, String> tc_status;
@FXML
private TableColumn<SumTableBean, Object> tc_log;
@FXML
private TableColumn<SumTableBean, String> tc_sapState;
@FXML
private TableColumn<SumTableBean, String> tc_plm;
@FXML
private TableColumn<SumTableBean, Object> tc_result;
@FXML
private TitledPane tp_sxtj;// 筛选条件pane
@FXML
private TitledPane rwtjPane; // 任务条件pane
@FXML
private GridPane gridPane; // 第一个pane插入日期控件
@FXML
private TextField tx_bh; // 文本 任务编号
@FXML
private ComboBox<String> cb_factory; // 工厂下拉
@FXML
private TextField tx_wbs; // wbs号
@FXML
private ComboBox<String> cb_status; // 数据状态
@FXML
private TextField tx_user;// 发起人
@FXML
private ComboBox<String> cb_sapState; // sap处理结果
@FXML
private TextField tx_projectName;// 项目名称
@FXML
private CheckBox bt_errTask;// 查询错误任务
@FXML
private CheckBox bt_errMsg; // 单个BOM错误信息
// 明细条件
@FXML
private ComboBox<String> tx_sapStatus;// sap数据状态
@FXML
private TextField tx_pcode;// 父物料编码
@FXML
private TextField tx_wbsMx;// wbs
@FXML
private TextField tx_sapReturn;// sap返回信息
@FXML
private TextField tx_batchNum;// 批次号
@FXML
private Button bt_wy; // 按钮尾页
@FXML
private Button bt_syy; // 上一页
@FXML
private Button bt_xyy;// 下一页
@FXML
private Button bt_sy;// 首页
@FXML
private Button bt_search;
@FXML
private TableView<SumTableBean> tableView;
// 全部关闭
@FXML
void clossAll(ActionEvent event) {
frame.dispose();
}
String getCombText(Object comb) {
String textVal = "";
if (comb instanceof TextField) {
textVal = ((TextField) comb).getText();
} else if (comb instanceof ComboBox) {
SingleSelectionModel<?> selectionModel = ((ComboBox<?>) comb).getSelectionModel();
if (selectionModel.getSelectedIndex() >= 0) {
textVal = ((ComboBox<?>) comb).getSelectionModel().getSelectedItem().toString();
}
} else if (comb instanceof CheckBox) {
boolean selected = ((CheckBox) comb).isSelected();
}
return textVal;
}
private int pageNum;// 分页显示当前第几页
private List<List<SumTableBean>> tableBeans = new ArrayList<List<SumTableBean>>();
// 查询操作
@FXML
void searchAction(ActionEvent event) {
// 拼接查询语句
StringBuilder sql = new StringBuilder(
"select \"CODE\",\"USER\",STARTTIME,\"NUMBER\",SAPRESULT,DATASTATUS,PLMRESULT,LOGURL from CHINT_BOM_TO_SAP_SUM where 1=1");
String code = getCombText(tx_bh);
if (!code.isEmpty()) {
sql.append(" and \"CODE\" = '").append(code).append("'");
}
String factory = getCombText(cb_factory);
if (!factory.isEmpty()) {
sql.append(" and factory = '").append(factory).append("'");
}
String wbsno = getCombText(tx_wbs);
if (!wbsno.isEmpty()) {
sql.append(" and wbsno = '").append(wbsno).append("'");
}
String datastatus = getCombText(cb_status);
if (!datastatus.isEmpty()) {
sql.append(" and datastatus = '").append(datastatus).append("'");
}
String user = getCombText(tx_user);
System.out.println("user==>" + user);
if (!user.isEmpty()) {
sql.append(" and \"USER\" = '").append(user).append("'");
}
String sapresult = getCombText(cb_sapState);
if (!sapresult.isEmpty()) {
sql.append(" and sapresult = '").append(sapresult).append("'");
}
String projectno = getCombText(tx_projectName);
if (!projectno.isEmpty()) {
sql.append(" and projectno = '").append(projectno).append("'");
}
if (bt_errTask.isSelected()) {
sql.append(" and SAPRESULT = '部分失败' ");
}
ObjectProperty<LocalDateTime> dateTimeProperty = dateTimeStart.dateTimeProperty();
if (dateTimeProperty != null && dateTimeProperty.get() != null) {
String startTime = dateTimeProperty.get().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
sql.append(" and starttime >= to_date('").append(startTime).append("','yyyy-mm-ddhh24:mi:ss') "); // to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("startTime==>" + startTime);
}
ObjectProperty<LocalDateTime> dateTimeProperty2 = dateTimeEnd.dateTimeProperty();
if (dateTimeProperty2 != null && dateTimeProperty2.get() != null) {
String endTime = dateTimeProperty2.get().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
sql.append(" and starttime <= to_date('").append(endTime).append("','yyyy-mm-ddhh24:mi:ss') "); // to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("endTime==>" + endTime);
}
// 拼接DETAILS表的SQL信息
StringBuilder detailSql = new StringBuilder("");
String batchNum = getCombText(tx_batchNum);
if (!batchNum.isEmpty()) {
detailSql.append(" and batchnumber = '").append(batchNum).append("'");
}
String wbsnoDetail = getCombText(tx_wbsMx);
if (!wbsnoDetail.isEmpty()) {
detailSql.append(" and wbsno = '").append(wbsnoDetail).append("'");
}
String message = getCombText(tx_sapReturn);
if (!message.isEmpty()) {
detailSql.append(" and message like '%").append(message).append("%'");
}
String productmaterialno = getCombText(tx_pcode);
if (!productmaterialno.isEmpty()) {
detailSql.append(" and productmaterialno like '%").append(productmaterialno).append("%'");
}
String status = getCombText(tx_sapStatus);
if (!status.isEmpty()) {
if (status.equals("成功")) {
status = "S";
} else {
status = "E";
}
detailSql.append(" and status = '").append(status).append("'");
}
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
SqlUtil.getTCDataConnection(prefs);
try {
tableBeans.clear();
sql.append(" order by \"CODE\" asc ");
System.out.println("read==>" + sql);
ResultSet read = SqlUtil.read(sql.toString());
int i = 1;
List<SumTableBean> beanList = null;
while (read.next()) {
// 分页 20 查询结果放入表格
System.out.println("read==>" + read.getInt(4));
SumTableBean sumBean = new SumTableBean(new SimpleIntegerProperty(i),
new SimpleStringProperty(String.valueOf(read.getInt(1))),
new SimpleStringProperty(read.getString(2)), new SimpleStringProperty(read.getString(3)),
new SimpleStringProperty(String.valueOf(read.getInt(4))),
new SimpleStringProperty(read.getString(5)), new SimpleStringProperty(read.getString(6)),
new SimpleStringProperty(read.getString(7)), bt_errMsg.isSelected(), detailSql, prefs, code,
read.getString(8));
if (i % 20 == 1) {
beanList = new ArrayList<SumTableBean>();
tableBeans.add(beanList);
}
beanList.add(sumBean);
i = i + 1;
}
if (tableBeans.size() == 0) {
MessageBox.post(frame, "未查询到传递记录.", "提示", 2);
beanList = new ArrayList<SumTableBean>();
tableBeans.add(beanList);
}
pageNum = 0;
System.out.println("beanList==>" + beanList.size());
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
} catch (Exception e) {
e.printStackTrace();
} finally {
SqlUtil.freeAll();
}
// if(bt_errMsg)
}
@FXML
private ScrollPane scrollPane;
@FXML
private BorderPane resultBorder;
@FXML
private BorderPane topBorder;
private SapResultFrame frame;
private DateTimePicker dateTimeStart;
private DateTimePicker dateTimeEnd;
protected AbstractAIFApplication app;
private TCSession session;
@Override
public void initData(KFXPanel paramKFXPanel) throws Exception {
// TODO Auto-generated method stub
frame = (SapResultFrame) paramKFXPanel.getParentDialog();
addWindListener(frame);
frame.setMaximumSize(frame.getMaximumSize());
System.out.println("frame==>" + frame);
this.app = AIFUtility.getCurrentApplication();
this.session = (TCSession) app.getSession();
dateTimeStart = new DateTimePicker();
dateTimeEnd = new DateTimePicker();
gridPane.add(dateTimeStart, 1, 3);
gridPane.add(dateTimeEnd, 1, 4);
initCombox();
// 表格列绑定bean对象
tc_xh.setSortable(false);
tc_zrws.setSortable(false);
tc_rwh.setSortable(false);
tc_fqsj.setSortable(false);
tc_fqr.setSortable(false);
tc_status.setSortable(false);
tc_log.setSortable(false);
tc_sapState.setSortable(false);
tc_plm.setSortable(false);
tc_result.setSortable(false);
// 列绑定bean对象
tc_xh.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("num"));
tc_zrws.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("cTaskNum"));// cTaskNum
tc_rwh.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("taskNo"));
tc_fqsj.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("startTime"));
tc_fqr.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("user"));
tc_status.setCellValueFactory(new PropertyValueFactory<>("dataStatus"));
tc_log.setCellValueFactory(new PropertyValueFactory<SumTableBean, Object>("logDownload"));
tc_sapState.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("sapResult"));
tc_plm.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("plmResult"));
tc_result.setCellValueFactory(new PropertyValueFactory<SumTableBean, Object>("details"));
tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.05));
tc_zrws.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
tc_rwh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
tc_fqsj.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_fqr.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_status.prefWidthProperty().bind(tableView.widthProperty().multiply(0.15));
tc_log.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_sapState.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_plm.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_result.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tp_result.setCollapsible(false);
mxtjPane.setCollapsible(false);
tp_sxtj.setCollapsible(false);
rwtjPane.setCollapsible(false);
tc_sapState.setCellFactory(column -> {
return new TableCell<SumTableBean, String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty && !item.isEmpty()) {
}
@FXML
private ScrollPane scrollPane;
@FXML
private BorderPane resultBorder;
@FXML
private BorderPane topBorder;
private SapResultFrame frame;
private DateTimePicker dateTimeStart;
private DateTimePicker dateTimeEnd;
protected AbstractAIFApplication app;
private TCSession session;
@Override
public void initData(KFXPanel paramKFXPanel) throws Exception {
// TODO Auto-generated method stub
frame = (SapResultFrame) paramKFXPanel.getParentDialog();
addWindListener(frame);
frame.setMaximumSize(frame.getMaximumSize());
System.out.println("frame==>" + frame);
this.app = AIFUtility.getCurrentApplication();
this.session = (TCSession) app.getSession();
dateTimeStart = new DateTimePicker();
dateTimeEnd = new DateTimePicker();
gridPane.add(dateTimeStart, 1, 3);
gridPane.add(dateTimeEnd, 1, 4);
initCombox();
// 表格列绑定bean对象
tc_xh.setSortable(false);
tc_zrws.setSortable(false);
tc_rwh.setSortable(false);
tc_fqsj.setSortable(false);
tc_fqr.setSortable(false);
tc_status.setSortable(false);
tc_log.setSortable(false);
tc_sapState.setSortable(false);
tc_plm.setSortable(false);
tc_result.setSortable(false);
// 列绑定bean对象
tc_xh.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("num"));
tc_zrws.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("cTaskNum"));// cTaskNum
tc_rwh.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("taskNo"));
tc_fqsj.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("startTime"));
tc_fqr.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("user"));
tc_status.setCellValueFactory(new PropertyValueFactory<>("dataStatus"));
tc_log.setCellValueFactory(new PropertyValueFactory<SumTableBean, Object>("logDownload"));
tc_sapState.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("sapResult"));
tc_plm.setCellValueFactory(new PropertyValueFactory<SumTableBean, String>("plmResult"));
tc_result.setCellValueFactory(new PropertyValueFactory<SumTableBean, Object>("details"));
tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.05));
tc_zrws.prefWidthProperty().bind(tableView.widthProperty().multiply(0.08));
tc_rwh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
tc_fqsj.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_fqr.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_status.prefWidthProperty().bind(tableView.widthProperty().multiply(0.15));
tc_log.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_sapState.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_plm.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tc_result.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
tp_result.setCollapsible(false);
mxtjPane.setCollapsible(false);
tp_sxtj.setCollapsible(false);
rwtjPane.setCollapsible(false);
tc_sapState.setCellFactory(column -> {
return new TableCell<SumTableBean, String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty && !item.isEmpty()) {
// double contrastPrice = Double.parseDouble(item);
if (item.equals("未返回")) {
// 不做格式
setStyle("-fx-background-color: #ffff99;");
} else if (item.equals("部分失败")) {
setStyle("-fx-background-color: #FF6600;");
} else {
setStyle("-fx-background-color: #A9D08E;");
}
setText(getItem());
setAlignment(Pos.CENTER); // 设置单元格内容居中对齐
} else {
setStyle("");
setText(empty ? null : getItem());
setAlignment(Pos.CENTER); // 设置单元格内容居中对齐
}
}
};
});
if (item.equals("未返回")) {
// 不做格式
setStyle("-fx-background-color: #ffff99;");
} else if (item.equals("部分失败")) {
setStyle("-fx-background-color: #FF6600;");
} else {
setStyle("-fx-background-color: #A9D08E;");
}
setText(getItem());
setAlignment(Pos.CENTER); // 设置单元格内容居中对齐
} else {
setStyle("");
setText(empty ? null : getItem());
setAlignment(Pos.CENTER); // 设置单元格内容居中对齐
}
}
};
});
// tableView.setMaxHeight(pageNum);
}
// 初始化下拉框内容
private void initCombox() {
// TODO Auto-generated method stub
List<String> factoryList = new ArrayList<String>();
factoryList.add("M040");
cb_factory.getItems().addAll(factoryList);
List<String> statusList = new ArrayList<String>();
statusList.add("数据检查未通过");
statusList.add("数据正常推送SAP");
statusList.add("数据未正常推送SAP");
cb_status.getItems().addAll(statusList);
List<String> sapStateList = new ArrayList<String>();
sapStateList.add("PLM数据检查未通过");
sapStateList.add("未返回");
sapStateList.add("处理中");
sapStateList.add("全部成功");
sapStateList.add("部分失败");
cb_sapState.getItems().addAll(sapStateList);
List<String> sapStatusList = new ArrayList<String>();
sapStatusList.add("成功");
sapStatusList.add("失败");
tx_sapStatus.getItems().addAll(sapStatusList);
}
// 跳转首页
@FXML
void firstBtnAction(ActionEvent event) {
pageNum = 0;
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
}
// 跳转上一页
@FXML
void lastBtnAction(ActionEvent event) {
if (pageNum > 0) {
pageNum = pageNum - 1;
}
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
// 跳转下一页
@FXML
void nextBtnAction(ActionEvent event) {
if (pageNum < tableBeans.size() - 1) {
pageNum = pageNum + 1;
}
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
// 跳转尾页
@FXML
void tailBtnAction(ActionEvent event) {
pageNum = tableBeans.size() - 1;
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
/**
* @param frame
* @function
*/
private void addWindListener(SapResultFrame frame) {
// TODO Auto-generated method stub
frame.addComponentListener(new ComponentListener() {
@Override
public void componentShown(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentResized(ComponentEvent e) {
// TODO Auto-generated method stub
}
// 初始化下拉框内容
private void initCombox() {
// TODO Auto-generated method stub
List<String> factoryList = new ArrayList<String>();
factoryList.add("M040");
cb_factory.getItems().addAll(factoryList);
List<String> statusList = new ArrayList<String>();
statusList.add("数据检查未通过");
statusList.add("数据正常推送SAP");
statusList.add("数据未正常推送SAP");
cb_status.getItems().addAll(statusList);
List<String> sapStateList = new ArrayList<String>();
sapStateList.add("PLM数据检查未通过");
sapStateList.add("未返回");
sapStateList.add("处理中");
sapStateList.add("全部成功");
sapStateList.add("部分失败");
cb_sapState.getItems().addAll(sapStateList);
List<String> sapStatusList = new ArrayList<String>();
sapStatusList.add("成功");
sapStatusList.add("失败");
tx_sapStatus.getItems().addAll(sapStatusList);
}
// 跳转首页
@FXML
void firstBtnAction(ActionEvent event) {
pageNum = 0;
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(0));
tableView.getItems().clear();
tableView.setItems(data);
}
// 跳转上一页
@FXML
void lastBtnAction(ActionEvent event) {
if (pageNum > 0) {
pageNum = pageNum - 1;
}
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
// 跳转下一页
@FXML
void nextBtnAction(ActionEvent event) {
if (pageNum < tableBeans.size() - 1) {
pageNum = pageNum + 1;
}
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
// 跳转尾页
@FXML
void tailBtnAction(ActionEvent event) {
pageNum = tableBeans.size() - 1;
ObservableList<SumTableBean> data = FXCollections.observableArrayList(tableBeans.get(pageNum));
tableView.getItems().clear();
tableView.setItems(data);
}
/**
* @param frame
* @function
*/
private void addWindListener(SapResultFrame frame) {
// TODO Auto-generated method stub
frame.addComponentListener(new ComponentListener() {
@Override
public void componentShown(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentResized(ComponentEvent e) {
// TODO Auto-generated method stub
// System.out.println("==============");
Component component = e.getComponent();
System.out.println("component==>" + component);
double width = component.getSize().getWidth();
Component component = e.getComponent();
System.out.println("component==>" + component);
double width = component.getSize().getWidth();
// // double width = primaryStage.getWidth();
System.out.println("width==>" + width);
scrollPane.setPrefWidth(width * 0.98);
topBorder.setPrefWidth(width * 0.98);
tp_sxtj.setPrefWidth(width * 0.98);
resultBorder.setPrefWidth(width * 0.98);
gridPane.setPrefWidth(width * 0.98);
tableView.setPrefWidth(width * 0.97);
System.out.println("width==>" + width);
scrollPane.setPrefWidth(width * 0.98);
topBorder.setPrefWidth(width * 0.98);
tp_sxtj.setPrefWidth(width * 0.98);
resultBorder.setPrefWidth(width * 0.98);
gridPane.setPrefWidth(width * 0.98);
tableView.setPrefWidth(width * 0.97);
// refTable.setPrefWidth(width * 0.97);
}
@Override
public void componentMoved(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentHidden(ComponentEvent e) {
// TODO Auto-generated method stub
}
});
}
@FXML
void resetClick(ActionEvent event) {
tx_bh.setText("");
cb_sapState.getSelectionModel().clearSelection();
cb_factory.getSelectionModel().clearSelection();
tx_user.setText("");
tx_wbs.setText("");
tx_projectName.setText("");
tx_pcode.setText("");
tx_wbsMx.setText("");
tx_batchNum.setText("");
tx_sapReturn.setText("");
cb_status.getSelectionModel().clearSelection();
tx_sapStatus.getSelectionModel().clearSelection();
bt_errTask.setSelected(false);
bt_errMsg.setSelected(false);
dateTimeStart.clearTimeProperty();
dateTimeEnd.clearTimeProperty();
}
@FXML
void closeClick(ActionEvent event) {
frame.dispose();
}
}
@Override
public void componentMoved(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentHidden(ComponentEvent e) {
// TODO Auto-generated method stub
}
});
}
@FXML
void resetClick(ActionEvent event) {
tx_bh.setText("");
cb_sapState.getSelectionModel().clearSelection();
cb_factory.getSelectionModel().clearSelection();
tx_user.setText("");
tx_wbs.setText("");
tx_projectName.setText("");
tx_pcode.setText("");
tx_wbsMx.setText("");
tx_batchNum.setText("");
tx_sapReturn.setText("");
cb_status.getSelectionModel().clearSelection();
tx_sapStatus.getSelectionModel().clearSelection();
bt_errTask.setSelected(false);
bt_errMsg.setSelected(false);
dateTimeStart.clearTimeProperty();
dateTimeEnd.clearTimeProperty();
}
@FXML
void closeClick(ActionEvent event) {
frame.dispose();
}
}

@ -6,16 +6,16 @@ import com.teamcenter.rac.aif.AbstractAIFApplication;
public class SearchSapResultComd extends KCommand {
private boolean top = true;
public SearchSapResultComd(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
new SapResultFrame();
}catch(Exception e) {
e.printStackTrace();
}
}
private boolean top = true;
public SearchSapResultComd(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
new SapResultFrame();
} catch (Exception e) {
e.printStackTrace();
}
}
// public DesignChangeCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
// super(app, commandId, actionInfo);
// new DesignChangeFrame(new DesignChangeDialogController());

@ -13,131 +13,154 @@ import javafx.scene.control.Button;
import javafx.stage.Stage;
public class SumTableBean {
//序 号
protected SimpleIntegerProperty num;
//任务号
protected SimpleStringProperty taskNo;
//发起人
protected SimpleStringProperty user;
//发起时间
protected SimpleStringProperty startTime;
//子任务数
protected SimpleStringProperty cTaskNum;
//SAP处理结果
protected SimpleStringProperty sapResult;
//数据状态
protected SimpleStringProperty dataStatus;
//PLM处理进度
protected SimpleStringProperty plmResult;
//结果明细
protected Button details = new Button();
protected Button logDownload = new Button();
private boolean onlyError;
private StringBuilder detailSql;
public Button getDetails() {
return details;
}
public Button getLogDownload() {
return logDownload;
}
public void setLogDownload(Button logDownload) {
this.logDownload = logDownload;
}
public void setDetails(Button details) {
this.details = details;
}
public Integer getNum() {
return num.get();
}
public void setNum(SimpleIntegerProperty num) {
this.num = num;
}
public String getTaskNo() {
return taskNo.get();
}
public void setTaskNo(SimpleStringProperty taskNo) {
this.taskNo = taskNo;
}
public String getUser() {
return user.get();
}
public void setUser(SimpleStringProperty user) {
this.user = user;
}
public String getStartTime() {
return startTime.get();
}
public void setStartTime(SimpleStringProperty startTime) {
this.startTime = startTime;
}
public String getcTaskNum() {
return cTaskNum.get();
}
public void setcTaskNum(SimpleStringProperty cTaskNum) {
this.cTaskNum = cTaskNum;
}
public String getSapResult() {
return sapResult.get();
}
public void setSapResult(SimpleStringProperty sapResult) {
this.sapResult = sapResult;
}
public String getDataStatus() {
return dataStatus.get();
}
public void setDataStatus(SimpleStringProperty dataStatus) {
this.dataStatus = dataStatus;
}
public String getPlmResult() {
return plmResult.get();
}
public void setPlmResult(SimpleStringProperty plmResult) {
this.plmResult = plmResult;
}
private String url;
private String code;
private String[] prefs;
public SumTableBean(SimpleIntegerProperty num, SimpleStringProperty taskNo, SimpleStringProperty user,
SimpleStringProperty startTime, SimpleStringProperty cTaskNum, SimpleStringProperty sapResult,
SimpleStringProperty dataStatus, SimpleStringProperty plmResult,boolean onlyError,StringBuilder detailSql,
String[] prefs,String code,String url) {
super();
this.num = num;
this.taskNo = taskNo;
this.user = user;
this.startTime = startTime;
this.cTaskNum = cTaskNum;
this.sapResult = sapResult;
this.dataStatus = dataStatus;
this.plmResult = plmResult;
this.onlyError = onlyError;
this.detailSql = detailSql;
this.code = taskNo.get();
this.prefs = prefs;
this.url = url;
details.setText("查看明细");
logDownload.setText("日志下载");
logDownload.setOnAction(e -> {
try {
if(!url.isEmpty()) {
String replaceAll = url.replaceAll("\n","").replaceAll("\r", "");
System.out.println(replaceAll);
BomToSapUtil.browse2(replaceAll);
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}); // 此按钮没有加入到图形中
details.setOnAction(e -> {
System.out.println("Process print = "+this.taskNo+" onlyError = "+this.onlyError);
StringBuilder sqlTotal = new StringBuilder("select batchnumber,productmaterialno,WBSNO,status,message,createdate,createtime,returndate,returntime,"
+ "PLMSTATUS from CHINT_BOM_TO_SAP_DETIALS where \"CODE\" = '");
// 序 号
protected SimpleIntegerProperty num;
// 任务号
protected SimpleStringProperty taskNo;
// 发起人
protected SimpleStringProperty user;
// 发起时间
protected SimpleStringProperty startTime;
// 子任务数
protected SimpleStringProperty cTaskNum;
// SAP处理结果
protected SimpleStringProperty sapResult;
// 数据状态
protected SimpleStringProperty dataStatus;
// PLM处理进度
protected SimpleStringProperty plmResult;
// 结果明细
protected Button details = new Button();
protected Button logDownload = new Button();
private boolean onlyError;
private StringBuilder detailSql;
public Button getDetails() {
return details;
}
public Button getLogDownload() {
return logDownload;
}
public void setLogDownload(Button logDownload) {
this.logDownload = logDownload;
}
public void setDetails(Button details) {
this.details = details;
}
public Integer getNum() {
return num.get();
}
public void setNum(SimpleIntegerProperty num) {
this.num = num;
}
public String getTaskNo() {
return taskNo.get();
}
public void setTaskNo(SimpleStringProperty taskNo) {
this.taskNo = taskNo;
}
public String getUser() {
return user.get();
}
public void setUser(SimpleStringProperty user) {
this.user = user;
}
public String getStartTime() {
return startTime.get();
}
public void setStartTime(SimpleStringProperty startTime) {
this.startTime = startTime;
}
public String getcTaskNum() {
return cTaskNum.get();
}
public void setcTaskNum(SimpleStringProperty cTaskNum) {
this.cTaskNum = cTaskNum;
}
public String getSapResult() {
return sapResult.get();
}
public void setSapResult(SimpleStringProperty sapResult) {
this.sapResult = sapResult;
}
public String getDataStatus() {
return dataStatus.get();
}
public void setDataStatus(SimpleStringProperty dataStatus) {
this.dataStatus = dataStatus;
}
public String getPlmResult() {
return plmResult.get();
}
public void setPlmResult(SimpleStringProperty plmResult) {
this.plmResult = plmResult;
}
private String url;
private String code;
private String[] prefs;
public SumTableBean(SimpleIntegerProperty num, SimpleStringProperty taskNo, SimpleStringProperty user,
SimpleStringProperty startTime, SimpleStringProperty cTaskNum, SimpleStringProperty sapResult,
SimpleStringProperty dataStatus, SimpleStringProperty plmResult, boolean onlyError, StringBuilder detailSql,
String[] prefs, String code, String url) {
super();
this.num = num;
this.taskNo = taskNo;
this.user = user;
this.startTime = startTime;
this.cTaskNum = cTaskNum;
this.sapResult = sapResult;
this.dataStatus = dataStatus;
this.plmResult = plmResult;
this.onlyError = onlyError;
this.detailSql = detailSql;
this.code = taskNo.get();
this.prefs = prefs;
this.url = url;
details.setText("查看明细");
logDownload.setText("日志下载");
logDownload.setOnAction(e -> {
try {
if (!url.isEmpty()) {
String replaceAll = url.replaceAll("\n", "").replaceAll("\r", "");
System.out.println(replaceAll);
BomToSapUtil.browse2(replaceAll);
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}); // 此按钮没有加入到图形中
details.setOnAction(e -> {
System.out.println("Process print = " + this.taskNo + " onlyError = " + this.onlyError);
StringBuilder sqlTotal = new StringBuilder(
"select batchnumber,productmaterialno,WBSNO,status,message,createdate,createtime,returndate,returntime,"
+ "PLMSTATUS from CHINT_BOM_TO_SAP_DETIALS where \"CODE\" = '");
sqlTotal.append(this.code).append("' ");
sqlTotal.append(this.detailSql);
try {
//单个BOM具体信息 : 全部状态.
// 单个BOM具体信息 : 全部状态.
// List<List<DetailsBean>> tableBeans = new ArrayList<List<DetailsBean>>();
// SqlUtil.getTCDataConnection(prefs);
// String sqlDetail = "";
@ -166,17 +189,17 @@ public class SumTableBean {
// }
//
// SqlUtil.freeAll();
ChildMessage open = new ChildMessage(this.onlyError,sqlTotal);
ChildMessage open = new ChildMessage(this.onlyError, sqlTotal);
open.start(new Stage());
}catch(Exception ex){
ex.printStackTrace();
}finally {
System.out.println("END"+sqlTotal.toString());
SqlUtil.freeAll();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
System.out.println("END" + sqlTotal.toString());
SqlUtil.freeAll();
}
}); // 此按钮没有加入到图形中
// BomToSapUtil.downLoadTest(code);
}
}
}

@ -27,223 +27,223 @@ import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class AssignIdController {
private String groupID;
private TCSession session;
private TextField field;
private TCComponent tar;
private boolean flag;
@FXML
private Button assignBtn;
private Button assignBtnTop; // 变更管理中的指派按钮
@FXML
private TextField ylText;
private String groupID;
private TCSession session;
private TextField field;
private TCComponent tar;
private boolean flag;
@FXML
private Button assignBtn;
private Button assignBtnTop; // 变更管理中的指派按钮
@FXML
private TextField ylText;
@FXML
private Button closeBtn;
@FXML
private Button closeBtn;
@FXML
private ComboBox<String> bmComb;
@FXML
private ComboBox<String> bmComb;
@FXML
private ComboBox<String> factoryComb;
@FXML
private ComboBox<String> factoryComb;
/**
* @param session
* @param groupID ID
* @param field
* @param tar
* @param flag
* @param assignBtn
* @function
*/
public void initData(TCSession session, String groupID, TextField field, TCComponent tar, boolean flag,
Button assignBtn) {
// TODO Auto-generated method stub
this.groupID = groupID;
this.session = session;
this.field = field;
this.flag = flag;
this.tar = tar;
this.assignBtnTop = assignBtn;
getCombox();
}
/**
* @param session
* @param groupID ID
* @param field
* @param tar
* @param flag
* @param assignBtn
* @function
*/
public void initData(TCSession session, String groupID, TextField field, TCComponent tar, boolean flag,
Button assignBtn) {
// TODO Auto-generated method stub
this.groupID = groupID;
this.session = session;
this.field = field;
this.flag = flag;
this.tar = tar;
this.assignBtnTop = assignBtn;
getCombox();
}
@FXML
void okBtnClick(ActionEvent event) {
SimpleDateFormat sdf = new SimpleDateFormat("yy");
String year = sdf.format(new Date());
String fac = factoryComb.getSelectionModel().getSelectedItem();
String off = bmComb.getSelectionModel().getSelectedItem();
if (off.equals("-")) {
off = "";
}
String TF = "";
/// if(1==1)
// return;
if (flag) { // 临时
TF = "L";
} else { // if (TF.trim().equals("正式更改通知单"))
TF = "";
}
String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF;
String flow = searchWord;
Connection conn = null;
conn = util.connect(conn, session);
String query = "select FLOW from CHINT_ECN_CODE where CODE='" + searchWord + "'";
System.out.println(query);
@FXML
void okBtnClick(ActionEvent event) {
SimpleDateFormat sdf = new SimpleDateFormat("yy");
String year = sdf.format(new Date());
String fac = factoryComb.getSelectionModel().getSelectedItem();
String off = bmComb.getSelectionModel().getSelectedItem();
if (off.equals("-")) {
off = "";
}
String TF = "";
/// if(1==1)
// return;
if (flag) { // 临时
TF = "L";
} else { // if (TF.trim().equals("正式更改通知单"))
TF = "";
}
String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF;
String flow = searchWord;
Connection conn = null;
conn = util.connect(conn, session);
String query = "select FLOW from CHINT_ECN_CODE where CODE='" + searchWord + "'";
System.out.println(query);
Statement stmt;
ResultSet rs_get;
try {
stmt = conn.createStatement();
rs_get = null;
rs_get = stmt.executeQuery(query);
if (rs_get.next()) {
String FLOW = rs_get.getString("FLOW");
flow = flow + FLOW;
FLOW = String.format("%04d", Integer.valueOf(FLOW) + 1);
query = "update CHINT_ECN_CODE set FLOW='" + FLOW + "' where CODE='" + searchWord + "'";
} else {
query = "insert into CHINT_ECN_CODE (FACTORY,OFFICE,CODE,FLOW) VALUES('" + fac + "','" + off + "','"
+ searchWord + "','0002')";
// query = "insert into CHINT_ECN_CODE (FACTORY,OFFICE,CODE,FLOW) VALUES('" +
// fac + "','" + off
// + "','" + searchWord + "','0002')";
Statement stmt;
ResultSet rs_get;
try {
stmt = conn.createStatement();
rs_get = null;
rs_get = stmt.executeQuery(query);
if (rs_get.next()) {
String FLOW = rs_get.getString("FLOW");
flow = flow + FLOW;
FLOW = String.format("%04d", Integer.valueOf(FLOW) + 1);
query = "update CHINT_ECN_CODE set FLOW='" + FLOW + "' where CODE='" + searchWord + "'";
} else {
query = "insert into CHINT_ECN_CODE (FACTORY,OFFICE,CODE,FLOW) VALUES('" + fac + "','" + off + "','"
+ searchWord + "','0002')";
// query = "insert into CHINT_ECN_CODE (FACTORY,OFFICE,CODE,FLOW) VALUES('" +
// fac + "','" + off
// + "','" + searchWord + "','0002')";
flow = flow + "0001";
}
field.setText(flow);
System.out.println(query);
if (rs_get != null) {
rs_get.close();
}
rs_get = stmt.executeQuery(query);
flow = flow + "0001";
}
field.setText(flow);
System.out.println(query);
if (rs_get != null) {
rs_get.close();
}
rs_get = stmt.executeQuery(query);
util.disconnect(conn, stmt, rs_get);
} catch (SQLException e1) {
e1.printStackTrace();
}
assignBtnTop.setDisable(true);// 只能指派一次
assignBtn.setDisable(true);// 只能指派一次
Stage stage = (Stage) closeBtn.getScene().getWindow();
stage.close();
}
util.disconnect(conn, stmt, rs_get);
} catch (SQLException e1) {
e1.printStackTrace();
}
assignBtnTop.setDisable(true);// 只能指派一次
assignBtn.setDisable(true);// 只能指派一次
Stage stage = (Stage) closeBtn.getScene().getWindow();
stage.close();
}
@FXML
void cancelBtnClick(ActionEvent event) {
Stage stage = (Stage) closeBtn.getScene().getWindow();
stage.close();
}
@FXML
void cancelBtnClick(ActionEvent event) {
Stage stage = (Stage) closeBtn.getScene().getWindow();
stage.close();
}
@FXML
void selectDepart(ActionEvent event) {
@FXML
void selectDepart(ActionEvent event) {
}
}
@FXML
void selectFactory(ActionEvent event) {
@FXML
void selectFactory(ActionEvent event) {
}
}
/**
*
* @function
*/
public void getCombox() {
// 根据首选项获取工厂和部门
String[] FO = session.getPreferenceService().getStringValues("CHINT_FAC_OFF");
List<String> facList = new ArrayList<>();
String first_FO = "";
final Map<String, List<String>> foMap = new HashMap<>();
for (int i = 0; i < FO.length; i++) {
/**
*
* @function
*/
public void getCombox() {
// 根据首选项获取工厂和部门
String[] FO = session.getPreferenceService().getStringValues("CHINT_FAC_OFF");
List<String> facList = new ArrayList<>();
String first_FO = "";
final Map<String, List<String>> foMap = new HashMap<>();
for (int i = 0; i < FO.length; i++) {
String group = FO[i].split(":")[0];
if (group.indexOf("|") != -1) {
if (group.split("\\|")[0].equals(groupID)) {
first_FO = group.split("\\|")[1];
}
group = group.split("\\|")[1];
}
// facList.add(FO[i].split(":")[0]);
facList.add(group);
List<String> list = new ArrayList<>();
String[] offices = FO[i].split(":")[1].split(";");
for (int j = 0; j < offices.length; j++) {
list.add(offices[j]);
}
// foMap.put(FO[i].split(":")[0], list);
foMap.put(group, list);
}
// 初始化下拉框的逻辑
factoryComb.getItems().addAll(facList);
factoryComb.getSelectionModel().select(first_FO);
// 添加监听 动态设置下拉框内容
factoryComb.valueProperty().addListener((obs, oldVal, newVal) -> {
System.out.println("选择了:" + newVal);
String index = factoryComb.getSelectionModel().getSelectedItem();
List<String> vector = foMap.get(index);
bmComb.getItems().clear();
bmComb.getItems().addAll(vector);
if (vector.size() == 1 && vector.get(0).equals("-")) {
bmComb.setVisible(false);
} else {
bmComb.setVisible(true);
}
});
String group = FO[i].split(":")[0];
if (group.indexOf("|") != -1) {
if (group.split("\\|")[0].equals(groupID)) {
first_FO = group.split("\\|")[1];
}
group = group.split("\\|")[1];
}
// facList.add(FO[i].split(":")[0]);
facList.add(group);
List<String> list = new ArrayList<>();
String[] offices = FO[i].split(":")[1].split(";");
for (int j = 0; j < offices.length; j++) {
list.add(offices[j]);
}
// foMap.put(FO[i].split(":")[0], list);
foMap.put(group, list);
}
// 初始化下拉框的逻辑
factoryComb.getItems().addAll(facList);
factoryComb.getSelectionModel().select(first_FO);
// 添加监听 动态设置下拉框内容
factoryComb.valueProperty().addListener((obs, oldVal, newVal) -> {
System.out.println("选择了:" + newVal);
String index = factoryComb.getSelectionModel().getSelectedItem();
List<String> vector = foMap.get(index);
bmComb.getItems().clear();
bmComb.getItems().addAll(vector);
if (vector.size() == 1 && vector.get(0).equals("-")) {
bmComb.setVisible(false);
} else {
bmComb.setVisible(true);
}
});
List<String> init = foMap.get(factoryComb.getSelectionModel().getSelectedItem());
bmComb.getItems().addAll(init);
List<String> init = foMap.get(factoryComb.getSelectionModel().getSelectedItem());
bmComb.getItems().addAll(init);
// 添加监听 预览信息
bmComb.valueProperty().addListener((obs, oldVal, newVal) -> {
System.out.println("选择了:" + newVal);
SimpleDateFormat sdf = new SimpleDateFormat("yy");
String year = sdf.format(new Date());
String fac = factoryComb.getSelectionModel().getSelectedItem();
String off = bmComb.getSelectionModel().getSelectedItem();
if (off.equals("-")) {
off = "";
}
String TF = "";
if (flag) { // 临时
TF = "L";
} else { // if (TF.trim().equals("正式更改通知单"))
TF = "";
}
String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF;
String flow = searchWord;
Connection conn = null;
conn = util.connect(conn, session);
String query = "select FLOW from CHINT_ECN_CODE where CODE='" + searchWord + "'";
System.out.println(query);
// 添加监听 预览信息
bmComb.valueProperty().addListener((obs, oldVal, newVal) -> {
System.out.println("选择了:" + newVal);
SimpleDateFormat sdf = new SimpleDateFormat("yy");
String year = sdf.format(new Date());
String fac = factoryComb.getSelectionModel().getSelectedItem();
String off = bmComb.getSelectionModel().getSelectedItem();
if (off.equals("-")) {
off = "";
}
String TF = "";
if (flag) { // 临时
TF = "L";
} else { // if (TF.trim().equals("正式更改通知单"))
TF = "";
}
String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF;
String flow = searchWord;
Connection conn = null;
conn = util.connect(conn, session);
String query = "select FLOW from CHINT_ECN_CODE where CODE='" + searchWord + "'";
System.out.println(query);
Statement stmt;
ResultSet rs_get;
try {
stmt = conn.createStatement();
rs_get = null;
rs_get = stmt.executeQuery(query);
if (rs_get.next()) {
String FLOW = rs_get.getString("FLOW");
flow = flow + FLOW;
FLOW = String.format("%04d", Integer.valueOf(FLOW) + 1);
} else {
flow = flow + "0001";
}
ylText.setText(flow);
System.out.println(query);
if (rs_get != null) {
rs_get.close();
}
Statement stmt;
ResultSet rs_get;
try {
stmt = conn.createStatement();
rs_get = null;
rs_get = stmt.executeQuery(query);
if (rs_get.next()) {
String FLOW = rs_get.getString("FLOW");
flow = flow + FLOW;
FLOW = String.format("%04d", Integer.valueOf(FLOW) + 1);
} else {
flow = flow + "0001";
}
ylText.setText(flow);
System.out.println(query);
if (rs_get != null) {
rs_get.close();
}
util.disconnect(conn, stmt, rs_get);
} catch (SQLException e1) {
e1.printStackTrace();
}
});
util.disconnect(conn, stmt, rs_get);
} catch (SQLException e1) {
e1.printStackTrace();
}
});
// comBoxOffice = new JComboBox(new DefaultComboBoxModel<String>(init.toArray(new String[init.size()])));
System.out.println("first_FO:" + first_FO);
System.out.println("first_FO:" + first_FO);
// if (tar.getType().equals("ZT2_Change")) {
// String[] fo = null;
// try {
@ -261,7 +261,7 @@ public class AssignIdController {
// } else {
//
// }
}
}
private Util util = new Util();
private Util util = new Util();
}

@ -36,36 +36,36 @@ import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class AssignIdDialog extends Application {
private String groupID;
private TCSession session;
private TextField field;
private TCComponent tar;
private Button assignBtn;
private boolean flag;
private String groupID;
private TCSession session;
private TextField field;
private TCComponent tar;
private Button assignBtn;
private boolean flag;
public AssignIdDialog(TCSession session, String groupID, TextField field, TCComponent tar, boolean flag,
Button assignBtn) {
super();
this.groupID = groupID;
this.session = session;
this.field = field;
this.tar = tar;
this.flag = flag;
this.assignBtn = assignBtn;
}
public AssignIdDialog(TCSession session, String groupID, TextField field, TCComponent tar, boolean flag,
Button assignBtn) {
super();
this.groupID = groupID;
this.session = session;
this.field = field;
this.tar = tar;
this.flag = flag;
this.assignBtn = assignBtn;
}
@Override
public void start(Stage primaryStage) throws IOException {
@Override
public void start(Stage primaryStage) throws IOException {
// StackPane root = new StackPane();
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("AssignIdPane.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root, 400.0, 240.0);
AssignIdController controller = (AssignIdController) fxmlLoader.getController();
primaryStage.setTitle("֪ͨµ¥±àºÅ");
controller.initData(session, groupID, field, tar, flag, assignBtn);
primaryStage.setScene(scene);
primaryStage.show();
}
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("AssignIdPane.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root, 400.0, 240.0);
AssignIdController controller = (AssignIdController) fxmlLoader.getController();
primaryStage.setTitle("֪ͨµ¥±àºÅ");
controller.initData(session, groupID, field, tar, flag, assignBtn);
primaryStage.setScene(scene);
primaryStage.show();
}
}

@ -8,20 +8,20 @@ import com.teamcenter.rac.util.MessageBox;
public class CreateEcnCommond extends KCommand {
public CreateEcnCommond(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
InterfaceAIFComponent targetComponent = app.getTargetComponent();
if (targetComponent.getType().equals("ZT2_ProjectItem") || targetComponent.getType().equals("ZT2_Change")) {
new CreateEcnFrame();
} else {
MessageBox.post("请选中项目零组件或者更改通知单或文件夹", "", MessageBox.ERROR);
}
public CreateEcnCommond(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
try {
InterfaceAIFComponent targetComponent = app.getTargetComponent();
if (targetComponent.getType().equals("ZT2_ProjectItem") || targetComponent.getType().equals("ZT2_Change")) {
new CreateEcnFrame();
} else {
MessageBox.post("请选中项目零组件或者更改通知单或文件夹", "", MessageBox.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
// public DesignChangeCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
// super(app, commandId, actionInfo);
// new DesignChangeFrame(new DesignChangeDialogController());

@ -10,17 +10,17 @@ import javafx.embed.swing.JFXPanel;
public class CreateEcnFrame extends KFrame {
public CreateEcnFrame() {
super();
}
public CreateEcnFrame() {
super();
}
@Override
protected void initUI() throws Exception {
this.setTitle("±ä¸ü¹ÜÀí");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1200, 800));
JFXPanel panel = new JFXPanel();
panel.setScene(new CreateEcnPanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
@Override
protected void initUI() throws Exception {
this.setTitle("±ä¸ü¹ÜÀí");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1200, 800));
JFXPanel panel = new JFXPanel();
panel.setScene(new CreateEcnPanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
}

@ -6,8 +6,8 @@ import com.chint.plm.fxUtil.KFXPanel;
public class CreateEcnPanel extends KFXPanel {
public CreateEcnPanel(Window dialog) {
super(dialog, "ChangeNoticePanel.fxml");
// TODO Auto-generated constructor stub
}
public CreateEcnPanel(Window dialog) {
super(dialog, "ChangeNoticePanel.fxml");
// TODO Auto-generated constructor stub
}
}

@ -10,170 +10,170 @@ import javafx.scene.control.TextArea;
public class EcnBean {
protected SimpleIntegerProperty num;
protected TextArea drawNo;// 图样代号
protected TextArea mark; // 标记
protected TextArea poiNum; // 处数
protected TextArea overChange;// 更改前
protected TextArea overVersion;// 更改前版本
protected TextArea afterVersion;// 更改后版本
protected TextArea afterChange;// 更改后
protected ComboBox<String> productSz = new ComboBox<String>();// 特性等级
protected ComboBox<String> changeReason = new ComboBox<String>();// 更改原因
protected ComboBox<String> wipTreat = new ComboBox<String>();// 在制品处理
public ComboBox<String> getProductSz() {
return productSz;
}
public void setProductSz(String productSz) {
this.productSz.getSelectionModel().select(productSz);
}
EcnBean(int ind, List<String> reasons, List<String> wips, List<String> products) {
num = new SimpleIntegerProperty(ind);
drawNo = new TextArea(); // ComboBoxTextArea
drawNo.setPrefSize(200, 40);
mark = new TextArea(); // ComboBoxTextArea
mark.setPrefSize(200, 40);
poiNum = new TextArea(); // ComboBoxTextArea
poiNum.setPrefSize(200, 40);
overChange = new TextArea(); // ComboBoxTextArea
overChange.setPrefSize(200, 40);
overVersion = new TextArea(); // ComboBoxTextArea
overVersion.setPrefSize(200, 40);
afterChange = new TextArea(); // ComboBoxTextArea
afterChange.setPrefSize(200, 40);
afterVersion = new TextArea(); // ComboBoxTextArea
afterVersion.setPrefSize(200, 40);
wipTreat.getItems().addAll(wips);
productSz.getItems().addAll(products);
productSz.getSelectionModel().selectFirst();
changeReason.getItems().addAll(reasons);
}
EcnBean(int ind, List<String> reasons, List<String> wips, String drawNoVal, String markVal, String placesNo,
String changeBefore, String changeAfter, String reasonVal, String processType, String szRevisionBef,
String szRevisionAft) {
num = new SimpleIntegerProperty(ind);
drawNo = new TextArea(); // ComboBoxTextArea
drawNo.setPrefSize(200, 40);
drawNo.setText(drawNoVal);
mark = new TextArea(); // ComboBoxTextArea
mark.setPrefSize(200, 40);
mark.setText(markVal);
poiNum = new TextArea(); // ComboBoxTextArea
poiNum.setPrefSize(200, 40);
poiNum.setText(placesNo);
overChange = new TextArea(); // ComboBoxTextArea
overChange.setPrefSize(200, 40);
overChange.setText(changeBefore);
overVersion = new TextArea(); // ComboBoxTextArea
overVersion.setPrefSize(200, 40);
overVersion.setText(szRevisionBef);
afterChange = new TextArea(); // ComboBoxTextArea
afterChange.setPrefSize(200, 40);
afterChange.setText(changeAfter);
afterVersion = new TextArea(); // ComboBoxTextArea
afterVersion.setPrefSize(200, 40);
afterVersion.setText(szRevisionAft);
wipTreat.getItems().addAll(wips);
wipTreat.getSelectionModel().select(processType);
changeReason.getItems().addAll(reasons);
changeReason.getSelectionModel().select(reasonVal);
}
public Integer getNum() {
return num.get();
}
public void setNum(SimpleIntegerProperty num) {
this.num = num;
}
public TextArea getDrawNo() {
return drawNo;
}
public void setDrawNo(TextArea drawNo) {
this.drawNo = drawNo;
}
public TextArea getMark() {
return mark;
}
public void setMark(TextArea mark) {
this.mark = mark;
}
public TextArea getPoiNum() {
return poiNum;
}
public void setPoiNum(TextArea poiNum) {
this.poiNum = poiNum;
}
public TextArea getOverChange() {
return overChange;
}
public void setOverChange(TextArea overChange) {
this.overChange = overChange;
}
public TextArea getOverVersion() {
return overVersion;
}
public void setOverVersion(TextArea overVersion) {
this.overVersion = overVersion;
}
public TextArea getAfterChange() {
return afterChange;
}
public void setAfterChange(TextArea afterChange) {
this.afterChange = afterChange;
}
public TextArea getAfterVersion() {
return afterVersion;
}
public void setAfterVersion(TextArea afterVersion) {
this.afterVersion = afterVersion;
}
public ComboBox<String> getChangeReason() {
return changeReason;
}
public void setChangeReason(ComboBox<String> changeReason) {
this.changeReason = changeReason;
}
public ComboBox<String> getWipTreat() {
return wipTreat;
}
public void setWipTreat(ComboBox<String> wipTreat) {
this.wipTreat = wipTreat;
}
protected SimpleIntegerProperty num;
protected TextArea drawNo;// 图样代号
protected TextArea mark; // 标记
protected TextArea poiNum; // 处数
protected TextArea overChange;// 更改前
protected TextArea overVersion;// 更改前版本
protected TextArea afterVersion;// 更改后版本
protected TextArea afterChange;// 更改后
protected ComboBox<String> productSz = new ComboBox<String>();// 特性等级
protected ComboBox<String> changeReason = new ComboBox<String>();// 更改原因
protected ComboBox<String> wipTreat = new ComboBox<String>();// 在制品处理
public ComboBox<String> getProductSz() {
return productSz;
}
public void setProductSz(String productSz) {
this.productSz.getSelectionModel().select(productSz);
}
EcnBean(int ind, List<String> reasons, List<String> wips, List<String> products) {
num = new SimpleIntegerProperty(ind);
drawNo = new TextArea(); // ComboBoxTextArea
drawNo.setPrefSize(200, 40);
mark = new TextArea(); // ComboBoxTextArea
mark.setPrefSize(200, 40);
poiNum = new TextArea(); // ComboBoxTextArea
poiNum.setPrefSize(200, 40);
overChange = new TextArea(); // ComboBoxTextArea
overChange.setPrefSize(200, 40);
overVersion = new TextArea(); // ComboBoxTextArea
overVersion.setPrefSize(200, 40);
afterChange = new TextArea(); // ComboBoxTextArea
afterChange.setPrefSize(200, 40);
afterVersion = new TextArea(); // ComboBoxTextArea
afterVersion.setPrefSize(200, 40);
wipTreat.getItems().addAll(wips);
productSz.getItems().addAll(products);
productSz.getSelectionModel().selectFirst();
changeReason.getItems().addAll(reasons);
}
EcnBean(int ind, List<String> reasons, List<String> wips, String drawNoVal, String markVal, String placesNo,
String changeBefore, String changeAfter, String reasonVal, String processType, String szRevisionBef,
String szRevisionAft) {
num = new SimpleIntegerProperty(ind);
drawNo = new TextArea(); // ComboBoxTextArea
drawNo.setPrefSize(200, 40);
drawNo.setText(drawNoVal);
mark = new TextArea(); // ComboBoxTextArea
mark.setPrefSize(200, 40);
mark.setText(markVal);
poiNum = new TextArea(); // ComboBoxTextArea
poiNum.setPrefSize(200, 40);
poiNum.setText(placesNo);
overChange = new TextArea(); // ComboBoxTextArea
overChange.setPrefSize(200, 40);
overChange.setText(changeBefore);
overVersion = new TextArea(); // ComboBoxTextArea
overVersion.setPrefSize(200, 40);
overVersion.setText(szRevisionBef);
afterChange = new TextArea(); // ComboBoxTextArea
afterChange.setPrefSize(200, 40);
afterChange.setText(changeAfter);
afterVersion = new TextArea(); // ComboBoxTextArea
afterVersion.setPrefSize(200, 40);
afterVersion.setText(szRevisionAft);
wipTreat.getItems().addAll(wips);
wipTreat.getSelectionModel().select(processType);
changeReason.getItems().addAll(reasons);
changeReason.getSelectionModel().select(reasonVal);
}
public Integer getNum() {
return num.get();
}
public void setNum(SimpleIntegerProperty num) {
this.num = num;
}
public TextArea getDrawNo() {
return drawNo;
}
public void setDrawNo(TextArea drawNo) {
this.drawNo = drawNo;
}
public TextArea getMark() {
return mark;
}
public void setMark(TextArea mark) {
this.mark = mark;
}
public TextArea getPoiNum() {
return poiNum;
}
public void setPoiNum(TextArea poiNum) {
this.poiNum = poiNum;
}
public TextArea getOverChange() {
return overChange;
}
public void setOverChange(TextArea overChange) {
this.overChange = overChange;
}
public TextArea getOverVersion() {
return overVersion;
}
public void setOverVersion(TextArea overVersion) {
this.overVersion = overVersion;
}
public TextArea getAfterChange() {
return afterChange;
}
public void setAfterChange(TextArea afterChange) {
this.afterChange = afterChange;
}
public TextArea getAfterVersion() {
return afterVersion;
}
public void setAfterVersion(TextArea afterVersion) {
this.afterVersion = afterVersion;
}
public ComboBox<String> getChangeReason() {
return changeReason;
}
public void setChangeReason(ComboBox<String> changeReason) {
this.changeReason = changeReason;
}
public ComboBox<String> getWipTreat() {
return wipTreat;
}
public void setWipTreat(ComboBox<String> wipTreat) {
this.wipTreat = wipTreat;
}
}

@ -3,110 +3,147 @@ package com.chint.plm.createEcn;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
public class RefTableBean {
protected SimpleStringProperty depart;//部门
protected SimpleStringProperty message; //行动
protected CheckBox shYes = new CheckBox();//是
protected CheckBox shNo = new CheckBox();//否
protected TextField user = new TextField();//更改前版本
protected TextField compDate = new TextField();//更改后
protected TextField mark = new TextField();//更改后版本
public String getDepart() {
return depart.get();
}
public void setDepart(SimpleStringProperty depart) {
this.depart = depart;
}
public String getMessage() {
return message.get();
}
public void setMessage(SimpleStringProperty message) {
this.message = message;
}
public CheckBox getShYes() {
return shYes;
}
public void setShYes(CheckBox shYes) {
this.shYes = shYes;
}
public CheckBox getShNo() {
return shNo;
}
public void setShNo(boolean shNo) {
this.shNo.setSelected(shNo);
}
public TextField getUser() {
return user;
}
public void setUser(String user) {
this.user.setText(user);
}
public TextField getCompDate() {
return compDate;
}
public void setCompDate(String compDate) {
this.compDate.setText(compDate);
}
public TextField getMark() {
return mark;
}
public void setMark(String mark) {
this.mark.setText(mark);
}
// protected ComboBox<String> changeReason = new ComboBox<String>();//更改原因
public RefTableBean(SimpleStringProperty depart, SimpleStringProperty message) {
super();
this.depart = depart;
this.message = message;
// this.shYes = shYes;
// this.shNo = shNo;
// this.user = user;
// this.compDate = compDate;
// this.mark = mark;
shNo.setSelected(true);
shYes.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
// TODO Auto-generated method stub
protected SimpleStringProperty depart;// 部门
protected SimpleStringProperty message; // 行动
protected CheckBox shYes = new CheckBox();// 是
protected CheckBox shNo = new CheckBox();// 否
// protected TextField user = new TextField();// 责任人
protected TextField compDate = new TextField();// 更改后
protected Object userPane;
private TextField userText;
private Button userBtn;
public Button getUserBtn() {
return userBtn;
}
public void setUserBtn(Button userBtn) {
this.userBtn = userBtn;
}
public Object getUserPane() {
if (userPane instanceof SimpleStringProperty) {
SimpleStringProperty userProp = (SimpleStringProperty) userPane;
return userProp.get();
}
return userPane;
}
public String getUserVal() {
if (userPane instanceof SimpleStringProperty) {
SimpleStringProperty userProp = (SimpleStringProperty) userPane;
return userProp.get();
}
return userText.getText();
}
public void setUserPane(String val) {
if (userPane instanceof SimpleStringProperty) {
SimpleStringProperty userProp = (SimpleStringProperty) userPane;
userProp.setValue(val);
} else if (userPane instanceof FlowPane && userText != null) {
userText.setText(val);
// flowPane.getc
}
}
protected TextField mark = new TextField();// 更改后版本
public String getDepart() {
return depart.get();
}
public void setDepart(SimpleStringProperty depart) {
this.depart = depart;
}
public String getMessage() {
return message.get();
}
public void setMessage(SimpleStringProperty message) {
this.message = message;
}
public CheckBox getShYes() {
return shYes;
}
public void setShYes(CheckBox shYes) {
this.shYes = shYes;
}
public CheckBox getShNo() {
return shNo;
}
public void setShNo(boolean shNo) {
this.shNo.setSelected(shNo);
}
public TextField getCompDate() {
return compDate;
}
public void setCompDate(String compDate) {
this.compDate.setText(compDate);
}
public TextField getMark() {
return mark;
}
public void setMark(String mark) {
this.mark.setText(mark);
}
// protected ComboBox<String> changeReason = new ComboBox<String>();//更改原因
public RefTableBean(SimpleStringProperty depart, SimpleStringProperty message, Boolean flag) {
super();
this.depart = depart;
this.message = message;
if (flag) {
FlowPane userPane = new FlowPane();
userText = new TextField();
userBtn = new Button("指派");
userPane.getChildren().add(userText);
userPane.getChildren().add(userBtn);
this.userPane = userPane;
}else {
this.userPane = new SimpleStringProperty();
}
shNo.setSelected(true);
shYes.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
// TODO Auto-generated method stub
// System.out.println("oldValue"+oldValue);
if(newValue) {
shNo.setSelected(false);
}
}
});
shNo.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
// TODO Auto-generated method stub
if (newValue) {
shNo.setSelected(false);
}
}
});
shNo.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
// TODO Auto-generated method stub
// System.out.println("oldValue"+oldValue);
if(newValue) {
shYes.setSelected(false);
}
}
});
}
if (newValue) {
shYes.setSelected(false);
}
}
});
}
}

@ -10,135 +10,152 @@ import javafx.collections.ObservableList;
import javafx.scene.control.Button;
public class RelateEcnBean {
protected SimpleStringProperty num;//序号
protected SimpleStringProperty contConde;//合同代号
protected SimpleStringProperty contName; //合同名称
protected SimpleStringProperty requestNo;//申请单号
protected SimpleStringProperty prodModel; //产品型号
protected SimpleStringProperty applicant; //申请人
protected SimpleStringProperty status; //状态
protected Button linkBtn = new Button("查看");
protected Button importBtn = new Button("导入");
public String getStatus() {
return status.get();
}
public void setStatus(SimpleStringProperty status) {
this.status = status;
}
public Button getLinkBtn() {
return linkBtn;
}
public void setLinkBtn(Button linkBtn) {
this.linkBtn = linkBtn;
}
public Button getImportBtn() {
return importBtn;
}
public void setImportBtn(Button importBtn) {
this.importBtn = importBtn;
}
public String getNum() {
return num.get();
}
public RelateEcnBean(SimpleStringProperty num, SimpleStringProperty contConde, SimpleStringProperty contName,
SimpleStringProperty requestNo, SimpleStringProperty prodModel, SimpleStringProperty applicant,
SimpleStringProperty status, String link,CreateEcnController controller,ResultSet read) throws SQLException {
super();
this.num = num;
this.contConde = contConde;
this.contName = contName;
this.requestNo = requestNo;
this.prodModel = prodModel;
this.applicant = applicant;
this.status = status;
//变更单号
String applyNo = read.getString("APPLYNO");
//七种责任人
String designPal = read.getString("DESIGNPRINCIPAL");
String techPal = read.getString("TECHPRINCIPAL");
String quantityPal = read.getString("QUALITYPRINCIPAL");
String producePal = read.getString("PRODUCEPRINCIPAL");
String purchasePal = read.getString("PURCHASEYPRINCIPAL");
String customPal = read.getString("CUSTOMNOTICEPRINCIPAL");//FINAPRICEPRINCIPAL
String finaPal = read.getString("FINAPRICEPRINCIPAL");
String docuName = read.getString("DOCUNAME"); //文件代号及名称
String designFile = read.getString("DESIGNFILE");//获取行动内容
linkBtn.setOnAction(e -> {
try {
BomToSapUtil.browse2(link);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
importBtn.setOnAction(e -> {
try {
ObservableList<RefTableBean> items = controller.refTable.getItems();
for(int i=0;i<7;i++) {
items.get(i).setUser(designPal);
}
for(int i=7;i<11;i++) {
items.get(i).setUser(techPal);
}
for(int i=11;i<15;i++) {
items.get(i).setUser(quantityPal);
}
for(int i=15;i<19;i++) {
items.get(i).setUser(producePal);
}
for(int i=19;i<24;i++) {
items.get(i).setUser(purchasePal);
}
for(int i=24;i<27;i++) {
items.get(i).setUser(customPal);
}
for(int i=27;i<28;i++) {
items.get(i).setUser(finaPal);
}
controller.markText.setText(docuName);
controller.relateEcnText.setText(applyNo);
controller.refTable.setItems(items);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
}
public void setNum(SimpleStringProperty num) {
this.num = num;
}
public String getContConde() {
return contConde.get();
}
public void setContConde(SimpleStringProperty contConde) {
this.contConde = contConde;
}
public String getContName() {
return contName.get();
}
public void setContName(SimpleStringProperty contName) {
this.contName = contName;
}
public String getRequestNo() {
return requestNo.get();
}
public void setRequestNo(SimpleStringProperty requestNo) {
this.requestNo = requestNo;
}
public String getProdModel() {
return prodModel.get();
}
public void setProdModel(SimpleStringProperty prodModel) {
this.prodModel = prodModel;
}
public String getApplicant() {
return applicant.get();
}
public void setApplicant(SimpleStringProperty applicant) {
this.applicant = applicant;
}
protected SimpleStringProperty num;// 序号
protected SimpleStringProperty contConde;// 合同代号
protected SimpleStringProperty contName; // 合同名称
protected SimpleStringProperty requestNo;// 申请单号
protected SimpleStringProperty prodModel; // 产品型号
protected SimpleStringProperty applicant; // 申请人
protected SimpleStringProperty status; // 状态
protected Button linkBtn = new Button("查看");
protected Button importBtn = new Button("导入");
public String getStatus() {
return status.get();
}
public void setStatus(SimpleStringProperty status) {
this.status = status;
}
public Button getLinkBtn() {
return linkBtn;
}
public void setLinkBtn(Button linkBtn) {
this.linkBtn = linkBtn;
}
public Button getImportBtn() {
return importBtn;
}
public void setImportBtn(Button importBtn) {
this.importBtn = importBtn;
}
public String getNum() {
return num.get();
}
public RelateEcnBean(SimpleStringProperty num, SimpleStringProperty contConde, SimpleStringProperty contName,
SimpleStringProperty requestNo, SimpleStringProperty prodModel, SimpleStringProperty applicant,
SimpleStringProperty status, String link, CreateEcnController controller, ResultSet read)
throws SQLException {
super();
this.num = num;
this.contConde = contConde;
this.contName = contName;
this.requestNo = requestNo;
this.prodModel = prodModel;
this.applicant = applicant;
this.status = status;
// 变更单号
String applyNo = read.getString("APPLYNO");
// 七种责任人
String designPal = read.getString("DESIGNPRINCIPAL");
String techPal = read.getString("TECHPRINCIPAL");
String quantityPal = read.getString("QUALITYPRINCIPAL");
String producePal = read.getString("PRODUCEPRINCIPAL");
String purchasePal = read.getString("PURCHASEYPRINCIPAL");
String customPal = read.getString("CUSTOMNOTICEPRINCIPAL");// FINAPRICEPRINCIPAL
String finaPal = read.getString("FINAPRICEPRINCIPAL");
String docuName = read.getString("DOCUNAME"); // 文件代号及名称
String designFile = read.getString("DESIGNFILE");// 获取行动内容
linkBtn.setOnAction(e -> {
try {
BomToSapUtil.browse2(link);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
importBtn.setOnAction(e -> {
try {
ObservableList<RefTableBean> items = controller.refTable.getItems();
for (int i = 0; i < 7; i++) {
items.get(i).setUserPane(designPal);
}
for (int i = 7; i < 11; i++) {
items.get(i).setUserPane(techPal);
}
for (int i = 11; i < 15; i++) {
items.get(i).setUserPane(quantityPal);
}
for (int i = 15; i < 19; i++) {
items.get(i).setUserPane(producePal);
}
for (int i = 19; i < 24; i++) {
items.get(i).setUserPane(purchasePal);
}
for (int i = 24; i < 27; i++) {
items.get(i).setUserPane(customPal);
}
for (int i = 27; i < 28; i++) {
items.get(i).setUserPane(finaPal);
}
controller.markText.setText(docuName);
controller.relateEcnText.setText(applyNo);
controller.refTable.setItems(items);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
}
public void setNum(SimpleStringProperty num) {
this.num = num;
}
public String getContConde() {
return contConde.get();
}
public void setContConde(SimpleStringProperty contConde) {
this.contConde = contConde;
}
public String getContName() {
return contName.get();
}
public void setContName(SimpleStringProperty contName) {
this.contName = contName;
}
public String getRequestNo() {
return requestNo.get();
}
public void setRequestNo(SimpleStringProperty requestNo) {
this.requestNo = requestNo;
}
public String getProdModel() {
return prodModel.get();
}
public void setProdModel(SimpleStringProperty prodModel) {
this.prodModel = prodModel;
}
public String getApplicant() {
return applicant.get();
}
public void setApplicant(SimpleStringProperty applicant) {
this.applicant = applicant;
}
}

@ -1,4 +1,5 @@
package com.chint.plm.createEcn;
import java.sql.ResultSet;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@ -30,6 +31,7 @@ import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class RelateEcnController {
@FXML
@ -67,7 +69,7 @@ public class RelateEcnController {
@FXML
private TextField requestNoText;
@FXML
private TitledPane tp_product;
@ -91,139 +93,151 @@ public class RelateEcnController {
@FXML
private TextField prodNameText;
private CreateEcnController controller;
private CreateEcnController controller;
private TCSession session;
public void initData(TCSession session, CreateEcnController controller) {
// TODO Auto-generated method stub
this.controller = controller;
this.session = session;
initTable();
}
public void initData(TCSession session, CreateEcnController controller) {
// TODO Auto-generated method stub
this.controller = controller;
this.session = session;
initTable();
}
/**
*
* @function
*/
private void initTable() {
// TODO Auto-generated method stub
TableColumn<RelateEcnBean,SimpleStringProperty> numCol = new TableColumn<RelateEcnBean,SimpleStringProperty>("序号");
TableColumn<RelateEcnBean,SimpleStringProperty> contCondeCol = new TableColumn<RelateEcnBean,SimpleStringProperty>("合同代号");
TableColumn<RelateEcnBean,SimpleStringProperty> contNameCol = new TableColumn<RelateEcnBean,SimpleStringProperty>("合同名称");
TableColumn<RelateEcnBean,SimpleStringProperty> requestNoCol = new TableColumn<RelateEcnBean,SimpleStringProperty>("申请单号");
TableColumn<RelateEcnBean,SimpleStringProperty> prodModelCol = new TableColumn<RelateEcnBean,SimpleStringProperty>("产品型号");
TableColumn<RelateEcnBean,SimpleStringProperty> applicantCol = new TableColumn<RelateEcnBean,SimpleStringProperty>("申请人");
TableColumn<RelateEcnBean,SimpleStringProperty> statusCol = new TableColumn<RelateEcnBean,SimpleStringProperty>("状态");
TableColumn<RelateEcnBean,Button> linkBtnCol = new TableColumn<RelateEcnBean,Button>("更改申请单链接");
TableColumn<RelateEcnBean,Button> importBtnCol = new TableColumn<RelateEcnBean,Button>("导入");
tableView.getColumns().addAll(numCol, contCondeCol, contNameCol,requestNoCol,prodModelCol, applicantCol, statusCol,
linkBtnCol,importBtnCol);
numCol.setSortable(false);
contCondeCol.setSortable(false);
contNameCol.setSortable(false);
requestNoCol.setSortable(false);
prodModelCol.setSortable(false);
applicantCol.setSortable(false);
statusCol.setSortable(false);
linkBtnCol.setSortable(false);
importBtnCol.setSortable(false);
//列绑定bean对象
numCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,SimpleStringProperty>("num"));
contCondeCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,SimpleStringProperty>("contConde"));
contNameCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,SimpleStringProperty>("contName"));
requestNoCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,SimpleStringProperty>("requestNo"));
prodModelCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,SimpleStringProperty>("prodModel"));
applicantCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,SimpleStringProperty>("applicant"));
statusCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,SimpleStringProperty>("status"));
linkBtnCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,Button>("linkBtn"));
importBtnCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean,Button>("importBtn"));
numCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06));
contCondeCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
contNameCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
requestNoCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
prodModelCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
applicantCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
statusCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
linkBtnCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
importBtnCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10));
}
/**
* @param event
* @function
*/
@FXML
// TODO Auto-generated method stub
TableColumn<RelateEcnBean, SimpleStringProperty> numCol = new TableColumn<RelateEcnBean, SimpleStringProperty>(
"序号");
TableColumn<RelateEcnBean, SimpleStringProperty> contCondeCol = new TableColumn<RelateEcnBean, SimpleStringProperty>(
"合同代号");
TableColumn<RelateEcnBean, SimpleStringProperty> contNameCol = new TableColumn<RelateEcnBean, SimpleStringProperty>(
"合同名称");
TableColumn<RelateEcnBean, SimpleStringProperty> requestNoCol = new TableColumn<RelateEcnBean, SimpleStringProperty>(
"申请单号");
TableColumn<RelateEcnBean, SimpleStringProperty> prodModelCol = new TableColumn<RelateEcnBean, SimpleStringProperty>(
"产品型号");
TableColumn<RelateEcnBean, SimpleStringProperty> applicantCol = new TableColumn<RelateEcnBean, SimpleStringProperty>(
"申请人");
TableColumn<RelateEcnBean, SimpleStringProperty> statusCol = new TableColumn<RelateEcnBean, SimpleStringProperty>(
"状态");
TableColumn<RelateEcnBean, Button> linkBtnCol = new TableColumn<RelateEcnBean, Button>("更改申请单链接");
TableColumn<RelateEcnBean, Button> importBtnCol = new TableColumn<RelateEcnBean, Button>("导入");
tableView.getColumns().addAll(numCol, contCondeCol, contNameCol, requestNoCol, prodModelCol, applicantCol,
statusCol, linkBtnCol, importBtnCol);
numCol.setSortable(false);
contCondeCol.setSortable(false);
contNameCol.setSortable(false);
requestNoCol.setSortable(false);
prodModelCol.setSortable(false);
applicantCol.setSortable(false);
statusCol.setSortable(false);
linkBtnCol.setSortable(false);
importBtnCol.setSortable(false);
// 列绑定bean对象
numCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, SimpleStringProperty>("num"));
contCondeCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, SimpleStringProperty>("contConde"));
contNameCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, SimpleStringProperty>("contName"));
requestNoCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, SimpleStringProperty>("requestNo"));
prodModelCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, SimpleStringProperty>("prodModel"));
applicantCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, SimpleStringProperty>("applicant"));
statusCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, SimpleStringProperty>("status"));
linkBtnCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, Button>("linkBtn"));
importBtnCol.setCellValueFactory(new PropertyValueFactory<RelateEcnBean, Button>("importBtn"));
numCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06));
contCondeCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
contNameCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
requestNoCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
prodModelCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
applicantCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
statusCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.1));
linkBtnCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.12));
importBtnCol.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10));
}
/**
* @param event
* @function
*/
@FXML
void searchClick(ActionEvent event) {
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
SqlUtil.getTCDataConnection(prefs);
try {
StringBuilder searchSqlBuff = new StringBuilder( "select * from CHINT_ECR_FROM_OA where 1=1 ");
appendSqlBuild(searchSqlBuff,prodModelText,"PRODUCTMODEL");
appendSqlBuild(searchSqlBuff,prodNameText,"PRODUCTNAME");
appendSqlBuild(searchSqlBuff,contCondeText,"CONTRACTNO");
appendSqlBuild(searchSqlBuff,contNameText,"CONTRACTNAME");
appendSqlBuild(searchSqlBuff,pattCodeText,"DESIGNNAME");
appendSqlBuild(searchSqlBuff,docCodeText,"DOCUNAME");
appendSqlBuild(searchSqlBuff,applicantText,"APPLYUSER");
appendSqlBuild(searchSqlBuff,requestNoText,"APPLYNO");
String startText = startTime.getEditor().getText();
if(!startText.isEmpty()) {
searchSqlBuff.append(" and to_date(APPLYDATE,'yyyy-mm-dd hh24:mi:ss') >= to_date('").append(startText).append("','yyyy-mm-dd') "); //to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("startText==>"+startText);
}
String endText = endTime.getEditor().getText();
if(!endText.isEmpty()) {
searchSqlBuff.append(" and to_date(APPLYDATE,'yyyy-mm-dd hh24:mi:ss') <= to_date('").append(endText).append("','yyyy-mm-dd') "); //to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("endText==>"+endText);
}
int num = 1;
ResultSet read = SqlUtil.read(searchSqlBuff.toString());
List<RelateEcnBean> ecnBeans = new ArrayList<>();
while(read.next()) {
String contConde = read.getString("CONTRACTNO");
String contName = read.getString("CONTRACTNAME");
String requestNo = read.getString("APPLYNO");
String prodModel = read.getString("PRODUCTMODEL");
String applicant = read.getString("APPLYUSER");//STATUS
String status = read.getString("STATUS");
String link = read.getString("APPLYLINK");
ecnBeans.add(
new RelateEcnBean(new SimpleStringProperty(num+""),new SimpleStringProperty(contConde),
new SimpleStringProperty(contName),new SimpleStringProperty(requestNo),new SimpleStringProperty(prodModel),
new SimpleStringProperty(applicant),new SimpleStringProperty(status),link,controller,read));
num++;
}
tableView.getItems().clear();
tableView.getItems().addAll(ecnBeans);
}catch(Exception e) {
e.printStackTrace();
}finally {
SqlUtil.freeAll();
}
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
SqlUtil.getTCDataConnection(prefs);
try {
StringBuilder searchSqlBuff = new StringBuilder("select * from CHINT_ECR_FROM_OA where 1=1 ");
appendSqlBuild(searchSqlBuff, prodModelText, "PRODUCTMODEL");
appendSqlBuild(searchSqlBuff, prodNameText, "PRODUCTNAME");
appendSqlBuild(searchSqlBuff, contCondeText, "CONTRACTNO");
appendSqlBuild(searchSqlBuff, contNameText, "CONTRACTNAME");
appendSqlBuild(searchSqlBuff, pattCodeText, "DESIGNNAME");
appendSqlBuild(searchSqlBuff, docCodeText, "DOCUNAME");
appendSqlBuild(searchSqlBuff, applicantText, "APPLYUSER");
appendSqlBuild(searchSqlBuff, requestNoText, "APPLYNO");
String startText = startTime.getEditor().getText();
if (!startText.isEmpty()) {
searchSqlBuff.append(" and to_date(APPLYDATE,'yyyy-mm-dd hh24:mi:ss') >= to_date('").append(startText)
.append("','yyyy-mm-dd') "); // to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("startText==>" + startText);
}
String endText = endTime.getEditor().getText();
if (!endText.isEmpty()) {
searchSqlBuff.append(" and to_date(APPLYDATE,'yyyy-mm-dd hh24:mi:ss') <= to_date('").append(endText)
.append("','yyyy-mm-dd') "); // to_date(?,'yyyy-mm-ddhh24:mi:ss')
System.out.println("endText==>" + endText);
}
int num = 1;
ResultSet read = SqlUtil.read(searchSqlBuff.toString());
List<RelateEcnBean> ecnBeans = new ArrayList<>();
while (read.next()) {
String contConde = read.getString("CONTRACTNO");
String contName = read.getString("CONTRACTNAME");
String requestNo = read.getString("APPLYNO");
String prodModel = read.getString("PRODUCTMODEL");
String applicant = read.getString("APPLYUSER");// STATUS
String status = read.getString("STATUS");
String link = read.getString("APPLYLINK");
ecnBeans.add(new RelateEcnBean(new SimpleStringProperty(num + ""), new SimpleStringProperty(contConde),
new SimpleStringProperty(contName), new SimpleStringProperty(requestNo),
new SimpleStringProperty(prodModel), new SimpleStringProperty(applicant),
new SimpleStringProperty(status), link, controller, read));
num++;
}
tableView.getItems().clear();
tableView.getItems().addAll(ecnBeans);
} catch (Exception e) {
e.printStackTrace();
} finally {
SqlUtil.freeAll();
}
}
/**
* @param event
* @function
*/
@FXML
void closeClick(ActionEvent event) {
Stage stage = (Stage)prodModelText.getScene().getWindow();
Stage stage = (Stage) prodModelText.getScene().getWindow();
stage.close();
}
/**
* @param searchSqlBuff sql
* @param textField
* @param baseName
* @param textField
* @param baseName
* @function SQL
*/
void appendSqlBuild(StringBuilder searchSqlBuff,TextField textField,String baseName) {
String text = textField.getText();
if (text!=null && !text.isEmpty() ) {
searchSqlBuff.append(" and ").append(baseName).append(" like '%").append(text).append("%' ");
}
void appendSqlBuild(StringBuilder searchSqlBuff, TextField textField, String baseName) {
String text = textField.getText();
if (text != null && !text.isEmpty()) {
searchSqlBuff.append(" and ").append(baseName).append(" like '%").append(text).append("%' ");
}
}
}

@ -13,25 +13,27 @@ import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class RelateEcnDialog extends Application {
private String groupID;
private TCSession session;
private CreateEcnController controller;
public class RelateEcnDialog extends Application {
private String groupID;
private TCSession session;
private CreateEcnController controller;
public RelateEcnDialog(TCSession session, CreateEcnController controller) {
super();
this.controller = controller;
this.session = session;
}
@Override
super();
this.controller = controller;
this.session = session;
}
@Override
public void start(Stage primaryStage) throws IOException {
// StackPane root = new StackPane();
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("RelateApplyPane.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root, 1200.0, 800.0);
RelateEcnController controller = (RelateEcnController) fxmlLoader.getController();
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("RelateApplyPane.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root, 1200.0, 800.0);
RelateEcnController controller = (RelateEcnController) fxmlLoader.getController();
primaryStage.setTitle("֪ͨµ¥±àºÅ");
controller.initData(session,this.controller);
controller.initData(session, this.controller);
primaryStage.setScene(scene);
primaryStage.show();
}

@ -34,408 +34,430 @@ import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class Util {
public Connection connect(Connection conn, TCSession session) {
String[] database = session.getPreferenceService().getStringValues("database_tc");
String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver";
String strUrl = "jdbc:oracle:thin:@10.128.18.139:1521:testdb";// 测试系统
strUrl = "jdbc:oracle:thin:@" + database[0] + ":" + database[1] + ":" + database[2];
String strUserName = "infodba";
strUserName = database[3];
String strPassword = "infodba";
strPassword = database[4];
try {
Class.forName(JdbcDriverClass);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
try {
conn = DriverManager.getConnection(strUrl, strUserName, strPassword);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
/**
*
* @param session
* @param PreServiceName:
* @param Filetype:excelMSExcelX
* @return
*/
public static File getFile(TCSession session,String PreServiceName,String Filetype) {
TCPreferenceService service = session.getPreferenceService();
String puid = service.getStringValue(PreServiceName);
if (puid == null)
{
System.out.println("未找到首选项");
return null;
}
TCComponentDataset dat;
try {
dat = (TCComponentDataset)session
.stringToComponent(puid);
TCComponentTcFile[] tcFile = dat.getTcFiles();
if(tcFile != null && tcFile.length == 0)
{
System.out.println("未找到配置文件");
}
else
{
return tcFile[0].getFmsFile();
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private static void setCellValue(XSSFCell cell2,int index,XSSFRow row0,String cellValue) {
// TODO Auto-generated method stub
if(cell2 == null) {
cell2 = row0.createCell(index);
}
cell2.setCellValue(cellValue);
}
private static XSSFRow getRow(XSSFSheet sheetAt,int rowNum) {
// TODO Auto-generated method stub
XSSFRow row = sheetAt.getRow(rowNum);
if(row ==null) {
row = sheetAt.createRow(rowNum);
}
return row;
}
/**
* @param dateset
* @return
* @function
*/
public static File getExcel(TCComponentDataset dateset) {
File fmsFile = null;
try {
TCComponentTcFile[] file = dateset.getTcFiles();
if (file.length == 0 || file.length != 1) {
MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING);
return null;
} else {
fmsFile = file[0].getFmsFile();
}
} catch (Exception e) {
e.printStackTrace();
}
return fmsFile;
}
/**
* @param target
* @return
* @function
*/
public static String getProjectName(TCComponent target) {
String name = "";
try {
if (target.getType().equals("ZT2_Change")) {
name = target.getProperty("zt2_ContractName");
} else if (target.getType().equals("ZT2_ProjectItem")) {
name = target.getProperty("object_name");
}
} catch (Exception e) {
e.printStackTrace();
}
return name;
}
/**
* @param target
* @return
* @function
*/
public static String getProjectNo(TCComponent target) {
String no = "";
try {
if (target.getType().equals("ZT2_Change")) {
no = target.getProperty("zt2_ContractNo");
} else if (target.getType().equals("ZT2_ProjectItem")) {
String zt2_ProjectCode = target.getProperty("zt2_ProjectCode");
if (!KUtil.isEmpty(zt2_ProjectCode)) {
no = zt2_ProjectCode;
} else {
no = target.getProperty("zt2_ProjectNo");
}
}
} catch (Exception e) {
e.printStackTrace();
}
return no;
}
/**
* @param target
* @param productModelList
* @return
* @function
*/
public static List<String> getProductNames(TCComponent target, List<String> productModelList) {
// 如果选中的是变更单,通过引用往上找到项目
try {
if (target.getType().equals("ZT2_Change")) {
AIFComponentContext[] a1 = target.whereReferenced();// 更改单文件夹
if (a1 == null || a1.length < 1) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");
productModelList.add(zt2_ProductModel);
return productModelList;
}
AIFComponentContext[] a2 = ((TCComponent) a1[0].getComponent()).whereReferenced();// 项目监控文件夹
try {
if (a2.length < 1 || !a2[0].getComponent().getProperty("object_name").contains("项目监控")) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");//zt2_ProductName 新的属性
productModelList.add(zt2_ProductModel);
return productModelList;
}
} catch (Exception e) {
e.printStackTrace();
}
AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件
target = (TCComponent) a3[0].getComponent();
}
} catch (TCException e1) {
e1.printStackTrace();
}
try {
TCComponent[] folders = target.getRelatedComponents("IMAN_reference");
for (int i = 0; i < folders.length; i++) {
if (folders[i].getProperty("object_name").contains("项目启动")) {
TCComponent[] folders2 = folders[i].getRelatedComponents("contents");
for (int j = 0; j < folders2.length; j++) {
if (folders2[j].getProperty("object_name").contains("产成品")) {
TCComponent[] ccbh = folders2[j].getRelatedComponents("contents");
for (int k = 0; k < ccbh.length; k++) {
if (ccbh[k].getType().equals("Part")) {
productModelList.add(ccbh[k].getProperty("object_name"));
}
}
}
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
return productModelList;
}
/**
* @param target
* @param productModelList
* @return
* @function
*/
public static List<String> getproductModel(TCComponent target, List<String> productModelList) {
// 如果选中的是变更单,通过引用往上找到项目
try {
if (target.getType().equals("ZT2_Change")) {
AIFComponentContext[] a1 = target.whereReferenced();// 更改单文件夹
if (a1 == null || a1.length < 1) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");
productModelList.add(zt2_ProductModel);
return productModelList;
}
AIFComponentContext[] a2 = ((TCComponent) a1[0].getComponent()).whereReferenced();// 项目监控文件夹
try {
if (a2.length < 1 || !a2[0].getComponent().getProperty("object_name").contains("项目监控")) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");
productModelList.add(zt2_ProductModel);
return productModelList;
}
} catch (Exception e) {
e.printStackTrace();
}
AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件
target = (TCComponent) a3[0].getComponent();
}
} catch (TCException e1) {
e1.printStackTrace();
}
try {
TCComponent[] folders = target.getRelatedComponents("IMAN_reference");
for (int i = 0; i < folders.length; i++) {
if (folders[i].getProperty("object_name").contains("项目启动")) {
TCComponent[] folders2 = folders[i].getRelatedComponents("contents");
for (int j = 0; j < folders2.length; j++) {
if (folders2[j].getProperty("object_name").contains("产成品")) {
TCComponent[] ccbh = folders2[j].getRelatedComponents("contents");
for (int k = 0; k < ccbh.length; k++) {
if (ccbh[k].getType().equals("Part")) {
productModelList.add(ccbh[k].getProperty("object_name"));
}
}
}
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
return productModelList;
}
public void disconnect(Connection conn, Statement stmt, ResultSet rs_get) {
try {
if (rs_get != null) {
rs_get.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* @param sourthPath
* @param filePath
* @param pages
* @function
*/
public static void deMerge(String sourthPath, String filePath, int pages) {
try {
FileInputStream fis = new FileInputStream(sourthPath);
HSSFWorkbook workBook = new HSSFWorkbook(fis);
HSSFSheet sheet = workBook.getSheetAt(0);
for (int i = 0; i < sheet.getNumMergedRegions(); ++i) {
CellRangeAddress range = sheet.getMergedRegion(i);
if (range.getFirstRow() > 23 * pages + 2) {
sheet.removeMergedRegion(i);
}
}
File file2 = null;
file2 = new File(filePath);
FileOutputStream fos = new FileOutputStream(file2);
workBook.write(fos);
} catch (Exception e) {
e.printStackTrace();
}
try {
FileInputStream fis = new FileInputStream(filePath);
HSSFWorkbook workBook = new HSSFWorkbook(fis);
HSSFSheet sheet = workBook.getSheetAt(0);
boolean loop = false;
for (int i = 0; i < sheet.getNumMergedRegions(); ++i) {
if (loop == true) {
continue;
}
CellRangeAddress range = sheet.getMergedRegion(i);
if (range.getFirstRow() > 23 * pages + 2) {
loop = true;
break;
}
}
if (loop == true) {
deMerge(filePath, filePath, pages);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param sourcePath
* @param filePath
* @param pages
* @function excel
*/
public static void delete(String sourcePath, String filePath, int pages) {
try {
FileInputStream fis = new FileInputStream(sourcePath);
HSSFWorkbook workBook = new HSSFWorkbook(fis);
HSSFSheet sheet = workBook.getSheetAt(0);
int rowCount = sheet.getLastRowNum();
for (int i = rowCount; i > pages * 23 + 1; i--) {
sheet.shiftRows(i, i, -1);
}
File file2 = null;
System.out.println(filePath);
file2 = new File(filePath);
FileOutputStream fos = new FileOutputStream(file2);
workBook.write(fos);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @return yyyy-MM-dd-HH-mm
* @function
*/
public static String GetNowDate() {
String temp_str = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm");
temp_str = sdf.format(dt);
return temp_str;
}
/**
* @param sheet
* @param startRow
* @param endRow
* @return
* @function
*/
public static List<CellRangeAddress> getMergeRegions(Sheet sheet, int startRow, int endRow) {
List<CellRangeAddress> list = new ArrayList<>();
for (int i = 0; i < sheet.getNumMergedRegions(); ++i) {
org.apache.poi.ss.util.CellRangeAddress oldRange = sheet.getMergedRegion(i);
if (oldRange.getFirstRow() >= startRow && oldRange.getLastRow() <= endRow) {
list.add(oldRange);
}
}
return list;
}
/**
* @param page
* @param lists
* @param sheet
* @param wb
* @function excel
*/
public static void addExcelPage(int page, List<CellRangeAddress> lists, HSSFSheet sheet, HSSFWorkbook wb) {
HSSFRow row;
for (int i = 2; i < 24; i++) {
row = sheet.createRow(page * 23 + i);
for (int j = 0; j < 17; j++) {
row.createCell(j);
}
POIUtil.copyRow(wb, sheet.getRow(i), row, true);
}
for (int i = 0; i < lists.size(); i++) {
CellRangeAddress range = lists.get(i);
CellRangeAddress newMergedRegion = new CellRangeAddress(range.getFirstRow() + page * 23,
range.getLastRow() + page * 23, range.getFirstColumn(), range.getLastColumn());
sheet.addMergedRegion(newMergedRegion);
}
}
/*
* public static void writeECNExcel(File file,String zt2_ContractNo) throws
* Exception { HSSFSheet sheet; HSSFWorkbook workBook; InputStream fis;
* OutputStream fos; fis = new FileInputStream(file) ; workBook = new
* HSSFWorkbook(fis); sheet =workBook.getSheetAt(0); HSSFCellStyle cellStyle =
* sheet.getRow(2).getCell(11).getCellStyle();
* sheet.getRow(3).getCell(11).setCellValue(zt2_ContractNo); if(cellStyle!=null)
* sheet.getRow(3).getCell(11).setCellStyle(cellStyle); fos = new
* FileOutputStream(file.getAbsolutePath()); workBook.write(fos); fos.flush();
* fos.close(); fis.close(); }
*/
public Connection connect(Connection conn, TCSession session) {
String[] database = session.getPreferenceService().getStringValues("database_tc");
String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver";
String strUrl = "jdbc:oracle:thin:@10.128.18.139:1521:testdb";// 测试系统
strUrl = "jdbc:oracle:thin:@" + database[0] + ":" + database[1] + ":" + database[2];
String strUserName = "infodba";
strUserName = database[3];
String strPassword = "infodba";
strPassword = database[4];
try {
Class.forName(JdbcDriverClass);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
try {
conn = DriverManager.getConnection(strUrl, strUserName, strPassword);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
/**
*
* @param session
* @param PreServiceName:
* @param Filetype:excelMSExcelX
* @return
*/
public static File getFile(TCSession session, String PreServiceName, String Filetype) {
TCPreferenceService service = session.getPreferenceService();
String puid = service.getStringValue(PreServiceName);
if (puid == null) {
System.out.println("未找到首选项");
return null;
}
TCComponentDataset dat;
try {
dat = (TCComponentDataset) session.stringToComponent(puid);
TCComponentTcFile[] tcFile = dat.getTcFiles();
if (tcFile != null && tcFile.length == 0) {
System.out.println("未找到配置文件");
} else {
return tcFile[0].getFmsFile();
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
/**
* @param cell2
* @param index
* @param row0
* @param cellValue
* @function
*/
public static void setCellValue(XSSFCell cell2, int index, XSSFRow row0, String cellValue) {
// TODO Auto-generated method stub
if (cell2 == null) {
cell2 = row0.createCell(index);
}
cell2.setCellValue(cellValue);
}
/**
* @param sheetAt
* @param rowNum
* @return excel
* @function
*/
public static XSSFRow getRow(XSSFSheet sheetAt, int rowNum) {
// TODO Auto-generated method stub
XSSFRow row = sheetAt.getRow(rowNum);
if (row == null) {
row = sheetAt.createRow(rowNum);
}
return row;
}
/**
* @param dateset
* @return
* @function
*/
public static File getExcel(TCComponentDataset dateset) {
File fmsFile = null;
try {
TCComponentTcFile[] file = dateset.getTcFiles();
if (file.length == 0 || file.length != 1) {
MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", MessageBox.WARNING);
return null;
} else {
fmsFile = file[0].getFmsFile();
}
} catch (Exception e) {
e.printStackTrace();
}
return fmsFile;
}
/**
* @param target
* @return
* @function
*/
public static String getProjectName(TCComponent target) {
String name = "";
try {
if (target.getType().equals("ZT2_Change")) {
name = target.getProperty("zt2_ContractName");
} else if (target.getType().equals("ZT2_ProjectItem")) {
name = target.getProperty("object_name");
}
} catch (Exception e) {
e.printStackTrace();
}
return name;
}
/**
* @param target
* @return
* @function
*/
public static String getProjectNo(TCComponent target) {
String no = "";
try {
if (target.getType().equals("ZT2_Change")) {
no = target.getProperty("zt2_ContractNo");
} else if (target.getType().equals("ZT2_ProjectItem")) {
String zt2_ProjectCode = target.getProperty("zt2_ProjectCode");
if (!KUtil.isEmpty(zt2_ProjectCode)) {
no = zt2_ProjectCode;
} else {
no = target.getProperty("zt2_ProjectNo");
}
}
} catch (Exception e) {
e.printStackTrace();
}
return no;
}
/**
* @param target
* @param productModelList
* @return
* @function
*/
public static List<String> getProductNames(TCComponent target, List<String> productModelList) {
// 如果选中的是变更单,通过引用往上找到项目
try {
if (target.getType().equals("ZT2_Change")) {
AIFComponentContext[] a1 = target.whereReferenced();// 更改单文件夹
if (a1 == null || a1.length < 1) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");
productModelList.add(zt2_ProductModel);
return productModelList;
}
AIFComponentContext[] a2 = ((TCComponent) a1[0].getComponent()).whereReferenced();// 项目监控文件夹
try {
if (a2.length < 1 || !a2[0].getComponent().getProperty("object_name").contains("项目监控")) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");// zt2_ProductName 新的属性
productModelList.add(zt2_ProductModel);
return productModelList;
}
} catch (Exception e) {
e.printStackTrace();
}
AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件
target = (TCComponent) a3[0].getComponent();
}
} catch (TCException e1) {
e1.printStackTrace();
}
try {
TCComponent[] folders = target.getRelatedComponents("IMAN_reference");
for (int i = 0; i < folders.length; i++) {
if (folders[i].getProperty("object_name").contains("项目启动")) {
TCComponent[] folders2 = folders[i].getRelatedComponents("contents");
for (int j = 0; j < folders2.length; j++) {
if (folders2[j].getProperty("object_name").contains("产成品")) {
TCComponent[] ccbh = folders2[j].getRelatedComponents("contents");
for (int k = 0; k < ccbh.length; k++) {
if (ccbh[k].getType().equals("Part")) {
productModelList.add(ccbh[k].getProperty("object_name"));
}
}
}
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
return productModelList;
}
/**
* @param target
* @param productModelList
* @return
* @function
*/
public static List<String> getproductModel(TCComponent target, List<String> productModelList) {
// 如果选中的是变更单,通过引用往上找到项目
try {
if (target.getType().equals("ZT2_Change")) {
AIFComponentContext[] a1 = target.whereReferenced();// 更改单文件夹
if (a1 == null || a1.length < 1) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");
productModelList.add(zt2_ProductModel);
return productModelList;
}
AIFComponentContext[] a2 = ((TCComponent) a1[0].getComponent()).whereReferenced();// 项目监控文件夹
try {
if (a2.length < 1 || !a2[0].getComponent().getProperty("object_name").contains("项目监控")) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel");
productModelList.add(zt2_ProductModel);
return productModelList;
}
} catch (Exception e) {
e.printStackTrace();
}
AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件
target = (TCComponent) a3[0].getComponent();
}
} catch (TCException e1) {
e1.printStackTrace();
}
try {
TCComponent[] folders = target.getRelatedComponents("IMAN_reference");
for (int i = 0; i < folders.length; i++) {
if (folders[i].getProperty("object_name").contains("项目启动")) {
TCComponent[] folders2 = folders[i].getRelatedComponents("contents");
for (int j = 0; j < folders2.length; j++) {
if (folders2[j].getProperty("object_name").contains("产成品")) {
TCComponent[] ccbh = folders2[j].getRelatedComponents("contents");
for (int k = 0; k < ccbh.length; k++) {
if (ccbh[k].getType().equals("Part")) {
productModelList.add(ccbh[k].getProperty("object_name"));
}
}
}
}
}
}
} catch (TCException e) {
e.printStackTrace();
}
return productModelList;
}
public void disconnect(Connection conn, Statement stmt, ResultSet rs_get) {
try {
if (rs_get != null) {
rs_get.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* @param sourthPath
* @param filePath
* @param pages
* @function
*/
public static void deMerge(String sourthPath, String filePath, int pages) {
try {
FileInputStream fis = new FileInputStream(sourthPath);
HSSFWorkbook workBook = new HSSFWorkbook(fis);
HSSFSheet sheet = workBook.getSheetAt(0);
for (int i = 0; i < sheet.getNumMergedRegions(); ++i) {
CellRangeAddress range = sheet.getMergedRegion(i);
if (range.getFirstRow() > 23 * pages + 2) {
sheet.removeMergedRegion(i);
}
}
File file2 = null;
file2 = new File(filePath);
FileOutputStream fos = new FileOutputStream(file2);
workBook.write(fos);
} catch (Exception e) {
e.printStackTrace();
}
try {
FileInputStream fis = new FileInputStream(filePath);
HSSFWorkbook workBook = new HSSFWorkbook(fis);
HSSFSheet sheet = workBook.getSheetAt(0);
boolean loop = false;
for (int i = 0; i < sheet.getNumMergedRegions(); ++i) {
if (loop == true) {
continue;
}
CellRangeAddress range = sheet.getMergedRegion(i);
if (range.getFirstRow() > 23 * pages + 2) {
loop = true;
break;
}
}
if (loop == true) {
deMerge(filePath, filePath, pages);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param sourcePath
* @param filePath
* @param pages
* @function excel
*/
public static void delete(String sourcePath, String filePath, int pages) {
try {
FileInputStream fis = new FileInputStream(sourcePath);
HSSFWorkbook workBook = new HSSFWorkbook(fis);
HSSFSheet sheet = workBook.getSheetAt(0);
int rowCount = sheet.getLastRowNum();
for (int i = rowCount; i > pages * 23 + 1; i--) {
sheet.shiftRows(i, i, -1);
}
File file2 = null;
System.out.println(filePath);
file2 = new File(filePath);
FileOutputStream fos = new FileOutputStream(file2);
workBook.write(fos);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @return yyyy-MM-dd-HH-mm
* @function
*/
public static String GetNowDate() {
String temp_str = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm");
temp_str = sdf.format(dt);
return temp_str;
}
/**
* @param sheet
* @param startRow
* @param endRow
* @return
* @function
*/
public static List<CellRangeAddress> getMergeRegions(Sheet sheet, int startRow, int endRow) {
List<CellRangeAddress> list = new ArrayList<>();
for (int i = 0; i < sheet.getNumMergedRegions(); ++i) {
org.apache.poi.ss.util.CellRangeAddress oldRange = sheet.getMergedRegion(i);
if (oldRange.getFirstRow() >= startRow && oldRange.getLastRow() <= endRow) {
list.add(oldRange);
}
}
return list;
}
/**
* @param page
* @param lists
* @param sheet
* @param wb
* @function excel
*/
public static void addExcelPage(int page, List<CellRangeAddress> lists, HSSFSheet sheet, HSSFWorkbook wb) {
HSSFRow row;
for (int i = 2; i < 24; i++) {
row = sheet.createRow(page * 23 + i);
for (int j = 0; j < 17; j++) {
row.createCell(j);
}
POIUtil.copyRow(wb, sheet.getRow(i), row, true);
}
for (int i = 0; i < lists.size(); i++) {
CellRangeAddress range = lists.get(i);
CellRangeAddress newMergedRegion = new CellRangeAddress(range.getFirstRow() + page * 23,
range.getLastRow() + page * 23, range.getFirstColumn(), range.getLastColumn());
sheet.addMergedRegion(newMergedRegion);
}
}
/*
* public static void writeECNExcel(File file,String zt2_ContractNo) throws
* Exception { HSSFSheet sheet; HSSFWorkbook workBook; InputStream fis;
* OutputStream fos; fis = new FileInputStream(file) ; workBook = new
* HSSFWorkbook(fis); sheet =workBook.getSheetAt(0); HSSFCellStyle cellStyle =
* sheet.getRow(2).getCell(11).getCellStyle();
* sheet.getRow(3).getCell(11).setCellValue(zt2_ContractNo); if(cellStyle!=null)
* sheet.getRow(3).getCell(11).setCellStyle(cellStyle); fos = new
* FileOutputStream(file.getAbsolutePath()); workBook.write(fos); fos.flush();
* fos.close(); fis.close(); }
*/
}

@ -13,120 +13,123 @@ import javafx.stage.Stage;
//import sun.util.logging.PlatformLogger;
public abstract class KFXPanel extends Application {
protected Scene scene;
protected KFXPanelController aifController;
protected Parent root;
protected String cssForm;
protected Window parentDialog;
static {
Platform.setImplicitExit(false);
protected Scene scene;
protected KFXPanelController aifController;
protected Parent root;
protected String cssForm;
protected Window parentDialog;
static {
Platform.setImplicitExit(false);
// Logging.getCSSLogger().setLevel(Platform.class...STYLESHEET_CASPIAN....Level.OFF);
}
public KFXPanel(Window dialog,String fxmlName) {
setParentDialog(dialog);
initUI(fxmlName);
initData();
}
public KFXPanel(Window dialog, Class<?> c, String css) {
setParentDialog(dialog);
this.cssForm = c.getResource(css).toExternalForm();
initUI();
initData();
}
public void setParentDialog(Window dialog) {
this.parentDialog = dialog;
}
public Window getParentDialog() {
return this.parentDialog;
}
public Parent getRoot() {
return this.root;
}
public KFXPanelController getController() {
return this.aifController;
}
public Scene getScene() {
if (this.scene == null) {
this.scene = new Scene(this.root);
this.scene.setFill(null);
}
return this.scene;
}
public void initData() {
try {
this.aifController.initData(this);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
protected void initUI(String fxmlName) {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
String resource = fxmlName;//"SearchSapResultPanel.fxml";
fxmlLoader.setLocation(getClass().getResource(resource));
this.root = (Parent)fxmlLoader.load();
this.aifController = (KFXPanelController)fxmlLoader.getController();
if (this.cssForm != null)
this.root.getStylesheets().add(this.cssForm);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
protected void initUI() {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
String resource = "SearchSapResultPanel.fxml";
fxmlLoader.setLocation(getClass().getResource(resource));
this.root = (Parent)fxmlLoader.load();
this.aifController = (KFXPanelController)fxmlLoader.getController();
if (this.cssForm != null)
this.root.getStylesheets().add(this.cssForm);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
public static void post(Window dialog, final String msg, final String title, int msgType) {
if (dialog == null) {
Platform.runLater(new Runnable() {
public void run() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle(title);
alert.setHeaderText("");
alert.setContentText(msg);
alert.showAndWait();
}
});
} else {
MessageBox.post(dialog, msg, title, msgType);
}
}
}
public KFXPanel(Window dialog, String fxmlName) {
setParentDialog(dialog);
initUI(fxmlName);
initData();
}
public KFXPanel(Window dialog, Class<?> c, String css) {
setParentDialog(dialog);
this.cssForm = c.getResource(css).toExternalForm();
initUI();
initData();
}
public void setParentDialog(Window dialog) {
this.parentDialog = dialog;
}
public Window getParentDialog() {
return this.parentDialog;
}
public Parent getRoot() {
return this.root;
}
public KFXPanelController getController() {
return this.aifController;
}
public Scene getScene() {
if (this.scene == null) {
this.scene = new Scene(this.root);
this.scene.setFill(null);
}
return this.scene;
}
public void initData() {
try {
this.aifController.initData(this);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
protected void initUI(String fxmlName) {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
String resource = fxmlName;// "SearchSapResultPanel.fxml";
fxmlLoader.setLocation(getClass().getResource(resource));
this.root = (Parent) fxmlLoader.load();
this.aifController = (KFXPanelController) fxmlLoader.getController();
if (this.cssForm != null)
this.root.getStylesheets().add(this.cssForm);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
protected void initUI() {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
String resource = "SearchSapResultPanel.fxml";
fxmlLoader.setLocation(getClass().getResource(resource));
this.root = (Parent) fxmlLoader.load();
this.aifController = (KFXPanelController) fxmlLoader.getController();
if (this.cssForm != null)
this.root.getStylesheets().add(this.cssForm);
} catch (Exception e) {
e.printStackTrace();
post(this.parentDialog, e.getMessage(), "", 1);
}
}
public static void post(Window dialog, final String msg, final String title, int msgType) {
if (dialog == null) {
Platform.runLater(new Runnable() {
public void run() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle(title);
alert.setHeaderText("");
alert.setContentText(msg);
alert.showAndWait();
}
});
} else {
MessageBox.post(dialog, msg, title, msgType);
}
}
// protected Stage primaryStage;
public void start(Stage primaryStage) throws Exception {
initUI();
initData();
public void start(Stage primaryStage) throws Exception {
initUI();
initData();
// this.primaryStage = primaryStage;
primaryStage.setScene(getScene());
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
primaryStage.setScene(getScene());
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

@ -1,28 +1,27 @@
package com.chint.plm.fxUtil;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
public abstract class KFXPanelController {
@FXML
protected AnchorPane coverPane;
public abstract void initData(KFXPanel paramKFXPanel) throws Exception;
public void setCoverVisible(final boolean visible) {
if (this.coverPane != null) {
Platform.runLater(new Runnable() {
public void run() {
KFXPanelController.this.coverPane.setVisible(visible);
@FXML
protected AnchorPane coverPane;
public abstract void initData(KFXPanel paramKFXPanel) throws Exception;
public void setCoverVisible(final boolean visible) {
if (this.coverPane != null) {
Platform.runLater(new Runnable() {
public void run() {
KFXPanelController.this.coverPane.setVisible(visible);
}
});
try {
Thread.sleep(10L);
} catch (Exception e) {
e.printStackTrace();
}
});
try {
Thread.sleep(10L);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}

@ -1,28 +1,29 @@
package com.chint.plm.fxUtil;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.UIUtilities;
import javax.swing.JFrame;
public abstract class KFrame extends JFrame {
// protected KDialogController controller;
public KFrame() {
try {
public KFrame() {
try {
// if (!this.controller.init())
// return;
initUI();
showFrame();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(this, e);
}
}
public void showFrame() {
pack();
UIUtilities.centerToScreen(this);
setVisible(true);
}
protected abstract void initUI() throws Exception;
initUI();
showFrame();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(this, e);
}
}
public void showFrame() {
pack();
UIUtilities.centerToScreen(this);
setVisible(true);
}
protected abstract void initUI() throws Exception;
}

@ -114,7 +114,6 @@ public class BomSendSapOp extends AbstractAIFOperation {
if(MATNR!=null) {
attributeValue = attributeValue+",ÔÚ"+MATNR+"BOMÖÐ";
}
// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
System.out.println(attributeValue);
errBuffer.append(attributeValue).append("\n");
}

Loading…
Cancel
Save