From 061b9be739dd8dd3b7e088ea9209da893b66ea48 Mon Sep 17 00:00:00 2001 From: "lidy@connor.net.cn" Date: Mon, 9 Dec 2024 17:03:01 +0800 Subject: [PATCH] =?UTF-8?q?20241209=E5=88=86=E5=8F=91=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/chint/plm/qms/EditingCell.java | 134 +++ .../src/com/chint/plm/qms/QMSBean.java | 320 +++++++ .../src/com/chint/plm/qms/QMSController.java | 863 ++++++++++++++++++ .../src/com/chint/plm/qms/QMSFrame.java | 25 + .../src/com/chint/plm/qms/QMSHandler.java | 76 ++ .../src/com/chint/plm/qms/QMSPanel.java | 15 + .../chint/sap2/createECN/CreateECNDialog.java | 5 +- .../DYSHElectricalTasksOperationV2.java | 10 +- .../sap2/sap_by/SAPZZDialogController.java | 31 +- .../chint/sap2/sap_gy/SAPGYController.java | 8 +- .../connor/chint/sap2/sap_gy/SAPGYDialog.java | 5 +- .../chint/sap2/sap_zy/SAPZYGG2Operation.java | 4 +- .../com/connor/chint/sap2/util/SAPUtil.java | 28 +- 13 files changed, 1483 insertions(+), 41 deletions(-) create mode 100644 com.connor.chint.sap2/src/com/chint/plm/qms/EditingCell.java create mode 100644 com.connor.chint.sap2/src/com/chint/plm/qms/QMSBean.java create mode 100644 com.connor.chint.sap2/src/com/chint/plm/qms/QMSController.java create mode 100644 com.connor.chint.sap2/src/com/chint/plm/qms/QMSFrame.java create mode 100644 com.connor.chint.sap2/src/com/chint/plm/qms/QMSHandler.java create mode 100644 com.connor.chint.sap2/src/com/chint/plm/qms/QMSPanel.java diff --git a/com.connor.chint.sap2/src/com/chint/plm/qms/EditingCell.java b/com.connor.chint.sap2/src/com/chint/plm/qms/EditingCell.java new file mode 100644 index 0000000..829bb30 --- /dev/null +++ b/com.connor.chint.sap2/src/com/chint/plm/qms/EditingCell.java @@ -0,0 +1,134 @@ +package com.chint.plm.qms; + +import javafx.beans.property.SimpleStringProperty; +import javafx.event.Event; +import javafx.geometry.Pos; +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableColumn.CellEditEvent; +import javafx.scene.control.TablePosition; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; +import javafx.util.converter.DefaultStringConverter; +import javafx.util.converter.IntegerStringConverter; + +import java.lang.reflect.Field; +import java.util.Objects; + +public class EditingCell extends TableCell { + private TextField textField; + + public EditingCell() { + } + + @Override + public void startEdit() { + if (!isEmpty()) { + super.startEdit(); + createTextField(); + setText(null); + setGraphic(textField); + textField.selectAll(); + } + } + + @Override + public void cancelEdit() { + super.cancelEdit(); + + setText(getItem()); + setGraphic(null); + } + + @Override + public void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (empty) { + setText(null); + setGraphic(null); + } else { + if (isEditing()) { + if (textField != null) { + textField.setText(getString()); + } + setText(null); + setGraphic(textField); + } else { + setText(getString()); + setGraphic(null); + } + } + } + + @Override + public void commitEdit(String newValue) { + if (!isEditing() && !Objects.equals(newValue, getItem())) { + TableView table = getTableView(); + if (table != null) { + TableColumn col = getTableColumn(); + CellEditEvent event = new CellEditEvent<>(table, new TablePosition<>(table, getIndex(), col), + TableColumn.editCommitEvent(), newValue); + Event.fireEvent(col, event); + System.out.println("开始利用反射将数据写入对象"); + T item = getTableView().getItems().get(getIndex()); + String property = col.getId(); + Class type = getItemFieldType(item, property); + Object convertedValue = convertValue(newValue, type); + setItemProperty(item, property, convertedValue); + } + } + + super.commitEdit(newValue); + updateItem(newValue, false); + } + + private void setItemProperty(T item, String property, Object value) { + try { + Field field = item.getClass().getDeclaredField(property); + field.setAccessible(true); + field.set(item, value); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + private Object convertValue(String value, Class type) { + if (type == SimpleStringProperty.class) { + return new SimpleStringProperty(value); + } else if (type == String.class) { + return value; + } else if (type == Integer.class) { + return new IntegerStringConverter().fromString(value); + } else if (type == Double.class) { + return new DefaultStringConverter().fromString(value); + } else { + return null; + } + } + + private Class getItemFieldType(T item, String property) { + try { + Field field = item.getClass().getDeclaredField(property); + return field.getType(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + return null; + } + } + + private void createTextField() { + textField = new TextField(getString()); + System.out.println("可读写模式"); + textField.setAlignment(Pos.CENTER); + textField.setMinWidth(getWidth() - getGraphicTextGap() * 2); + textField.focusedProperty().addListener((ob, old, now) -> { + if (!now) { + commitEdit(textField.getText()); + } + }); + } + + private String getString() { + return getItem() == null ? "" : getItem(); + } +} \ No newline at end of file diff --git a/com.connor.chint.sap2/src/com/chint/plm/qms/QMSBean.java b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSBean.java new file mode 100644 index 0000000..589e91b --- /dev/null +++ b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSBean.java @@ -0,0 +1,320 @@ +package com.chint.plm.qms; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import javafx.beans.property.SimpleStringProperty; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ComboBox; +import javafx.scene.control.TableRow; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class QMSBean { + + private Integer code; + private SimpleStringProperty xh = new SimpleStringProperty(); + private SimpleStringProperty qmsinspectioncode = new SimpleStringProperty(); + private SimpleStringProperty qmsinspectionname = new SimpleStringProperty(); + private SimpleStringProperty qmssuperiorinspectionname = new SimpleStringProperty(); + private SimpleStringProperty qmsinspectionschemename = new SimpleStringProperty(); + private SimpleStringProperty qmspushuser = new SimpleStringProperty(); + private ComboBox plmvaluetype = new ComboBox(); + private SimpleStringProperty plminspectioncode = new SimpleStringProperty(); + private TextField plmdesignation = new TextField(); + private ComboBox plmsequence = new ComboBox(); + private SimpleStringProperty result = new SimpleStringProperty(); + private SimpleStringProperty status = new SimpleStringProperty(); + private SimpleStringProperty synctime = new SimpleStringProperty(); + private SimpleStringProperty plmchangeuser = new SimpleStringProperty(); + private boolean isEdit; + private boolean red = false; + private CheckBox checkBox = new CheckBox(); + private TableView table = null; + public QMSBean() { + } + + public QMSBean(boolean isEdit,Integer code, String xh, String qmsinspectioncode, String qmsinspectionname, + String qmssuperiorinspectionname, String qmsinspectionschemename, String qmspushuser, + String plmvaluetype, String plminspectioncode, String plmdesignation, String plmsequence, + String result, String status, Date synctime, String plmchangeuser) { + super(); + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-M-dd HH:mm:ss"); + this.code = code; + checkBox.setSelected(false); + checkBox.setDisable(!isEdit); + this.xh.set(xh); + this.qmsinspectioncode.set(qmsinspectioncode); + + + this.qmsinspectionname.set(qmsinspectionname); + + + this.qmssuperiorinspectionname.set(qmssuperiorinspectionname); + + + this.qmsinspectionschemename.set(qmsinspectionschemename); + + + this.qmspushuser.set(qmspushuser); + + + + this.plmvaluetype.getItems().addAll("参数化","型号规格(3d模型)","物料描述规格(2d图纸)"); + this.plmvaluetype.setValue(plmvaluetype); + this.plmvaluetype.setEditable(false); + this.plmvaluetype.setDisable(!isEdit); + + this.plminspectioncode.set(plminspectioncode); + + + this.plmdesignation.setText(plmdesignation); + this.plmdesignation.setEditable(isEdit); + + + this.plmsequence.getItems().addAll("1","2","3","4","5","6","7","8","9"); + this.plmsequence.setValue(plmsequence); + this.plmsequence.setEditable(false); + this.plmsequence.setDisable(!isEdit); + + + + this.result.set(result); + + + this.status.set(status); + + + this.synctime.set(synctime == null ? "" : sdf2.format(synctime)); + + + this.plmchangeuser.set(plmchangeuser); + + + } + + public CheckBox getCheckBox() { + return checkBox; + } + + public void setCheckBox(CheckBox checkBox) { + this.checkBox = checkBox; + } + + + public Integer getCode() { + return code; + } + + + + public void setCode(Integer code) { + this.code = code; + } + + + + public String getXh() { + return xh.get(); + } + + + + public void setXh(SimpleStringProperty xh) { + this.xh = xh; + } + + + + public String getQmsinspectioncode() { + return qmsinspectioncode.get(); + } + + + + public void setQmsinspectioncode(SimpleStringProperty qmsinspectioncode) { + this.qmsinspectioncode = qmsinspectioncode; + } + + + + public String getQmsinspectionname() { + return qmsinspectionname.get(); + } + + + + public void setQmsinspectionname(SimpleStringProperty qmsinspectionname) { + this.qmsinspectionname = qmsinspectionname; + } + + + + public String getQmssuperiorinspectionname() { + return qmssuperiorinspectionname.get(); + } + + + + public void setQmssuperiorinspectionname(SimpleStringProperty qmssuperiorinspectionname) { + this.qmssuperiorinspectionname = qmssuperiorinspectionname; + } + + + + public String getQmsinspectionschemename() { + return qmsinspectionschemename.get(); + } + + + + public void setQmsinspectionschemename(SimpleStringProperty qmsinspectionschemename) { + this.qmsinspectionschemename = qmsinspectionschemename; + } + + + + public String getQmspushuser() { + return qmspushuser.get(); + } + + + + public void setQmspushuser(SimpleStringProperty qmspushuser) { + this.qmspushuser = qmspushuser; + } + + + + public ComboBox getPlmvaluetype() { + return plmvaluetype; + } + + + + public void setPlmvaluetype(ComboBox plmvaluetype) { + this.plmvaluetype=plmvaluetype; + } + + + + public String getPlminspectioncode() { + return plminspectioncode.get(); + } + + + + public void setPlminspectioncode(SimpleStringProperty plminspectioncode) { + this.plminspectioncode = plminspectioncode; + } + + + + public TextField getPlmdesignation() { + return plmdesignation; + } + + + + public void setPlmdesignation(TextField plmdesignation) { + this.plmdesignation = plmdesignation; + } + + + + public ComboBox getPlmsequence() { + return plmsequence; + } + + + + public void setPlmsequence(ComboBox plmsequence) { + this.plmsequence = plmsequence; + } + + + + public String getResult() { + return result.get(); + } + + + + public void setResult(SimpleStringProperty result) { + this.result = result; + } + + + + public String getStatus() { + return status.get(); + } + + + + public void setStatus(SimpleStringProperty status) { + this.status = status; + } + + + + public String getSynctime() { + return synctime.get(); + } + + + + public void setSynctime(SimpleStringProperty synctime) { + this.synctime = synctime; + } + + + + public String getPlmchangeuser() { + return plmchangeuser.get(); + } + + + + public void setPlmchangeuser(SimpleStringProperty plmchangeuser) { + this.plmchangeuser = plmchangeuser; + } + + + + public boolean isEdit() { + return isEdit; + } + + + + public void setEdit(boolean isEdit) { + this.isEdit = isEdit; + } + + + + public boolean isRed() { + return red; + } + + + + public void setRed(boolean red) { + this.red = red; + } + + @Override + public String toString() { + return "QMSBean [code=" + code + ", xh=" + xh + ", qmsinspectioncode=" + qmsinspectioncode + + ", qmsinspectionname=" + qmsinspectionname + ", qmssuperiorinspectionname=" + + qmssuperiorinspectionname + ", qmsinspectionschemename=" + qmsinspectionschemename + ", qmspushuser=" + + qmspushuser + ", plmvaluetype=" + plmvaluetype + ", plminspectioncode=" + plminspectioncode + + ", plmdesignation=" + plmdesignation + ", plmsequence=" + plmsequence + ", result=" + result + + ", status=" + status + ", synctime=" + synctime + ", plmchangeuser=" + plmchangeuser + ", isEdit=" + + isEdit + ", red=" + red + "]"; + } + + + +} diff --git a/com.connor.chint.sap2/src/com/chint/plm/qms/QMSController.java b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSController.java new file mode 100644 index 0000000..6e22c58 --- /dev/null +++ b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSController.java @@ -0,0 +1,863 @@ +package com.chint.plm.qms; + +import java.awt.Component; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.ParseException; +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.regex.Matcher; +import java.util.regex.Pattern; + +import com.chint.plm.rdmCreate.KFXPanel; +import com.chint.plm.rdmCreate.KFXPanelController; +import com.chint.plm.rdmCreate.RdmCreateBean; +import com.connor.chint.sap2.util.KUtil; +import com.connor.chint.sap2.util.SAPUtil; +import com.connor.chint.sap2.util.SqlUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import javafx.application.Platform; +import javafx.beans.property.SimpleStringProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ComboBox; +import javafx.scene.control.DatePicker; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.SplitPane; +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableRow; +import javafx.scene.control.TableView; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import javafx.scene.control.TitledPane; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.cell.TextFieldTableCell; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Pane; +import javafx.util.Callback; + +public class QMSController extends KFXPanelController { + private Connection conn; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + private String PlanTime;// + private String lineSeparator = System.lineSeparator();// 换行符 + private String[] prefs = null; + private double paneWidth; + private double paneHight; + ObservableList data = null; + //ComboBox plmvaluetype = new ComboBox(); + boolean isAdmin = false; + boolean isEdit = false; + String factory = ""; + @FXML + private Button bc; + + @FXML + private ScrollPane scroll; + + @FXML + private TextField f1; + + @FXML + private TextField f2; + + @FXML + private TextField f3; + + @FXML + private CheckBox c1; + + @FXML + private CheckBox c2; + + @FXML + private CheckBox c3; + + @FXML + private Pane pane1; + + @FXML + private Button cx; + + @FXML + private Button cz; + + @FXML + private Pane pane; + + @FXML + private TableView table; + // table的列 + // private TableColumn tc_1 = new TableColumn("序号"); + + private QMSFrame frame; + protected AbstractAIFApplication app; + private TCSession session; + + /** + * 初始化界面 + */ + @Override + public void initData(KFXPanel paramKFXPanel) throws Exception { + // TODO Auto-generated method stub + // 连接数据库 根据条件查询 + + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + + this.prefs = session.getPreferenceService().getStringValues("CHINT_SRM_SQL_CONNECT"); + + f1.setPrefSize(180, 28); + f2.setPrefSize(180, 28); + f3.setPrefSize(180, 28); + System.out.println("===============开始连接tc数据库==============="); + frame = (QMSFrame) paramKFXPanel.getParentDialog(); + addWindListener(frame); + //填界table监听 + table.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { + if (newValue != null) { + int index = table.getSelectionModel().getSelectedIndex(); + System.out.println("Selected row at index: " + index); + + QMSBean item = table.getItems().get(index); + System.out.println("===================================================="+item.getQmsinspectioncode()); + + + + + + + } + }); + + factory = SAPUtil.getGroupID(session); + String[] pref = session.getPreferenceService().getStringValues("CHINT_QMS_INSPECIFICATION_CODE_RULE"); + String userId = session.getUser().getUserId(); + + if(userId.equalsIgnoreCase("admin")) { + isAdmin = true; + isEdit = true; + } + + + // 获取对应组织的流水码 + for (int z = 0; z < pref.length; z++) { + String[] split = pref[z].split(":"); + if(split[0].equalsIgnoreCase(factory)) { + if(split[1].contains(userId)) { + isEdit = true; + } + } + } + + + if(!isEdit) { + bc.setVisible(false); + } + + + + table.setEditable(true); + frame.setMaximumSize(frame.getMaximumSize()); + System.out.println("frame==>" + frame); + + TableColumn checkboxColumn = new TableColumn<>(""); + checkboxColumn.setCellValueFactory(new PropertyValueFactory("checkBox")); + checkboxColumn.prefWidthProperty().bind(table.widthProperty().multiply(0.03)); + + + TableColumn tc1 = new TableColumn<>("序号"); + tc1.setCellValueFactory(new PropertyValueFactory("xh")); + tc1.prefWidthProperty().bind(table.widthProperty().multiply(0.03)); + + TableColumn tc2 = new TableColumn<>("检验项编码"); + tc2.setCellValueFactory(new PropertyValueFactory("qmsinspectioncode")); + tc2.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn tc3 = new TableColumn<>("检验项名称"); + tc3.setCellValueFactory(new PropertyValueFactory("qmsinspectionname")); + tc3.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn tc4 = new TableColumn<>("上级检验项"); + tc4.setCellValueFactory(new PropertyValueFactory("qmssuperiorinspectionname")); + tc4.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn tc5 = new TableColumn<>("检验方案名称"); + tc5.setCellValueFactory(new PropertyValueFactory("qmsinspectionschemename")); + tc5.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn tc6 = new TableColumn<>("QMS推送人员"); + tc6.setCellValueFactory(new PropertyValueFactory("qmspushuser")); + tc6.prefWidthProperty().bind(table.widthProperty().multiply(0.06)); + + TableColumn> tc7 = new TableColumn<>("取值类型"); + tc7.setCellValueFactory(new PropertyValueFactory>("plmvaluetype")); + tc7.prefWidthProperty().bind(table.widthProperty().multiply(0.17)); + //tc7.setSortable(false); + // tc7.setCellFactory(TextFieldTableCell.forTableColumn()); // +// +// // 设置单元格工厂以监听修改 +// tc7.setCellFactory(new Callback, TableCell>() { +// @Override +// public TableCell call(TableColumn param) { +// return new TableCell() { +// @Override +// public void updateItem(TextField item, boolean empty) { +// //super.updateItem(item, empty); +// if (item == null) { +// //setText(null); +// } else { +// // 当单元格内容修改时,这里会被调用 +// //setText(item.getText()); +// // 可以在这里添加你想要的逻辑,比如打印修改后的值 +// System.out.println("Cell modified to: " + item.getText()); +// } +// } +// }; +// } +// }); + + + + +// +// // 监听单元格编辑 +// tc7.setOnEditCommit(event -> { +// // 获取编辑后的值 +// +// // 获取行索引 +// int rowIndex = table.getSelectionModel().getSelectedIndex(); +// +// // 获取同一行的"Copy"列 +// data = table.getItems(); +// QMSBean item = data.get(rowIndex); +// item.setRed(true); +// System.out.println("bean================"+item.toString()); +// System.out.println("red完成"); +// +// +// +// // 设置行的样式 +// table.setRowFactory(tv -> { +// TableRow row = new TableRow<>(); +// row.itemProperty().addListener((obs, previousItem, newItem) -> { +// QMSBean qmsBean = row.getItem(); +// System.out.println("newItem========================="+qmsBean); +// if (qmsBean != null && qmsBean.isRed()) { +// // 当行中有数据时设置样式 +// row.setStyle("-fx-background-color: red;"); +// } else { +// // 当行为空时恢复默认样式 +// row.setStyle(""); +// } +// }); +// return row ; +// }); +// table.refresh(); +// }); +// + + TableColumn tc8 = new TableColumn<>("PLM检验项编码"); + tc8.setCellValueFactory(new PropertyValueFactory("plminspectioncode")); + tc8.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn tc9 = new TableColumn<>("参数代号"); + tc9.setCellValueFactory(new PropertyValueFactory("plmdesignation")); + tc9.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn> tc10 = new TableColumn<>("规格位数(顺序)"); + tc10.setCellValueFactory(new PropertyValueFactory>("plmsequence")); + tc10.prefWidthProperty().bind(table.widthProperty().multiply(0.13)); + + TableColumn tc11 = new TableColumn<>("检验项判定"); + tc11.setCellValueFactory(new PropertyValueFactory("result")); + tc11.prefWidthProperty().bind(table.widthProperty().multiply(0.13)); + + TableColumn tc12 = new TableColumn<>("是否同步QMS"); + tc12.setCellValueFactory(new PropertyValueFactory("status")); + tc12.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn tc13 = new TableColumn<>("保存时间"); + tc13.setCellValueFactory(new PropertyValueFactory("synctime")); + tc13.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); + + TableColumn tc14 = new TableColumn<>("修改账号"); + tc14.setCellValueFactory(new PropertyValueFactory("plmchangeuser")); + tc14.prefWidthProperty().bind(table.widthProperty().multiply(0.06)); + + + + + //tc7.setCellFactory(TextFieldTableCell.forTableColumn()); // 设置单元格为可编辑 + checkboxColumn.setEditable(isEdit); + tc7.setEditable(isEdit); + tc9.setEditable(isEdit); + tc10.setEditable(isEdit); + + + // 把代码中定义的table列加入tableView + table.getColumns().addAll(checkboxColumn,tc1, tc2, tc3, tc4, tc5, tc6, tc7, tc8, tc9, tc10, tc11, tc12, tc13, tc14); + + // 设置文本框的高度 +// jTextField1.setPrefHeight(30); + + // 表格列绑定bean对象 + // tc_1.setSortable(false); + + // 列绑定bean对象 + // tc_1.setCellValueFactory(new PropertyValueFactory("xh")); + + // 设置table列宽度 + // tc_1.prefWidthProperty().bind(table.widthProperty().multiply(0.04)); + +// //设置是否可编辑 +// tc_1.setEditable(false); +// tc_2.setEditable(false); +// tc_3.setEditable(false); +// tc_4.setEditable(false); +// tc_5.setEditable(false); +// tc_6.setEditable(false); +// tc_7.setEditable(false); +// tc_8.setEditable(true); +// tc_9.setEditable(true); +// tc_10.setEditable(false); + +// tableView.setMaxHeight(pageNum); + + + cx(); + } + + /** + * @param frame + * @function 添加页面的监听 + */ + private void addWindListener(QMSFrame frame) { + // TODO Auto-generated method stub + + frame.addComponentListener(new ComponentListener() { + + @Override + public void componentShown(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + /** + * 最大化时把pane也设置大 + */ + @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(); + double hight = component.getSize().getHeight(); + paneWidth = pane.getWidth(); + paneHight = pane.getHeight(); + double widthxs = width/paneWidth; + double hightxs = hight/paneHight; + //System.out.println("Widthxs============"+widthxs); +// // double width = primaryStage.getWidth(); + System.out.println("width=============>" + width); + System.out.println("pane==========="+pane.getWidth()); + + System.out.println("pane1==========="+pane1.getWidth()); + + System.out.println("scroll==========="+scroll.getWidth()); + + System.out.println("table==========="+table.getWidth()); + + + + pane.setPrefWidth(width * 0.98); + pane.setPrefHeight(hight * 0.98); + + pane1.setPrefWidth(width * 0.98); + //pane1.setPrefHeight(hight * 0.98); + + scroll.setPrefWidth(width * 0.96); + scroll.setPrefHeight((hight - 110) * 0.96); + + table.setPrefWidth(width * 0.95); + table.setPrefHeight((hight - 110) * 0.95); + + System.out.println("width2=============>" + width); + System.out.println("pane=2=========="+pane.getWidth()); + + System.out.println("pane1==2========="+pane1.getWidth()); + System.out.println("scroll==2========="+scroll.getWidth()); + + System.out.println("table==2========="+table.getWidth()); + + +// scroll.setPrefWidth(scroll.getWidth() * widthxs); +// scroll.setPrefHeight(scroll.getHeight() * hightxs); +// +// +// pane1.setPrefWidth(pane1.getWidth() * widthxs); +// pane1.setPrefHeight(pane1.getHeight() * hightxs); +// + + + + //grid.setPrefWidth(width * 0.98); + //gridTop.setPrefWidth(width * 0.98); + +// table.setPrefWidth(table.getWidth() * widthxs); +// table.setPrefHeight(table.getHeight() * hightxs); + + } + + @Override + public void componentMoved(ComponentEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void componentHidden(ComponentEvent e) { + // TODO Auto-generated method stub + + } + }); + + } + + // 重置 + @FXML + void czAction(ActionEvent event) { + c1.setSelected(false); + c2.setSelected(false); + c3.setSelected(false); + f1.setText(""); + f2.setText(""); + f3.setText(""); + } + +//查询 + @FXML + void cxAction(ActionEvent event) throws TCException { + +// SqlUtil.SRMGetTCDataConnection(prefs); +// //判断该用户是否有权限编辑界面 +// +// System.out.println("======================清除"); +// table.getItems().clear(); +// List quotations = new ArrayList(); +// // 拼接查询语句 +// String sql = "select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where 1=1 "; +// +// if (f1.getText() != null && !"".equals(f1.getText().trim())) { +// sql += "and \"qmsinspectioncode\" like '%" + f1.getText() + "%'"; +// } +// if (f2.getText() != null && !"".equals(f2.getText().trim())) { +// sql += "and \"qmsinspectionname\" like '%" + f2.getText() + "%'"; +// } +// if (f3.getText() != null && !"".equals(f3.getText().trim())) { +// sql += "and \"plmdesignation\" like '%" + f3.getText() + "%'"; +// } +// +// if (c1.isSelected()) { +// sql += "and \"synctime\" is null"; +// } +// +// if (c2.isSelected()) { +// sql += "and \"plmvaluetype\" = '参数化' "; +// } +// +// if (c2.isSelected()) { +// sql += "and \"plmvaluetype\" != '参数化' "; +// } +// +// sql += "order by \"qmsinspectioncode\" desc"; +// System.out.println("sql:" + sql); +// +// +//// this.plmvaluetype.textProperty().addListener((observable, oldValue, newValue) -> { +//// System.out.println("Text changed from '" + oldValue + "' to '" + newValue + "'"); +//// this.table.setRowFactory(tv -> { +//// TableRow row = new TableRow<>(); +//// row.itemProperty().addListener((obs, previousItem, newItem) -> { +//// QMSBean qmsBean = row.getItem(); +//// System.out.println("newItem========================="+qmsBean); +//// if(qmsBean.getPlmvaluetype().getText().equals(oldValue)) { +//// String xh = qmsBean.getXh(); +//// qmsBean.setRed(true); +//// System.out.println("xh==============="+xh); +//// if (qmsBean != null && qmsBean.isRed()) { +//// // 当行中有数据时设置样式 +//// row.setStyle("-fx-background-color: red;"); +//// } else { +//// // 当行为空时恢复默认样式 +//// row.setStyle(""); +//// } +//// } +//// +//// }); +//// return row ; +//// }); +//// +//// }); +// +// +// try { +// +// ResultSet res = SqlUtil.read(sql); +// // 处理查询数据结果集 +// int xh = 1; +// while (res.next()) { +// +// +// QMSBean QMSBean = new QMSBean(isEdit, (Integer) res.getInt("code"), xh + "", +// res.getString("qmsinspectioncode") != null ? res.getString("qmsinspectioncode") : "", +// res.getString("qmsinspectionname") != null ? res.getString("qmsinspectionname") : "", +// res.getString("qmssuperiorinspectionname") != null ? res.getString("qmssuperiorinspectionname"): "", +// res.getString("qmsinspectionschemename") != null ? res.getString("qmsinspectionschemename"): "", +// res.getString("qmspushuser") != null ? res.getString("qmspushuser") : "", +// res.getString("plmvaluetype") != null ? res.getString("plmvaluetype") : "" , +// res.getString("plminspectioncode") != null ? res.getString("plminspectioncode") : "", +// res.getString("plmdesignation") != null ? res.getString("plmdesignation") : "", +// res.getString("plmsequence") != null ? res.getString("plmsequence") : "", +// res.getString("result") != null ? res.getString("result") : "", +// res.getString("status") != null ? res.getString("status") : "", +// res.getDate("plmchangetime"), +// res.getString("plmchangeuser") != null ? res.getString("plmchangeuser") : ""); +// +// System.out.println("QMSBean===" + QMSBean); +// quotations.add(QMSBean); +// xh++; +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// +// if (quotations.size() > 0) { +// // 组织界面数据 +// data = FXCollections.observableArrayList(quotations); +// +// table.getItems().clear(); +// table.setItems(data); +// } else { +// // 未查到数据 +// Alert alert = new Alert(AlertType.INFORMATION); +// alert.setTitle("提示"); +// alert.setHeaderText("未查到数据!"); +// // alert.setContentText("导入完成"); +// alert.showAndWait(); +// } + cx(); + } + + + public void cx(){ + SqlUtil.SRMGetTCDataConnection(prefs); + //判断该用户是否有权限编辑界面 + + System.out.println("======================清除"); + table.getItems().clear(); + List quotations = new ArrayList(); + // 拼接查询语句 + String sql = ""; + if(isAdmin) { + sql = "select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where 1=1 "; + }else { + sql = "select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"factory\"='"+factory+"' "; + } + + if (f1.getText() != null && !"".equals(f1.getText().trim())) { + sql += " and \"qmsinspectioncode\" like '%" + f1.getText() + "%'"; + } + if (f2.getText() != null && !"".equals(f2.getText().trim())) { + sql += " and \"qmsinspectionname\" like '%" + f2.getText() + "%'"; + } + if (f3.getText() != null && !"".equals(f3.getText().trim())) { + sql += " and \"plmdesignation\" like '%" + f3.getText() + "%'"; + } + + if (c1.isSelected()) { + sql += " and \"plminspectioncode\" is null"; + } + + if (c2.isSelected()) { + sql += " and \"plmvaluetype\" = '参数化' "; + } + + if (c3.isSelected()) { + sql += " and \"plmvaluetype\" != '参数化' "; + } + + sql += " order by \"qmsinspectioncode\" desc"; + System.out.println("sql:" + sql); + + +// this.plmvaluetype.textProperty().addListener((observable, oldValue, newValue) -> { +// System.out.println("Text changed from '" + oldValue + "' to '" + newValue + "'"); +// this.table.setRowFactory(tv -> { +// TableRow row = new TableRow<>(); +// row.itemProperty().addListener((obs, previousItem, newItem) -> { +// QMSBean qmsBean = row.getItem(); +// System.out.println("newItem========================="+qmsBean); +// if(qmsBean.getPlmvaluetype().getText().equals(oldValue)) { +// String xh = qmsBean.getXh(); +// qmsBean.setRed(true); +// System.out.println("xh==============="+xh); +// if (qmsBean != null && qmsBean.isRed()) { +// // 当行中有数据时设置样式 +// row.setStyle("-fx-background-color: red;"); +// } else { +// // 当行为空时恢复默认样式 +// row.setStyle(""); +// } +// } +// +// }); +// return row ; +// }); +// +// }); + + + try { + + ResultSet res = SqlUtil.read(sql); + // 处理查询数据结果集 + int xh = 1; + while (res.next()) { + + + QMSBean QMSBean = new QMSBean(isEdit, (Integer) res.getInt("code"), xh + "", + res.getString("qmsinspectioncode") != null ? res.getString("qmsinspectioncode") : "", + res.getString("qmsinspectionname") != null ? res.getString("qmsinspectionname") : "", + res.getString("qmssuperiorinspectionname") != null ? res.getString("qmssuperiorinspectionname"): "", + res.getString("qmsinspectionschemename") != null ? res.getString("qmsinspectionschemename"): "", + res.getString("qmspushuser") != null ? res.getString("qmspushuser") : "", + res.getString("plmvaluetype") != null ? res.getString("plmvaluetype") : "" , + res.getString("plminspectioncode") != null ? res.getString("plminspectioncode") : "", + res.getString("plmdesignation") != null ? res.getString("plmdesignation") : "", + res.getString("plmsequence") != null ? res.getString("plmsequence") : "", + res.getString("result") != null ? res.getString("result") : "", + res.getString("status") != null ? res.getString("status") : "", + res.getDate("plmchangetime"), + res.getString("plmchangeuser") != null ? res.getString("plmchangeuser") : ""); + + System.out.println("QMSBean===" + QMSBean); + quotations.add(QMSBean); + xh++; + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + if (quotations.size() > 0) { + // 组织界面数据 + data = FXCollections.observableArrayList(quotations); + + table.getItems().clear(); + table.setItems(data); + } else { + + + Platform.runLater(new Runnable() { + @Override + public void run() { + + // 未查到数据 + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle("提示"); + alert.setHeaderText("未查到数据!"); + // alert.setContentText("导入完成"); + alert.showAndWait(); + } + }); + + + } + } + + +//保存 + @FXML + void bcAction(ActionEvent event) throws TCException { + ObservableList items = table.getItems(); + SqlUtil.SRMGetTCDataConnection(prefs); + String factory = SAPUtil.getGroupID(session); + int count = 0; + //保存之前循环判断值 + for (int i = 0; i < items.size(); i++) { + QMSBean qmsBean = items.get(i); + boolean selected = qmsBean.getCheckBox().isSelected(); + if(selected) { + String plmvaluetype = qmsBean.getPlmvaluetype().getValue() == null || qmsBean.getPlmvaluetype().getValue().isEmpty() ?"":qmsBean.getPlmvaluetype().getValue(); + String plmdesignation =qmsBean.getPlmdesignation().getText() == null || qmsBean.getPlmdesignation().getText().isEmpty() ? "" : qmsBean.getPlmdesignation().getText(); + String plmsequence =qmsBean.getPlmsequence().getValue() == null || qmsBean.getPlmsequence().getValue().isEmpty() ? "" : qmsBean.getPlmsequence().getValue(); + if(plmvaluetype.equals("参数化") && plmdesignation.isEmpty()) { + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle("提示"); + alert.setHeaderText("第"+qmsBean.getXh()+"行的参数代号不能为空!"); + //alert.setContentText("导入完成"); + alert.showAndWait(); + return; + }else if(plmvaluetype.contains("规格") && plmsequence.isEmpty()){ + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle("提示"); + alert.setHeaderText("第"+qmsBean.getXh()+"行的规格位数(顺序)不能为空!"); + //alert.setContentText("导入完成"); + alert.showAndWait(); + return; + } + + + } + } + + + + for (int i = 0; i < items.size(); i++) { + QMSBean qmsBean = items.get(i); + boolean selected = qmsBean.getCheckBox().isSelected(); + if(selected) { + + //判断检验项编码是否为空 为空数据库获取流水号 + String plminspectioncode = ""; + plminspectioncode = qmsBean.getPlminspectioncode(); + if(plminspectioncode == null || plminspectioncode.isEmpty()) { + //取数据库获取流水号 + SqlUtil.SRMGetTCDataConnection(prefs); + String selectLSH = "select \"code\" from CHINT_QMS_INSPECIFICATION_NUMBER_RULE where \"factory\" = '"+factory+"'"; + String lsh = ""; + try { + + ResultSet res = SqlUtil.read(selectLSH); + // 处理查询数据结果集 + while (res.next()) { + lsh = res.getString(1); + } + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + if(lsh == null || lsh.isEmpty()) { + // 获取流水号的首选项 + String[] lsmPref = session.getPreferenceService().getStringValues("CHINT_QMS_INSPECIFICATION_NUMBER_RULE"); + // 获取对应组织的流水码 + for (int z = 0; z < lsmPref.length; z++) { + String[] split = lsmPref[z].split(":"); + // 判断当前组织与首选项是否相同 + if (split[0].equals(factory)) { + lsh = split[1]; + SqlUtil.SRMGetTCDataConnection(prefs); + //数据库中插入 + String updateSql = "INSERT INTO CHINT_QMS_INSPECIFICATION_NUMBER_RULE (\"factory\",\"code\",\"flow\") VALUES ('" + + factory + "','" + lsh + "','" + lsh +"')"; + System.out.println("updateSql========"+updateSql); + SqlUtil.update(updateSql); + } + } + plminspectioncode = lsh; + }else { + //流水号+1 + // 正则表达式,匹配所有的字母和数字 + + Pattern pattern = Pattern.compile("(\\D+)(\\d+)"); + Matcher matcher = pattern.matcher(lsh); + + if (matcher.find()) { + String alphaPart = matcher.group(1); // 字母部分 + String numericPartStr = matcher.group(2); // 数字部分字符串 + + // 将数字部分转换为整数,加1,再转回字符串 + int numericPartInt = Integer.parseInt(numericPartStr); + numericPartInt++; // 加1 + String newNumericPart = String.format("%0" + numericPartStr.length() + "d", + numericPartInt); // 保持原数字的长度,前面补0 + + // 重新拼接字符串 + lsh = alphaPart + newNumericPart; + + System.out.println("新组成的字符串: " + lsh); + } else { + System.out.println("未在字符串中找到符合模式的部分。"); + } + // 流水码+1 //设置流水号到数据库 + SqlUtil.SRMGetTCDataConnection(prefs); + if (!lsh.isEmpty()) { + String updateSql = "update CHINT_QMS_INSPECIFICATION_NUMBER_RULE set \"code\" = '"+lsh+"' where \"factory\" = '"+factory+"'"; + System.out.println("updateSql========"+updateSql); + SqlUtil.update(updateSql); + } + plminspectioncode = lsh; + } + + + } + + count++; + //保存操作 + String plmvaluetype = qmsBean.getPlmvaluetype().getValue() == null || qmsBean.getPlmvaluetype().getValue().isEmpty() ?"":qmsBean.getPlmvaluetype().getValue(); + String plmdesignation =qmsBean.getPlmdesignation().getText() == null || qmsBean.getPlmdesignation().getText().isEmpty() ? "" : qmsBean.getPlmdesignation().getText(); + String plmsequence =qmsBean.getPlmsequence().getValue() == null || qmsBean.getPlmsequence().getValue().isEmpty() ? "" : qmsBean.getPlmsequence().getValue(); + String sql = "update CHINT_QMS_INSPECIFICATION_CODE_RULE set \"plmvaluetype\" = '"+plmvaluetype + +"',\"plmdesignation\" = '"+plmdesignation + +"',\"plmsequence\" = '"+plmsequence + +"',\"plminspectioncode\" = '"+ plminspectioncode +"' where \"code\"='"+qmsBean.getCode()+"'"; + System.out.println("sql ========================"+sql); + SqlUtil.update(sql); + } + } + + if(count == 0) { + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle("提示"); + alert.setHeaderText("请勾选数据!"); + //alert.setContentText("导入完成"); + alert.showAndWait(); + }else { + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle("提示"); + alert.setHeaderText("项目保存完成!"); + //alert.setContentText("导入完成"); + alert.showAndWait(); + } + } +} diff --git a/com.connor.chint.sap2/src/com/chint/plm/qms/QMSFrame.java b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSFrame.java new file mode 100644 index 0000000..008b50f --- /dev/null +++ b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSFrame.java @@ -0,0 +1,25 @@ +package com.chint.plm.qms; +import java.awt.BorderLayout; +import java.awt.Dimension; + +import com.chint.plm.rdmCreate.KFrame; + +import javafx.embed.swing.JFXPanel; + +public class QMSFrame extends KFrame { + + public QMSFrame() { + super(); + } + + @Override + protected void initUI() throws Exception { + this.setTitle("质量检验项维护界面"); + this.setLayout(new BorderLayout()); + // this.setPreferredSize(new Dimension(1300, 900)); + JFXPanel panel = new JFXPanel(); + panel.setScene(new QMSPanel(this).getScene()); + this.add(BorderLayout.CENTER, panel); + } + +} diff --git a/com.connor.chint.sap2/src/com/chint/plm/qms/QMSHandler.java b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSHandler.java new file mode 100644 index 0000000..175ac64 --- /dev/null +++ b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSHandler.java @@ -0,0 +1,76 @@ +package com.chint.plm.qms; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.util.HashMap; + +import org.apache.log4j.chainsaw.Main; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + + +import com.connor.chint.sap2.util.SAPUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * 成本单管理 + * @author admin + * 2023/11/16 + */ +public class QMSHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + try { + new Thread() { + @Override + public void run() { +// NewJFrame newJFrame = new NewJFrame(session); +// int width2 = newJFrame.getWidth(); +// int height2 = newJFrame.getHeight(); +// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 +// int screenWidth = screenSize.width; // 获取屏幕宽度 +// int screenHeight = screenSize.height; // 获取屏幕高度 +// int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标 +// int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标 +// newJFrame.setTitle("工装需求查询"); +// // this.getContentPane().setBackground(Color.red); +// newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255)); +// newJFrame.setSize(1240, height2); // 设置Frame的大小 +// newJFrame.setLocation(x, y); // 设置Frame的位置 +// newJFrame.setResizable(false); +// newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作 +// newJFrame.setVisible(true); + +// String groupID = ""; +// try { +// groupID = SAPUtil.getGroupID(session); +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.out.println("groupID==="+groupID); +// //Project Administration +// if(!groupID.equals("Project Administration")) { +// MessageBox.post("请切换至项目管理组执行此功能。", "提示", MessageBox.INFORMATION); +// return; +// } +// + new QMSFrame(); + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + +} diff --git a/com.connor.chint.sap2/src/com/chint/plm/qms/QMSPanel.java b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSPanel.java new file mode 100644 index 0000000..4d77b3c --- /dev/null +++ b/com.connor.chint.sap2/src/com/chint/plm/qms/QMSPanel.java @@ -0,0 +1,15 @@ +package com.chint.plm.qms; + +import java.awt.Window; + +import com.chint.plm.rdmCreate.KFXPanel; + + + +public class QMSPanel extends KFXPanel { + + public QMSPanel(Window dialog) { + super(dialog, "QMS.fxml"); + // TODO Auto-generated constructor stub + } +} \ No newline at end of file diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/createECN/CreateECNDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/createECN/CreateECNDialog.java index faff6c8..7dc8a7b 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/createECN/CreateECNDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/createECN/CreateECNDialog.java @@ -529,11 +529,12 @@ public class CreateECNDialog extends AbstractAIFDialog implements ActionListener KUtil.stopTableEditing(t_part); int rowCount = t_part.getRowCount(); boolean write = true; + + /*lidy20241205必须填写变更前后的内容,才可申请。代码调整,取消限制 if (rowCount < 1) { MessageBox.post("请补充内容", "", MessageBox.INFORMATION); return; } - for (int i = 0; i < rowCount; i++) { if (((String) t_part.getValueAt(i, 7)) == null || ((String) t_part.getValueAt(i, 7)).trim().length() == 0) { @@ -546,7 +547,7 @@ public class CreateECNDialog extends AbstractAIFDialog implements ActionListener write = false; break; } - } + }*/ if (write == true) { try { String newId = JTextField7.getText(); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/electrical_task/DYSHElectricalTasksOperationV2.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/electrical_task/DYSHElectricalTasksOperationV2.java index 160cf1b..1a76da8 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/electrical_task/DYSHElectricalTasksOperationV2.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/electrical_task/DYSHElectricalTasksOperationV2.java @@ -75,8 +75,8 @@ public class DYSHElectricalTasksOperationV2 extends AbstractAIFOperation { TCComponentItemRevision rev = ((TCComponentItem) ccpChilds[i].getComponent()).getLatestItemRevision(); String zt2_MaterialNo = rev.getProperty("zt2_MaterialNo"); int index = zt2_MaterialNo.indexOf("-"); - // 主物料编码 - String type = index > -1 ? zt2_MaterialNo.substring(0, index) : zt2_MaterialNo; + // 主物料编码 直接取子物料编码 + String type = zt2_MaterialNo; //index > -1 ? zt2_MaterialNo.substring(0, index) : zt2_MaterialNo; // 出厂编码 TCComponent[] meops = rev.getRelatedComponents("ZT2_FactoryNumber"); // 产成品名称 @@ -117,9 +117,9 @@ public class DYSHElectricalTasksOperationV2 extends AbstractAIFOperation { param.put("PLMId", itemId); param.put("Code", projectCode); param.put("Name", projectName); - for (Map.Entry entry : ccp_types.entrySet()) { - String materialCode = entry.getKey(); - String materialCodePart = entry.getValue(); + for (String key : keys) { + String materialCode = key; + String materialCodePart = ccp_types.get(key); List factoryNos = ccp_factoryNos.get(materialCode); String factoryId = ""; if (factoryNos.size() > 0) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java index 9f9c6a9..fa4c01e 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_by/SAPZZDialogController.java @@ -221,22 +221,23 @@ public class SAPZZDialogController { for (int i = 0; i < len; i++) { try { TCComponentItemRevision rev = selectedParts.get(i).getZzDesignRev(); - - //TODO lidy20241112 BOM传递SAP时拼接辅料BOM - Map classMap = rev.getItem().getClassificationAttributes(); - String flfz = classMap.get("辅料分组"); - String sql = "select \"flno\",\"tuhao\",\"gx\" from CHINT_GYFL_M005 where \"group\"='" + flfz + "'"; - System.out.println("sql:" + sql); - ResultSet rs = SqlUtil.read(sql); HashMap> flMap = new HashMap<>(); - while(rs.next()) { - String tuhao = rs.getString(2); - tuhao = tuhao.substring(0, tuhao.indexOf("-")); - if(!flMap.containsKey(tuhao)) { - flMap.put(tuhao, new ArrayList<>()); - } - flMap.get(tuhao).add(new String[] { rs.getString(1), rs.getString(3) }); - } + if(rev != null) { + //TODO lidy20241112 BOM传递SAP时拼接辅料BOM + Map classMap = rev.getItem().getClassificationAttributes(); + String flfz = classMap.get("辅料分组"); + String sql = "select \"flno\",\"tuhao\",\"gx\" from CHINT_GYFL_M005 where \"group\"='" + flfz + "'"; + System.out.println("sql:" + sql); + ResultSet rs = SqlUtil.read(sql); + while(rs.next()) { + String tuhao = rs.getString(2); + tuhao = tuhao.substring(0, tuhao.indexOf("-")); + if(!flMap.containsKey(tuhao)) { + flMap.put(tuhao, new ArrayList<>()); + } + flMap.get(tuhao).add(new String[] { rs.getString(1), rs.getString(3) }); + } + } new SAPZZOperation(app, selectedParts.get(i), dists, SAPZZDialogController.this, flMap) .executeOperation(); diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java index 65a461c..28c4b1e 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYController.java @@ -562,6 +562,7 @@ public class SAPGYController { } my.setShowLabel("正在向SAP传递BOM、工艺信息。。。。。。"); entry = cPart_schemes.entrySet(); + System.out.println("entry cPart_schemes:" + cPart_schemes.size()); // 日志路径集 List logPathList = new ArrayList(); @@ -730,22 +731,22 @@ public class SAPGYController { * child.setProperty("zt2_SapState", sapState); child.save(); child.unlock(); } */ TXTUtil.writeTXT(txtPath, "SAP状态修改结束------"); - } TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session); - System.out.println("日志所挂对象:" + ccp); + System.out.println("日志所挂对象1:" + ccp); TXTUtil.addTxttoTarget(ccp, dataset); } - } if(yb) SqlUtil.free(); my.setVisible(false); if (errMessage.toString().length() > 0) { + System.out.println("errMessage:" + errMessage); new SAPMessageUtil(dialog, "", "传递异常:\n" + errMessage.toString()); } else { + System.out.println("高压开关传递成功AM推送记录"); String txtPath = TXTUtil.createTxt("工艺发布"); if (successParts.size() > 0) { succsessBuff.append("以下方案传递成功:\n"); @@ -770,7 +771,6 @@ public class SAPGYController { TXTUtil.savaLogAtClient(projectMonitorFolder, TXTUtil.mergeTxt("项目BOM传递SAP日志" + format2.format(new Date()), logPathList), session); } - } // 检查工艺路线 diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYDialog.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYDialog.java index ad34b6f..af5c4d4 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYDialog.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_gy/SAPGYDialog.java @@ -260,12 +260,14 @@ public class SAPGYDialog extends AbstractAIFDialog { setCompEnabled(false); MyProgressBarCompent my = null; try { + System.out.println("sendToSap2 start"); KUtil.setByPass(true); my = new MyProgressBarCompent("", "高压开关BOM传递SAP......"); controller.sendToSap2(my, false); + System.out.println("sendToSap2 finish"); } catch (Exception e1) { - MessageBox.post(SAPGYDialog.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR); e1.printStackTrace(); + MessageBox.post(SAPGYDialog.this, "发生错误:" + e1.getMessage(), "", MessageBox.ERROR); } finally { if (my != null) my.setVisible(false); @@ -273,6 +275,7 @@ public class SAPGYDialog extends AbstractAIFDialog { // pb.disposeDialog(); } setCompEnabled(true); + System.out.println("b_ok finish"); } }).start(); } diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYGG2Operation.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYGG2Operation.java index 61f9fc7..cbc2df7 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYGG2Operation.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/sap_zy/SAPZYGG2Operation.java @@ -399,11 +399,9 @@ public class SAPZYGG2Operation extends AbstractAIFOperation { } String design_user = session.getUser().getProperty("user_name"); txtPath = TXTUtil.createTxt("BOM传递成功AM推送记录"); + System.out.println("BOM传递成功AM推送记录 SAPZYGG2Operation"); SAPUtil.sendAM8("", project, session, ccps, design_user, txtPath); - } - - MessageBox.post("传递结束", "", MessageBox.INFORMATION); } catch (Exception e) { diff --git a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java index 062677a..dfde7fd 100644 --- a/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java +++ b/com.connor.chint.sap2/src/com/connor/chint/sap2/util/SAPUtil.java @@ -766,6 +766,7 @@ public class SAPUtil { // 事业部发易发通知 public static void sendAM8(String ban, TCComponent project, TCSession session, List revs, String design_user, String logPath) throws Exception { + System.out.println("sendAM8事业部发易发通知"); long time0 = System.currentTimeMillis(); String groupID = SAPUtil.getGroupID(session); String[] prefs = ChintPreferenceUtil.getPreferences(ChintPreferenceUtil.CHINT_Notify, session); @@ -803,7 +804,6 @@ public class SAPUtil { } List list_types = new ArrayList<>(map_type_users.keySet()); Collections.sort(list_types, new Comparator() { - @Override public int compare(String o1, String o2) { return o2.compareTo(o1); @@ -839,12 +839,15 @@ public class SAPUtil { break; } } + System.out.println("ban:" + ban); + System.out.println("map_type_users:" + map_type_users); if (KUtil.isEmpty(ban)) { if (map_type_users.size() == 0) { mess.append(object_string).append(" 的 ").append(" BOM已传递到SAP,请及时处理! WBS:"); mess.append(zt2_WBSNo).append(";设计员:").append(design_user).append("。"); userIDs.append(user_else.get(0)); + System.out.println("mess1:" + mess.toString()); } else { Map user_message = new HashMap(); String object_name; @@ -860,8 +863,8 @@ public class SAPUtil { id = map_type_users.get(type); user_message.put(type, id); } - } + System.out.println("user_message:" + user_message); for (String key : user_message.keySet()) { id = user_message.get(key); mess.append(object_string).append(" 的 ").append(key).append(" BOM已传递到SAP,请及时处理! WBS:"); @@ -875,10 +878,8 @@ public class SAPUtil { return; } } else { - mess.append(object_string).append(" 的 ").append(ban).append(" BOM已传递到SAP,请及时处理! WBS:"); mess.append(zt2_WBSNo).append(";设计员:").append(design_user).append("。"); - // 只匹配一次 if (index == 1) { if (user_else.size() > 0) { @@ -892,7 +893,6 @@ public class SAPUtil { String type; boolean flag = false; for (int i = 0, len = revs.size(); i < len; i++) { - object_name = revs.get(i).getProperty("object_name"); if (isSend.indexOf(object_name) != -1) continue; @@ -911,9 +911,7 @@ public class SAPUtil { userIDs.append(id); flag = true; } - } - } } } @@ -925,7 +923,6 @@ public class SAPUtil { sendMsg(mess.toString(), userIDs.toString(), logPath); long endTime = System.currentTimeMillis(); System.out.println("耗时:" + (endTime - time0) / 1000.00 + "秒"); - } // 事业部发易发通知 @@ -3406,6 +3403,7 @@ public class SAPUtil { // TXTUtil.writeTXT(logPath, "AM消息推送结束"); // } public static void sendMsg(String mess, String userID, String logPath) { + System.out.println("sendMsg开始AM消息推送"); TXTUtil.writeTXT(logPath, "开始AM消息推送"); TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); String mess2 = sendMsg(mess, userID); @@ -3421,8 +3419,16 @@ public class SAPUtil { String mess2 = stub2.chintSendMsgServices(userID, "", mess, "");//(userID, "", mess, "PLM");*/ //TODO lidy20240829新接口 先获取token,再组织数据 - String msgJson = "{\"emails\":[\"" + userID + "\"],\"mobiles\": [],\"content\": \"" + mess + "\"}"; - +// String msgJson = "{\"emails\":[\"" + userID + "\"],\"mobiles\": [],\"content\": \"" + mess + "\"}"; + StringBuilder msgJson = new StringBuilder("{\"emails\":[\""); + String[] sp = userID.split(";"); + for(int i = 0; i < sp.length; i++) { + msgJson.append(sp[i]); + if(i < sp.length - 1) + msgJson.append("\",\""); + } + msgJson.append("\"],\"mobiles\": [],\"content\": \"").append(mess).append("\"}"); + System.out.println("JSON==>" + msgJson); OkHttpClient client = new OkHttpClient(); RequestBody body = RequestBody.create(null, new byte[0]); Request request = new Request.Builder() @@ -3441,7 +3447,7 @@ public class SAPUtil { client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json"); - body = RequestBody.create(mediaType, msgJson); + body = RequestBody.create(mediaType, msgJson.toString()); request = new Request.Builder() .url("https://pub.chintelec.com/api/open/Feishu/sendMessages") .post(body)