Merge pull request '1、创建编辑更改通知单下拉框去重' (#27) from ldy into main

Reviewed-on: http://yunpi.tpddns.cn:3000/ZT_CODE/chint_wuhan/pulls/27
main
李冬阳 8 months ago
commit 91c8cadc6e

@ -2,7 +2,6 @@ package com.chint.plm.createEcn;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,20 +9,18 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Vector;
import com.chint.plm.fxUtil.KFXPanel;
import com.chint.plm.fxUtil.KFXPanelController;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.stage.Stage; import javafx.stage.Stage;
/** /**
@ -34,22 +31,26 @@ public class AssignIdController {
private String groupID; private String groupID;
private TCSession session; private TCSession session;
private TextField field; private TextField field;
private TCComponent tar; // private TCComponent tar;
private boolean flag; // private boolean flag;
@FXML @FXML
private Button assignBtn; private Button assignBtn;
private Button assignBtnTop; // 变更管理中的指派按钮 private Button assignBtnTop; // 变更管理中的指派按钮
@FXML @FXML
private TextField ylText; private TextField ylText;
@FXML @FXML
private Button closeBtn; private Button closeBtn;
@FXML @FXML
private ComboBox<String> bmComb; private ComboBox<String> bmComb;
@FXML @FXML
private ComboBox<String> factoryComb; private ComboBox<String> factoryComb;
@FXML
private RadioButton rb_tempChange; // 临时更改通知单
@FXML
private RadioButton rb_formalChange; // 正式更改通知单
private RadioButton p_tempChange;
private RadioButton p_formalChange;
/** /**
* @param session * @param session
@ -58,22 +59,59 @@ public class AssignIdController {
* @param tar * @param tar
* @param flag * @param flag
* @param assignBtn * @param assignBtn
* @param p_tempChange
* @param p_formalChange
* @function * @function
*/ */
public void initData(TCSession session, String groupID, TextField field, TCComponent tar, boolean flag, public void initData(TCSession session, String groupID, TextField field, Button assignBtn,
Button assignBtn) { RadioButton p_tempChange, RadioButton p_formalChange) {
// TODO Auto-generated method stub // Auto-generated method stub
this.groupID = groupID; this.groupID = groupID;
this.session = session; this.session = session;
this.field = field; this.field = field;
this.flag = flag;
this.tar = tar;
this.assignBtnTop = assignBtn; this.assignBtnTop = assignBtn;
this.p_tempChange = p_tempChange;
this.p_formalChange = p_formalChange;
getCombox(); getCombox();
//lidy20240919变更指派通知单号界面增加更改类型里面选择了正式或者临时外面页要一起跟着变
ToggleGroup group = new ToggleGroup(); // 变更类型组
// 实现单选功能
rb_formalChange.setToggleGroup(group);
rb_tempChange.setToggleGroup(group);
if(p_tempChange.isSelected())
rb_tempChange.setSelected(true);
else
rb_formalChange.setSelected(true);
rb_tempChange.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
updateYL();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post("生成单号失败,error:" + e1.getMessage(), "", MessageBox.INFORMATION);
}
}
});
rb_formalChange.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
updateYL();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post("生成单号失败,error:" + e1.getMessage(), "", MessageBox.INFORMATION);
}
}
});
} }
@FXML @FXML
void okBtnClick(ActionEvent event) { void okBtnClick(ActionEvent event) {
Connection conn = null;
Statement stmt = null;
ResultSet rs_get = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yy"); SimpleDateFormat sdf = new SimpleDateFormat("yy");
String year = sdf.format(new Date()); String year = sdf.format(new Date());
String fac = factoryComb.getSelectionModel().getSelectedItem(); String fac = factoryComb.getSelectionModel().getSelectedItem();
@ -84,21 +122,19 @@ public class AssignIdController {
String TF = ""; String TF = "";
/// if(1==1) /// if(1==1)
// return; // return;
if (flag) { // 临时 if (rb_tempChange.isSelected()) { // 临时
TF = "L"; TF = "L";
p_tempChange.setSelected(true);
} else { // if (TF.trim().equals("正式更改通知单")) } else { // if (TF.trim().equals("正式更改通知单"))
TF = ""; TF = "";
p_formalChange.setSelected(true);
} }
String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF; String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF;
String flow = searchWord; String flow = searchWord;
Connection conn = null;
conn = util.connect(conn, session); conn = util.connect(conn, session);
String query = "select FLOW from CHINT_ECN_CODE where CODE='" + searchWord + "'"; String query = "select FLOW from CHINT_ECN_CODE where CODE='" + searchWord + "'";
System.out.println(query); System.out.println(query);
Statement stmt;
ResultSet rs_get;
try {
stmt = conn.createStatement(); stmt = conn.createStatement();
rs_get = null; rs_get = null;
rs_get = stmt.executeQuery(query); rs_get = stmt.executeQuery(query);
@ -123,14 +159,19 @@ public class AssignIdController {
} }
rs_get = stmt.executeQuery(query); rs_get = stmt.executeQuery(query);
util.disconnect(conn, stmt, rs_get);
} catch (SQLException e1) {
e1.printStackTrace();
}
assignBtnTop.setDisable(true);// 只能指派一次 assignBtnTop.setDisable(true);// 只能指派一次
assignBtn.setDisable(true);// 只能指派一次 assignBtn.setDisable(true);// 只能指派一次
//lidy20240919指派了更改界面临时正式变更就不能改了
p_tempChange.setDisable(true);
p_formalChange.setDisable(true);
Stage stage = (Stage) closeBtn.getScene().getWindow(); Stage stage = (Stage) closeBtn.getScene().getWindow();
stage.close(); stage.close();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post("生成单号失败,error:" + e1.getMessage(), "", MessageBox.INFORMATION);
}
util.disconnect(conn, stmt, rs_get);
} }
@FXML @FXML
@ -201,6 +242,37 @@ public class AssignIdController {
// 添加监听 预览信息 // 添加监听 预览信息
bmComb.valueProperty().addListener((obs, oldVal, newVal) -> { bmComb.valueProperty().addListener((obs, oldVal, newVal) -> {
System.out.println("选择了:" + newVal); System.out.println("选择了:" + newVal);
try {
updateYL();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post("生成单号失败,error:" + e1.getMessage(), "", MessageBox.INFORMATION);
}
});
// comBoxOffice = new JComboBox(new DefaultComboBoxModel<String>(init.toArray(new String[init.size()])));
System.out.println("first_FO:" + first_FO);
// if (tar.getType().equals("ZT2_Change")) {
// String[] fo = null;
// try {
// fo = selectFO(tar.getProperty("item_id").split("-")[0]);
// } catch (TCException e1) {
// e1.printStackTrace();
// }
// factoryComb.getSelectionModel().select(fo[0]);
// bmComb.getSelectionModel().select(fo[1]);
// factoryComb.setDisable(true);
// bmComb.setDisable(true);
// }
// if (tar.getType().equals("ZT2_Change")) {
// assignBtn.setDisable(true);
// } else {
//
// }
}
private boolean updateYL() throws Exception {
boolean update = true;
SimpleDateFormat sdf = new SimpleDateFormat("yy"); SimpleDateFormat sdf = new SimpleDateFormat("yy");
String year = sdf.format(new Date()); String year = sdf.format(new Date());
String fac = factoryComb.getSelectionModel().getSelectedItem(); String fac = factoryComb.getSelectionModel().getSelectedItem();
@ -209,10 +281,12 @@ public class AssignIdController {
off = ""; off = "";
} }
String TF = ""; String TF = "";
if (flag) { // 临时 if (rb_tempChange.isSelected()) { // 临时
TF = "L"; TF = "L";
} else { // if (TF.trim().equals("正式更改通知单")) p_tempChange.setSelected(true);
} else {
TF = ""; TF = "";
p_formalChange.setSelected(true);
} }
String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF; String searchWord = fac.split("-")[0] + off.split("-")[0] + "-" + year + TF;
String flow = searchWord; String flow = searchWord;
@ -223,9 +297,9 @@ public class AssignIdController {
Statement stmt; Statement stmt;
ResultSet rs_get; ResultSet rs_get;
try {
stmt = conn.createStatement(); stmt = conn.createStatement();
rs_get = null; rs_get = null;
System.out.println(query);
rs_get = stmt.executeQuery(query); rs_get = stmt.executeQuery(query);
if (rs_get.next()) { if (rs_get.next()) {
String FLOW = rs_get.getString("FLOW"); String FLOW = rs_get.getString("FLOW");
@ -233,38 +307,15 @@ public class AssignIdController {
FLOW = String.format("%04d", Integer.valueOf(FLOW) + 1); FLOW = String.format("%04d", Integer.valueOf(FLOW) + 1);
} else { } else {
flow = flow + "0001"; flow = flow + "0001";
update = false;
} }
ylText.setText(flow); ylText.setText(flow);
System.out.println(query);
if (rs_get != null) { if (rs_get != null) {
rs_get.close(); rs_get.close();
} }
util.disconnect(conn, stmt, rs_get); util.disconnect(conn, stmt, rs_get);
} catch (SQLException e1) {
e1.printStackTrace();
}
});
// comBoxOffice = new JComboBox(new DefaultComboBoxModel<String>(init.toArray(new String[init.size()]))); return update;
System.out.println("first_FO:" + first_FO);
// if (tar.getType().equals("ZT2_Change")) {
// String[] fo = null;
// try {
// fo = selectFO(tar.getProperty("item_id").split("-")[0]);
// } catch (TCException e1) {
// e1.printStackTrace();
// }
// factoryComb.getSelectionModel().select(fo[0]);
// bmComb.getSelectionModel().select(fo[1]);
// factoryComb.setDisable(true);
// bmComb.setDisable(true);
// }
// if (tar.getType().equals("ZT2_Change")) {
// assignBtn.setDisable(true);
// } else {
//
// }
} }
private Util util = new Util(); private Util util = new Util();

