diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/ChildMessage.class b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/ChildMessage.class index bc6ffe1..e353d39 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/ChildMessage.class and b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/ChildMessage.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsBean.class b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsBean.class index 934add3..951f293 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsBean.class and b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsBean.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsController.class b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsController.class index c6f755d..e229bf3 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsController.class and b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/DetailsController.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/SumTableBean.class b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/SumTableBean.class index 4f845f0..de51f90 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/SumTableBean.class and b/com.connor.chint.wuhan/bin/com/chint/plm/SearchSapResult/SumTableBean.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController$1.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController$1.class index b36c075..d0b15ec 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController$1.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController.class index 7c54df5..54bde88 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/CreateEcnController.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$1.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$1.class index 92ba401..97c5db9 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$1.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$2.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$2.class index 241b622..bad967e 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$2.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean$2.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean.class index 8f9733d..15ac212 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RefTableBean.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnBean.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnBean.class index 6c458f3..1cce78e 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnBean.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnBean.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnController.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnController.class index ea8bdea..ade0fc5 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnController.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnController.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnDialog.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnDialog.class index 0384844..3498b55 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnDialog.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/RelateEcnDialog.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/Util.class b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/Util.class index da864fe..c84f519 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/Util.class and b/com.connor.chint.wuhan/bin/com/chint/plm/createEcn/Util.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel$1.class b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel$1.class index 9d83b8f..42f52ac 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel$1.class and b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel.class b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel.class index 858afd5..57367c4 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel.class and b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanel.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController$1.class b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController$1.class index fccd3d6..211de20 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController$1.class and b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController$1.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController.class b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController.class index 83d7944..4b67c7d 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController.class and b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFXPanelController.class differ diff --git a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFrame.class b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFrame.class index afb164c..89c0928 100644 Binary files a/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFrame.class and b/com.connor.chint.wuhan/bin/com/chint/plm/fxUtil/KFrame.class differ diff --git a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapOp.class b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapOp.class index 7b23a40..1cd54c5 100644 Binary files a/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapOp.class and b/com.connor.chint.wuhan/bin/com/connor/chint/yunpi/command/BomSendSapOp.class differ diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/ChildMessage.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/ChildMessage.java index 46c3b05..154c2f6 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/ChildMessage.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/ChildMessage.java @@ -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> 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(); } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsBean.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsBean.java index 7e4365e..2afa884 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsBean.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsBean.java @@ -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; + } + } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsController.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsController.java index 537b872..6d1c2ce 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsController.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/DetailsController.java @@ -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 tc_cDate; - @FXML - private TableColumn tc_msg; - @FXML - private TableColumn tc_cTime; - - @FXML - private TableView tableView; - - @FXML - private TableColumn tc_returnTime; - - @FXML - private TableColumn tc_batch; - - @FXML - private TextField pageNumTxt; - @FXML - private TableColumn tc_wbs; - @FXML - private TableColumn tc_SapResult; - - @FXML - private TableColumn tc_xh; - @FXML - private TableColumn tc_material; - @FXML - private TableColumn tc_returnDate; - @FXML - private TableColumn 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> tableBeans; // 记录表格里面的数据 - - List> errMsgBeans; // 记录错误的数据 - List> allMsgBeans; // 记录全部数据 - - @FXML - void firstAction(ActionEvent event) { - pageNum = 0; - ObservableList data = FXCollections.observableArrayList(tableBeans.get(0)); - tableView.getItems().clear(); - tableView.setItems(data); - } - - @FXML - void lastAction(ActionEvent event) { - if (pageNum > 0) { - pageNum = pageNum - 1; - } - ObservableList 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 data = FXCollections.observableArrayList(tableBeans.get(pageNum)); - tableView.getItems().clear(); - tableView.setItems(data); - } - - @FXML - void tailAction(ActionEvent event) { - pageNum = tableBeans.size() - 1; - ObservableList 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 allBeans = new ArrayList(); - for (int i = 0; i < tableBeans.size(); i++) { - allBeans.addAll(tableBeans.get(i)); - } - ObservableList 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 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("num")); - tc_batch.setCellValueFactory(new PropertyValueFactory("batchNum")); - tc_material.setCellValueFactory(new PropertyValueFactory("productMaterialNo")); - tc_wbs.setCellValueFactory(new PropertyValueFactory("wbsNo")); - tc_SapResult.setCellValueFactory(new PropertyValueFactory("status")); - tc_msg.setCellValueFactory(new PropertyValueFactory<>("message")); + @FXML + private Button bt_last; + @FXML + private Button bt_next; + @FXML + private TableColumn tc_cDate; + @FXML + private TableColumn tc_msg; + @FXML + private TableColumn tc_cTime; + + @FXML + private TableView tableView; + + @FXML + private TableColumn tc_returnTime; + + @FXML + private TableColumn tc_batch; + + @FXML + private TextField pageNumTxt; + @FXML + private TableColumn tc_wbs; + @FXML + private TableColumn tc_SapResult; + + @FXML + private TableColumn tc_xh; + @FXML + private TableColumn tc_material; + @FXML + private TableColumn tc_returnDate; + @FXML + private TableColumn 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> tableBeans; // 记录表格里面的数据 + + List> errMsgBeans = new ArrayList<>(); // 记录错误的数据 + List> allMsgBeans = new ArrayList<>(); // 记录全部数据 + + /** + * @param event + * @function 跳转到第一页 + */ + @FXML + void firstAction(ActionEvent event) { + pageNum = 0; + ObservableList 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 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 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 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 allBeans = new ArrayList(); + for (int i = 0; i < tableBeans.size(); i++) { + allBeans.addAll(tableBeans.get(i)); + } + ObservableList 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 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("num")); + tc_batch.setCellValueFactory(new PropertyValueFactory("batchNum")); + tc_material.setCellValueFactory(new PropertyValueFactory("productMaterialNo")); + tc_wbs.setCellValueFactory(new PropertyValueFactory("wbsNo")); + tc_SapResult.setCellValueFactory(new PropertyValueFactory("status")); + tc_msg.setCellValueFactory(new PropertyValueFactory<>("message")); // tc_log.setCellValueFactory(new PropertyValueFactory<>("user")); - tc_cDate.setCellValueFactory(new PropertyValueFactory("createDate")); - tc_cTime.setCellValueFactory(new PropertyValueFactory("createTime")); - tc_returnDate.setCellValueFactory(new PropertyValueFactory("returnDate")); - tc_returnTime.setCellValueFactory(new PropertyValueFactory("returnTime")); - tc_plm.setCellValueFactory(new PropertyValueFactory("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 data = FXCollections.observableArrayList(tableBeans.get(0)); - tableView.getItems().clear(); - tableView.setItems(data); - lb_page.setText("/" + tableBeans.size()); + tc_cDate.setCellValueFactory(new PropertyValueFactory("createDate")); + tc_cTime.setCellValueFactory(new PropertyValueFactory("createTime")); + tc_returnDate.setCellValueFactory(new PropertyValueFactory("returnDate")); + tc_returnTime.setCellValueFactory(new PropertyValueFactory("returnTime")); + tc_plm.setCellValueFactory(new PropertyValueFactory("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 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() { - @Override - public void changed(ObservableValue 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() { - @Override - public void changed(ObservableValue 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() { - @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() { + @Override + public void changed(ObservableValue 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() { + @Override + public void changed(ObservableValue 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() { + @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 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> tableBeans = new ArrayList>(); - 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 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(); - tableBeans.add(beanList); - } - beanList.add(sumBean); - i = i + 1; - } - SqlUtil.freeAll(); - if (tableBeans.size() == 0) { - beanList = new ArrayList(); - tableBeans.add(beanList); - } - if (errMsgBeans.size() == 0 && cb_errBtn.isSelected()) { - errMsgBeans = tableBeans; - } else if (allMsgBeans.size() == 0 && !cb_errBtn.isSelected()) { - allMsgBeans = tableBeans; - } - } - - ObservableList 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> tableBeans = new ArrayList>(); + 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 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(); + tableBeans.add(beanList); + } + beanList.add(sumBean); + i = i + 1; + } + SqlUtil.freeAll(); + if (tableBeans.size() == 0) { + beanList = new ArrayList(); + tableBeans.add(beanList); + } + if (errMsgBeans.size() == 0 && cb_errBtn.isSelected()) { + errMsgBeans = tableBeans; + } else if (allMsgBeans.size() == 0 && !cb_errBtn.isSelected()) { + allMsgBeans = tableBeans; + } + } + + ObservableList 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"); + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultFrame.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultFrame.java index 2ca3996..774c3b1 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultFrame.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultFrame.java @@ -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); + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultPanel.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultPanel.java index ed5ecff..b9cc00c 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultPanel.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SapResultPanel.java @@ -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 + } } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapController.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapController.java index 0b75b5c..37354c3 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapController.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapController.java @@ -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 tc_xh; - @FXML - private TableColumn tc_zrws; - @FXML - private TableColumn tc_rwh; - @FXML - private TableColumn tc_fqsj; - @FXML - private TableColumn tc_fqr; - @FXML - private TableColumn tc_status; - @FXML - private TableColumn tc_log; - @FXML - private TableColumn tc_sapState; - @FXML - private TableColumn tc_plm; - @FXML - private TableColumn 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 cb_factory; // 工厂下拉 - @FXML - private TextField tx_wbs; // wbs号 - @FXML - private ComboBox cb_status; // 数据状态 - @FXML - private TextField tx_user;// 发起人 - @FXML - private ComboBox cb_sapState; // sap处理结果 - @FXML - private TextField tx_projectName;// 项目名称 - @FXML - private CheckBox bt_errTask;// 查询错误任务 - @FXML - private CheckBox bt_errMsg; // 单个BOM错误信息 - // 明细条件 - @FXML - private ComboBox 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 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> tableBeans = new ArrayList>(); - - // 查询操作 - @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 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 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 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(); - tableBeans.add(beanList); - } - beanList.add(sumBean); - i = i + 1; - } - if (tableBeans.size() == 0) { - MessageBox.post(frame,"未查询到传递记录.", "提示", 2); - beanList = new ArrayList(); - tableBeans.add(beanList); - } - pageNum = 0; - System.out.println("beanList==>" + beanList.size()); - ObservableList 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 tc_xh; + @FXML + private TableColumn tc_zrws; + @FXML + private TableColumn tc_rwh; + @FXML + private TableColumn tc_fqsj; + @FXML + private TableColumn tc_fqr; + @FXML + private TableColumn tc_status; + @FXML + private TableColumn tc_log; + @FXML + private TableColumn tc_sapState; + @FXML + private TableColumn tc_plm; + @FXML + private TableColumn 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 cb_factory; // 工厂下拉 + @FXML + private TextField tx_wbs; // wbs号 + @FXML + private ComboBox cb_status; // 数据状态 + @FXML + private TextField tx_user;// 发起人 + @FXML + private ComboBox cb_sapState; // sap处理结果 + @FXML + private TextField tx_projectName;// 项目名称 + @FXML + private CheckBox bt_errTask;// 查询错误任务 + @FXML + private CheckBox bt_errMsg; // 单个BOM错误信息 + // 明细条件 + @FXML + private ComboBox 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 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> tableBeans = new ArrayList>(); + + // 查询操作 + @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 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 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 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(); + tableBeans.add(beanList); + } + beanList.add(sumBean); + i = i + 1; + } + if (tableBeans.size() == 0) { + MessageBox.post(frame, "未查询到传递记录.", "提示", 2); + beanList = new ArrayList(); + tableBeans.add(beanList); + } + pageNum = 0; + System.out.println("beanList==>" + beanList.size()); + ObservableList 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("num")); - tc_zrws.setCellValueFactory(new PropertyValueFactory("cTaskNum"));// cTaskNum - tc_rwh.setCellValueFactory(new PropertyValueFactory("taskNo")); - tc_fqsj.setCellValueFactory(new PropertyValueFactory("startTime")); - tc_fqr.setCellValueFactory(new PropertyValueFactory("user")); - tc_status.setCellValueFactory(new PropertyValueFactory<>("dataStatus")); - tc_log.setCellValueFactory(new PropertyValueFactory("logDownload")); - tc_sapState.setCellValueFactory(new PropertyValueFactory("sapResult")); - tc_plm.setCellValueFactory(new PropertyValueFactory("plmResult")); - tc_result.setCellValueFactory(new PropertyValueFactory("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() { - @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("num")); + tc_zrws.setCellValueFactory(new PropertyValueFactory("cTaskNum"));// cTaskNum + tc_rwh.setCellValueFactory(new PropertyValueFactory("taskNo")); + tc_fqsj.setCellValueFactory(new PropertyValueFactory("startTime")); + tc_fqr.setCellValueFactory(new PropertyValueFactory("user")); + tc_status.setCellValueFactory(new PropertyValueFactory<>("dataStatus")); + tc_log.setCellValueFactory(new PropertyValueFactory("logDownload")); + tc_sapState.setCellValueFactory(new PropertyValueFactory("sapResult")); + tc_plm.setCellValueFactory(new PropertyValueFactory("plmResult")); + tc_result.setCellValueFactory(new PropertyValueFactory("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() { + @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 factoryList = new ArrayList(); - factoryList.add("M040"); - cb_factory.getItems().addAll(factoryList); - List statusList = new ArrayList(); - statusList.add("数据检查未通过"); - statusList.add("数据正常推送SAP"); - statusList.add("数据未正常推送SAP"); - cb_status.getItems().addAll(statusList); - List sapStateList = new ArrayList(); - sapStateList.add("PLM数据检查未通过"); - sapStateList.add("未返回"); - sapStateList.add("处理中"); - sapStateList.add("全部成功"); - sapStateList.add("部分失败"); - cb_sapState.getItems().addAll(sapStateList); - List sapStatusList = new ArrayList(); - sapStatusList.add("成功"); - sapStatusList.add("失败"); - tx_sapStatus.getItems().addAll(sapStatusList); - } - - // 跳转首页 - @FXML - void firstBtnAction(ActionEvent event) { - pageNum = 0; - ObservableList data = FXCollections.observableArrayList(tableBeans.get(0)); - tableView.getItems().clear(); - tableView.setItems(data); - } - - // 跳转上一页 - @FXML - void lastBtnAction(ActionEvent event) { - if (pageNum > 0) { - pageNum = pageNum - 1; - } - ObservableList 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 data = FXCollections.observableArrayList(tableBeans.get(pageNum)); - tableView.getItems().clear(); - tableView.setItems(data); - } - - // 跳转尾页 - @FXML - void tailBtnAction(ActionEvent event) { - pageNum = tableBeans.size() - 1; - ObservableList 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 factoryList = new ArrayList(); + factoryList.add("M040"); + cb_factory.getItems().addAll(factoryList); + List statusList = new ArrayList(); + statusList.add("数据检查未通过"); + statusList.add("数据正常推送SAP"); + statusList.add("数据未正常推送SAP"); + cb_status.getItems().addAll(statusList); + List sapStateList = new ArrayList(); + sapStateList.add("PLM数据检查未通过"); + sapStateList.add("未返回"); + sapStateList.add("处理中"); + sapStateList.add("全部成功"); + sapStateList.add("部分失败"); + cb_sapState.getItems().addAll(sapStateList); + List sapStatusList = new ArrayList(); + sapStatusList.add("成功"); + sapStatusList.add("失败"); + tx_sapStatus.getItems().addAll(sapStatusList); + } + + // 跳转首页 + @FXML + void firstBtnAction(ActionEvent event) { + pageNum = 0; + ObservableList data = FXCollections.observableArrayList(tableBeans.get(0)); + tableView.getItems().clear(); + tableView.setItems(data); + } + + // 跳转上一页 + @FXML + void lastBtnAction(ActionEvent event) { + if (pageNum > 0) { + pageNum = pageNum - 1; + } + ObservableList 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 data = FXCollections.observableArrayList(tableBeans.get(pageNum)); + tableView.getItems().clear(); + tableView.setItems(data); + } + + // 跳转尾页 + @FXML + void tailBtnAction(ActionEvent event) { + pageNum = tableBeans.size() - 1; + ObservableList 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(); + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapResultComd.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapResultComd.java index 3366e2c..2aebcdb 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapResultComd.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SearchSapResultComd.java @@ -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()); diff --git a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SumTableBean.java b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SumTableBean.java index 3fdd4ac..efa897a 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SumTableBean.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/SearchSapResult/SumTableBean.java @@ -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> tableBeans = new ArrayList>(); // 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); - } - + } + } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdController.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdController.java index db06b82..1542fac 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdController.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdController.java @@ -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 bmComb; + @FXML + private ComboBox bmComb; - @FXML - private ComboBox factoryComb; + @FXML + private ComboBox 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 facList = new ArrayList<>(); - String first_FO = ""; - final Map> foMap = new HashMap<>(); - for (int i = 0; i < FO.length; i++) { + /** + * + * @function 根据首选项获取工厂和部门 + */ + public void getCombox() { + // 根据首选项获取工厂和部门 + String[] FO = session.getPreferenceService().getStringValues("CHINT_FAC_OFF"); + List facList = new ArrayList<>(); + String first_FO = ""; + final Map> 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 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 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 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 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 init = foMap.get(factoryComb.getSelectionModel().getSelectedItem()); - bmComb.getItems().addAll(init); + List 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(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(); } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdDialog.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdDialog.java index fcfdc29..1b91870 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdDialog.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/AssignIdDialog.java @@ -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(); + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnCommond.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnCommond.java index 713d3a5..facf414 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnCommond.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnCommond.java @@ -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()); diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnController.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnController.java index 8802c9f..fc59eec 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnController.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnController.java @@ -13,7 +13,10 @@ import java.sql.Statement; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; @@ -22,15 +25,24 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddress; import org.casic.javafx.control.DateTimePicker; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; import com.chint.plm.SearchSapResult.SumTableBean; import com.chint.plm.fxUtil.KFXPanel; import com.chint.plm.fxUtil.KFXPanelController; import com.connor.chint.JDBPackage.JDBFrame; +import com.connor.chint.sap2.util.BomToSapUtil; import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.POIUtil; import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SqlUtil; +import com.squareup.okhttp.MediaType; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.RequestBody; +import com.squareup.okhttp.Response; import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aifrcp.AIFUtility; @@ -71,979 +83,1077 @@ import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class CreateEcnController extends KFXPanelController { - @FXML - private TextField ecnId; - @FXML - private Button assignBtn; - @FXML - private TableView tableView; - @FXML - private StackPane stackPane; - @FXML - private DatePicker changeDate; - @FXML - private TitledPane referencePane; - @FXML - private RadioButton rb_product; - @FXML - private GridPane gridPane; - @FXML - private RadioButton rb_tempChange; // 临时更改通知单 - @FXML - private RadioButton rb_Process; - @FXML - private ScrollPane scollPane; - @FXML - private TitledPane tp_product; - @FXML - private TitledPane tc_details; - private List parts = new ArrayList(); - private List reasons = new ArrayList(); - private List wips = new ArrayList(); - private List products = new ArrayList(); - private List ecnBeans = new ArrayList(); - protected AbstractAIFApplication app; - private TCSession session; - private TCComponent target; - @FXML - private RadioButton rb_formalChange; // 正式更改通知单 - @FXML - private TextField factoryText; - @FXML - private GridPane productPane; - - @FXML - private TextField htNameText; - @FXML - public TextField markText; - @FXML - private TextField contractText; - @FXML - private ComboBox prodNameComb; - @FXML - private FlowPane departPane; - private List partBtns = new ArrayList<>(); - @FXML - private ComboBox pmCombox; - private CreateEcnController controller; - private CreateEcnFrame frame; - private String[] database; - - @Override - public void initData(KFXPanel paramKFXPanel) throws Exception { - // TODO Auto-generated method stub - this.app = AIFUtility.getCurrentApplication(); - this.session = (TCSession) app.getSession(); - target = (TCComponent) app.getTargetComponent(); - database = session.getPreferenceService().getStringValues("database_tc"); - CreateEcnFrame frame = (CreateEcnFrame) paramKFXPanel.getParentDialog(); - this.frame = frame; - addWindListener(frame); - // 过程组 - ToggleGroup group = new ToggleGroup(); // 变更类型组 - // 实现单选功能 - rb_formalChange.setToggleGroup(group); - rb_tempChange.setToggleGroup(group); - rb_formalChange.setSelected(true); - referencePane.setExpanded(false); - - ToggleGroup groupGc = new ToggleGroup(); // 变更类型组 - rb_product.setToggleGroup(groupGc); - rb_Process.setToggleGroup(groupGc); - tp_product.setCollapsible(false); - tc_details.setCollapsible(false); - controller = this; - createDetailTable(); - - createRefTable(); - // 获取选中的对象 - - initText(); - - } - - @FXML - private Button createBtn; - - /** - * @param event - * @throws Exception - * @function 创建按钮 - */ - @FXML - void createClick(ActionEvent event) throws Exception { - if (ecnId.getText().isEmpty()) { - MessageBox.post("请先指派变更单ID", "提示", 2); - return; - } - String changeName = "临时更改通知单"; - if (rb_formalChange.isSelected()) { - changeName = "正式更改通知单"; - } - if (target.getType().equals("ZT2_Change")) { - TCComponentItem item = (TCComponentItem) target; - setItemProperty(item, changeName); - - String type = item.getProperty("zt2_Template"); - TCComponentDataset dataset = null; - File file = null; - if (item.getRelatedComponents("IMAN_reference").length > 0) { - TCComponent[] comps = item.getRelatedComponents("IMAN_reference"); - for (int i = 0, len = comps.length; i < len; i++) { - if (comps[i] instanceof TCComponentDataset) { - dataset = (TCComponentDataset) comps[i]; - break; - } - } - // dataset=(TCComponentDataset) item.getRelatedComponents("IMAN_reference")[0]; - TCComponentDataset datasetM = getDataset(type, 0); - file = Util.getExcel(datasetM); - createOrReplace(dataset, file, changeName); - } else { - dataset = getDataset(type, 1); - file = Util.getExcel(dataset); - createOrReplace(dataset, file, changeName); - item.setRelated("IMAN_reference", new TCComponent[] { dataset }); - } - MessageBox.post("编辑完成", "", MessageBox.INFORMATION); - } else if (target.getType().equals("ZT2_ProjectItem")) { - String zt2_WBSNo = target.getProperty("zt2_WBSNo"); - // 针对新建, - TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ZT2_Change"); - TCComponentItem item = itemType.create(ecnId.getText(), null, "ZT2_Change", changeName, "", null); - // 设置属性 - boolean flag = true; - try { - setItemProperty(item, changeName); - } catch (Exception e1) { - e1.printStackTrace(); - flag = false; - if (e1.getMessage().contains("无法设置属性 更改前")) { - MessageBox.post( - "更改单生成异常:" + e1.getMessage() + "\n" - + " 【更改前】【更改后】字符总数不能超过256个字符\n (一个中文字=2个字符,1个标点或者英文=1个字符)", - "保存异常", MessageBox.INFORMATION); - } else if (e1.getMessage().contains("无法设置属性 更改后")) { - MessageBox.post( - "更改单生成异常:" + e1.getMessage() + "\n" - + " 【更改前】【更改后】字符总数不能超过256个字符 \n (一个中文字=2个字符,1个标点或者英文=1个字符)", - "保存异常", MessageBox.INFORMATION); - } else { - MessageBox.post("更改单生成异常:" + e1.getMessage(), "保存异常", MessageBox.INFORMATION); - } - item.delete(); - - } - if (flag) { - TCComponent targetFolder = getTargetFolder(target); - targetFolder.add("contents", new TCComponent[] { item }); - // 新建数据集挂到对象规范关系下,导出相关属性 - // 获取模板的puid - String type = item.getProperty("zt2_Template"); - TCComponentDataset dataset = null; - dataset = getDataset(type, 1); - item.setProperty("zt2_WBSNo", zt2_WBSNo); - - File file = Util.getExcel(dataset); - - createOrReplace(dataset, file, changeName); - - item.setRelated("IMAN_reference", new TCComponent[] { dataset }); - item.unlock(); - MessageBox.post("创建完成", "", MessageBox.INFORMATION); - } - - } - - // 影响分析信息 保存到CHINT_ECN_NOTIFICATION中 - try { - SqlUtil.getTCDataConnection(database); - String deleteSql = "delete CHINT_ECN_NOTIFICATION where \"ecncode\" = ? "; - String endCode = ecnId.getText(); - SqlUtil.delete(deleteSql, new String[] { endCode }); - String insertSql = "insert into CHINT_ECN_NOTIFICATION (\"ecncode\", \"code\", \"section\", \"no\" ," - + "\"actionstatement\",\"result\",\"principal\",\"pctime\",\"remark\") values (?,?,?,?,?,?,?,?,?)"; - ObservableList items = refTable.getItems(); - - for (int i = 0; i < 7; i++) { - RefTableBean refTableBean = items.get(i); - String result = refTableBean.getShYes().isSelected() ? "是" : "否"; - SqlUtil.write(new String[] { endCode, "1", refTableBean.getDepart(), String.valueOf(i + 1), - refTableBean.getMessage(), result, refTableBean.getUser().getText(), - refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); - } - for (int i = 7; i < 11; i++) { - RefTableBean refTableBean = items.get(i); - String result = refTableBean.getShYes().isSelected() ? "是" : "否"; - SqlUtil.write(new String[] { endCode, "2", refTableBean.getDepart(), String.valueOf(i - 6), - refTableBean.getMessage(), result, refTableBean.getUser().getText(), - refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); - } - for (int i = 11; i < 15; i++) { - RefTableBean refTableBean = items.get(i); - String result = refTableBean.getShYes().isSelected() ? "是" : "否"; - SqlUtil.write(new String[] { endCode, "3", refTableBean.getDepart(), String.valueOf(i - 10), - refTableBean.getMessage(), result, refTableBean.getUser().getText(), - refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); - } - for (int i = 15; i < 19; i++) { - RefTableBean refTableBean = items.get(i); - String result = refTableBean.getShYes().isSelected() ? "是" : "否"; - SqlUtil.write(new String[] { endCode, "4", refTableBean.getDepart(), String.valueOf(i - 14), - refTableBean.getMessage(), result, refTableBean.getUser().getText(), - refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); - } - for (int i = 19; i < 24; i++) { - RefTableBean refTableBean = items.get(i); - String result = refTableBean.getShYes().isSelected() ? "是" : "否"; - SqlUtil.write(new String[] { endCode, "5", refTableBean.getDepart(), String.valueOf(i - 18), - refTableBean.getMessage(), result, refTableBean.getUser().getText(), - refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); - } - for (int i = 24; i < 27; i++) { - RefTableBean refTableBean = items.get(i); - String result = refTableBean.getShYes().isSelected() ? "是" : "否"; - SqlUtil.write(new String[] { endCode, "6", refTableBean.getDepart(), String.valueOf(i - 23), - refTableBean.getMessage(), result, refTableBean.getUser().getText(), - refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); - } - for (int i = 27; i < 28; i++) { - RefTableBean refTableBean = items.get(i); - String result = refTableBean.getShYes().isSelected() ? "是" : "否"; - SqlUtil.write(new String[] { endCode, "7", refTableBean.getDepart(), String.valueOf(i - 26), - refTableBean.getMessage(), result, refTableBean.getUser().getText(), - refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - SqlUtil.freeAll(); - } - createBtn.setDisable(true); - } - - /** - * @param 数据集 - * @param 文件路径 - * @param 更改类型 创建或者替换excel文件 - */ - protected void createOrReplace(TCComponentDataset dataset, File file, String changeName) { - // 20200407新增删除多余的 - try { - FileInputStream fis = new FileInputStream(file); - HSSFWorkbook workBook = new HSSFWorkbook(fis); - HSSFSheet sheet = workBook.getSheetAt(0); - sheet.getRow(1).getCell(6).setCellValue(changeName); - sheet.getRow(1).getCell(13).setCellValue(ecnId.getText()); + @FXML + private TextField ecnId; + @FXML + private Button assignBtn; + @FXML + private TableView tableView; + @FXML + private StackPane stackPane; + @FXML + private DatePicker changeDate; + @FXML + private TitledPane referencePane; + @FXML + private RadioButton rb_product; + @FXML + private GridPane gridPane; + @FXML + private RadioButton rb_tempChange; // 临时更改通知单 + @FXML + private RadioButton rb_Process; + @FXML + private ScrollPane scollPane; + @FXML + private TitledPane tp_product; + @FXML + private TitledPane tc_details; + private List parts = new ArrayList(); + private List reasons = new ArrayList(); + private List wips = new ArrayList(); + private List products = new ArrayList(); + private List ecnBeans = new ArrayList(); + protected AbstractAIFApplication app; + private TCSession session; + private TCComponent target; + @FXML + private RadioButton rb_formalChange; // 正式更改通知单 + @FXML + private TextField factoryText; + @FXML + private GridPane productPane; + + @FXML + private TextField htNameText; + @FXML + public TextField markText; + @FXML + private TextField contractText; + @FXML + private ComboBox prodNameComb; + @FXML + private FlowPane departPane; + private List partBtns = new ArrayList<>(); + @FXML + private ComboBox pmCombox; + private CreateEcnController controller; + private CreateEcnFrame frame; + private String[] database; + + @Override + public void initData(KFXPanel paramKFXPanel) throws Exception { + // TODO Auto-generated method stub + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + target = (TCComponent) app.getTargetComponent(); + database = session.getPreferenceService().getStringValues("database_tc"); + CreateEcnFrame frame = (CreateEcnFrame) paramKFXPanel.getParentDialog(); + this.frame = frame; + addWindListener(frame); + // 过程组 + ToggleGroup group = new ToggleGroup(); // 变更类型组 + // 实现单选功能 + rb_formalChange.setToggleGroup(group); + rb_tempChange.setToggleGroup(group); + rb_formalChange.setSelected(true); + referencePane.setExpanded(false); + + ToggleGroup groupGc = new ToggleGroup(); // 变更类型组 + rb_product.setToggleGroup(groupGc); + rb_Process.setToggleGroup(groupGc); + tp_product.setCollapsible(false); + tc_details.setCollapsible(false); + controller = this; + createDetailTable(); + + createRefTable(); + // 获取选中的对象 + + initText(); + + } + + @FXML + private Button createBtn; + + /** + * @param event + * @throws Exception + * @function 创建按钮 + */ + @FXML + void createClick(ActionEvent event) throws Exception { + if (ecnId.getText().isEmpty()) { + MessageBox.post("请先指派变更单ID", "提示", 2); + return; + } + String changeName = "临时更改通知单"; + if (rb_formalChange.isSelected()) { + changeName = "正式更改通知单"; + } + if (target.getType().equals("ZT2_Change")) { + TCComponentItem item = (TCComponentItem) target; + setItemProperty(item, changeName); + + String type = item.getProperty("zt2_Template"); + TCComponentDataset dataset = null; + File file = null; + if (item.getRelatedComponents("IMAN_reference").length > 0) { + TCComponent[] comps = item.getRelatedComponents("IMAN_reference"); + for (int i = 0, len = comps.length; i < len; i++) { + if (comps[i] instanceof TCComponentDataset) { + dataset = (TCComponentDataset) comps[i]; + break; + } + } + // dataset=(TCComponentDataset) item.getRelatedComponents("IMAN_reference")[0]; + TCComponentDataset datasetM = getDataset(type, 0); + file = Util.getExcel(datasetM); + createOrReplace(dataset, file, changeName); + } else { + dataset = getDataset(type, 1); + file = Util.getExcel(dataset); + createOrReplace(dataset, file, changeName); + item.setRelated("IMAN_reference", new TCComponent[] { dataset }); + } + MessageBox.post("编辑完成", "", MessageBox.INFORMATION); + } else if (target.getType().equals("ZT2_ProjectItem")) { + String zt2_WBSNo = target.getProperty("zt2_WBSNo"); + // 针对新建, + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ZT2_Change"); + TCComponentItem item = itemType.create(ecnId.getText(), null, "ZT2_Change", changeName, "", null); + // 设置属性 + boolean flag = true; + try { + setItemProperty(item, changeName); + } catch (Exception e1) { + e1.printStackTrace(); + flag = false; + if (e1.getMessage().contains("无法设置属性 更改前")) { + MessageBox.post( + "更改单生成异常:" + e1.getMessage() + "\n" + + " 【更改前】【更改后】字符总数不能超过256个字符\n (一个中文字=2个字符,1个标点或者英文=1个字符)", + "保存异常", MessageBox.INFORMATION); + } else if (e1.getMessage().contains("无法设置属性 更改后")) { + MessageBox.post( + "更改单生成异常:" + e1.getMessage() + "\n" + + " 【更改前】【更改后】字符总数不能超过256个字符 \n (一个中文字=2个字符,1个标点或者英文=1个字符)", + "保存异常", MessageBox.INFORMATION); + } else { + MessageBox.post("更改单生成异常:" + e1.getMessage(), "保存异常", MessageBox.INFORMATION); + } + item.delete(); + + } + if (flag) { + TCComponent targetFolder = getTargetFolder(target); + targetFolder.add("contents", new TCComponent[] { item }); + // 新建数据集挂到对象规范关系下,导出相关属性 + // 获取模板的puid + String type = item.getProperty("zt2_Template"); + TCComponentDataset dataset = null; + dataset = getDataset(type, 1); + item.setProperty("zt2_WBSNo", zt2_WBSNo); + + File file = Util.getExcel(dataset); + + createOrReplace(dataset, file, changeName); + + item.setRelated("IMAN_reference", new TCComponent[] { dataset }); + item.unlock(); + MessageBox.post("创建完成", "", MessageBox.INFORMATION); + } + + } + + // 影响分析信息 保存到CHINT_ECN_NOTIFICATION中 + try { + SqlUtil.getTCDataConnection(database); + String deleteSql = "delete CHINT_ECN_NOTIFICATION where \"ecncode\" = ? "; + String endCode = ecnId.getText(); + SqlUtil.delete(deleteSql, new String[] { endCode }); + String insertSql = "insert into CHINT_ECN_NOTIFICATION (\"ecncode\", \"code\", \"section\", \"no\" ," + + "\"actionstatement\",\"result\",\"principal\",\"pctime\",\"remark\") values (?,?,?,?,?,?,?,?,?)"; + ObservableList items = refTable.getItems(); + + // 1222 新增逻辑,责任人指派 + for (int i = 0; i < 7; i++) { + RefTableBean refTableBean = items.get(i); + String result = refTableBean.getShYes().isSelected() ? "是" : "否"; + SqlUtil.write(new String[] { endCode, "1", refTableBean.getDepart(), String.valueOf(i + 1), + refTableBean.getMessage(), result, refTableBean.getUserVal(), + refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); + } + for (int i = 7; i < 11; i++) { + RefTableBean refTableBean = items.get(i); + String result = refTableBean.getShYes().isSelected() ? "是" : "否"; + SqlUtil.write(new String[] { endCode, "2", refTableBean.getDepart(), String.valueOf(i - 6), + refTableBean.getMessage(), result, refTableBean.getUserVal(), + refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); + } + for (int i = 11; i < 15; i++) { + RefTableBean refTableBean = items.get(i); + String result = refTableBean.getShYes().isSelected() ? "是" : "否"; + SqlUtil.write(new String[] { endCode, "3", refTableBean.getDepart(), String.valueOf(i - 10), + refTableBean.getMessage(), result, refTableBean.getUserVal(), + refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); + } + for (int i = 15; i < 19; i++) { + RefTableBean refTableBean = items.get(i); + String result = refTableBean.getShYes().isSelected() ? "是" : "否"; + SqlUtil.write(new String[] { endCode, "4", refTableBean.getDepart(), String.valueOf(i - 14), + refTableBean.getMessage(), result, refTableBean.getUserVal(), + refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); + } + for (int i = 19; i < 24; i++) { + RefTableBean refTableBean = items.get(i); + String result = refTableBean.getShYes().isSelected() ? "是" : "否"; + SqlUtil.write(new String[] { endCode, "5", refTableBean.getDepart(), String.valueOf(i - 18), + refTableBean.getMessage(), result, refTableBean.getUserVal(), + refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); + } + for (int i = 24; i < 27; i++) { + RefTableBean refTableBean = items.get(i); + String result = refTableBean.getShYes().isSelected() ? "是" : "否"; + SqlUtil.write(new String[] { endCode, "6", refTableBean.getDepart(), String.valueOf(i - 23), + refTableBean.getMessage(), result, refTableBean.getUserVal(), + refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); + } + for (int i = 27; i < 28; i++) { + RefTableBean refTableBean = items.get(i); + String result = refTableBean.getShYes().isSelected() ? "是" : "否"; + SqlUtil.write(new String[] { endCode, "7", refTableBean.getDepart(), String.valueOf(i - 26), + refTableBean.getMessage(), result, refTableBean.getUserVal(), + refTableBean.getCompDate().getText(), refTableBean.getMark().getText() }, insertSql); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + SqlUtil.freeAll(); + } + createBtn.setDisable(true); + } + + /** + * @param 数据集 + * @param 文件路径 + * @param 更改类型 创建或者替换excel文件 + */ + protected void createOrReplace(TCComponentDataset dataset, File file, String changeName) { + // 20200407新增删除多余的 + try { + FileInputStream fis = new FileInputStream(file); + HSSFWorkbook workBook = new HSSFWorkbook(fis); + HSSFSheet sheet = workBook.getSheetAt(0); + sheet.getRow(1).getCell(6).setCellValue(changeName); + sheet.getRow(1).getCell(13).setCellValue(ecnId.getText()); // int page = 0; - List mergeRegions = null; - - for (int i = 0; i < pages; i++) { - int pace = 0; - if (sheet.getRow(2 + i * 23) == null) { - if (mergeRegions == null) { - mergeRegions = Util.getMergeRegions(sheet, 2, 24); - } - Util.addExcelPage(i, mergeRegions, sheet, workBook); - int index = 0; - for (int k = i * 5; k < (i + 1) * 5; k++) { - sheet.getRow(5 + 3 * index + i * 23).getCell(1).setCellValue(""); - sheet.getRow(5 + 3 * index + i * 23).getCell(6).setCellValue(""); - sheet.getRow(5 + 3 * index + i * 23).getCell(9).setCellValue(""); - sheet.getRow(5 + 3 * index + i * 23).getCell(12).setCellValue(""); - sheet.getRow(5 + 3 * index + i * 23).getCell(14).setCellValue(""); - index++; - } - } - sheet.getRow(2 + i * 23).getCell(15).setCellValue("共 " + pages + " 页"); - sheet.getRow(3 + i * 23).getCell(1).setCellValue(changeType); + List mergeRegions = null; + + for (int i = 0; i < pages; i++) { + int pace = 0; + if (sheet.getRow(2 + i * 23) == null) { + if (mergeRegions == null) { + mergeRegions = Util.getMergeRegions(sheet, 2, 24); + } + Util.addExcelPage(i, mergeRegions, sheet, workBook); + int index = 0; + for (int k = i * 5; k < (i + 1) * 5; k++) { + sheet.getRow(5 + 3 * index + i * 23).getCell(1).setCellValue(""); + sheet.getRow(5 + 3 * index + i * 23).getCell(6).setCellValue(""); + sheet.getRow(5 + 3 * index + i * 23).getCell(9).setCellValue(""); + sheet.getRow(5 + 3 * index + i * 23).getCell(12).setCellValue(""); + sheet.getRow(5 + 3 * index + i * 23).getCell(14).setCellValue(""); + index++; + } + } + sheet.getRow(2 + i * 23).getCell(15).setCellValue("共 " + pages + " 页"); + sheet.getRow(3 + i * 23).getCell(1).setCellValue(changeType); // sheet.getRow(3 + i * 23).getCell(9).setCellValue(jobNames);//工作号 去掉了 - sheet.getRow(3 + i * 23).getCell(11).setCellValue(contractNo); - sheet.getRow(3 + i * 23).getCell(14).setCellValue(changeTime); - sheet.getRow(23 + i * 23).getCell(2).setCellValue(contractName); - - String[] unitCount = changeUnit1.split(";"); - for (int j = 0; j < unitCount.length; j++) { - sheet.getRow(5 + j + i * 23).getCell(15).setCellValue(unitCount[j]); - } - HSSFCell cell; - - for (int k = i * 5; k < (i + 1) * 5; k++) { - if (k > changeDrawingNo.length - 1) { - break; - } - sheet.getRow(5 + 3 * pace + i * 23).getCell(1).setCellValue(changeDrawingNo[k]); - sheet.getRow(5 + 3 * pace + i * 23).getCell(3).setCellValue(sign[k]); + sheet.getRow(3 + i * 23).getCell(11).setCellValue(contractNo); + sheet.getRow(3 + i * 23).getCell(14).setCellValue(changeTime); + sheet.getRow(23 + i * 23).getCell(2).setCellValue(contractName); + + String[] unitCount = changeUnit1.split(";"); + for (int j = 0; j < unitCount.length; j++) { + sheet.getRow(5 + j + i * 23).getCell(15).setCellValue(unitCount[j]); + } + HSSFCell cell; + + for (int k = i * 5; k < (i + 1) * 5; k++) { + if (k > changeDrawingNo.length - 1) { + break; + } + sheet.getRow(5 + 3 * pace + i * 23).getCell(1).setCellValue(changeDrawingNo[k]); + sheet.getRow(5 + 3 * pace + i * 23).getCell(3).setCellValue(sign[k]); // sheet.getRow(5 + 3 * pace + i * 23).getCell(4).setCellValue(placesNo[k]); - sheet.getRow(5 + 3 * pace + i * 23).getCell(5).setCellValue(partition[k]); - sheet.getRow(5 + 3 * pace + i * 23).getCell(6).setCellValue(changeBefore1[k]); - sheet.getRow(5 + 3 * pace + i * 23).getCell(9).setCellValue(changeAfter1[k]); - sheet.getRow(5 + 3 * pace + i * 23).getCell(12).setCellValue(changeReason[k]); - sheet.getRow(5 + 3 * pace + i * 23).getCell(14).setCellValue(processType1[k]); - - pace++; - } - - } - if (pages == 0) { - sheet.getRow(2).getCell(15).setCellValue("共 1 页"); - sheet.getRow(3).getCell(1).setCellValue(productModel); + sheet.getRow(5 + 3 * pace + i * 23).getCell(5).setCellValue(partition[k]); + sheet.getRow(5 + 3 * pace + i * 23).getCell(6).setCellValue(changeBefore1[k]); + sheet.getRow(5 + 3 * pace + i * 23).getCell(9).setCellValue(changeAfter1[k]); + sheet.getRow(5 + 3 * pace + i * 23).getCell(12).setCellValue(changeReason[k]); + sheet.getRow(5 + 3 * pace + i * 23).getCell(14).setCellValue(processType1[k]); + + pace++; + } + + } + if (pages == 0) { + sheet.getRow(2).getCell(15).setCellValue("共 1 页"); + sheet.getRow(3).getCell(1).setCellValue(productModel); // sheet.getRow(3).getCell(9).setCellValue(jobNames); - sheet.getRow(3).getCell(11).setCellValue(contractNo); - sheet.getRow(3).getCell(14).setCellValue(changeTime); - sheet.getRow(23).getCell(2).setCellValue(contractName); - String[] unitCount = changeUnit1.split(";"); - for (int j = 0; j < unitCount.length; j++) { - sheet.getRow(5 + j).getCell(15).setCellValue(unitCount[j]); - } - } - File file2 = null; - String timeNow = Util.GetNowDate(); - String filePath = System.getProperty("java.io.tmpdir") + timeNow + ".xls"; - file2 = new File(filePath); - FileOutputStream fos = new FileOutputStream(file2); - workBook.write(fos); - - Util.deMerge(filePath, filePath, pages); - Util.delete(filePath, filePath, pages); - dataset.setFiles(new String[] { filePath }, new String[] { "excel" }); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private String contractNo; // 合同代号 - private String contractName;// 合同名称 - private String productModel; // 产品型号 - private String changeType; // 正式临时 - private String changeTime;// 更改实施日期 - private String changeUnit1; // 属性变更发往部门 - - /** - * @param item 对象 - * @param changeName 变更类型 - * @throws Exception - * @function 修改变更对象的属性 - */ - protected void setItemProperty(TCComponentItem item, String changeName) throws Exception { - - contractNo = contractText.getText(); // 合同代号 - contractName = htNameText.getText();// 合同名称 - productModel = pmCombox.getSelectionModel().getSelectedItem(); // 产品型号 - String productName = prodNameComb.getSelectionModel().getSelectedItem(); - String fileName = markText.getText(); - changeType = changeName; // 正式临时 - item.setProperty("zt2_ContractNo", contractNo); - item.setProperty("zt2_ContractName", contractName); - item.setProperty("zt2_ProductModel", productModel); - item.setProperty("zt2_ChangeType", changeType); - item.setProperty("zt2_FileName", fileName); - item.setProperty("zt2_ProductName", productName); - item.setProperty("zt2_ChangRequestNo", relateEcnText.getText()); - changeTime = changeDate.getEditor().getText(); - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-M-dd"); - if (changeTime.length() > 0) { - Date date = sdf2.parse(changeTime); - item.setDateProperty("zt2_ChangeDate", date); - } - StringBuilder unit = new StringBuilder(""); - for (int j = 0; j < partBtns.size(); j++) { - CheckBox radioButton = partBtns.get(j); - if (radioButton.isSelected()) { - if (unit.length() > 0) { - unit.append(";").append(radioButton.getText()); - } else { - unit.append(radioButton.getText()); - } - } - } - changeUnit1 = unit.toString(); // 属性变更发往部门 - item.setProperty("zt2_ChangeUnit1", changeUnit1); - ObservableList items = tableView.getItems(); - int rowCount = items.size(); - - System.out.println(rowCount); - changeDrawingNo = new String[rowCount]; - sign = new String[rowCount]; + sheet.getRow(3).getCell(11).setCellValue(contractNo); + sheet.getRow(3).getCell(14).setCellValue(changeTime); + sheet.getRow(23).getCell(2).setCellValue(contractName); + String[] unitCount = changeUnit1.split(";"); + for (int j = 0; j < unitCount.length; j++) { + sheet.getRow(5 + j).getCell(15).setCellValue(unitCount[j]); + } + } + File file2 = null; + String timeNow = Util.GetNowDate(); + String filePath = System.getProperty("java.io.tmpdir") + timeNow + ".xls"; + file2 = new File(filePath); + FileOutputStream fos = new FileOutputStream(file2); + workBook.write(fos); + + Util.deMerge(filePath, filePath, pages); + Util.delete(filePath, filePath, pages); + dataset.setFiles(new String[] { filePath }, new String[] { "excel" }); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + private String contractNo; // 合同代号 + private String contractName;// 合同名称 + private String productModel; // 产品型号 + private String changeType; // 正式临时 + private String changeTime;// 更改实施日期 + private String changeUnit1; // 属性变更发往部门 + + /** + * @param item 对象 + * @param changeName 变更类型 + * @throws Exception + * @function 修改变更对象的属性 + */ + protected void setItemProperty(TCComponentItem item, String changeName) throws Exception { + + contractNo = contractText.getText(); // 合同代号 + contractName = htNameText.getText();// 合同名称 + productModel = pmCombox.getSelectionModel().getSelectedItem(); // 产品型号 + String productName = prodNameComb.getSelectionModel().getSelectedItem(); + String fileName = markText.getText(); + changeType = changeName; // 正式临时 + item.setProperty("zt2_ContractNo", contractNo); + item.setProperty("zt2_ContractName", contractName); + item.setProperty("zt2_ProductModel", productModel); + item.setProperty("zt2_ChangeType", changeType); + item.setProperty("zt2_FileName", fileName); + item.setProperty("zt2_ProductName", productName); + item.setProperty("zt2_ChangRequestNo", relateEcnText.getText()); + changeTime = changeDate.getEditor().getText(); + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-M-dd"); + if (changeTime.length() > 0) { + Date date = sdf2.parse(changeTime); + item.setDateProperty("zt2_ChangeDate", date); + } + StringBuilder unit = new StringBuilder(""); + for (int j = 0; j < partBtns.size(); j++) { + CheckBox radioButton = partBtns.get(j); + if (radioButton.isSelected()) { + if (unit.length() > 0) { + unit.append(";").append(radioButton.getText()); + } else { + unit.append(radioButton.getText()); + } + } + } + changeUnit1 = unit.toString(); // 属性变更发往部门 + item.setProperty("zt2_ChangeUnit1", changeUnit1); + ObservableList items = tableView.getItems(); + int rowCount = items.size(); + + System.out.println(rowCount); + changeDrawingNo = new String[rowCount]; + sign = new String[rowCount]; // placesNo = new String[rowCount]; - partition = new String[rowCount]; - changeBefore1 = new String[rowCount]; - changeAfter1 = new String[rowCount]; - changeReason = new String[rowCount]; - processType1 = new String[rowCount]; - szVersionBefs = new String[rowCount]; - szVersionAfts = new String[rowCount]; - - productSzs = new String[rowCount]; - processSzs = new String[rowCount]; - - int modulus = changeDrawingNo.length % 5; - int dlivery = changeDrawingNo.length / 5; - if (modulus == 0) { - pages = dlivery; - } else { - pages = dlivery + 1; - System.out.println("页数pages:" + pages); - } - for (int i = 0; i < rowCount; i++) { - EcnBean ecnBean = items.get(i); - changeDrawingNo[i] = ecnBean.getDrawNo().getText(); - sign[i] = ecnBean.getMark().getText(); + partition = new String[rowCount]; + changeBefore1 = new String[rowCount]; + changeAfter1 = new String[rowCount]; + changeReason = new String[rowCount]; + processType1 = new String[rowCount]; + szVersionBefs = new String[rowCount]; + szVersionAfts = new String[rowCount]; + + productSzs = new String[rowCount]; + processSzs = new String[rowCount]; + + int modulus = changeDrawingNo.length % 5; + int dlivery = changeDrawingNo.length / 5; + if (modulus == 0) { + pages = dlivery; + } else { + pages = dlivery + 1; + System.out.println("页数pages:" + pages); + } + for (int i = 0; i < rowCount; i++) { + EcnBean ecnBean = items.get(i); + changeDrawingNo[i] = ecnBean.getDrawNo().getText(); + sign[i] = ecnBean.getMark().getText(); // placesNo[i] = ecnBean.getPoiNum().getText(); - partition[i] = ecnBean.getPoiNum().getText(); - changeBefore1[i] = ecnBean.getOverChange().getText(); - changeAfter1[i] = ecnBean.getAfterChange().getText(); - String reasonItem = ecnBean.getChangeReason().getSelectionModel().getSelectedItem(); - changeReason[i] = reasonItem == null ? "" : reasonItem; - String processTypeItem = ecnBean.getWipTreat().getSelectionModel().getSelectedItem(); - processType1[i] = processTypeItem == null ? "" : processTypeItem; - szVersionBefs[i] = ecnBean.getOverVersion().getText(); - szVersionAfts[i] = ecnBean.getAfterVersion().getText(); - productSzs[i] = ecnBean.getProductSz().getSelectionModel().getSelectedItem(); - processSzs[i] = rb_product.isSelected() ? "Y" : "N"; - } - item.getTCProperty("zt2_ChangeDrawingNo").setStringValueArray(changeDrawingNo); - item.getTCProperty("zt2_Sign").setStringValueArray(sign); - item.getTCProperty("zt2_PlacesNo").setStringValueArray(partition); // 处数 - item.getTCProperty("zt2_ChangeBefore1").setStringValueArray(changeBefore1); - item.getTCProperty("zt2_ChangeAfter1").setStringValueArray(changeAfter1); - item.getTCProperty("zt2_ChangeReason").setStringValueArray(changeReason); - item.getTCProperty("zt2_ProcessType1").setStringValueArray(processType1); - item.getTCProperty("zt2_SZVersionbefore").setStringValueArray(szVersionBefs); - item.getTCProperty("zt2_SZRevisedversion").setStringValueArray(szVersionAfts); - item.getTCProperty("zt2_SZProduct").setStringValueArray(productSzs); - item.getTCProperty("zt2_SZProcess").setStringValueArray(processSzs); - } - - private int pages = 0; - private String[] changeDrawingNo; // 属性zt2_ChangeDrawingNo - private String[] sign; // 属性zt2_Sign + partition[i] = ecnBean.getPoiNum().getText(); + changeBefore1[i] = ecnBean.getOverChange().getText(); + changeAfter1[i] = ecnBean.getAfterChange().getText(); + String reasonItem = ecnBean.getChangeReason().getSelectionModel().getSelectedItem(); + changeReason[i] = reasonItem == null ? "" : reasonItem; + String processTypeItem = ecnBean.getWipTreat().getSelectionModel().getSelectedItem(); + processType1[i] = processTypeItem == null ? "" : processTypeItem; + szVersionBefs[i] = ecnBean.getOverVersion().getText(); + szVersionAfts[i] = ecnBean.getAfterVersion().getText(); + productSzs[i] = ecnBean.getProductSz().getSelectionModel().getSelectedItem(); + processSzs[i] = rb_product.isSelected() ? "Y" : "N"; + } + item.getTCProperty("zt2_ChangeDrawingNo").setStringValueArray(changeDrawingNo); + item.getTCProperty("zt2_Sign").setStringValueArray(sign); + item.getTCProperty("zt2_PlacesNo").setStringValueArray(partition); // 处数 + item.getTCProperty("zt2_ChangeBefore1").setStringValueArray(changeBefore1); + item.getTCProperty("zt2_ChangeAfter1").setStringValueArray(changeAfter1); + item.getTCProperty("zt2_ChangeReason").setStringValueArray(changeReason); + item.getTCProperty("zt2_ProcessType1").setStringValueArray(processType1); + item.getTCProperty("zt2_SZVersionbefore").setStringValueArray(szVersionBefs); + item.getTCProperty("zt2_SZRevisedversion").setStringValueArray(szVersionAfts); + item.getTCProperty("zt2_SZProduct").setStringValueArray(productSzs); + item.getTCProperty("zt2_SZProcess").setStringValueArray(processSzs); + } + + private int pages = 0; + private String[] changeDrawingNo; // 属性zt2_ChangeDrawingNo + private String[] sign; // 属性zt2_Sign // private String[] placesNo; //属性zt2_PlacesNo - private String[] partition; // 属性zt2_Partition - private String[] changeBefore1; // 属性zt2_ChangeBefore1 - private String[] changeAfter1; // 属性zt2_ChangeAfter1 - private String[] changeReason; // 属性zt2_ChangeReason - private String[] processType1; // 属性zt2_ProcessType1 - private String[] szVersionBefs; // 变更前版本 - private String[] szVersionAfts; // 变更后版本 - private String[] productSzs; // 变更后版本 - private String[] processSzs; // 变更后版本 - - /** - * @param event - * @function 关闭页面操作 - */ - @FXML - void disposeClick(ActionEvent event) { - frame.dispose(); - } - - /** - * @throws Exception - * @function 初始化页面组件 - */ - private void initText() throws Exception { - List productModelList = new ArrayList<>(); - productModelList = Util.getproductModel(target, productModelList); - factoryText.setEditable(false); - pmCombox.getItems().addAll(productModelList); - List unitList = new ArrayList<>(); - contractText.setText(Util.getProjectNo(target)); - contractText.setEditable(false); - htNameText.setText(Util.getProjectName(target)); - htNameText.setEditable(false); - ecnId.setEditable(false); - rb_product.setSelected(true); - if (target.getType().equals("ZT2_ProjectItem")) { - // 获取产成品的名称 - List ccpNameFromProject = KUtil.getCCPNameFromProject(target, session); - prodNameComb.getItems().addAll(ccpNameFromProject); - } else { - // 对象类型为变更对象时 , 设置ID,时间,产品型号、 - List productNameList = new ArrayList<>(); - productNameList = Util.getProductNames(target, productNameList); - prodNameComb.getItems().addAll(productNameList); - String productModel = target.getProperty("zt2_ProductModel"); - pmCombox.getSelectionModel().select(productModel); - assignBtn.setDisable(true); - ecnId.setText(target.getProperty("item_id")); - TCProperty[] properties = null; - try { - Date date = target.getDateProperty("zt2_ChangeDate"); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - if (date != null) { - changeDate.getEditor().setText(sdf.format(date)); - } - // 初始化选中工厂 - if (target.getType().equals("ZT2_Change")) { - String[] changeUnit1 = target.getProperty("zt2_ChangeUnit1").split(";"); - for (int j = 0; j < changeUnit1.length; j++) { - unitList.add(changeUnit1[j]); - } - } + private String[] partition; // 属性zt2_Partition + private String[] changeBefore1; // 属性zt2_ChangeBefore1 + private String[] changeAfter1; // 属性zt2_ChangeAfter1 + private String[] changeReason; // 属性zt2_ChangeReason + private String[] processType1; // 属性zt2_ProcessType1 + private String[] szVersionBefs; // 变更前版本 + private String[] szVersionAfts; // 变更后版本 + private String[] productSzs; // 变更后版本 + private String[] processSzs; // 变更后版本 + + /** + * @param event + * @function 关闭页面操作 + */ + @FXML + void disposeClick(ActionEvent event) { + frame.dispose(); + } + + /** + * @throws Exception + * @function 初始化页面组件 + */ + private void initText() throws Exception { + List productModelList = new ArrayList<>(); + productModelList = Util.getproductModel(target, productModelList); + factoryText.setEditable(false); + pmCombox.getItems().addAll(productModelList); + List unitList = new ArrayList<>(); + contractText.setText(Util.getProjectNo(target)); + contractText.setEditable(false); + htNameText.setText(Util.getProjectName(target)); + htNameText.setEditable(false); + ecnId.setEditable(false); + rb_product.setSelected(true); + if (target.getType().equals("ZT2_ProjectItem")) { + // 获取产成品的名称 + List ccpNameFromProject = KUtil.getCCPNameFromProject(target, session); + prodNameComb.getItems().addAll(ccpNameFromProject); + } else { + // 对象类型为变更对象时 , 设置ID,时间,产品型号、 + List productNameList = new ArrayList<>(); + productNameList = Util.getProductNames(target, productNameList); + prodNameComb.getItems().addAll(productNameList); + String productModel = target.getProperty("zt2_ProductModel"); + pmCombox.getSelectionModel().select(productModel); + assignBtn.setDisable(true); + ecnId.setText(target.getProperty("item_id")); + TCProperty[] properties = null; + try { + Date date = target.getDateProperty("zt2_ChangeDate"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if (date != null) { + changeDate.getEditor().setText(sdf.format(date)); + } + // 初始化选中工厂 + if (target.getType().equals("ZT2_Change")) { + String[] changeUnit1 = target.getProperty("zt2_ChangeUnit1").split(";"); + for (int j = 0; j < changeUnit1.length; j++) { + unitList.add(changeUnit1[j]); + } + } // zt2_Partition - target.refresh(); - properties = target.getTCProperties( - new String[] { "zt2_ChangeDrawingNo", "zt2_Sign", "zt2_PlacesNo", "zt2_Partition", - "zt2_ChangeBefore1", "zt2_ChangeAfter1", "zt2_ChangeReason", "zt2_ProcessType1", - "zt2_SZVersionbefore", "zt2_SZRevisedversion", "zt2_SZProduct", "zt2_SZProcess" }); - } catch (TCException e1) { - e1.printStackTrace(); - } - String[] ChangeDrawingNo = properties[0].getStringArrayValue(); - String[] sign = properties[1].getStringArrayValue(); - String[] placesNo = properties[2].getStringArrayValue(); + target.refresh(); + properties = target.getTCProperties( + new String[] { "zt2_ChangeDrawingNo", "zt2_Sign", "zt2_PlacesNo", "zt2_Partition", + "zt2_ChangeBefore1", "zt2_ChangeAfter1", "zt2_ChangeReason", "zt2_ProcessType1", + "zt2_SZVersionbefore", "zt2_SZRevisedversion", "zt2_SZProduct", "zt2_SZProcess" }); + } catch (TCException e1) { + e1.printStackTrace(); + } + String[] ChangeDrawingNo = properties[0].getStringArrayValue(); + String[] sign = properties[1].getStringArrayValue(); + String[] placesNo = properties[2].getStringArrayValue(); // String[] partition = properties[3].getStringArrayValue(); - String[] ChangeBefore1 = properties[4].getStringArrayValue(); - String[] ChangeAfter1 = properties[5].getStringArrayValue(); - String[] ChangeReason = properties[6].getStringArrayValue(); - String[] ProcessType1 = properties[7].getStringArrayValue(); - String[] szVersionBef = properties[8].getStringArrayValue(); - String[] szVersionAft = properties[9].getStringArrayValue(); - String[] szProduct = properties[10].getStringArrayValue(); - String[] szProcess = properties[11].getStringArrayValue(); - if (szProcess.length > 0) { - rb_Process.setSelected(szProcess[0].equals("N")); - } - String fileName = target.getProperty("zt2_FileName"); - String productName = target.getProperty("zt2_ProductName"); - String changRequestNo = target.getProperty("zt2_ChangRequestNo");// relateEcnText.getText() - prodNameComb.getSelectionModel().select(productName); - markText.setText(fileName); - relateEcnText.setText(changRequestNo); + String[] ChangeBefore1 = properties[4].getStringArrayValue(); + String[] ChangeAfter1 = properties[5].getStringArrayValue(); + String[] ChangeReason = properties[6].getStringArrayValue(); + String[] ProcessType1 = properties[7].getStringArrayValue(); + String[] szVersionBef = properties[8].getStringArrayValue(); + String[] szVersionAft = properties[9].getStringArrayValue(); + String[] szProduct = properties[10].getStringArrayValue(); + String[] szProcess = properties[11].getStringArrayValue(); + if (szProcess.length > 0) { + rb_Process.setSelected(szProcess[0].equals("N")); + } + String fileName = target.getProperty("zt2_FileName"); + String productName = target.getProperty("zt2_ProductName"); + String changRequestNo = target.getProperty("zt2_ChangRequestNo");// relateEcnText.getText() + prodNameComb.getSelectionModel().select(productName); + markText.setText(fileName); + relateEcnText.setText(changRequestNo); // String productName = prodNameComb.getSelectionModel().getSelectedItem(); // String fileName = markText.getText(); // item.setProperty("zt2_FileName", fileName); // item.setProperty("zt2_ProductName", productName); - int rowNum = 0; - for (int j = 0; j < ChangeDrawingNo.length; j++) { - rowNum++; - EcnBean ecnBean = new EcnBean(rowNum, reasons, wips, ChangeDrawingNo[j], sign[j], placesNo[j], - ChangeBefore1[j], ChangeAfter1[j], ChangeReason[j], ProcessType1[j], szVersionBef[j], - szVersionAft[j]); - ecnBeans.add(ecnBean); - ecnBean.setProductSz(szProduct[j]); - } - } - tableView.getItems().addAll(ecnBeans); - for (int i = 0; i < parts.size(); i++) { - CheckBox btn = new CheckBox(parts.get(i)); - partBtns.add(btn); - departPane.getChildren().add(btn); - if (unitList.contains(parts.get(i))) { - btn.setSelected(true); - } - } - - try { - SqlUtil.getTCDataConnection(database); - ObservableList items = refTable.getItems(); - int i = 0; - String refTableSql = "select * from CHINT_ECN_NOTIFICATION where \"ecncode\" = '" + ecnId.getText() - + "' order by \"code\" asc , \"no\" asc "; - System.out.println("refTableSql==>" + refTableSql); - ResultSet read = SqlUtil.read(refTableSql); - while (read.next()) { + int rowNum = 0; + for (int j = 0; j < ChangeDrawingNo.length; j++) { + rowNum++; + EcnBean ecnBean = new EcnBean(rowNum, reasons, wips, ChangeDrawingNo[j], sign[j], placesNo[j], + ChangeBefore1[j], ChangeAfter1[j], ChangeReason[j], ProcessType1[j], szVersionBef[j], + szVersionAft[j]); + ecnBeans.add(ecnBean); + ecnBean.setProductSz(szProduct[j]); + } + } + tableView.getItems().addAll(ecnBeans); + for (int i = 0; i < parts.size(); i++) { + CheckBox btn = new CheckBox(parts.get(i)); + partBtns.add(btn); + departPane.getChildren().add(btn); + if (unitList.contains(parts.get(i))) { + btn.setSelected(true); + } + } + + try { + SqlUtil.getTCDataConnection(database); + ObservableList items = refTable.getItems(); + int i = 0; + String refTableSql = "select * from CHINT_ECN_NOTIFICATION where \"ecncode\" = '" + ecnId.getText() + + "' order by \"code\" asc , \"no\" asc "; + System.out.println("refTableSql==>" + refTableSql); + ResultSet read = SqlUtil.read(refTableSql); + while (read.next()) { // \"result\",\"principal\",\"pctime\",\"remark\" - RefTableBean refTableBean = items.get(i); - refTableBean.setCompDate(read.getString("pctime")); - refTableBean.setMark(read.getString("remark")); - refTableBean.setUser(read.getString("principal")); - String result = read.getString("result"); - System.out.println("refTableSql==>" + read.getString("principal")); - if (result.equals("否")) { - refTableBean.setShNo(true); - } - i = i + 1; - } - refTable.setItems(items); + RefTableBean refTableBean = items.get(i); + refTableBean.setCompDate(read.getString("pctime")); + refTableBean.setMark(read.getString("remark")); + refTableBean.setUserPane(read.getString("principal")); + String result = read.getString("result"); + System.out.println("refTableSql==>" + read.getString("principal")); + if (result.equals("否")) { + refTableBean.setShNo(true); + } + i = i + 1; + } + refTable.setItems(items); // if() // refTable.getItems().clear(); // refTable.getItems().addAll(items); - } catch (Exception e) { - e.printStackTrace(); - } finally { - SqlUtil.freeAll(); - } - } - - /* - * - */ - /** - * @param type - * @param 固定1 - * @return 数据集模板 - * @throws TCException - * @function 根据类型获取数据集模板 - */ - protected TCComponentDataset getDataset(String type, int i) throws TCException { - TCComponentDataset dataset = null; - TCComponentDataset newDataset = null; - - try { - SqlUtil.getTCDataConnection(database); + } catch (Exception e) { + e.printStackTrace(); + } finally { + SqlUtil.freeAll(); + } + } + + /* + * + */ + /** + * @param type + * @param 固定1 + * @return 数据集模板 + * @throws TCException + * @function 根据类型获取数据集模板 + */ + protected TCComponentDataset getDataset(String type, int i) throws TCException { + TCComponentDataset dataset = null; + TCComponentDataset newDataset = null; + + try { + SqlUtil.getTCDataConnection(database); // conn = util.connect(conn, session); - String query = "select DATASET from CHINT_ECN_TYPE where CODE='" + SAPUtil.getGroupID() + "'"; - System.out.println(query); + String query = "select DATASET from CHINT_ECN_TYPE where CODE='" + SAPUtil.getGroupID() + "'"; + System.out.println(query); // Statement stmt = conn.createStatement(); - ResultSet rs_get = SqlUtil.read(query); + ResultSet rs_get = SqlUtil.read(query); // rs_get = stmt.executeQuery(query); - if (rs_get.next()) { - String DatasetUid = rs_get.getString("DATASET"); - try { - dataset = (TCComponentDataset) session.stringToComponent(DatasetUid); - newDataset = dataset.saveAs(null); - } catch (TCException e) { - e.printStackTrace(); - } - - } - if (rs_get != null) { - rs_get.close(); - } + if (rs_get.next()) { + String DatasetUid = rs_get.getString("DATASET"); + try { + dataset = (TCComponentDataset) session.stringToComponent(DatasetUid); + newDataset = dataset.saveAs(null); + } catch (TCException e) { + e.printStackTrace(); + } + + } + if (rs_get != null) { + rs_get.close(); + } // util.disconnect(conn, stmt, rs_get); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - SqlUtil.freeAll(); - } - if (i == 0) { - return dataset; - } else { - return newDataset; - } - } - - /** - * @param target项目对象 - * @return 更改单文件夹 - * @function 获取项目的更改单文件夹 - */ - private TCComponent getTargetFolder(TCComponent target) { - 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("更改单")) { - return folders2[j]; - } - } - } - } - } catch (TCException e) { - e.printStackTrace(); - } - return null; - } - - /** - * - * @function 初始化影响分析的表格 绑定bean - */ - private void createDetailTable() { - // TODO Auto-generated method stub - - TableColumn tc_beforChange = new TableColumn("更改前"); - TableColumn tc_afterChange = new TableColumn("更改后"); - TableColumn tc_afterVer = new TableColumn("更改后版本"); - - TableColumn tc_drawNo = new TableColumn("图样代号"); - TableColumn tc_mark = new TableColumn("标记"); - TableColumn tc_xh = new TableColumn("序号"); - TableColumn> tc_wipTreat = new TableColumn>("在制品处理"); - TableColumn tc_beforVer = new TableColumn("更改前版本"); - TableColumn> productSz = new TableColumn>("特性等级"); - TableColumn> tc_reason = new TableColumn>("更改原因"); - TableColumn tc_poiNum = new TableColumn("处数"); - tableView.getColumns().addAll(tc_xh, tc_drawNo, tc_mark, tc_poiNum, tc_beforChange, tc_beforVer, tc_afterChange, - tc_afterVer, productSz, tc_reason, tc_wipTreat); - - tc_xh.setSortable(false); - tc_drawNo.setSortable(false); - tc_mark.setSortable(false); - tc_poiNum.setSortable(false); - tc_beforChange.setSortable(false); - tc_beforVer.setSortable(false); - tc_afterChange.setSortable(false); - tc_afterVer.setSortable(false); - tc_reason.setSortable(false); - productSz.setSortable(false); - tc_wipTreat.setSortable(false); - // 列绑定bean对象 - tc_xh.setCellValueFactory(new PropertyValueFactory("num")); - tc_drawNo.setCellValueFactory(new PropertyValueFactory("drawNo")); - tc_mark.setCellValueFactory(new PropertyValueFactory("mark")); - tc_poiNum.setCellValueFactory(new PropertyValueFactory("poiNum")); - tc_beforChange.setCellValueFactory(new PropertyValueFactory("overChange")); - tc_beforVer.setCellValueFactory(new PropertyValueFactory("overVersion")); - tc_afterChange.setCellValueFactory(new PropertyValueFactory("afterChange")); - tc_afterVer.setCellValueFactory(new PropertyValueFactory("afterVersion")); - tc_reason.setCellValueFactory(new PropertyValueFactory>("changeReason")); - tc_wipTreat.setCellValueFactory(new PropertyValueFactory>("wipTreat")); - productSz.setCellValueFactory(new PropertyValueFactory>("productSz")); - - tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); - tc_drawNo.prefWidthProperty().bind(tableView.widthProperty().multiply(0.18)); - tc_mark.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); - tc_poiNum.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); - tc_beforChange.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10)); - tc_beforVer.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); - tc_afterChange.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10)); - productSz.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); - tc_afterVer.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); - tc_reason.prefWidthProperty().bind(tableView.widthProperty().multiply(0.14)); // 0.4 - tc_wipTreat.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10)); - } - - @FXML - public TableView refTable; - - /** - * - * @function 影响分析数据表格 - */ - private void createRefTable() { - // TODO Auto-generated method stub - // 影响分析表格 -// protected SimpleStringProperty depart;//部门 -// protected SimpleStringProperty message; //行动 -// protected CheckBox shYes = new CheckBox();//是 -// protected CheckBox shNo = new CheckBox();//否 -// protected TextField user;//更改前版本 -// protected TextField compDate;//更改后 -// protected TextField mark;//更改后版本 - TableColumn deapart = new TableColumn("部门"); - TableColumn message = new TableColumn("行动(需要书面证据)"); - TableColumn shYes = new TableColumn("是"); // 要求值(设计) - TableColumn shNo = new TableColumn("否"); - TableColumn user = new TableColumn("责任人"); - TableColumn compDate = new TableColumn("完成时间"); // - TableColumn mark = new TableColumn("备注"); // - - deapart.setCellValueFactory(new PropertyValueFactory("depart")); - message.setCellValueFactory(new PropertyValueFactory("message")); - shYes.setCellValueFactory(new PropertyValueFactory("shYes")); - shNo.setCellValueFactory(new PropertyValueFactory("shNo")); - user.setCellValueFactory(new PropertyValueFactory("user")); - compDate.setCellValueFactory(new PropertyValueFactory("compDate")); - mark.setCellValueFactory(new PropertyValueFactory("mark")); - - deapart.setSortable(false); - message.setSortable(false); - shYes.setSortable(false); - shNo.setSortable(false); - user.setSortable(false); - compDate.setSortable(false); - mark.setSortable(false); - refTable.getColumns().addAll(deapart, message, shYes, shNo, user, compDate, mark); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + SqlUtil.freeAll(); + } + if (i == 0) { + return dataset; + } else { + return newDataset; + } + } + + /** + * @param target项目对象 + * @return 更改单文件夹 + * @function 获取项目的更改单文件夹 + */ + private TCComponent getTargetFolder(TCComponent target) { + 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("更改单")) { + return folders2[j]; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + /** + * + * @function 初始化影响分析的表格 绑定bean + */ + private void createDetailTable() { + // TODO Auto-generated method stub + + TableColumn tc_beforChange = new TableColumn("更改前"); + TableColumn tc_afterChange = new TableColumn("更改后"); + TableColumn tc_afterVer = new TableColumn("更改后版本"); + + TableColumn tc_drawNo = new TableColumn("图样代号"); + TableColumn tc_mark = new TableColumn("标记"); + TableColumn tc_xh = new TableColumn("序号"); + TableColumn> tc_wipTreat = new TableColumn>("在制品处理"); + TableColumn tc_beforVer = new TableColumn("更改前版本"); + TableColumn> productSz = new TableColumn>("特性等级"); + TableColumn> tc_reason = new TableColumn>("更改原因"); + TableColumn tc_poiNum = new TableColumn("处数"); + tableView.getColumns().addAll(tc_xh, tc_drawNo, tc_mark, tc_poiNum, tc_beforChange, tc_beforVer, tc_afterChange, + tc_afterVer, productSz, tc_reason, tc_wipTreat); + + tc_xh.setSortable(false); + tc_drawNo.setSortable(false); + tc_mark.setSortable(false); + tc_poiNum.setSortable(false); + tc_beforChange.setSortable(false); + tc_beforVer.setSortable(false); + tc_afterChange.setSortable(false); + tc_afterVer.setSortable(false); + tc_reason.setSortable(false); + productSz.setSortable(false); + tc_wipTreat.setSortable(false); + // 列绑定bean对象 + tc_xh.setCellValueFactory(new PropertyValueFactory("num")); + tc_drawNo.setCellValueFactory(new PropertyValueFactory("drawNo")); + tc_mark.setCellValueFactory(new PropertyValueFactory("mark")); + tc_poiNum.setCellValueFactory(new PropertyValueFactory("poiNum")); + tc_beforChange.setCellValueFactory(new PropertyValueFactory("overChange")); + tc_beforVer.setCellValueFactory(new PropertyValueFactory("overVersion")); + tc_afterChange.setCellValueFactory(new PropertyValueFactory("afterChange")); + tc_afterVer.setCellValueFactory(new PropertyValueFactory("afterVersion")); + tc_reason.setCellValueFactory(new PropertyValueFactory>("changeReason")); + tc_wipTreat.setCellValueFactory(new PropertyValueFactory>("wipTreat")); + productSz.setCellValueFactory(new PropertyValueFactory>("productSz")); + + tc_xh.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); + tc_drawNo.prefWidthProperty().bind(tableView.widthProperty().multiply(0.18)); + tc_mark.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); + tc_poiNum.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); + tc_beforChange.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10)); + tc_beforVer.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); + tc_afterChange.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10)); + productSz.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); + tc_afterVer.prefWidthProperty().bind(tableView.widthProperty().multiply(0.06)); + tc_reason.prefWidthProperty().bind(tableView.widthProperty().multiply(0.14)); // 0.4 + tc_wipTreat.prefWidthProperty().bind(tableView.widthProperty().multiply(0.10)); + } + + @FXML + public TableView refTable; + + /** + * + * @function 影响分析数据表格 + */ + private void createRefTable() { + // TODO Auto-generated method stub + // 影响分析表格 + + TableColumn deapart = new TableColumn("部门"); + TableColumn message = new TableColumn("行动(需要书面证据)"); + TableColumn shYes = new TableColumn("是"); // 要求值(设计) + TableColumn shNo = new TableColumn("否"); + TableColumn user = new TableColumn("责任人"); + TableColumn compDate = new TableColumn("完成时间"); // + TableColumn mark = new TableColumn("备注"); // + + deapart.setCellValueFactory(new PropertyValueFactory("depart")); + message.setCellValueFactory(new PropertyValueFactory("message")); + shYes.setCellValueFactory(new PropertyValueFactory("shYes")); + shNo.setCellValueFactory(new PropertyValueFactory("shNo")); + user.setCellValueFactory(new PropertyValueFactory("userPane")); + compDate.setCellValueFactory(new PropertyValueFactory("compDate")); + mark.setCellValueFactory(new PropertyValueFactory("mark")); + + deapart.setSortable(false); + message.setSortable(false); + shYes.setSortable(false); + shNo.setSortable(false); + user.setSortable(false); + compDate.setSortable(false); + mark.setSortable(false); + refTable.getColumns().addAll(deapart, message, shYes, shNo, user, compDate, mark); // //设置宽度 - deapart.prefWidthProperty().bind(refTable.widthProperty().multiply(0.14)); - message.prefWidthProperty().bind(refTable.widthProperty().multiply(0.36)); - shYes.prefWidthProperty().bind(refTable.widthProperty().multiply(0.05)); - shNo.prefWidthProperty().bind(refTable.widthProperty().multiply(0.05)); - user.prefWidthProperty().bind(refTable.widthProperty().multiply(0.13)); - compDate.prefWidthProperty().bind(refTable.widthProperty().multiply(0.13)); - mark.prefWidthProperty().bind(refTable.widthProperty().multiply(0.14)); - List refTableBeans = new ArrayList(); - // 初始化数据 写死的 - refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("产品图样、目录、铭牌等"))); - refTableBeans.add( - new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("技术方案、DFMEA、产品质量特性重要度分级表"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("BOM物料更改"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("包装图样/规范"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("发货标签更改"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("客户承诺相关设计文件"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("环保要求更改"))); - - refTableBeans - .add(new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("工艺流程图、PFMEA、工艺守则"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("作业指导书、包装指导书"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("客户承诺相关工艺文件"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("模具、工装、设备更改"))); - - refTableBeans.add(new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("控制计划"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("进货/过程/成品检验文件"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("供应商产品质量检验报告"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("客户承诺相关质量文件"))); - - refTableBeans.add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("断点标识(物料切换)"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("在制品确认及处理"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("成品确认及处理"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("计划确认及调整"))); - - refTableBeans.add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("采购价格变化"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("更改信息(资料、价格)传递"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("合格供方评价(新增时)"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("供应商合同修改"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("供应商处产品确认"))); - - refTableBeans.add(new RefTableBean(new SimpleStringProperty("销售中心"), new SimpleStringProperty("通知客户"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("销售中心"), new SimpleStringProperty("客户批准"))); - refTableBeans.add(new RefTableBean(new SimpleStringProperty("销售中心"), new SimpleStringProperty("修改客户协议"))); - - refTableBeans.add(new RefTableBean(new SimpleStringProperty("财务部"), new SimpleStringProperty("销售价格变化"))); - - refTable.getItems().addAll(refTableBeans); - - } - - // 最大化 - /** - * @param frame - * @function 添加页面的监听 - */ - private void addWindListener(CreateEcnFrame 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 + deapart.prefWidthProperty().bind(refTable.widthProperty().multiply(0.14)); + message.prefWidthProperty().bind(refTable.widthProperty().multiply(0.30)); + shYes.prefWidthProperty().bind(refTable.widthProperty().multiply(0.05)); + shNo.prefWidthProperty().bind(refTable.widthProperty().multiply(0.05)); + user.prefWidthProperty().bind(refTable.widthProperty().multiply(0.19)); + compDate.prefWidthProperty().bind(refTable.widthProperty().multiply(0.13)); + mark.prefWidthProperty().bind(refTable.widthProperty().multiply(0.14)); + List refTableBeans = new ArrayList(); + // 初始化数据 写死的 + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("产品图样、目录、铭牌等"), true)); + // 第一个部门增加指派按钮 + refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), + new SimpleStringProperty("技术方案、DFMEA、产品质量特性重要度分级表"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("BOM物料更改"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("包装图样/规范"), false)); + refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("发货标签更改"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("客户承诺相关设计文件"), false)); + refTableBeans.add(new RefTableBean(new SimpleStringProperty("技术部"), new SimpleStringProperty("环保要求更改"), false)); + + refTableBeans.add( + new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("工艺流程图、PFMEA、工艺守则"), true)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("作业指导书、包装指导书"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("客户承诺相关工艺文件"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("工艺部"), new SimpleStringProperty("模具、工装、设备更改"), false)); + + refTableBeans.add(new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("控制计划"), true)); + refTableBeans.add( + new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("进货/过程/成品检验文件"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("供应商产品质量检验报告"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("质量部"), new SimpleStringProperty("客户承诺相关质量文件"), false)); + + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("断点标识(物料切换)"), true)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("在制品确认及处理"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("成品确认及处理"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("生产部"), new SimpleStringProperty("计划确认及调整"), false)); + + refTableBeans.add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("采购价格变化"), true)); + refTableBeans.add( + new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("更改信息(资料、价格)传递"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("合格供方评价(新增时)"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("供应商合同修改"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("采购部"), new SimpleStringProperty("供应商处产品确认"), false)); + + refTableBeans.add(new RefTableBean(new SimpleStringProperty("销售中心"), new SimpleStringProperty("通知客户"), true)); + refTableBeans.add(new RefTableBean(new SimpleStringProperty("销售中心"), new SimpleStringProperty("客户批准"), false)); + refTableBeans + .add(new RefTableBean(new SimpleStringProperty("销售中心"), new SimpleStringProperty("修改客户协议"), false)); + + refTableBeans.add(new RefTableBean(new SimpleStringProperty("财务部"), new SimpleStringProperty("销售价格变化"), true)); + addAssignAction(refTableBeans); + refTable.getItems().addAll(refTableBeans); + + } + + /** + * @param refTableBeans + * @function 添加监听 + */ + private void addAssignAction(List refTableBeans) { + // TODO Auto-generated method stub + Button userBtn = refTableBeans.get(0).getUserBtn(); + String userVal = refTableBeans.get(0).getUserVal(); + assignBtnAction(userBtn, 0, 7, userVal, refTableBeans); + assignBtnAction(refTableBeans.get(7).getUserBtn(), 7, 11, refTableBeans.get(7).getUserVal(), refTableBeans); + assignBtnAction(refTableBeans.get(11).getUserBtn(), 11, 15, refTableBeans.get(11).getUserVal(), refTableBeans); + assignBtnAction(refTableBeans.get(15).getUserBtn(), 15, 19, refTableBeans.get(15).getUserVal(), refTableBeans); + assignBtnAction(refTableBeans.get(19).getUserBtn(), 19, 24, refTableBeans.get(19).getUserVal(), refTableBeans); + assignBtnAction(refTableBeans.get(24).getUserBtn(), 24, 27, refTableBeans.get(24).getUserVal(), refTableBeans); + assignBtnAction(refTableBeans.get(27).getUserBtn(), 27, 28, refTableBeans.get(27).getUserVal(), refTableBeans); + } + + /** + * @param userBtn + * @param start + * @param end + * @param userVal + * @param refTableBeans + * @function + */ + private void assignBtnAction(Button userBtn, int start, int end, String userVal, List refTableBeans) { + // TODO Auto-generated method stub + userBtn.setOnAction(e -> { + try { + Map userItemMap = getUserItemOA(userVal); + for (int i = start; i < end; i++) { + refTableBeans.get(i).setUserPane(userItemMap.keySet().iterator().next()); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }); + } + + /** + * @param name + * @return Email和id的map + * @throws Exception + * @function 调用OA接口获取用户的9位ID + */ + Map getUserItemOA(String name) throws Exception { + OkHttpClient client = new OkHttpClient(); + Map emailMap = new HashMap<>(); + MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); + RequestBody body = RequestBody.create(mediaType, "Name=" + name + "&Email="); + Request request = new Request.Builder() + .url("http://10.207.0.245:8012/Portal/Webservices/EH/EH_Q_BPM_Two_Service.asmx/GetUserItems") + .method("POST", body).addHeader("Content-Type", "application/x-www-form-urlencoded").build(); + Response response = client.newCall(request).execute(); + String string = response.body().string(); + Document document = DocumentHelper.parseText(string); + Element rootElement = document.getRootElement(); + String type = rootElement.elementText("TYPE"); + String message = rootElement.elementText("MESSAGE"); + if (type.equals("S")) { + List elements = rootElement.elements("items"); + + for (Element element : elements) { + Element userItemCs = element.element("EH_HR_UserItems_CS"); + String email = userItemCs.elementText("Email"); + String status = userItemCs.elementText("ObjectID"); + emailMap.put(email, status); + } + if (emailMap.size() > 0) { + + } else { +// String key = emailMap.keySet().iterator().next(); +// return emailMap.get(key); + } + } else { + MessageBox.post("指派失败:" + message, "提示", 2); + } +// Element element = body.element("MT_MATERIAL_BOP_REQ"); +// Element INTERGRATIONLIST = element.addElement("INTERGRATIONLIST"); + return emailMap; + } + + // 最大化 + /** + * @param frame + * @function 添加页面的监听 + */ + private void addWindListener(CreateEcnFrame 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("=============="); - double width = e.getComponent().getSize().getWidth(); + double width = e.getComponent().getSize().getWidth(); // // double width = primaryStage.getWidth(); - System.out.println("width==>" + width); - scollPane.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 - - } - }); - - SqlUtil.getTCDataConnection(database); - try { - - String sql = "select PART,REASON,MANAGE,DATASET,UNIT,GRADE from CHINT_ECN_TYPE where CODE = ?"; - ResultSet read = SqlUtil.read(sql, new String[] { SAPUtil.getGroupID() }); - if (read.next()) { - String part = read.getString(1); - String reason = read.getString(2); - String manage = read.getString(3); - String dataset = read.getString(4); - String factory = read.getString(5); - String grade = read.getString(6); - factoryText.setText(factory); - String[] partArray = part.split(";"); - String[] reasonArray = reason.split(";"); - String[] manageArray = manage.split(";"); - String[] grades = grade.split(";"); - parts = new ArrayList(Arrays.asList(partArray)); - reasons = new ArrayList(Arrays.asList(reasonArray)); - wips = new ArrayList(Arrays.asList(manageArray)); - products = new ArrayList(Arrays.asList(grades)); - } - - } catch (Exception e) { - e.printStackTrace(); - } finally { - SqlUtil.freeAll(); - } - - } - - /** - * @param event - * @function 添加5行 - */ - @FXML - void addRows(ActionEvent event) { - for (int i = 0; i < 5; i++) { - ecnBeans.add(new EcnBean(ecnBeans.size() + 1, reasons, wips, products)); - } - ObservableList data = FXCollections.observableArrayList(ecnBeans); - tableView.getItems().clear(); - tableView.setItems(data); - } - - /** - * @param event - * @function 添加行 - */ - @FXML - void addRow(ActionEvent event) { - ecnBeans.add(new EcnBean(ecnBeans.size() + 1, reasons, wips, products)); - ObservableList data = FXCollections.observableArrayList(ecnBeans); - tableView.getItems().clear(); - tableView.setItems(data); - } - - /** - * @param event - * @function 删除行 - */ - @FXML - void deleteRow(ActionEvent event) { - int selectedIndex = tableView.getSelectionModel().getSelectedIndex(); - System.out.println("selectedIndex==>" + selectedIndex); - ecnBeans.remove(selectedIndex); - for (int i = selectedIndex; i < ecnBeans.size(); i++) { - ecnBeans.get(i).setNum(new SimpleIntegerProperty(i + 1)); - } - ObservableList data = FXCollections.observableArrayList(ecnBeans); - tableView.getItems().clear(); - tableView.setItems(data); - } - - /** - * @param event - * @function 指派按钮 - */ - @FXML - void assignClick(ActionEvent event) { + System.out.println("width==>" + width); + scollPane.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 + + } + }); + + SqlUtil.getTCDataConnection(database); + try { + + String sql = "select PART,REASON,MANAGE,DATASET,UNIT,GRADE from CHINT_ECN_TYPE where CODE = ?"; + ResultSet read = SqlUtil.read(sql, new String[] { SAPUtil.getGroupID() }); + if (read.next()) { + String part = read.getString(1); + String reason = read.getString(2); + String manage = read.getString(3); + String dataset = read.getString(4); + String factory = read.getString(5); + String grade = read.getString(6); + factoryText.setText(factory); + String[] partArray = part.split(";"); + String[] reasonArray = reason.split(";"); + String[] manageArray = manage.split(";"); + String[] grades = grade.split(";"); + parts = new ArrayList(Arrays.asList(partArray)); + reasons = new ArrayList(Arrays.asList(reasonArray)); + wips = new ArrayList(Arrays.asList(manageArray)); + products = new ArrayList(Arrays.asList(grades)); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + SqlUtil.freeAll(); + } + + } + + /** + * @param event + * @function 添加5行 + */ + @FXML + void addRows(ActionEvent event) { + for (int i = 0; i < 5; i++) { + ecnBeans.add(new EcnBean(ecnBeans.size() + 1, reasons, wips, products)); + } + ObservableList data = FXCollections.observableArrayList(ecnBeans); + tableView.getItems().clear(); + tableView.setItems(data); + } + + /** + * @param event + * @function 添加行 + */ + @FXML + void addRow(ActionEvent event) { + ecnBeans.add(new EcnBean(ecnBeans.size() + 1, reasons, wips, products)); + ObservableList data = FXCollections.observableArrayList(ecnBeans); + tableView.getItems().clear(); + tableView.setItems(data); + } + + /** + * @param event + * @function 删除行 + */ + @FXML + void deleteRow(ActionEvent event) { + int selectedIndex = tableView.getSelectionModel().getSelectedIndex(); + System.out.println("selectedIndex==>" + selectedIndex); + ecnBeans.remove(selectedIndex); + for (int i = selectedIndex; i < ecnBeans.size(); i++) { + ecnBeans.get(i).setNum(new SimpleIntegerProperty(i + 1)); + } + ObservableList data = FXCollections.observableArrayList(ecnBeans); + tableView.getItems().clear(); + tableView.setItems(data); + } + + /** + * @param event + * @function 指派按钮 + */ + @FXML + void assignClick(ActionEvent event) { // rb_tempChange // assignBtn ecnId - try { - AssignIdDialog dialog = new AssignIdDialog(session, SAPUtil.getGroupID(), ecnId, target, - rb_tempChange.isSelected(), assignBtn); - dialog.start(new Stage()); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @FXML - public TextField relateEcnText; - - /** - * @param event - * @function 关联申请单按钮 - */ - @FXML - void relateClick(ActionEvent event) { - RelateEcnDialog dialog = new RelateEcnDialog(session, controller); - try { - dialog.start(new Stage()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } + try { + AssignIdDialog dialog = new AssignIdDialog(session, SAPUtil.getGroupID(), ecnId, target, + rb_tempChange.isSelected(), assignBtn); + dialog.start(new Stage()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @FXML + public TextField relateEcnText; + + /** + * @param event + * @function 关联申请单按钮 + */ + @FXML + void relateClick(ActionEvent event) { + RelateEcnDialog dialog = new RelateEcnDialog(session, controller); + try { + dialog.start(new Stage()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnFrame.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnFrame.java index fb76417..51f0c54 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnFrame.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnFrame.java @@ -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); + } } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnPanel.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnPanel.java index a80bf4c..b283917 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnPanel.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/CreateEcnPanel.java @@ -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 + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/EcnBean.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/EcnBean.java index 596ff89..b8e51f7 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/EcnBean.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/EcnBean.java @@ -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 productSz = new ComboBox();// 特性等级 - protected ComboBox changeReason = new ComboBox();// 更改原因 - protected ComboBox wipTreat = new ComboBox();// 在制品处理 - - public ComboBox getProductSz() { - return productSz; - } - - public void setProductSz(String productSz) { - this.productSz.getSelectionModel().select(productSz); - } - - EcnBean(int ind, List reasons, List wips, List 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 reasons, List 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 getChangeReason() { - return changeReason; - } - - public void setChangeReason(ComboBox changeReason) { - this.changeReason = changeReason; - } - - public ComboBox getWipTreat() { - return wipTreat; - } - - public void setWipTreat(ComboBox 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 productSz = new ComboBox();// 特性等级 + protected ComboBox changeReason = new ComboBox();// 更改原因 + protected ComboBox wipTreat = new ComboBox();// 在制品处理 + + public ComboBox getProductSz() { + return productSz; + } + + public void setProductSz(String productSz) { + this.productSz.getSelectionModel().select(productSz); + } + + EcnBean(int ind, List reasons, List wips, List 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 reasons, List 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 getChangeReason() { + return changeReason; + } + + public void setChangeReason(ComboBox changeReason) { + this.changeReason = changeReason; + } + + public ComboBox getWipTreat() { + return wipTreat; + } + + public void setWipTreat(ComboBox wipTreat) { + this.wipTreat = wipTreat; + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RefTableBean.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RefTableBean.java index b1c653b..205a060 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RefTableBean.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RefTableBean.java @@ -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 changeReason = new ComboBox();//更改原因 - 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() { - - @Override - public void changed(ObservableValue 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 changeReason = new ComboBox();//更改原因 + 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() { + + @Override + public void changed(ObservableValue 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() { - - @Override - public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { - // TODO Auto-generated method stub + if (newValue) { + shNo.setSelected(false); + } + } + }); + shNo.selectedProperty().addListener(new ChangeListener() { + + @Override + public void changed(ObservableValue 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); + } + } + }); + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnBean.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnBean.java index aad1db2..db0c403 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnBean.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnBean.java @@ -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 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 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; + } + } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnController.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnController.java index 78a3da3..3f2c780 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnController.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnController.java @@ -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 numCol = new TableColumn("序号"); - TableColumn contCondeCol = new TableColumn("合同代号"); - TableColumn contNameCol = new TableColumn("合同名称"); - - TableColumn requestNoCol = new TableColumn("申请单号"); - TableColumn prodModelCol = new TableColumn("产品型号"); - TableColumn applicantCol = new TableColumn("申请人"); - TableColumn statusCol = new TableColumn("状态"); - TableColumn linkBtnCol = new TableColumn("更改申请单链接"); - TableColumn importBtnCol = new TableColumn("导入"); - 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("num")); - contCondeCol.setCellValueFactory(new PropertyValueFactory("contConde")); - contNameCol.setCellValueFactory(new PropertyValueFactory("contName")); - requestNoCol.setCellValueFactory(new PropertyValueFactory("requestNo")); - prodModelCol.setCellValueFactory(new PropertyValueFactory("prodModel")); - applicantCol.setCellValueFactory(new PropertyValueFactory("applicant")); - statusCol.setCellValueFactory(new PropertyValueFactory("status")); - linkBtnCol.setCellValueFactory(new PropertyValueFactory("linkBtn")); - importBtnCol.setCellValueFactory(new PropertyValueFactory("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 numCol = new TableColumn( + "序号"); + TableColumn contCondeCol = new TableColumn( + "合同代号"); + TableColumn contNameCol = new TableColumn( + "合同名称"); + + TableColumn requestNoCol = new TableColumn( + "申请单号"); + TableColumn prodModelCol = new TableColumn( + "产品型号"); + TableColumn applicantCol = new TableColumn( + "申请人"); + TableColumn statusCol = new TableColumn( + "状态"); + TableColumn linkBtnCol = new TableColumn("更改申请单链接"); + TableColumn importBtnCol = new TableColumn("导入"); + 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("num")); + contCondeCol.setCellValueFactory(new PropertyValueFactory("contConde")); + contNameCol.setCellValueFactory(new PropertyValueFactory("contName")); + requestNoCol.setCellValueFactory(new PropertyValueFactory("requestNo")); + prodModelCol.setCellValueFactory(new PropertyValueFactory("prodModel")); + applicantCol.setCellValueFactory(new PropertyValueFactory("applicant")); + statusCol.setCellValueFactory(new PropertyValueFactory("status")); + linkBtnCol.setCellValueFactory(new PropertyValueFactory("linkBtn")); + importBtnCol.setCellValueFactory(new PropertyValueFactory("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 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 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("%' "); + } } - + } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnDialog.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnDialog.java index 6fa3f95..fffde4a 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnDialog.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/RelateEcnDialog.java @@ -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(); } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/Util.java b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/Util.java index 5e55766..aa8c309 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/createEcn/Util.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/createEcn/Util.java @@ -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:excel类型(MSExcelX) - * @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 getProductNames(TCComponent target, List 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 getproductModel(TCComponent target, List 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 getMergeRegions(Sheet sheet, int startRow, int endRow) { - List 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 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:excel类型(MSExcelX) + * @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 getProductNames(TCComponent target, List 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 getproductModel(TCComponent target, List 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 getMergeRegions(Sheet sheet, int startRow, int endRow) { + List 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 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(); } + */ } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanel.java b/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanel.java index 04cedca..6862fac 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanel.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanel.java @@ -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); + } } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanelController.java b/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanelController.java index 348ae5a..c0980c2 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanelController.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFXPanelController.java @@ -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(); - } - } - } + } + } } diff --git a/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFrame.java b/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFrame.java index 7758c72..8269585 100644 --- a/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFrame.java +++ b/com.connor.chint.wuhan/src/com/chint/plm/fxUtil/KFrame.java @@ -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; } \ No newline at end of file diff --git a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java index d1bd2f7..6ccff5d 100644 --- a/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java +++ b/com.connor.chint.wuhan/src/com/connor/chint/yunpi/command/BomSendSapOp.java @@ -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"); }