@ -1,30 +1,6 @@
package com.chint.plm.createEcn; package com.chint.plm.createEcn;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
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.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import com.chint.plm.SearchSapResult.DetailsBean;
import com.chint.plm.SearchSapResult.DetailsController;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import javafx.application.Application; import javafx.application.Application;
@ -32,6 +8,7 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -39,19 +16,22 @@ public class AssignIdDialog extends Application {
private String groupID; private String groupID;
private TCSession session; private TCSession session;
private TextField field; private TextField field;
private TCComponent tar; // private TCComponent tar;
private Button assignBtn; private Button assignBtn;
private boolean flag; // private boolean flag;
private RadioButton p_tempChange;
private RadioButton p_formalChange;
public AssignIdDialog(TCSession session, String groupID, TextField field, TCComponent tar, boolean flag, public AssignIdDialog(TCSession session, String groupID, TextField field, Button assignBtn,
Button assignBtn) { RadioButton p_tempChange, RadioButton p_formalChange) {
super(); super();
this.groupID = groupID; this.groupID = groupID;
this.session = session; this.session = session;
this.field = field; this.field = field;
this.tar = tar;
this.flag = flag;
this.assignBtn = assignBtn; this.assignBtn = assignBtn;
this.p_tempChange = p_tempChange;
this.p_formalChange = p_formalChange;
} }
@Override @Override
@ -63,7 +43,7 @@ public class AssignIdDialog extends Application {
Scene scene = new Scene(root, 400.0, 240.0); Scene scene = new Scene(root, 400.0, 240.0);
AssignIdController controller = (AssignIdController) fxmlLoader.getController(); AssignIdController controller = (AssignIdController) fxmlLoader.getController();
primaryStage.setTitle("֪ͨµ¥±àºÅ"); primaryStage.setTitle("֪ͨµ¥±àºÅ");
controller.initData(session, groupID, field, tar, flag, assignBtn); controller.initData(session, groupID, field, assignBtn, p_tempChange, p_formalChange);
primaryStage.setScene(scene); primaryStage.setScene(scene);
primaryStage.show(); primaryStage.show();
} }

@ -33,12 +33,14 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<ComboBox fx:id="bmComb" maxWidth="200.0" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="创建者工厂:" /> <Label text="创建者工厂:" />
<Label text="创建者部门:" GridPane.rowIndex="1" />
<Label text="预览" GridPane.rowIndex="2" />
<ComboBox fx:id="factoryComb" maxWidth="200.0" prefWidth="150.0" GridPane.columnIndex="1" /> <ComboBox fx:id="factoryComb" maxWidth="200.0" prefWidth="150.0" GridPane.columnIndex="1" />
<TextField fx:id="ylText" maxWidth="200.0" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="2" /> <Label text="创建者部门:" GridPane.rowIndex="1" />
<ComboBox fx:id="bmComb" maxWidth="200.0" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<RadioButton fx:id="rb_formalChange" maxWidth="200.0" prefWidth="150.0" mnemonicParsing="false" text="正式更改" GridPane.rowIndex="2" />
<RadioButton fx:id="rb_tempChange" mnemonicParsing="false" text="临时更改" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="预览" GridPane.rowIndex="3" />
<TextField fx:id="ylText" maxWidth="200.0" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
</children> </children>
</GridPane> </GridPane>
</children> </children>

@ -811,6 +811,8 @@ public class CreateEcnController extends KFXPanelController {
String productModel = target.getProperty("zt2_ProductModel"); String productModel = target.getProperty("zt2_ProductModel");
pmCombox.getSelectionModel().select(productModel); pmCombox.getSelectionModel().select(productModel);
assignBtn.setDisable(true); assignBtn.setDisable(true);
rb_tempChange.setDisable(true);
rb_formalChange.setDisable(true);
ecnId.setText(target.getProperty("item_id")); ecnId.setText(target.getProperty("item_id"));
TCProperty[] properties = null; TCProperty[] properties = null;
try { try {
@ -1507,8 +1509,8 @@ public class CreateEcnController extends KFXPanelController {
// rb_tempChange // rb_tempChange
// assignBtn ecnId // assignBtn ecnId
try { try {
AssignIdDialog dialog = new AssignIdDialog(session, SAPUtil.getGroupID(), ecnId, target, AssignIdDialog dialog = new AssignIdDialog(session, SAPUtil.getGroupID(), ecnId,
rb_tempChange.isSelected(), assignBtn); assignBtn, rb_tempChange, rb_formalChange);
dialog.start(new Stage()); dialog.start(new Stage());
} catch (Exception e) { } catch (Exception e) {
// Auto-generated catch block // Auto-generated catch block

@ -258,7 +258,9 @@ public class Util {
TCComponent[] ccbh = folders2[j].getRelatedComponents("contents"); TCComponent[] ccbh = folders2[j].getRelatedComponents("contents");
for (int k = 0; k < ccbh.length; k++) { for (int k = 0; k < ccbh.length; k++) {
if (ccbh[k].getType().equals("Part")) { if (ccbh[k].getType().equals("Part")) {
productModelList.add(ccbh[k].getProperty("object_name")); String name = ccbh[k].getProperty("object_name");
if(!productModelList.contains(name))
productModelList.add(name);
} }
} }
} }
@ -285,6 +287,7 @@ public class Util {
AIFComponentContext[] a1 = target.whereReferenced();// ¸ü¸Äµ¥Îļþ¼Ð AIFComponentContext[] a1 = target.whereReferenced();// ¸ü¸Äµ¥Îļþ¼Ð
if (a1 == null || a1.length < 1) { if (a1 == null || a1.length < 1) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel"); String zt2_ProductModel = target.getProperty("zt2_ProductModel");
if(!productModelList.contains(zt2_ProductModel))
productModelList.add(zt2_ProductModel); productModelList.add(zt2_ProductModel);
return productModelList; return productModelList;
} }
@ -293,6 +296,7 @@ public class Util {
try { try {
if (a2.length < 1 || !a2[0].getComponent().getProperty("object_name").contains("ÏîÄ¿¼à¿Ø")) { if (a2.length < 1 || !a2[0].getComponent().getProperty("object_name").contains("ÏîÄ¿¼à¿Ø")) {
String zt2_ProductModel = target.getProperty("zt2_ProductModel"); String zt2_ProductModel = target.getProperty("zt2_ProductModel");
if(!productModelList.contains(zt2_ProductModel))
productModelList.add(zt2_ProductModel); productModelList.add(zt2_ProductModel);
return productModelList; return productModelList;
} }
@ -317,7 +321,9 @@ public class Util {
TCComponent[] ccbh = folders2[j].getRelatedComponents("contents"); TCComponent[] ccbh = folders2[j].getRelatedComponents("contents");
for (int k = 0; k < ccbh.length; k++) { for (int k = 0; k < ccbh.length; k++) {
if (ccbh[k].getType().equals("Part")) { if (ccbh[k].getType().equals("Part")) {
productModelList.add(ccbh[k].getProperty("object_name")); String name = ccbh[k].getProperty("object_name");
if(!productModelList.contains(name))
productModelList.add(name);
} }
} }
} }

@ -793,7 +793,7 @@ public class KUtil {
for(AIFComponentContext context:ccpContexts) { for(AIFComponentContext context:ccpContexts) {
InterfaceAIFComponent component = context.getComponent(); InterfaceAIFComponent component = context.getComponent();
String property = component.getProperty("object_name"); String property = component.getProperty("object_name");
if(component instanceof TCComponentItem) { if((component instanceof TCComponentItem) && !ccpRevList.contains(property)) {
ccpRevList.add(property); ccpRevList.add(property);
} }
} }

Loading…
Cancel
Save