Compare commits

...

2 Commits

@ -51,5 +51,8 @@
<classpathentry kind="lib" path="lib/guava-31.1-jre.jar"/> <classpathentry kind="lib" path="lib/guava-31.1-jre.jar"/>
<classpathentry kind="lib" path="lib/hutool-all-5.8.8.jar"/> <classpathentry kind="lib" path="lib/hutool-all-5.8.8.jar"/>
<classpathentry kind="lib" path="lib/swingx-1.6.1.jar"/> <classpathentry kind="lib" path="lib/swingx-1.6.1.jar"/>
<classpathentry kind="lib" path="poi/axiom-api-1.2.7.jar"/>
<classpathentry kind="lib" path="poi/axis2-kernel-1.4.1.jar"/>
<classpathentry kind="lib" path="json_lib/jfxrt.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

@ -79,7 +79,8 @@ Bundle-ClassPath: .,
poi/okhttp-2.7.4.jar, poi/okhttp-2.7.4.jar,
poi/okio-1.13.0.jar, poi/okio-1.13.0.jar,
lib/json-org.jar, lib/json-org.jar,
lib/commons-dbcp2-2.8.0.jar lib/commons-dbcp2-2.8.0.jar,
json_lib/jfxrt.jar
Export-Package: com.connor.chint.sap2, Export-Package: com.connor.chint.sap2,
com.connor.chint.sap2.assignfactoryno, com.connor.chint.sap2.assignfactoryno,
com.connor.chint.sap2.bombuilder, com.connor.chint.sap2.bombuilder,

@ -31,7 +31,8 @@ bin.includes = plugin.xml,\
lib/mysql-connector-java-8.0.12.jar,\ lib/mysql-connector-java-8.0.12.jar,\
poi/okhttp-2.7.4.jar,\ poi/okhttp-2.7.4.jar,\
poi/okio-1.13.0.jar,\ poi/okio-1.13.0.jar,\
lib/json-org.jar lib/json-org.jar,\
json_lib/jfxrt.jar
src.includes = icons/,\ src.includes = icons/,\
poi/jacob-1.20-x64.dll,\ poi/jacob-1.20-x64.dll,\
poi/jacob-1.20-x86.dll,\ poi/jacob-1.20-x86.dll,\

@ -64,6 +64,7 @@
<command name="自动更新型号和工作号" id="com.connor.chint.sap2.commands.SetPropertyCommand"/> <command name="自动更新型号和工作号" id="com.connor.chint.sap2.commands.SetPropertyCommand"/>
<command name="变压器采购清单" id="com.connor.chint.sap2.commands.PPartsReportCommand"/> <command name="变压器采购清单" id="com.connor.chint.sap2.commands.PPartsReportCommand"/>
<command name="部件采购单BOM编制" id="com.chint.plm.modules.transformer.bomsetup.BomSetupCommand"/> <command name="部件采购单BOM编制" id="com.chint.plm.modules.transformer.bomsetup.BomSetupCommand"/>
<command name="创建框架BOM" id="com.connor.chint.sap2.createKjBom.CreateKjBomCommand"/>
<!--中压设备--> <!--中压设备-->
<command name="创建工程图" id="com.connor.chint.sap2.commands.CreateEDCommand"/> <command name="创建工程图" id="com.connor.chint.sap2.commands.CreateEDCommand"/>
<command name="申请项目产成品" id="com.connor.chint.sap2.commands.ZYProjectAppendixCommand#M008"/> <command name="申请项目产成品" id="com.connor.chint.sap2.commands.ZYProjectAppendixCommand#M008"/>
@ -111,7 +112,7 @@
<!--物料管理--> <!--物料管理-->
<command name="物料编码申请" id="com.connor.chint.sap2.commands.MaterialNoCommand"/> <command name="物料编码申请" id="com.connor.chint.sap2.commands.MaterialNoCommand"/>
<command name="物料请购SAP" id="com.connor.chint.sap2.commands.WLQGSAPCommand"/> <command name="物料请购SAP" id="com.connor.chint.sap2.commands.WLQGSAPCommand"/>
<command name="自制件编码批量申请" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand"/> <command name="自制件编码批量申请" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand"/><!--物料编码批量申请-->
<command name="工程图批量申请物料编码" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT"/> <command name="工程图批量申请物料编码" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT"/>
<command name="外购件编码批量申请" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#M007_2"/> <command name="外购件编码批量申请" id="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#M007_2"/>
@ -306,6 +307,7 @@
<command name="项目计划管理" id="com.connor.chint.sap2.commands.OpenPiCommand"/> <command name="项目计划管理" id="com.connor.chint.sap2.commands.OpenPiCommand"/>
<command name="互感器成本BOM导出" id="com.chint.plm.costbomreport.BomCostReportCmd"/> <command name="互感器成本BOM导出" id="com.chint.plm.costbomreport.BomCostReportCmd"/>
<command name="创建RDM研发项目" id="com.chint.plm.rdmCreate.RdmCreateHandler"/>
</extension> </extension>
<extension point="org.eclipse.ui.handlers"> <extension point="org.eclipse.ui.handlers">
<handler commandId="com.connor.chint.sap2.commands.OpenPiCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.OpenPiCommand" class="com.connor.chint.sap2.KHandler"/>
@ -418,6 +420,7 @@
<handler commandId="com.connor.chint.sap2.commands.SetPropertyCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.SetPropertyCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.PPartsReportCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.PPartsReportCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.chint.plm.modules.transformer.bomsetup.BomSetupCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.chint.plm.modules.transformer.bomsetup.BomSetupCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.createKjBom.CreateKjBomCommand" class="com.connor.chint.sap2.KHandler"/>
<!--中压--> <!--中压-->
<handler commandId="com.connor.chint.sap2.commands.SpecStatementCommand#M008_Part2" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.SpecStatementCommand#M008_Part2" class="com.connor.chint.sap2.KHandler"/>
@ -621,6 +624,7 @@
<!--右键物料描述复制--> <!--右键物料描述复制-->
<handler commandId="com.connor.chint.sap2.commands.CopyObjectDescCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.CopyObjectDescCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.chint.plm.rdmCreate.RdmCreateHandler" class="com.chint.plm.rdmCreate.RdmCreateHandler"/>
</extension> </extension>
<extension point="org.eclipse.ui.bindings"> <extension point="org.eclipse.ui.bindings">
@ -675,6 +679,27 @@
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.chint.plm.rdmCreate.RdmCreateHandler" id = "com.chint.plm.rdmCreate.RdmCreateHandler">
<visibleWhen>
<and>
<or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.chint.plm.rdmCreate.RdmCreateHandler">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="com.connor.chint.sap2.commands.OpenPiCommand" id="com.connor.chint.sap2.commands.OpenPiCommand"> <command commandId="com.connor.chint.sap2.commands.OpenPiCommand" id="com.connor.chint.sap2.commands.OpenPiCommand">
<visibleWhen> <visibleWhen>
<and> <and>
@ -2037,6 +2062,24 @@
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<!--
<command commandId = "com.connor.chint.sap2.createKjBom.CreateKjBomCommand" id = "com.connor.chint.sap2.menu.cgdexport">
<visibleWhen>
<and>
<with
variable="rac_command_suppression">
<not>
<iterate
operator="or">
<equals
value="com.connor.chint.sap2.createKjBom.CreateKjBomCommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>-->
</menuContribution> </menuContribution>

@ -18,24 +18,41 @@ public class WorkhourService {
* @return * @return
*/ */
public static EasyResponse<List<String>> getProducttype(String companycode) { public static EasyResponse<List<String>> getProducttype(String companycode) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourType/getProducttype"; String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProducttype";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>(); Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode); paramMap.put("companycode", companycode);
String result = HttpUtils.get(url, paramMap); String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){}); return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
} }
/**
* »ñÈ¡µçѹµÈ¼
* @param companycode
* @param producttype
* @return
*/
public static EasyResponse<List<String>> getVoltagelevel(String companycode, String producttype) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getVoltagelevel";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode);
paramMap.put("producttype", producttype);
String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
}
/** /**
* »ñÈ¡²úÆ·ÐͺŠ* »ñÈ¡²úÆ·ÐͺÅ
* @param companycode * @param companycode
* @param producttype * @param producttype
* @param voltagelevel
* @return * @return
*/ */
public static EasyResponse<List<String>> getProductxh(String companycode, String producttype) { public static EasyResponse<List<String>> getProductxh(String companycode, String producttype, String voltagelevel) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourXh/getProductxh"; String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getProductxh";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>(); Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode); paramMap.put("companycode", companycode);
paramMap.put("producttype", producttype); paramMap.put("producttype", producttype);
paramMap.put("voltagelevel", voltagelevel);
String result = HttpUtils.get(url, paramMap); String result = HttpUtils.get(url, paramMap);
return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){}); return JSONObject.parseObject(result, new TypeReference<EasyResponse<List<String>>>(EasyResponse.class){});
} }
@ -46,7 +63,7 @@ public class WorkhourService {
* @return * @return
*/ */
public static EasyResponse<List<String>> getJsask(String companycode) { public static EasyResponse<List<String>> getJsask(String companycode) {
String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhourAsk/getJsask"; String url = ApiContext.getApiUrl() + "/api/plm/ChintWorkhour/getJsask";
Map<String, Object> paramMap = new LinkedHashMap<String, Object>(); Map<String, Object> paramMap = new LinkedHashMap<String, Object>();
paramMap.put("companycode", companycode); paramMap.put("companycode", companycode);
String result = HttpUtils.get(url, paramMap); String result = HttpUtils.get(url, paramMap);

@ -0,0 +1,135 @@
package com.chint.plm.rdmCreate;
import com.sun.javafx.util.Logging;
import com.teamcenter.rac.util.MessageBox;
import java.awt.Window;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
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);
// 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);
}
}
// protected Stage primaryStage;
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);
}
}

@ -0,0 +1,27 @@
package com.chint.plm.rdmCreate;
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);
}
});
try {
Thread.sleep(10L);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,29 @@
package com.chint.plm.rdmCreate;
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 {
// 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;
}

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<Pane fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="840.0" prefWidth="1270.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.chint.plm.rdmCreate.RdmCreateController">
<children>
<TitledPane fx:id="titlePane" animated="false" layoutY="-1.0" prefHeight="105.0" prefWidth="1272.0" text="创建研发项目">
<content>
<AnchorPane fx:id="anchorPane1" minHeight="0.0" minWidth="0.0" prefHeight="67.0" prefWidth="1270.0">
<children>
<GridPane fx:id="gridTop" layoutX="197.0" layoutY="18.0" prefHeight="49.0" prefWidth="839.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button fx:id="cjButton" mnemonicParsing="false" onAction="#cjbutton" prefHeight="41.0" prefWidth="136.0" text="创建" GridPane.halignment="CENTER" />
<Button fx:id="gbxmButton" mnemonicParsing="false" onAction="#gbxmButton" prefHeight="43.0" prefWidth="135.0" text="关闭项目" GridPane.columnIndex="2" GridPane.halignment="CENTER" />
</children>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<Pane fx:id="pane1" layoutY="109.0" prefHeight="726.0" prefWidth="309.0">
<children>
<AnchorPane fx:id="anchorPane2" minHeight="0.0" minWidth="0.0" prefHeight="726.0" prefWidth="309.0">
<children>
<GridPane fx:id="grid" layoutX="20.0" layoutY="41.0" prefHeight="457.0" prefWidth="253.0">
<children>
<Label prefHeight="20.0" prefWidth="82.0" text="内部订单号" />
<Label text="项目定义" GridPane.rowIndex="1" />
<Label text="集团项目号" GridPane.rowIndex="2" />
<Label text="项目名称" GridPane.rowIndex="3" />
<Label text="项目经理" GridPane.rowIndex="4" />
<Label text="工厂" GridPane.rowIndex="5" />
<Label text="推送者" GridPane.rowIndex="6" />
<Label text="推送时间早于" GridPane.rowIndex="7" />
<Label text="推送时间晚于" GridPane.rowIndex="8" />
<Label text="状态" GridPane.rowIndex="9" />
<TextField fx:id="f0" GridPane.columnIndex="1" />
<TextField fx:id="f1" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="f2" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField fx:id="f3" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<TextField fx:id="f4" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<TextField fx:id="f6" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<DatePicker fx:id="f7" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<DatePicker fx:id="f8" GridPane.columnIndex="1" GridPane.rowIndex="8" />
<ComboBox fx:id="f5" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<ComboBox fx:id="f9" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="9" />
<Button fx:id="cxButton" mnemonicParsing="false" onAction="#cxButton" prefHeight="30.0" prefWidth="88.0" text="查询" GridPane.columnIndex="1" GridPane.rowIndex="11" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="122.0" minWidth="10.0" prefWidth="93.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="160.0" minWidth="10.0" prefWidth="160.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
</children>
</Pane>
<Pane fx:id="pane2" layoutX="318.0" layoutY="108.0" prefHeight="733.0" prefWidth="949.0">
<children>
<AnchorPane fx:id="anchorPane3" minHeight="0.0" minWidth="0.0" prefHeight="726.0" prefWidth="949.0">
<children>
<ScrollPane fx:id="scrollpane" prefHeight="726.0" prefWidth="941.0">
<content>
<AnchorPane fx:id="anchorPane4" minHeight="0.0" minWidth="0.0" prefHeight="707.0" prefWidth="922.0">
<children>
<TableView fx:id="table" prefHeight="711.0" prefWidth="927.0" />
</children>
</AnchorPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
</children>
</Pane>
</children>
</Pane>

@ -0,0 +1,200 @@
package com.chint.plm.rdmCreate;
import java.sql.Date;
import java.text.SimpleDateFormat;
import javafx.beans.property.BooleanProperty;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextArea;
public class RdmCreateBean {
private TextArea ordernumber = new TextArea();
private TextArea projectno = new TextArea();
private TextArea rdmprojectno = new TextArea();
private TextArea projectname = new TextArea();
private TextArea projectleader = new TextArea();
private TextArea factory = new TextArea();
private TextArea pushuser = new TextArea();
private TextArea pushdate = new TextArea();
private TextArea status = new TextArea();
private TextArea createdate = new TextArea();
private TextArea projectleaderid = new TextArea();
private TextArea pushuserid = new TextArea();
private CheckBox checkBox = new CheckBox();
public CheckBox getCheckBox() {
return checkBox;
}
public void setCheckBox(CheckBox checkBox) {
this.checkBox = checkBox;
}
public RdmCreateBean(String ordernumber, String projectno, String rdmprojectno, String projectname,
String projectleader, String factory, String pushuser, Date pushdate, String status, Date createdate,
String projectleaderid, String pushuserid) {
super();
this.checkBox.setSelected(false);
this.ordernumber.setText(ordernumber);
this.ordernumber.setEditable(false);
this.ordernumber.setPrefSize(200, 40);
this.projectno.setText(projectno);
this.projectno.setEditable(false);
this.projectno.setPrefSize(200, 40);
this.rdmprojectno.setText(rdmprojectno);
this.rdmprojectno.setEditable(false);
this.rdmprojectno.setPrefSize(200, 40);
this.projectname.setText(projectname);
this.projectname.setEditable(false);
this.projectname.setPrefSize(200, 40);
this.projectleader.setText(projectleader);
this.projectleader.setEditable(false);
this.projectleader.setPrefSize(200, 40);
this.factory.setText(factory);
this.factory.setEditable(false);
this.factory.setPrefSize(200, 40);
this.pushuser.setText(pushuser);
this.pushuser.setEditable(false);
this.pushuser.setPrefSize(200, 40);
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-M-dd");
this.pushdate.setText(sdf2.format(pushdate));
this.pushdate.setEditable(false);
this.pushdate.setPrefSize(200, 40);
this.status.setText(status);
this.status.setEditable(false);
this.status.setPrefSize(200, 40);
this.createdate.setText(sdf2.format(createdate));
this.createdate.setEditable(false);
this.createdate.setPrefSize(200, 40);
this.projectleaderid.setText(projectleaderid);
this.projectleaderid.setEditable(false);
this.projectleaderid.setPrefSize(200, 40);
this.pushuserid.setText(pushuserid);
this.pushuserid.setEditable(false);
this.pushuserid.setPrefSize(200, 40);
}
public void setOrdernumber(TextArea ordernumber) {
this.ordernumber = ordernumber;
}
public void setProjectno(TextArea projectno) {
this.projectno = projectno;
}
public void setRdmprojectno(TextArea rdmprojectno) {
this.rdmprojectno = rdmprojectno;
}
public void setProjectname(TextArea projectname) {
this.projectname = projectname;
}
public void setProjectleader(TextArea projectleader) {
this.projectleader = projectleader;
}
public void setFactory(TextArea factory) {
this.factory = factory;
}
public void setPushuser(TextArea pushuser) {
this.pushuser = pushuser;
}
public void setPushdate(TextArea pushdate) {
this.pushdate = pushdate;
}
public void setStatus(TextArea status) {
this.status = status;
}
public void setCreatedate(TextArea createdate) {
this.createdate = createdate;
}
public void setProjectleaderid(TextArea projectleaderid) {
this.projectleaderid = projectleaderid;
}
public void setPushuserid(TextArea pushuserid) {
this.pushuserid = pushuserid;
}
public TextArea getOrdernumber() {
return ordernumber;
}
public TextArea getProjectno() {
return projectno;
}
public TextArea getRdmprojectno() {
return rdmprojectno;
}
public TextArea getProjectname() {
return projectname;
}
public TextArea getProjectleader() {
return projectleader;
}
public TextArea getFactory() {
return factory;
}
public TextArea getPushuser() {
return pushuser;
}
public TextArea getPushdate() {
return pushdate;
}
public TextArea getStatus() {
return status;
}
public TextArea getCreatedate() {
return createdate;
}
public TextArea getProjectleaderid() {
return projectleaderid;
}
public TextArea getPushuserid() {
return pushuserid;
}
}

@ -0,0 +1,716 @@
package com.chint.plm.rdmCreate;
/**
* ===============================================================================
* Copyright (c) 2012-2024 CONNOR lijh. Unpublished - All Rights Reserved
* ===============================================================================
* File description:
*
* GZXQController.java
*
* ===============================================================================
* DATE Name Description of Change
*
* 2024-06-13 ljh create
* ===============================================================================
*/
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 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.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList;
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.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
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.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
public class RdmCreateController 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;
@FXML
private Button cxButton;
@FXML
private TextField f0;
@FXML
private TextField f1;
@FXML
private AnchorPane anchorPane1;
@FXML
private TextField f2;
@FXML
private AnchorPane anchorPane2;
@FXML
private TextField f3;
@FXML
private TextField f4;
@FXML
private AnchorPane anchorPane3;
@FXML
private GridPane gridTop;
@FXML
private ComboBox<String> f5;
@FXML
private AnchorPane anchorPane4;
@FXML
private TextField f6;
@FXML
private TitledPane titlePane;
@FXML
private DatePicker f7;
@FXML
private DatePicker f8;
@FXML
private ComboBox<String> f9;
// @FXML
// private SplitPane splitPane;
@FXML
private Button cjButton;
@FXML
private GridPane grid;
@FXML
private Button gbxmButton;
@FXML
private Pane pane;
@FXML
private TableView<RdmCreateBean> table;
@FXML
private Pane pane1;
@FXML
private Pane pane2;
@FXML
private ScrollPane scrollpane;
// table的列
private TableColumn<String, TextField> tc_1 = new TableColumn<String, TextField>("序号");
private String f7Str;
private String f8Str;
private RdmCreateFrame 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");
System.out.println("===============开始连接tc数据库===============");
frame = (RdmCreateFrame) paramKFXPanel.getParentDialog();
addWindListener(frame);
initCombox();
frame.setMaximumSize(frame.getMaximumSize());
System.out.println("frame==>" + frame);
//初始化第一列勾选框
TableColumn checkboxColumn = new TableColumn<>("");
checkboxColumn.setCellValueFactory(new PropertyValueFactory<RdmCreateBean, TextArea>("checkBox"));
checkboxColumn.prefWidthProperty().bind(table.widthProperty().multiply(0.03));
table.getColumns().add(checkboxColumn);
//根据首选项初始化table
String[] chint_tcproject_result_rule = session.getPreferenceService().getStringValues("CHINT_TCPROJECT_RESULT_RULE");
if(chint_tcproject_result_rule == null || chint_tcproject_result_rule.length <= 0) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("请正确配置“CHINT_TCPROJECT_RESULT_RULE”首选项");
//alert.setContentText("导入完成");
alert.showAndWait();
return;
}
for (int i = 0; i < chint_tcproject_result_rule.length; i++) {
String[] split = chint_tcproject_result_rule[i].split(":");
if(split.length == 3) {
TableColumn tempColume = new TableColumn<RdmCreateBean, TextArea>(split[0]);
tempColume.setSortable(false);
tempColume.setCellValueFactory(new PropertyValueFactory<RdmCreateBean, TextArea>(split[1]));
tempColume.prefWidthProperty().bind(table.widthProperty().multiply(Double.parseDouble(split[2])));
table.getColumns().add(tempColume);
}
}
//设置文本框的高度
// jTextField1.setPrefHeight(30);
// 表格列绑定bean对象
// tc_1.setSortable(false);
// 列绑定bean对象
// tc_1.setCellValueFactory(new PropertyValueFactory<GzxqBean, TextArea>("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);
//把代码中定义的table列加入tableView
// table.getColumns().addAll(tc_1, tc_2, tc_3, tc_4, tc_5, tc_6, tc_7,
// tc_8, tc_9, tc_10);
// tableView.setMaxHeight(pageNum);
}
// 初始化下拉框内容
private void initCombox() {
// TODO Auto-generated method stub
SqlUtil.SRMGetTCDataConnection(prefs);
String groupSql = "SELECT PNAME FROM ppom_group WHERE RPARENTU=(SELECT PUID FROM ppom_group WHERE PNAME='CHINT') order by PNAME ASC";
List<String> gcList = new ArrayList<String>();
ResultSet res;
try {
res = SqlUtil.read(groupSql);
//处理查询数据结果集
while (res.next()) {
gcList.add(res.getString(1));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
f5.getItems().addAll(gcList);
List<String> ztList = new ArrayList<String>();
ztList.add("未创建");
ztList.add("已创建");
ztList.add("已变更");
ztList.add("已更新");
ztList.add("已关闭");
f9.getItems().addAll(ztList);
}
/**
* @param frame
* @function
*/
private void addWindListener(RdmCreateFrame 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());
pane.setPrefWidth(width * 0.98);
pane.setPrefHeight(hight * 0.98);
System.out.println("pane==========="+pane.getWidth());
//anchorPane1.setPrefWidth(width * 0.98);
//anchorPane2.setPrefWidth(width * 0.98);
System.out.println("anchorPane3==========="+anchorPane3.getWidth());
anchorPane3.setPrefWidth(anchorPane3.getWidth() * widthxs);
anchorPane3.setPrefHeight(anchorPane3.getHeight() * hightxs);
System.out.println("anchorPane3==========="+anchorPane3.getWidth());
anchorPane4.setPrefWidth(anchorPane4.getWidth() * widthxs);
anchorPane4.setPrefHeight(anchorPane4.getHeight() * hightxs);
System.out.println("scrollpane==========="+scrollpane.getWidth());
scrollpane.setPrefWidth(scrollpane.getWidth() * widthxs);
scrollpane.setPrefHeight(scrollpane.getHeight() * hightxs);
System.out.println("scrollpane==========="+scrollpane.getWidth());
System.out.println("pane2==========="+pane2.getWidth());
pane2.setPrefWidth(pane2.getWidth() * widthxs);
pane2.setPrefHeight(pane2.getHeight() * hightxs);
System.out.println("pane2==========="+pane2.getWidth());
if(width == 1308.0) {
titlePane.setPrefWidth(width * 1.0);
System.out.println("111111111111111111111111111111111111111111111111111111111111111111111");
}else {
titlePane.setPrefWidth(width * 0.929);
}
//grid.setPrefWidth(width * 0.98);
//gridTop.setPrefWidth(width * 0.98);
System.out.println("table==========="+table.getWidth());
table.setPrefWidth(table.getWidth() * widthxs);
table.setPrefHeight(table.getHeight() * hightxs);
System.out.println("table==========="+table.getWidth());
// bpane.setPrefWidth(width * 0.98);
// titlePaneCondition.setPrefWidth(width * 0.98);
// titlePaneResult.setPrefWidth(width * 0.98);
// gridPaneCondition.setPrefWidth(width * 0.97);
// gridPaneCondition.setPrefWidth(width * 0.97);
// tablePane.setPrefWidth(width * 0.98);
// tableView.setPrefWidth(width * 0.97);
// gridPaneResult.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 cjbutton(ActionEvent event) throws Exception {
SqlUtil.SRMGetTCDataConnection(prefs);
ObservableList<RdmCreateBean> items = table.getItems();
int count = 0;
TCComponentUserType userType = (TCComponentUserType)this.session
.getTypeComponent("User");
TCComponentGroupType groupType = (TCComponentGroupType) session.getTypeComponent("Group");
StringBuffer sbInfo = new StringBuffer();
for (int i = 0; i < items.size(); i++) {
RdmCreateBean rdmCreateBean = items.get(i);
boolean selected = rdmCreateBean.getCheckBox().isSelected();
if(selected) {
count++;
List<TCComponentUser> members = new ArrayList();//指派的用户id
List<String> exitUserName = new ArrayList();//存在的用户名称
List<String> notExitUserName = new ArrayList();//不存在的用户名称
//判断tc是否已经创建过项目
Map<String, String> field = new HashMap<String, String>();
String ordernumber = rdmCreateBean.getOrdernumber().getText();
String id = ordernumber+"-"+rdmCreateBean.getProjectno().getText();
System.out.println("id="+id);
field.put("ordernumber", ordernumber);
TCComponentContextList contxt = KUtil.query(session, "chint_query_tcproject", field);
if(contxt == null || contxt.getListCount() == 0) {
//去数据库中查询要指派的人员
String selectSql = "SELECT USERID,\"USER\",FACTORY FROM CHINT_RDM_PROJECT_PDTTEAMS WHERE ordernumber ='"+ordernumber+"'";
System.out.println("selectSql==="+selectSql);
ResultSet res = SqlUtil.read(selectSql);
//处理查询数据结果集
while (res.next()) {
TCComponentUser userT = null;
try {
System.out.println("res.getString(1)=="+res.getString(1));
userT = userType.find(res.getString(1));
}catch (Exception e) {
// TODO: handle exception
notExitUserName.add(res.getString(2));//找不到人报错
System.out.println("res.getString(2)=="+res.getString(2));
continue;
}
if (userT != null) {
// TCComponentGroup group = groupType.find(res.getString(3));
// KUtil.setByPass(true);
// userT.setDefaultGroup(group);
// KUtil.setByPass(false);
members.add(userT);
exitUserName.add(res.getString(2));
System.out.println("111");
}else {
notExitUserName.add(res.getString(2));
System.out.println("222");
}
}
// //如果没有人可以指派 会报错
// if(members.size() <= 0) {
// sbInfo.append("项目创建失败:内部订单号:"+ordernumber+"项目ID为"+id+lineSeparator);
// sbInfo.append("失败原因:当前创建人,要加到项目小组成员并设置成项目管理员。"+lineSeparator);
// sbInfo.append(lineSeparator);
// continue;
// }
TCComponentProjectType projecttype = (TCComponentProjectType) session
.getTypeComponent("TC_Project");
TCComponentProject proj=null;
TCComponentUser user = session.getUser();
// proj = projecttype.create(id, id, "",
// new TCComponent[] {user}, user, new TCComponentUser[] {user});
//把自己加进去
members.add(user);
exitUserName.add(session.getUserName());
proj = projecttype.create(id,
id, "",
(TCComponent[])members.toArray(
new TCComponent[members.size()]), user,//把人员指派到项目
(TCComponentUser[])members.toArray(
new TCComponentUser[members.size()]));
//设置属性
proj.setProperties(new String[] {"zt2_ordernumber","zt2_projectno","zt2_rdmprojectno","zt2_projectname","zt2_projectleader","zt2_projectleaderid","zt2_factory","zt2_pushuser","zt2_pushuserid"},
new String[] {rdmCreateBean.getOrdernumber().getText(),rdmCreateBean.getProjectno().getText(),rdmCreateBean.getRdmprojectno().getText(),rdmCreateBean.getProjectname().getText(),rdmCreateBean.getProjectleader().getText(),rdmCreateBean.getProjectleaderid().getText(),rdmCreateBean.getFactory().getText(),rdmCreateBean.getPushuser().getText(),rdmCreateBean.getPushuserid().getText()});
String pushDate = rdmCreateBean.getPushdate().getText();
if(pushDate != null && !pushDate.isEmpty()) {
Date parse = sdf.parse(pushDate);
proj.setDateProperty("zt2_pushdate", parse);
}
//创建完项目 修改数据库中的状态
String updateSql = "UPDATE CHINT_RDM_PROJECT SET status = '已创建' WHERE ordernumber = '"+rdmCreateBean.getOrdernumber().getText()+"'";
System.out.println("updateSql==="+updateSql);
try {
SqlUtil.update(updateSql);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
//输出项目创建的信息
sbInfo.append("项目已创建完成:内部订单号:"+ordernumber+"项目ID为"+id+lineSeparator);
if(exitUserName.size() > 0) {
sbInfo.append("人员已指派");
for (int j = 0; j < exitUserName.size(); j++) {
sbInfo.append(exitUserName.get(j)+",");
}
}
if(notExitUserName.size() > 0) {
sbInfo.append("人员未指派");
for (int j = 0; j < notExitUserName.size(); j++) {
sbInfo.append(notExitUserName.get(j)+",");
}
}
sbInfo.append(lineSeparator);
sbInfo.append(lineSeparator);
}else {
//获取查询查到的项目
TCComponentProject proj = (TCComponentProject)contxt.get(0).getComponent();
//设置属性
proj.setProperties(new String[] {"zt2_ordernumber","zt2_projectno","zt2_rdmprojectno","zt2_projectname","zt2_projectleader","zt2_projectleaderid","zt2_factory","zt2_pushuser","zt2_pushuserid"},
new String[] {rdmCreateBean.getOrdernumber().getText(),rdmCreateBean.getProjectno().getText(),rdmCreateBean.getRdmprojectno().getText(),rdmCreateBean.getProjectname().getText(),rdmCreateBean.getProjectleader().getText(),rdmCreateBean.getProjectleaderid().getText(),rdmCreateBean.getFactory().getText(),rdmCreateBean.getPushuser().getText(),rdmCreateBean.getPushuserid().getText()});
String pushDate = rdmCreateBean.getPushdate().getText();
if(pushDate != null && !pushDate.isEmpty()) {
Date parse = sdf.parse(pushDate);
proj.setDateProperty("zt2_pushdate", parse);
}
//创建完项目 修改数据库中的状态
String updateSql = "UPDATE CHINT_RDM_PROJECT SET status = '已更新' WHERE ordernumber = '"+rdmCreateBean.getOrdernumber().getText()+"'";
System.out.println("updateSql==="+updateSql);
sbInfo.append("项目已更新完成:内部订单号:"+ordernumber+"项目ID为"+id+lineSeparator);
sbInfo.append(lineSeparator);
try {
SqlUtil.update(updateSql);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
}
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(sbInfo.toString());
//alert.setContentText("导入完成");
alert.showAndWait();
}
}
//关闭项目
@FXML
void gbxmButton(ActionEvent event) throws SQLException {
SqlUtil.SRMGetTCDataConnection(prefs);
ObservableList<RdmCreateBean> items = table.getItems();
int count = 0;
for (int i = 0; i < items.size(); i++) {
RdmCreateBean rdmCreateBean = items.get(i);
boolean selected = rdmCreateBean.getCheckBox().isSelected();
if(selected) {
String updateSql = "UPDATE CHINT_RDM_PROJECT SET status = '已关闭' WHERE ordernumber = '"+rdmCreateBean.getOrdernumber().getText()+"'";
System.out.println("updateSql==="+updateSql);
try {
SqlUtil.update(updateSql);
count++;
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
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();
}
}
//查询
@FXML
void cxButton(ActionEvent event) throws ParseException {
SqlUtil.SRMGetTCDataConnection(prefs);
f7Str = f7.getEditor().getText();
f8Str = f8.getEditor().getText();
String selectedFactory = f5.getSelectionModel().getSelectedItem();
String selectedStatus = f9.getSelectionModel().getSelectedItem();
ArrayList fieldList = new ArrayList();
System.out.println("======================清除");
table.getItems().clear();
List<RdmCreateBean> quotations = new ArrayList<RdmCreateBean>();
String factory = "";
// 拼接查询语句
String sql = "select ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,pushdate,status,createdate,projectleaderid,pushuserid from CHINT_RDM_PROJECT where 1=1 ";
if(f0.getText()!=null && !"".equals(f0.getText().trim())) {
sql += "and ordernumber = \'" + f0.getText() +"\'";
}
if(f1.getText()!=null && !"".equals(f1.getText().trim())) {
sql += "and projectno = \'" + f1.getText() +"\'";
}
if(f2.getText()!=null && !"".equals(f2.getText().trim())) {
sql += "and rdmprojectno = \'" + f2.getText() +"\'";
}
if(f3.getText()!=null && !"".equals(f3.getText().trim())) {
sql += "and projectname = \'" + f3.getText() +"\'";
}
if(f4.getText()!=null && !"".equals(f4.getText().trim())) {
sql += "and projectleader = \'" + f4.getText() +"\'";
}
if(selectedFactory != null && !selectedFactory.isEmpty()) {
sql += "and factory like \'%" + selectedFactory +"%\'";
}
if(f6.getText()!=null && !"".equals(f6.getText().trim())) {
sql += "and pushuser = \'" + f6.getText() +"\'";
}
if(f7Str !=null && !"".equals(f7Str)) {
Date date = sdf.parse(f7Str);
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
fieldList.add(sqlDate);
//sql += "and pushdate <= \'" + sqlDate +"\'";
sql += "and pushdate <= ?";
}
if(f8Str !=null && !"".equals(f8Str)) {
Date date = sdf.parse(f8Str);
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
fieldList.add(sqlDate);
//sql += "and pushdate >= \'" + sqlDate +"\'";
sql += "and pushdate >= ?";
}
if(selectedStatus != null && !selectedStatus.isEmpty()) {
sql += "and status = \'" + selectedStatus +"\'";
}
System.out.println("sql:"+sql);
try {
ResultSet res = SqlUtil.read(sql,fieldList.toArray(new java.sql.Date[0]));
//处理查询数据结果集
while (res.next()) {
RdmCreateBean rdmCreateBean = new RdmCreateBean(
res.getString("ordernumber") != null ? res.getString("ordernumber") : "",
res.getString("projectno") != null ? res.getString("projectno") : "",
res.getString("rdmprojectno") != null ? res.getString("rdmprojectno") : "",
res.getString("projectname") != null ? res.getString("projectname") : "",
res.getString("projectleader") != null ? res.getString("projectleader") : "",
res.getString("factory") != null ? res.getString("factory") : "",
res.getString("pushuser") != null ? res.getString("pushuser") : "",
res.getDate("pushdate"),
res.getString("status") != null ? res.getString("status") : "",
res.getDate("createdate"),
res.getString("projectleaderid") != null ? res.getString("projectleaderid") : "",
res.getString("pushuserid") != null ? res.getString("pushuserid") : "");
System.out.println("rdmCreateBean==="+rdmCreateBean);
quotations.add(rdmCreateBean);
}
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
if(quotations.size() > 0) {
//组织界面数据
ObservableList<RdmCreateBean> 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();
}
}
}

@ -0,0 +1,25 @@
package com.chint.plm.rdmCreate;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javafx.embed.swing.JFXPanel;
public class RdmCreateFrame extends KFrame {
public RdmCreateFrame() {
super();
}
@Override
protected void initUI() throws Exception {
this.setTitle("´´½¨RDMÑз¢ÏîÄ¿");
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(1300, 900));
JFXPanel panel = new JFXPanel();
panel.setScene(new RdmCreatePanel(this).getScene());
this.add(BorderLayout.CENTER, panel);
}
}

@ -0,0 +1,79 @@
package com.chint.plm.rdmCreate;
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 RdmCreateHandler 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 RdmCreateFrame();
}
}.start();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
new RdmCreateFrame();
}
}

@ -0,0 +1,13 @@
package com.chint.plm.rdmCreate;
import java.awt.Window;
public class RdmCreatePanel extends KFXPanel {
public RdmCreatePanel(Window dialog) {
super(dialog, "RdmCreate.fxml");
// TODO Auto-generated constructor stub
}
}

@ -0,0 +1,40 @@
package com.connor.chint.sap2.createKjBom;
import java.util.Objects;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
public class BomBean {
String revName;
TCComponentBOMLine bomLine;
public BomBean(String revName, TCComponentBOMLine bomLine) {
super();
this.revName = revName;
this.bomLine = bomLine;
}
@Override
public int hashCode() {
return Objects.hash(revName);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BomBean other = (BomBean) obj;
return other.revName.contains(revName);
}
public BomBean(String revName) {
super();
this.revName = revName;
}
@Override
public String toString() {
return "BomBean [revName=" + revName + ", bomLine=" + bomLine + "]\n";
}
}

@ -0,0 +1,34 @@
package com.connor.chint.sap2.createKjBom;
public class CBean {
String cId;
String folderName;
String piName;
public String getcId() {
return cId;
}
public void setcId(String cId) {
this.cId = cId;
}
public String getFolderName() {
return folderName;
}
public void setFolderName(String folderName) {
this.folderName = folderName;
}
public String getPiName() {
return piName;
}
public void setPiName(String piName) {
this.piName = piName;
}
public CBean(String cId, String folderName, String piName) {
super();
this.cId = cId;
this.folderName = folderName;
this.piName = piName;
}
}

@ -0,0 +1,42 @@
package com.connor.chint.sap2.createKjBom;
/**
* @copyRight
* @author E-mail:hub@connor.net.cn
* @date 2017-7-3 11:47:03
* @version v1.0
* @parameter
* @since
* @return
*/
public class ClassProperty {
private int propertyID;
private String value;
public ClassProperty() {
}
public ClassProperty(int propertyID, String value) {
this.propertyID = propertyID;
this.value = value;
}
public int getPropertyID() {
return propertyID;
}
public void setPropertyID(int propertyID) {
this.propertyID = propertyID;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

@ -0,0 +1,58 @@
package com.connor.chint.sap2.createKjBom;
import java.util.ArrayList;
import java.util.List;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateKjBomCommand extends KCommand {
// private boolean top = true;
// private TCComponentBOMLine line;
public CreateKjBomCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
// InterfaceAIFComponent targetComponent = app.getTargetComponent();
try {
TCSession session = (TCSession)app.getSession();
String groupID = SAPUtil.getGroupID(session);//
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_kjbomTemp", session);
List<KjBean> kjList = new ArrayList<KjBean>();
for(String pref : prefs) {
// 1ZDB300000P-xxx|1ZDB300000P=2-组件布置图;1ZDB400000T=3-铁心图纸&H铁心
if(!pref.startsWith(groupID))
continue;
String[] split = pref.substring(groupID.length() + 1).split("\\|");
String kjBomId = split[0];
KjBean bean = new KjBean(kjBomId);
String[] split2 = split[1].split(";");
for(String s : split2) {
String[] split3 = s.split("=");
if(split3[1].contains("&")) {
String[] split4 = split3[1].split("&");
CBean cb = new CBean(split3[0],split4[0],split4[1]);
bean.cbeans.add(cb);
}else {
CBean cb = new CBean(split3[0],split3[1],"");
bean.cbeans.add(cb);
}
}
kjList.add(bean);
}
if(kjList.size() == 0) {
MessageBox.post("首选项中未找到配置,请登陆正确组", "", MessageBox.WARNING);
return;
}
this.setRunnable(new KjBomDialog(app, "", kjList));
}catch(Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,28 @@
package com.connor.chint.sap2.createKjBom;
import java.util.ArrayList;
import java.util.List;
public class KjBean {
public String kjBs;
public String kjbomId;
public List<CBean> cbeans = new ArrayList<CBean>();
public String getKjbomId() {
return kjbomId;
}
public void setKjbomId(String kjbomId) {
this.kjbomId = kjbomId;
}
public KjBean(String kjbomId) {
super();
this.kjbomId = kjbomId;
String[] split = kjbomId.split("-");
kjBs = split[1];
}
@Override
public String toString() {
return kjbomId;
}
}

@ -0,0 +1,172 @@
package com.connor.chint.sap2.createKjBom;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.util.MessageBox;
public class KjBomDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private List<KjBean> kjList;
// private AbstractAIFApplication app;
private KjController controller;
public KjBomDialog(AbstractAIFApplication app, String actionInfo,List<KjBean> beanList) {
// Auto-generated constructor stub
super(false);
// KUtil.setByPass(true);
// this.app = app;
this.kjList = beanList;
this.controller = new KjController(app);
}
@Override
public void run() {
// Auto-generated method stub
try {
if (!controller.checkProject()) {
MessageBox.post(this, "请选择项目文件夹对象", "", MessageBox.INFORMATION);
return;
}
initUI();
showDialog();
/*
* if(!controller.isAllHave) { MessageBox.post(this,
* "项目中"+controller.name+"方案未同步WBS,请手动执行", "",MessageBox.INFORMATION); }else {
* b_syn.setVisible(false); }
*/
} catch (Exception e) {
MessageBox.post(this, "申请方案编码时发生错误:" + e.getMessage(), "", MessageBox.ERROR);
e.printStackTrace();
return;
}
}
private JButton okButton;
private JButton celButton;
private JComboBox<KjBean> kjCombox;
public void initUI() {
this.setTitle("创建框架BOM");
this.setPreferredSize(new Dimension(400,150));
JPanel p1 = new JPanel(new BorderLayout());
p1.setBorder(new TitledBorder(new EtchedBorder(), "框架BOM模板"));
kjCombox = new JComboBox<KjBean>();
for(KjBean bean:kjList) {
kjCombox.addItem(bean);
}
p1.add(kjCombox);
JPanel rootPanel = new JPanel(new FlowLayout());
this.okButton = new JButton("确认");
this.celButton = new JButton("取消");
rootPanel.add(okButton);
rootPanel.add(celButton);
this.setLayout(new BorderLayout());
this.add(p1, BorderLayout.NORTH);
this.add(rootPanel, BorderLayout.CENTER);
// dialog.add(tablePanel, BorderLayout.CENTER);
this.add(rootPanel, BorderLayout.SOUTH);
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
addListeners();
}
private void addListeners() {
// Auto-generated method stub
celButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
dispose();
}
});
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
//开始创建框架BOM
//1.遍历原有框架BOM获取项目代号 、 检查项目结构文件夹、检查id是否唯一
//2.根据项目找到组件布置图 拆分BOM
//3.根据云派信息转换所有权
new Thread() {
@Override
public void run() {
MyProgressBarCompent comp = null;
KUtil.setByPass(true);
try {
comp = new MyProgressBarCompent("", "正在创建框架BOM......");
int selectedIndex = kjCombox.getSelectedIndex();
KjBean kjBean = kjList.get(selectedIndex);
StringBuilder build = new StringBuilder("");
String tempId = kjBean.getKjbomId();
boolean checkFolder = controller.checkFolder(tempId, kjBean, build);
if(!checkFolder) {
comp.setVisible(false);
dispose();
MessageBox.post(build.toString(), "",2);
return;
}
if(controller.byqCCPFromProject.size()>1) {
Object[] options = {"是","否"};
int response = JOptionPane.showOptionDialog(null, "项目产成品存在多台变压器,请确认是否为同一工程图号", "选择",JOptionPane.YES_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if(response == -1 || response==1)
{
return;
}
}
// List<CBean> cbeans = kjBean.cbeans;
boolean createKjBom = controller.createKjBom(kjBean,comp);
comp.setVisible(false);
if(!createKjBom) {
dispose();
return;
}else {
dispose();
MessageBox.post("框架BOM创建完成。", "提示",2);
}
} catch (Exception e1) {
// Auto-generated catch block
e1.printStackTrace();
}finally {
KUtil.setByPass(false);
}
if(comp!=null) {
comp.setVisible(false);
}
dispose();
}
}.start();
}
});
}
}

@ -0,0 +1,864 @@
package com.connor.chint.sap2.createKjBom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JOptionPane;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPUtil;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCAccessControlService;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentRevisionRule;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.ui.common.RACUIUtil;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsOutput;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
import com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureInputInfo;
import com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureResponse;
import com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureSaveAsIn;
public class KjController {
private AbstractAIFApplication app;
private TCSession session;
private TCComponent project;
private String wbsNo = "";
private String projectDh = "";
private String projectId = "";
//存放已经存在的框架BOM的ID
Map<TCComponentItemRevision,TCComponentItem> oldkjIdMap = new HashMap<TCComponentItemRevision,TCComponentItem>();
//存放框架BOM对应的另存ID
Map<TCComponentItemRevision,String> kjIdMap = new HashMap<TCComponentItemRevision,String>();
private List<TCComponentBOMLine> copyLines = new ArrayList<TCComponentBOMLine>();
private String kjBs;
// public
// private TCComponentItemType ccomponentitemtype;
Map<String, String> idName = new HashMap<String, String>();
//存放 ID-文件夹
private Map<String, TCComponentFolder> fMap = new HashMap<>();
private Map<String, TCComponentUser> nameUser = new HashMap<>();
private TCComponentItem tqqgdItem;
protected List<TCComponentItemRevision> byqCCPFromProject;
public KjController(AbstractAIFApplication app) {
// Auto-generated constructor stub
this.app = app;
this.session = (TCSession) app.getSession();
}
public boolean checkProject() throws Exception {
InterfaceAIFComponent target = app.getTargetComponent();
if (target == null || !(target instanceof TCComponent)) {
return false;
}
String type = target.getType();
if (type.equals("ZT2_ProjectItem")) {
project = (TCComponent) target;
projectId = project.getStringProperty("item_id");
projectDh = project.getProperty("zt2_ProjectCode");
wbsNo = project.getProperty("zt2_WBSNo");
System.out.println("WBS号:" + wbsNo);
return true;
}
return false;
}
protected boolean checkFolder(String kjBomId, KjBean kjBean, StringBuilder errBuff) throws Exception {
boolean flag = true;
try {
//获取首选项里的文件夹名称、判断当前项目是否存在
fMap.clear();
Map<String, TCComponentFolder> fodlers = new HashMap<>();
TCComponentFolder xmzxFolder = KUtil.getXMZXFolderFromProject(project);
byqCCPFromProject = getByqCCPFromProject(project, session);
AIFComponentContext[] childFolders = xmzxFolder.getChildren();
TCComponentFolder bztFolder = null;
TCComponentFolder dcsjFolder = null;
for(AIFComponentContext context : childFolders) {
InterfaceAIFComponent c = context.getComponent();
if(c instanceof TCComponentFolder) {
String cName = c.getProperty("object_name");
if(cName.equals("2-组件布置图")) {
bztFolder = (TCComponentFolder)c;
}else if(cName.equals("1-电磁设计")) {
dcsjFolder = (TCComponentFolder)c;
}
fodlers.put(cName, (TCComponentFolder)c);
}
}
if(bztFolder!=null) {
AIFComponentContext[] children = bztFolder.getChildren();
for(AIFComponentContext cont : children) {
InterfaceAIFComponent component = cont.getComponent();
String type = component.getType();
if(type.equals("ZT2_Requisition")) {
tqqgdItem = (TCComponentItem)component;
}
}
}
TCComponentItem dcsjItem = null;;
if(dcsjFolder != null) {
AIFComponentContext[] children = dcsjFolder.getChildren();
for(AIFComponentContext cont : children) {
InterfaceAIFComponent component = cont.getComponent();
String type = component.getType();
if(type.equals("ZT2_MainMat")) {
dcsjItem = (TCComponentItem)component;
}
}
}
if(dcsjItem == null) {
errBuff.append("当前项目中未创建物主材采购单,不允许创建框架BOM.\n");
flag = false;
}else {
TCComponentItemRevision latestItemRevision = dcsjItem.getLatestItemRevision();
if(!KUtil.isTCM(latestItemRevision)){
errBuff.append("当前项目中主材采购单版本未发布,不允许创建框架BOM.\n");flag = false;
}
if(!KUtil.isTCM(KUtil.getRevBOMView(latestItemRevision))) {
errBuff.append("当前项目中主材采购单BOM视图版本未发布,不允许创建框架BOM.\n");flag = false;
}
}
if(tqqgdItem == null) {
errBuff.append("当前项目中未创建物料提前请购单,不允许创建框架BOM.\n");flag = false;
}else {
TCComponentItemRevision latestItemRevision = tqqgdItem.getLatestItemRevision();
if(!KUtil.isTCM(latestItemRevision)){
errBuff.append("当前项目中物料提前请购单版本未发布,不允许创建框架BOM.\n");flag = false;
}
if(!KUtil.isTCM(KUtil.getRevBOMView(latestItemRevision))) {
errBuff.append("当前项目中物料提前请购单BOM视图版本未发布,不允许创建框架BOM.\n");flag = false;
}
}
OkHttpClient client = new OkHttpClient();
String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session);
Request request = new Request.Builder()
.url(preference + "/api/open/task/getTaskInfo/" + projectId)
.build();
Response response = client.newCall(request).execute();
String string = response.body().string();
System.out.println(string);
JSONObject parseObject = JSON.parseObject(string);
JSONArray datas = parseObject.getJSONArray("data");
idName.clear();
if(datas!=null) {
for(int t=0;t<datas.size();t++) {
JSONObject jsonObject = datas.getJSONObject(t);
String string2 = jsonObject.getString("userid");
if(string2!=null && !string2.equals("")) {
idName.put(jsonObject.getString("taskname"),string2);
}
System.out.println(jsonObject.getString("taskname")+"====="+string2);
}
}
System.out.println(idName.toString());
List<CBean> beanList = kjBean.cbeans;
// ZT2_Requisition
for(CBean bean : beanList) {
String piName = bean.piName;
String folderName = bean.folderName;
if(idName.containsKey(piName)) {
String userId = idName.get(piName);
TCComponent userName = getUserName(userId,session);
if(userName!=null) {
nameUser.put(bean.cId,(TCComponentUser) userName);
}
}
if(!fodlers.containsKey(folderName)) {
errBuff.append("项目执行下没有找到名称为:"+folderName+"的文件夹");
return false;
}else {
fMap.put(bean.cId, fodlers.get(folderName));
}
}
System.out.println(nameUser.toString());
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
return flag;
}
private static TCComponent getUserName(String userID, TCSession session) throws Exception {
Map<String, String> fields = new HashMap<>();
fields.put("用户 ID", userID);
TCComponentContextList quertList = KUtil.query(session, "__WEB_find_user", fields);
if (quertList.getListCount() > 0) {
// System.out.println("user:"+quertList.get(0).getComponent());
return (TCComponent)quertList.get(0).getComponent();
}
return null;
}
private String objectToJson(List<ClassProperty> props) {
String str = null;
try {
net.sf.json.JSONArray json = net.sf.json.JSONArray.fromObject(props);// 将java对象转换为json对象
str = json.toString();// 将json对象转换为字符串
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("JSON =>" + str);
return str;
}
@SuppressWarnings("deprecation")
protected boolean createKjBom(KjBean bean, MyProgressBarCompent comp) throws Exception {
StringBuilder builder = new StringBuilder("");
TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D");
TCComponentItem newItem = ccomponentitemtype.find(bean.getKjbomId());
TCComponentItemRevision kjBomRev = newItem.getLatestItemRevision();
TCTypeService service = session.getTypeService();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
TCComponentBOMWindow window = winType.create(null);
TCComponentBOMLine kjBomLine = window.setWindowTopLine(newItem, kjBomRev, null, null);
kjBs = bean.kjBs;
kjIdMap.clear();
oldkjIdMap.clear();
Map<String, ExpandPSData[]> bomLineTreeNodeSOA = BomToSapUtil.getBomLineTreeNodeSOA(kjBomLine);
builder.setLength(0);
// 遍历获取BOM结构 判断ID是否存在
String item_id = kjBomRev.getProperty("item_id");
String replaceAll = item_id.replaceAll(kjBs, projectDh);
kjIdMap.put(kjBomRev, replaceAll);
Map<String, TCComponentItem> findMap = new HashMap<String, TCComponentItem>();
//遍历获取BOM新ID
List<TCComponentBOMLine> useLines = new ArrayList<TCComponentBOMLine>();
createId(kjBomLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 1);
System.out.println("kjIdMap==>" + kjIdMap.toString());
System.out.println("builder==>" + builder.toString());
if(builder.length() > 0) {
// MessageBox.post(builder.toString(), "提示",2);
String[] msgs = builder.toString().split("");
builder.setLength(0);
for(int i = 0; i < msgs.length; i++) {
builder.append(msgs[i]).append("");
if(i % 4 == 3) {
builder.append("\n");
}
}
Object[] options = { "是", "否" };
comp.setVisible(false);
builder.append("是否要继续生成.");
int response = JOptionPane.showOptionDialog(null, builder.toString(), "选择", JOptionPane.YES_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if(response == -1 || response == 1) {
window.close();
return false;
}
} //else
{
comp = new MyProgressBarCompent("", "正在创建框架BOM......");
//开始克隆BOM
cloneOrUpdate(session, kjBomLine, copyLines, useLines);
//添加到文件夹
System.out.println("oldkjIdMap==>" + oldkjIdMap.toString());
for(TCComponentItemRevision rev : oldkjIdMap.keySet()) {
TCComponentItem find = oldkjIdMap.get(rev);
String id = find.getProperty("item_id");
String[] split = id.split("-");
System.out.println("id1==>" + id);
if(fMap.containsKey(split[0])) {
TCComponentFolder tcComponentFolder = fMap.get(split[0]);
try {
tcComponentFolder.add("contents", find);
}catch(Exception e) {
if(!e.getMessage().contains("存在于目标文件夹中"))
e.printStackTrace();
}
}
}
System.out.println("nameUser==>" + nameUser.toString());
System.out.println("fMap==>" + fMap.toString());
for(TCComponentItemRevision rev : kjIdMap.keySet()) {
String id = kjIdMap.get(rev);
TCComponentItem[] finds = ccomponentitemtype.findItems(id);
if(finds == null || finds.length == 0) {
System.out.println(id + "对象未找到");
continue;
}
TCComponentItem find = finds[0];
String[] split = id.split("-");
System.out.println("id2==>" + split[0]);
if(fMap.containsKey(split[0])) {
TCComponentFolder tcComponentFolder = fMap.get(split[0]);
try {
tcComponentFolder.add("contents", find);
}catch(Exception e) {
if(!e.getMessage().contains("存在于目标文件夹中"))
e.printStackTrace();
}
}
if(nameUser.containsKey(split[0])) {
TCComponentUser tcComponentUser = nameUser.get(split[0]);
try {
changeOwners(find,tcComponentUser);
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
}
TCComponentItem find = ccomponentitemtype.findItems(replaceAll)[0];
System.out.println("find==>" + find);
if(findMap.size()>0) {
// window.lock();
TCComponentBOMLine newTopline = window.setWindowTopLine(find, find.getLatestItemRevision(),null, null);
Map<String, ExpandPSData[]> bomLineTreeNodeSOA2 = BomToSapUtil.getBomLineTreeNodeSOA(newTopline);
updateKjBom( findMap , bomLineTreeNodeSOA2,newTopline.getUid());
newTopline.save();
window.save();
window.refresh();
// window.unlock();
// window.close();
}
String groupId = SAPUtil.getGroupID(session);
TCComponentBOMLine newTopline = window.setWindowTopLine(find, find.getLatestItemRevision(),null, null);
//如果存在已经有的框架BOM对象遍历BOM然后替换再进行下面操作
System.out.println("byqCCPFromProject==>" + byqCCPFromProject.toString());
if(byqCCPFromProject.size()>0) {
try {
if(groupId.equals("M005")) {
for(TCComponentItemRevision ccp : byqCCPFromProject) {
AIFComponentContext[] factorys = KUtil.getPseudoFolder(ccp, "ZT2_FactoryNumber").getChildren();
if(factorys.length > 0) {
for(AIFComponentContext f : factorys) {
find.getLatestItemRevision().add("ZT2_FactoryNumber", (TCComponent) f.getComponent());
}
}else {
find.getLatestItemRevision().add("representation_for", ccp);
}
}
}else
find.getLatestItemRevision().add("representation_for", byqCCPFromProject);
}catch(Exception e) {
if(!e.getMessage().contains("存在于目标文件夹中"))
e.printStackTrace();
}
}
List<ClassProperty> propList = new ArrayList<ClassProperty>();
//TODO 读取CHINT_kjbomTemp_FL首选项根据组织、图纸母号找到对应的分类库 ICM230101
String prefId = groupId + ":" + bean.kjbomId, classID = "";
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_kjbomTemp_FL", session);
for(String pref : prefs) {
if(!pref.startsWith(prefId))
continue;
classID = pref.substring(pref.indexOf("|") + 1);
}
if(classID.isEmpty()) {
MessageBox.post(prefId + "未找到对应分类库", "提示", MessageBox.WARNING);
}else
sendToClass(find.getUid(), classID, objectToJson(propList));
List<TCComponentBOMLine> listBoms = listBoms(newTopline);
//存放名称对应的BOM行
List<BomBean> bomBeans = new ArrayList<>();
for(TCComponentBOMLine listBom : listBoms) {
String name = listBom.getItemRevision().getProperty("object_name");
bomBeans.add(new BomBean(name, listBom));
}
System.out.println("bomBeans==>" + bomBeans.toString());
// Map<String,List<TCComponentBOMLine>> remarkMap = new HashMap<String,List<TCComponentBOMLine>>();
//拆分BOM逻辑获取物料提前请购单的BOM
if(tqqgdItem != null) {
TCComponentBOMWindow window2 = winType.create(null);
TCComponentBOMLine qgdBomline = window2.setWindowTopLine(tqqgdItem, tqqgdItem.getLatestItemRevision(), null, null);
AIFComponentContext[] children = qgdBomline.getChildren();
//遍历物料提前请购单 根据备注添加BOM到对应位置
// lidy20240710创建框架BOM中功能中的从提前请购组件BOM中抓取成分搭建进生成的框架BOM
//需要将抓取的物料明细在复制后增加注释信息BOM行属性数据来源bl_occ_zt2_wlsource写入“提前请购单”
for(int i = 0; i < children.length; i++) {
TCComponentBOMLine wlLine = (TCComponentBOMLine) children[i].getComponent();
TCComponentItem item = wlLine.getItem();
if(item.getType().equals("ZT2_MainMat")) {
AIFComponentContext[] children2 = wlLine.getChildren();
for(AIFComponentContext c2 : children2) {
TCComponentBOMLine wlLine2 = (TCComponentBOMLine) c2.getComponent();
String object_name = wlLine2.getProperty("ZT2_Remark");
String objName = wlLine2.getItem().getProperty("object_name");
System.out.println(object_name);
System.out.println(objName + "gg");
if(!object_name.equals("") && bomBeans.contains(new BomBean(object_name))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean(object_name)));
if(checkSource(bomBean.bomLine, wlLine2))
continue;
bomBean.bomLine.add(wlLine2, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}else if(object_name.equals("") && objName.contains("硅钢条料")) {
if(bomBeans.contains(new BomBean("硅钢片"))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean("硅钢片")));
if(checkSource(bomBean.bomLine, wlLine2))
continue;
bomBean.bomLine.add(wlLine2, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}
}else {
if(checkSource(newTopline, wlLine2))
continue;
TCComponentBOMLine add = newTopline.add(wlLine2, false);
add.setProperty("bl_occ_zt2_wlsource", "提前请购单");
System.out.println(add);
newTopline.save();
}
}
}else {
String object_name = wlLine.getProperty("ZT2_Remark");
System.out.println(object_name);
String objName = wlLine.getItem().getProperty("object_name");
if(!object_name.equals("") && bomBeans.contains(new BomBean(object_name))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean(object_name)));
if(checkSource(bomBean.bomLine, wlLine))
continue;
bomBean.bomLine.add(wlLine, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}else if(object_name.equals("") && objName.equals("硅钢条料")) {
if(bomBeans.contains(new BomBean("硅钢片"))) {
BomBean bomBean = bomBeans.get(bomBeans.indexOf(new BomBean("硅钢片")));
if(checkSource(bomBean.bomLine, wlLine))
continue;
bomBean.bomLine.add(wlLine, false).setProperty("bl_occ_zt2_wlsource", "提前请购单");
bomBean.bomLine.save();
}
}else {
if(checkSource(newTopline, wlLine))
continue;
TCComponentBOMLine add = newTopline.add(wlLine, false);
add.setProperty("bl_occ_zt2_wlsource", "提前请购单");
System.out.println(add);
newTopline.save();
}
}
}
window2.close();
newTopline.window().save();
}
changePrivilege(session, find);
}
window.close();
comp.setVisible(false);
return true;
}
private static void changePrivilege(TCSession session, TCComponent dataset) throws Exception {
KUtil.setByPass(true);
TCAccessControlService accessControlService = session.getTCAccessControlService();
TCComponentUser user = session.getUser();
accessControlService.grantPrivilege(dataset, user, new String[]{"WRITE","READ"});
// KUtil.setByPass(false);
}
@SuppressWarnings("deprecation")
private void updateKjBom(Map<String, TCComponentItem> findMap, Map<String, ExpandPSData[]> bomLineTreeNodeSOA, String uid) throws Exception {
// Auto-generated method stub
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(uid);
for(ExpandPSData expandPSData : expandPSDatas) {
TCComponentBOMLine bomLine = expandPSData.bomLine;
TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine;
String itemId = itemRevOfBOMLine.getProperty("item_id");
System.out.println("findMap===>" + findMap.toString());
System.out.println("itemId===>" + itemId.toString());
if(findMap.containsKey(itemId)) {
TCComponentItem tcItem = findMap.get(itemId);
System.out.println("tcItem===>" + tcItem.toString());
TCComponentItemRevision lastRev = tcItem.getLatestItemRevision();
bomLine.replace(tcItem, lastRev, null);
bomLine.save();
// bomLine.unlock();
}
updateKjBom(findMap, bomLineTreeNodeSOA, bomLine.getUid());//ExpandPSData[] expandPSDatas2 = bomLineTreeNodeSOA.get(bomLine.getUid());
}
}
@SuppressWarnings("deprecation")
private static void changeOwners(TCComponentItem item, TCComponentUser user) throws Exception {
TCComponent[] revs = item.getRelatedComponents("revision_list");
TCComponentItemRevision rev;
TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group");
TCComponent bom = null;
TCComponent[] datasets;
for (int i = 0, len = revs.length; i < len; i++) {
rev = (TCComponentItemRevision) revs[i];
bom = rev.getRelatedComponent("structure_revisions");
datasets = rev.getRelatedComponents("IMAN_specification");
for (int m = 0, len2 = datasets.length; m < len2; m++) {
datasets[m].lock();
datasets[m].changeOwner(user, group);
datasets[m].save();
datasets[m].unlock();
}
if (bom != null) {
bom.lock();
bom.changeOwner(user, group);
bom.save();
bom.unlock();
}
rev.lock();
rev.changeOwner(user, group);
rev.save();
rev.unlock();
}
bom = item.getRelatedComponent("bom_view_tags");
if (bom != null) {
bom.lock();
bom.changeOwner(user, group);
bom.save();
bom.unlock();
}
item.lock();
item.changeOwner(user, group);
item.save();
item.unlock();
}
private void sendToClass(String wsoPUID, String classID, String json) {
// AbstractAIFApplication app;
// app=AIFUtility.getCurrentApplication();
// TCSession session;
// session=(TCSession) app.getSession();
try {
TCPreferenceService preferenceService = session.getPreferenceService();
// String account=preferenceService.getStringValue("Autocode_PriverUser_ID");
String url = preferenceService.getStringValue("Autocode_SendClassServer_URL");
ServiceClient sc = new ServiceClient();
Options opts = new Options();
// url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";
EndpointReference end = new EndpointReference(url);
opts.setTo(end);
opts.setAction("SendToClass");
sc.setOptions(opts);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", "");
OMElement method = fac.createOMElement("SendToClass", omNs);
OMElement value = fac.createOMElement("wsoPuiid", omNs);
value.setText(wsoPUID);
OMElement value1 = fac.createOMElement("classID", omNs);
value1.setText(classID);
OMElement value2 = fac.createOMElement("JsonContainer", omNs);
// "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]"
value2.setText(json);
method.addChild(value);
method.addChild(value1);
method.addChild(value2);
OMElement res = sc.sendReceive(method);
res.getFirstElement().getText();
System.out.println(res.getFirstElement().getText());
} catch (Exception e) {
e.printStackTrace();
}
}
private void createId(TCComponentBOMLine pLine, Map<String, ExpandPSData[]> bomLineTreeNodeSOA,
StringBuilder builder, TCComponentItemType ccomponentitemtype,
Map<String, TCComponentItem> findMap, List<TCComponentBOMLine> useLines, int type) throws Exception {
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(pLine.getUid());
if(type != 0) {
copyLines.add(pLine);
}
for(ExpandPSData expandPSData : expandPSDatas) {
TCComponentBOMLine cLine = expandPSData.bomLine;
TCComponentItemRevision cRev = expandPSData.itemRevOfBOMLine;
if(cRev.getType().contains("ZT2_Design3D")) {
String item_id = cRev.getProperty("item_id");
String replaceAll = item_id.replaceAll(kjBs, projectDh);
/*if(type == 0) {
useLines.add(cLine);
oldkjIdMap.put(cRev, cLine.getItem());
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 0);
}else {
}*/
TCComponentItem[] finds = ccomponentitemtype.findItems(replaceAll);
if(finds != null && finds.length > 0) {
builder.append("当前ID已经存在:").append(replaceAll).append("");
findMap.put(item_id, finds[0]);
useLines.add(cLine);
oldkjIdMap.put(cRev, finds[0]);
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 0);
}else {
kjIdMap.put(cRev, replaceAll);
createId(cLine, bomLineTreeNodeSOA, builder, ccomponentitemtype, findMap, useLines, 1);
}
}else {
copyLines.add(cLine);
}
}
}
//批量复制
private void cloneOrUpdate(TCSession session, TCComponentBOMLine parentLine,
List<TCComponentBOMLine> bomLines, List<TCComponentBOMLine> useLines) {
com.teamcenter.services.rac.structuremanagement.StructureService service =
com.teamcenter.services.rac.structuremanagement.StructureService.getService(session);
// idMapAdd.clear();
CloneStructureInputInfo[] infos = new CloneStructureInputInfo[1];
infos[0] = new CloneStructureInputInfo();
// infos[0].bomline = puid;
infos[0].cadOptions = new String[] { "PartFamilyMaster" };
try {
infos[0].defaultFolder = session.getUser().getNewStuffFolder();
infos[0].cloneFlags = 2;
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureProjectInfo projectInfo
= new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureProjectInfo();
projectInfo.assign = false;
projectInfo.validate = false;
infos[0].projects = projectInfo;
TCComponentRevisionRule revisionRule = parentLine.window().getRevisionRule();
infos[0].revRule = revisionRule;
TCComponentItemRevision[] revs = new TCComponentItemRevision[] { parentLine.getItemRevision() };
infos[0].topItemRevs = revs;
System.out.println("Save class Partial bomLine -- " + bomLines.size());
List<CloneStructureSaveAsIn> saveList = new ArrayList<CloneStructureSaveAsIn>();
for(TCComponentBOMLine subLine : bomLines) {
// for(int i = 0; i < bomLines.size(); i++) {
// TCComponentBOMLine subLine = bomLines.get(i);
TCComponentItem item = subLine.getItem();
CloneStructureSaveAsIn dataMap = null;
if(item.getType().equals("ZT2_Design3D")) {
// subLine.replace
dataMap = getDataMap(subLine, 0, session);
}else {
dataMap = getDataMap(subLine, 1, session);
}
saveList.add(dataMap);
}
for(TCComponentBOMLine subLine : useLines) {
CloneStructureSaveAsIn dataMap = getDataMap(subLine, 1, session);
saveList.add(dataMap);
}
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureDefaultNaming naming =
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.CloneStructureDefaultNaming();
CloneStructureSaveAsIn[] array = saveList.toArray(new CloneStructureSaveAsIn[saveList.size()]);
infos[0].dataMap = array;
naming.autogen = true;
infos[0].defaultName = naming;
infos[0].topLines = new TCComponentBOMLine[] { parentLine };
// TCComponentBOMLine.get
// puid.getr
} catch (Exception e1) {
// Auto-generated catch block
e1.printStackTrace();
}
CloneStructureResponse cloneStructure = service.cloneStructure(infos);
// infos[0].
// cloneStructureExpandOrUpdate.serviceData;
if (cloneStructure.serviceData.sizeOfPartialErrors() > 0) {
for (int i = 0; i < cloneStructure.serviceData.sizeOfPartialErrors(); i++) {
System.out.println("Save class Partial Error -- " + cloneStructure.serviceData
.getPartialError(i).getMessages()[0]);
}
}
try {
System.out.println("Save class Partial Error -- " + cloneStructure.serviceData.sizeOfUpdatedObjects());
if(cloneStructure.serviceData.sizeOfUpdatedObjects()>0) {
TCComponent updatedObject = cloneStructure.serviceData.getUpdatedObject(0);
System.out.println(session.componentToString(updatedObject) + " >> " + updatedObject);
}
// for(int i = 0; i < cloneStructure.serviceData.sizeOfCreatedObjects(); i++) {
// TCComponent plainObject = cloneStructure.serviceData.getCreatedObject(i);
// System.out.println(session.componentToString(plainObject));
// }
// for(int i = 0; i < cloneStructure.serviceData.sizeOfPlainObjects(); i++) {
// TCComponent plainObject = cloneStructure.serviceData.getPlainObject(i);
// System.out.println(session.componentToString(plainObject));
// }
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
private CloneStructureSaveAsIn getDataMap(TCComponentBOMLine child, int type, TCSession session) throws Exception {
TCComponentItemRevision rev = child.getItemRevision();
CloneStructureSaveAsIn dataMap = new CloneStructureSaveAsIn();
Map<String, String[]> newItemRevinfo = new HashMap<>();
dataMap.cloneOperationType = type;
// dataMap.newItemRevinfo =
dataMap.origItemRevComp = rev;
newItemRevinfo.put("sequence_limit", new String[] { "3" });
newItemRevinfo.put("fnd0CheckoutOnSaveAs", new String[] { "false" });
newItemRevinfo.put("item_revision_id", new String[] { "" });
newItemRevinfo.put("sequence_id", new String[] { "1" });
newItemRevinfo.put("object_name", new String[] { rev.getStringProperty("object_name") });
if(type == 0) {
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData[] copys =
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData[1];
com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData copy =
new com.teamcenter.services.rac.structuremanagement._2014_10.Structure.DeepCopyData();
copy.attachedObject = rev.getItem();
copy.copyAction = "CopyAsObject";
copy.copyRelations = true;
copy.isRequired = true;
copy.isTargetPrimary = true;
copy.operationInputTypeName = "";
copy.propertyName = "items_tag";
copy.propertyType = "Reference";
Map<String, String[]> operationInputs = new HashMap<>();
operationInputs.put("fnd0CheckoutOnSaveAs", new String[] { "false" });
operationInputs.put("is_configuration_item", new String[] { "false" });
String zt2Unit = rev.getItem().getTCProperty("zt2_unit").getStringValue();
// rev.getItem().get("zt2_unit");
operationInputs.put("zt2_unit", new String[] { zt2Unit });
String newId = "";
try {
newId = kjIdMap.get(rev);
// newId
}catch(Exception e) {
e.printStackTrace();
}
operationInputs.put("item_id", new String[] { newId }); // 获取规则
copy.operationInputs = operationInputs;
copys[0] = copy;
dataMap.deepCopyDataOverride = copys;
}
dataMap.newItemRevinfo = newItemRevinfo;
return dataMap;
}
/**
* BOMBOMBOMBOMBOM
*
* @param parent
* @param target
* @return BOMtrue
* @throws Exception
*/
private boolean checkSource(TCComponentBOMLine parent, TCComponentBOMLine target) throws Exception {
String id = target.getProperty("bl_item_item_id");
for(AIFComponentContext c : parent.getChildren()) {
TCComponentBOMLine child = (TCComponentBOMLine) c.getComponent();
if(child.getProperty("bl_item_item_id").equals(id) && child.getProperty("bl_occ_zt2_wlsource").equals("提前请购单"))
return true;
}
return false;
}
private List<TCComponentItemRevision> getByqCCPFromProject(TCComponent targetComp, TCSession session) throws Exception {
List<TCComponentItemRevision> ccpRevList = new ArrayList<TCComponentItemRevision>();
TCComponent[] refs = targetComp.getRelatedComponents("IMAN_reference");
int len = refs == null ? 0 : refs.length;
TCComponentFolder projStart = null;
System.out.println("查找项目启动文件夹:" + targetComp);
for (int i = 0; i < len; i++) {
String cName = refs[i].getProperty("object_name");
System.out.println(">> 找到子对象:" + cName);
if ((refs[i] instanceof TCComponentFolder) && cName.contains("项目启动")) {
projStart = (TCComponentFolder) refs[i];
break;
}
}
if (projStart == null) {
return null;
}
TCComponentFolder ccpFolder = null;
AIFComponentContext[] cFolders = projStart.getChildren();
len = cFolders == null ? 0 : cFolders.length;
for (int i = 0; i < len; i++) {
InterfaceAIFComponent c = cFolders[i].getComponent();
String cName = c.getProperty("object_name");
if ((c instanceof TCComponentFolder) && cName.contains("产成品")) {
ccpFolder = (TCComponentFolder) c;
break;
}
}
String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_NO_KJTOPROD_M060", session);
AIFComponentContext[] ccpContexts = ccpFolder.getChildren();
for(AIFComponentContext context:ccpContexts) {
InterfaceAIFComponent component = context.getComponent();
String property = component.getProperty("object_name");
if(property.contains("变压器")) {
boolean flag = false;
for(String preference:preferences) {
if(property.contains(preference)) {
flag = true;
break;
}
}
if(component instanceof TCComponentItem && !flag) {
TCComponentItemRevision latestItemRevision = ((TCComponentItem)component).getLatestItemRevision();
ccpRevList.add(latestItemRevision);
}
}
}
return ccpRevList;
}
private List<TCComponentBOMLine> listBoms(TCComponentBOMLine bomLine) {
// List<String> bomLineNodes = list;
// 预定义BOM父子对map及ItemRev map
List<TCComponentBOMLine> listBoms = new ArrayList<>();
try {
// TCComponentItemRevision object = bomLine.getItemRevision();
// String object_type = object.getType();
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService
.getService(RACUIUtil.getTCSession());
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo();
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref();
levelInfo.parentBomLines = new TCComponentBOMLine[] { bomLine }; // 输入顶层BOMLine对象
levelInfo.excludeFilter = "None";
levelPref.expItemRev = false;
levelPref.info = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelationAndTypesFilter[0];
// 使用以下方法展开完整的BOM行
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = structureService
.expandPSAllLevels(levelInfo, levelPref);
if (levelResp.output.length > 0) {
// 将BOM构建成uid父子对关系
for (ExpandPSAllLevelsOutput data : levelResp.output) {
TCComponentBOMLine parentBomLine = (TCComponentBOMLine) data.parent.bomLine;
listBoms.add(parentBomLine);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return listBoms;
}
}

@ -11,37 +11,37 @@ public class BOMDifferenceBean {
/** /**
* *
*/ */
public TCComponentItemRevision oldRev; private TCComponentItemRevision oldRev;
/** /**
* *
*/ */
public TCComponentItemRevision newRev; private TCComponentItemRevision newRev;
/** /**
* *
*/ */
public TCComponentItemRevision oldPartRev; private TCComponentItemRevision oldPartRev;
/** /**
* *
*/ */
public TCComponentItemRevision newPartRev; private TCComponentItemRevision newPartRev;
/** /**
* *
*/ */
public TCComponentItemRevision parentPartRev; private TCComponentItemRevision parentPartRev;
/** /**
* *
*/ */
public String zt2_MaterialNo_Parent; private String zt2_MaterialNo_Parent;
/** /**
* *
*/ */
public String object_desc_Parent; private String object_desc_Parent;
/** /**
* *
*/ */
public String object_name_Parent; private String object_name_Parent;
public String getObject_name_Parent() { public String getObject_name_Parent() {
return object_name_Parent; return object_name_Parent;
@ -58,17 +58,21 @@ public class BOMDifferenceBean {
/** /**
* BOMLine * BOMLine
*/ */
TCComponentBOMLine oldBOMLine; private TCComponentBOMLine oldBOMLine;
/** /**
* BOMLine * BOMLine
*/ */
TCComponentBOMLine newBOMLine; private TCComponentBOMLine newBOMLine;
/** /**
* *
*/ */
private String rev_object_type; private String rev_object_type;
private TCComponentItemRevision rev; private TCComponentItemRevision rev;
/**
* ÊÇ·ñ¿ò¼Ü²ã
*/
private boolean isKj;
public TCComponentItem getItem() { public TCComponentItem getItem() {
return item; return item;
@ -276,6 +280,14 @@ public class BOMDifferenceBean {
this.rev = rev; this.rev = rev;
} }
public boolean isKj() {
return isKj;
}
public void setKj(boolean isKj) {
this.isKj = isKj;
}
public String getId() { public String getId() {
return (zt2_MaterialNo_Parent == null ? "" : zt2_MaterialNo_Parent) + "@" + (item == null ? "" : item); return (zt2_MaterialNo_Parent == null ? "" : zt2_MaterialNo_Parent) + "@" + (item == null ? "" : item);
} }

@ -323,8 +323,8 @@ public class CreateBOMDifferenceDialog extends AbstractAIFDialog {
if (pb != null) { if (pb != null) {
pb.disposeDialog(); pb.disposeDialog();
} }
MessageBox.post("½çÃæ³õʼ»¯Ê§°Ü:" + e.getMessage(), "", 2);
e.printStackTrace(); e.printStackTrace();
MessageBox.post("½çÃæ³õʼ»¯Ê§°Ü:" + e.getMessage(), "", 2);
disposeDialog(); disposeDialog();
} finally { } finally {
KUtil.setByPass(false); KUtil.setByPass(false);

@ -1,25 +1,23 @@
package com.connor.chint.sap2.dy.createBOMDifference; package com.connor.chint.sap2.dy.createBOMDifference;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsOutput;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
/** /**
* *
@ -28,197 +26,271 @@ import com.teamcenter.rac.kernel.TCSession;
* *
*/ */
public class CreateBOMDifference_GKController { public class CreateBOMDifference_GKController {
private static HashMap<String, ArrayList<Object[]>> oldStBomMap;
private static HashMap<String, ArrayList<Object[]>> newStBomMap;
private static HashMap<String, Boolean> shitiMap;
private static HashMap<String, ExpandPSData[]> bomMap;
public static final String SQL_Process = "select nvl(a.rprimary_objectu,'-1') from PIMANRELATION a " public static final String SQL_Process = "select nvl(a.rprimary_objectu,'-1') from PIMANRELATION a "
+ "left join PIMANTYPE b on a.rrelation_typeu=b.puid " + "left join PIMANTYPE b on a.rrelation_typeu=b.puid "
+ "left join PWORKSPACEOBJECT c on c.puid =a.rprimary_objectu " + "left join PWORKSPACEOBJECT c on c.puid =a.rprimary_objectu "
+ "where a.rsecondary_objectu =? and b.ptype_name='IMAN_METarget' and c.pobject_type='MEProcessRevision' "; + "where a.rsecondary_objectu =? and b.ptype_name='IMAN_METarget' and c.pobject_type='MEProcessRevision' ";
@SuppressWarnings("deprecation")
public static void getRevMap(TCSession session, TCComponent[] oldComponents, TCComponent[] newComponents, public static void getRevMap(TCSession session, TCComponent[] oldComponents, TCComponent[] newComponents,
List<BOMCompareBean> beans) throws TCException { List<BOMCompareBean> beans) throws Exception {
Map<TCComponentItem, BOMDifferenceBean> map_item_beans = new HashMap<>(); oldStBomMap = new HashMap<>();
newStBomMap = new HashMap<>();
shitiMap = new HashMap<>();
bomMap = new HashMap<>();
StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
// HashMap<TCComponentItem, BOMDifferenceBean> map_item_beans = new HashMap<>();
HashMap<String, BOMDifferenceBean> map_item_beans = new HashMap<>();
ArrayList<BOMDifferenceBean> kjBeans = new ArrayList<>();
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
throw new Exception("无法连接数据库,请检查首选项<database_tc>配置。");
}
for (TCComponent comp : oldComponents) { for (TCComponent comp : oldComponents) {
TCComponentItemRevision rev = (TCComponentItemRevision) comp; TCComponentItemRevision rev = (TCComponentItemRevision) comp;
TCComponentItem item = rev.getItem(); TCComponentItem item = rev.getItem();
BOMDifferenceBean bean = map_item_beans.get(item); String id = item.getProperty("item_id");
BOMDifferenceBean bean = map_item_beans.get(id);
if (bean == null) { if (bean == null) {
bean = new BOMDifferenceBean(); bean = new BOMDifferenceBean();
bean.setItem(item); bean.setItem(item);
bean.setOldRev(rev); bean.setOldRev(rev);
if(rev.getProperty("zt2_DrawingNo").equals("高开框架BOM")) {
bean.setKj(true);
kjBeans.add(bean);
}else if(isShiti(rev)) {
bean.setKj(false);
kjBeans.add(bean);
}
} }
map_item_beans.put(item, bean); map_item_beans.put(id, bean);
} }
for (TCComponent comp : newComponents) { for (TCComponent comp : newComponents) {
TCComponentItemRevision rev = (TCComponentItemRevision) comp; TCComponentItemRevision rev = (TCComponentItemRevision) comp;
TCComponentItem item = rev.getItem(); TCComponentItem item = rev.getItem();
BOMDifferenceBean bean = map_item_beans.get(item); String id = item.getProperty("item_id");
BOMDifferenceBean bean = map_item_beans.get(id);
if (bean == null) { if (bean == null) {
bean = new BOMDifferenceBean(); bean = new BOMDifferenceBean();
bean.setItem(item); bean.setItem(item);
bean.setNewRev(rev); bean.setNewRev(rev);
if(rev.getProperty("zt2_DrawingNo").equals("高开框架BOM")) {
bean.setKj(true);
kjBeans.add(bean);
}else if(isShiti(rev)) {
bean.setKj(false);
kjBeans.add(bean);
}
} else { } else {
bean.setNewRev(rev); bean.setNewRev(rev);
} }
map_item_beans.put(item, bean); map_item_beans.put(id, bean);
} }
try { if(kjBeans.size() == 0) {
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session); throw new Exception("关系下未找到框架层对象");
if (SqlUtil.getTCDataConnection(prefs) == null) { }
throw new Exception("无法连接数据库,请检查首选项<database_tc>配置。");
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
// win.lock();
TCComponentBOMWindow win2 = bomWinType.create(null);
// win2.lock();
List<BOMCompareBean> compares;
List<TCComponentItem> items = new ArrayList<>();
List<TCComponentItem> item_compares = new ArrayList<>();
HashMap<TCComponentItem, BOMDifferenceBean> map_childs = new HashMap<>();
HashMap<String, List<BOMCompareBean>> map_compares = new HashMap<>();
// for (Entry<String, BOMDifferenceBean> entry : map_item_beans.entrySet()) {
// BOMDifferenceBean bean = entry.getValue();
for(BOMDifferenceBean kjBean : kjBeans) {
TCComponentItemRevision oldKjRev = kjBean.getOldRev(), newKjRev = kjBean.getNewRev();
if(kjBean.isKj() && (oldKjRev == null || newKjRev == null)) {
throw new Exception("更改前后关系下框架层对象不匹配");
} }
TCComponentBOMLine oldKjLine = win.setWindowTopLine(oldKjRev.getItem(), oldKjRev, null, null);
TCComponentBOMLine newKjLine = win2.setWindowTopLine(newKjRev.getItem(), newKjRev, null, null);
getBomLineTreeNodeSOA(oldKjRev, structureService, bomWinType);
getBomLineTreeNodeSOA(newKjRev, structureService, bomWinType);
oldStBomMap.clear();
newStBomMap.clear();
//TODO recycleBom
System.out.println("recycleBom------" + oldKjLine + ">>" + newKjLine);
recycleBom(oldKjRev.toString(), oldKjRev.toString(), true, bomWinType, map_item_beans, 1.0, structureService);
System.out.println("oldBomMap------" + printBomMap(oldStBomMap));
recycleBom(newKjRev.toString(), newKjRev.toString(), false, bomWinType, map_item_beans, 1.0, structureService);
System.out.println("newBomMap------" + printBomMap(newStBomMap));
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentItem item = kjBean.getItem();
TCComponentBOMWindow win = bomWinType.create(null); System.out.println("框架------" + item + " old:" + kjBean.getOldRev() + "; new:" + kjBean.getNewRev());
win.lock();
TCComponentBOMWindow win2 = bomWinType.create(null);
win2.lock();
List<BOMCompareBean> compares;
List<TCComponentItem> items = new ArrayList<>();
List<TCComponentItem> item_compares = new ArrayList<>();
Map<TCComponentItem, BOMDifferenceBean> map_childs = new HashMap<>();
Map<TCComponentItem, List<BOMCompareBean>> map_compares = new HashMap<>();
for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_item_beans.entrySet()) { BOMDifferenceBean parentBean;
BOMDifferenceBean bean = entry.getValue(); if (map_childs.containsKey(item)) {
TCComponentItem item = entry.getKey(); parentBean = map_childs.get(item);
System.out.println("遍历------" + item + " old:" + bean.getOldRev() + "; new:" + bean.getNewRev()); parentBean.setOldBOMLine(oldKjLine);
if (item_compares.indexOf(item) != -1) { parentBean.setNewBOMLine(newKjLine);
System.out.println("已读取,跳过"); parentBean.setOldRev(oldKjRev);
continue; parentBean.setNewRev(newKjRev);
} } else {
System.out.println("未读取,遍历BOM---"); parentBean = new BOMDifferenceBean();
parentBean.setOldQuantity(1);
if (bean.getOldRev() != null && bean.getNewRev() != null) { parentBean.setNewQuantity(1);
win.setWindowTopLine(entry.getKey(), bean.getOldRev(), null, null); parentBean.setOldBOMLine(oldKjLine);
win2.setWindowTopLine(entry.getKey(), bean.getNewRev(), null, null); parentBean.setNewBOMLine(newKjLine);
win.refresh(); parentBean.setOldRev(oldKjRev);
win2.refresh(); parentBean.setNewRev(newKjRev);
String zt2_MaterialNo = "";
BOMDifferenceBean parentBean; String object_desc = "";
if (map_childs.containsKey(item)) { String object_name = "";
parentBean = map_childs.get(item); TCComponentItemRevision parentRev = null;
parentBean.setOldBOMLine(win.getTopBOMLine()); parentRev = SAPUtil.getSAPPart(parentBean.getNewBOMLine(), session);
parentBean.setNewBOMLine(win2.getTopBOMLine()); if (parentRev != null) {
} else { zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo");
parentBean = new BOMDifferenceBean(); object_desc = parentRev.getProperty("object_desc");
parentBean.setOldQuantity(1); object_name = parentRev.getProperty("object_name");
parentBean.setNewQuantity(1);
parentBean.setOldBOMLine(win.getTopBOMLine());
parentBean.setNewBOMLine(win2.getTopBOMLine());
String zt2_MaterialNo = "";
String object_desc = "";
String object_name = "";
TCComponentItemRevision parentRev = null;
parentRev = SAPUtil.getSAPPart(parentBean.getNewBOMLine(), session);
if (parentRev != null) {
zt2_MaterialNo = parentRev.getProperty("zt2_MaterialNo");
object_desc = parentRev.getProperty("object_desc");
object_name = parentRev.getProperty("object_name");
}
parentBean.setZt2_MaterialNo_Parent(zt2_MaterialNo);
parentBean.setObject_desc_Parent(object_desc);
parentBean.setObject_name_Parent(object_name);
parentBean.setParentPartRev(parentRev);
}
System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, false, item_compares, map_item_beans, map_childs, 0);
map_compares.put(item, compares);
// map_childs.remove(item);
items.add(item);
} }
System.out.println("比较结束"); parentBean.setZt2_MaterialNo_Parent(zt2_MaterialNo);
parentBean.setObject_desc_Parent(object_desc);
parentBean.setObject_name_Parent(object_name);
parentBean.setParentPartRev(parentRev);
} }
// System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, false, item_compares, map_item_beans, map_childs, 0);
map_compares.put(kjBean.getId(), compares);
// map_childs.remove(item);
items.add(item);
System.out.println("比较结束");
}
/*
List<TCComponentItem> keys = new ArrayList<>(map_childs.keySet());
BOMDifferenceBean bean2;
for (int i = 0, len = keys.size(); i < len; i++) {
TCComponentItem item = keys.get(i);
BOMDifferenceBean bean = map_childs.get(item);
bean2 = map_item_beans.get(item.getProperty("item_id"));
bean.setOldRev(bean2.getOldRev());
bean.setNewRev(bean2.getNewRev());
System.out.println("子项遍历------" + item + " old:" + bean.getOldRev() + "; new:" + bean.getNewRev());
if (bean.getOldRev() != null && bean.getNewRev() != null) {
win.setWindowTopLine(item, bean.getOldRev(), null, null);
win2.setWindowTopLine(item, bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
BOMDifferenceBean parentBean = map_childs.get(item);
parentBean.setOldBOMLine(win.getTopBOMLine());
parentBean.setNewBOMLine(win2.getTopBOMLine());
System.out.println("子项--------" + parentBean);
System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, true, item_compares, map_item_beans, map_childs, 0);
map_compares.put(item, compares);
List<TCComponentItem> keys = new ArrayList<>(map_childs.keySet()); items.add(item);
BOMDifferenceBean bean2;
for (int i = 0, len = keys.size(); i < len; i++) {
TCComponentItem item = keys.get(i);
BOMDifferenceBean bean = map_childs.get(item);
bean2 = map_item_beans.get(item);
bean.setOldRev(bean2.getOldRev());
bean.setNewRev(bean2.getNewRev());
System.out.println("子项遍历------" + item + " old:" + bean.getOldRev() + "; new:" + bean.getNewRev());
if (bean.getOldRev() != null && bean.getNewRev() != null) {
win.setWindowTopLine(item, bean.getOldRev(), null, null);
win2.setWindowTopLine(item, bean.getNewRev(), null, null);
win.refresh();
win2.refresh();
BOMDifferenceBean parentBean = map_childs.get(item);
parentBean.setOldBOMLine(win.getTopBOMLine());
parentBean.setNewBOMLine(win2.getTopBOMLine());
System.out.println("子项--------" + parentBean);
System.out.println("oldLine:" + win.getTopBOMLine()+"; newLine:" + win2.getTopBOMLine());
parentBean.setItem(item);
compares = new ArrayList<>();
bomCompare_M006(parentBean, session, parentBean.getOldQuantity(), parentBean.getNewQuantity(),
compares, true, true, item_compares, map_item_beans, map_childs, 0);
map_compares.put(item, compares);
items.add(item);
}
System.out.println("比较结束");
} }
System.out.println("读取变更----开始"); System.out.println("比较结束");
for (Entry<TCComponentItem, List<BOMCompareBean>> entry : map_compares.entrySet()) { }*/
System.out.println("变更对象:" + entry.getKey()); System.out.println("读取变更----开始");
compares = entry.getValue(); HashMap<String, Integer> idList = new HashMap<>();
if (compares != null) { ArrayList<String> parentList = new ArrayList<>();
for (int i = 0, len = compares.size(); i < len; i++) { for (String id : map_compares.keySet()) {
System.out.println(i + "-----" + compares.get(i)); // String id = entry.getKey();
System.out.println("变更对象:" + id);
// if(!id.startsWith("@"))
// continue;
compares = map_compares.get(id);
if (compares != null) {
for (int i = 0, len = compares.size(); i < len; i++) {
BOMCompareBean compare = compares.get(i);
System.out.println(i + "-----" + compare);
String cid = compare.getId();
if(idList.containsKey(cid)) {
if(!parentList.contains(compare.getParentId())) {
BOMCompareBean bean = beans.get(idList.get(cid));
bean.addNum_Old(compare.getNum_Old());
bean.addNum_New(compare.getNum_New());
parentList.add(compare.getParentId());
}
continue;
} }
beans.addAll(compares); parentList.add(compare.getParentId());
idList.put(cid, beans.size());
beans.add(compare);
} }
} }
System.out.println("读取变更----结束");
win.unlock();
win.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
} }
// for(int i = beans.size() - 1; i >= 0; i--) {
// BOMCompareBean bean = beans.get(i);
// if(bean.getNum_Old() != null && bean.getNum_New() != null) {
// if(bean.getNum_Old().equals(bean.getNum_New()))
// beans.remove(i);
// else if(!bean.getNum_Old().isEmpty() && !bean.getNum_New().isEmpty())
// bean.setChangeType("物料数量变更");
// }
// }
System.out.println("读取变更----结束");
win.unlock();
win.close();
// win2.unlock();
// win2.close();
} }
/** /**
* *
* *
* @param revType * @param revType
* @param rev * @param rev
* @param con * @param con
* @throws SQLException * @throws SQLException
*/ */
public static boolean isVirtual(TCComponentItemRevision rev) throws SQLException { public static boolean isShiti(TCComponentItemRevision rev) throws Exception {
/** /**
* , * ,
*/ */
ResultSet rs = SqlUtil.read(SQL_Process, new Object[] { rev.getUid() }); String uid = rev.getUid();
String puid = ""; if(shitiMap.containsKey(uid))
return shitiMap.get(uid);
ResultSet rs = SqlUtil.read(SQL_Process, new Object[] { uid });
// String puid = "";
if (rs.next()) { if (rs.next()) {
puid = rs.getString(1); // puid = rs.getString(1);
shitiMap.put(uid, true);
SqlUtil.free(); SqlUtil.free();
System.out.println(puid + "-----实体图纸:" + rev); // System.out.println(puid + "-----实体图纸:" + rev);
return true; return true;
} }
System.out.println(puid + "-----虚拟图纸:" + rev); // System.out.println(puid + "-----虚拟图纸:" + rev);
shitiMap.put(uid, false);
SqlUtil.free(); SqlUtil.free();
return false; return false;
} }
public static void bomCompare_M006(BOMDifferenceBean parentBean, TCSession session, double parent_quantity_old, public static void bomCompare_M006(BOMDifferenceBean parentBean, TCSession session, double parent_quantity_old,
double parent_quantity_new, List<BOMCompareBean> beans, boolean isAddVis, boolean isRepeat, double parent_quantity_new, List<BOMCompareBean> beans, boolean isAddVis, boolean isRepeat,
List<TCComponentItem> item_compares, Map<TCComponentItem, BOMDifferenceBean> map_item_beans, List<TCComponentItem> item_compares, HashMap<String, BOMDifferenceBean> map_item_beans,
Map<TCComponentItem, BOMDifferenceBean> map_childs, int level) throws TCException, SQLException { HashMap<TCComponentItem, BOMDifferenceBean> map_childs, int level) throws Exception {
if (level > 0 && map_item_beans.containsKey(parentBean.getItem())) { TCComponentItem patentItem = parentBean.getItem();
System.out.println("包含父子项-------:" + parentBean.getItem() + "||" + parentBean); /*String id = patentItem.getProperty("item_id");
if (level > 0 && map_item_beans.containsKey(id)) {
System.out.println("包含父子项-------:" + id + "||" + parentBean);
BOMDifferenceBean bomDifferenceBean = map_item_beans.get(parentBean.getItem()); BOMDifferenceBean bomDifferenceBean = map_item_beans.get(id);
double oldQuantity = bomDifferenceBean.getOldQuantity(); double oldQuantity = bomDifferenceBean.getOldQuantity();
double newQuantity = bomDifferenceBean.getNewQuantity(); double newQuantity = bomDifferenceBean.getNewQuantity();
System.out.println("已经存在?-------:" + newQuantity + "||" + oldQuantity); System.out.println("已经存在?-------:" + newQuantity + "||" + oldQuantity);
@ -229,60 +301,75 @@ public class CreateBOMDifference_GKController {
bomDifferenceBean.setOldQuantity(parentBean.getOldQuantity()+oldQuantity); bomDifferenceBean.setOldQuantity(parentBean.getOldQuantity()+oldQuantity);
bomDifferenceBean.setNewQuantity(parentBean.getNewQuantity()+newQuantity); bomDifferenceBean.setNewQuantity(parentBean.getNewQuantity()+newQuantity);
// } // }
map_item_beans.put(parentBean.getItem(), bomDifferenceBean); map_item_beans.put(id, bomDifferenceBean);
map_childs.put(parentBean.getItem(), parentBean); map_childs.put(parentBean.getItem(), parentBean);
return; return;
} }
*/
// if (item_compares.indexOf(parentBean.getItem()) != -1 && !isRepeat) { // if (item_compares.indexOf(parentBean.getItem()) != -1 && !isRepeat) {
// System.out.println("已添加过" + parentBean.getItem()); // System.out.println("已添加过" + parentBean.getItem());
// return; // return;
// } // }
System.out.println("未添加过:" + parentBean.getItem()); System.out.println("未添加过:" + patentItem);
item_compares.add(parentBean.getItem()); item_compares.add(patentItem);
TCComponentBOMLine parentLine_old = parentBean.getOldBOMLine(); // TCComponentBOMLine parentLine_old = parentBean.getOldBOMLine();
TCComponentBOMLine parentLine_new = parentBean.getNewBOMLine(); // TCComponentBOMLine parentLine_new = parentBean.getNewBOMLine();
TCComponentItemRevision parentLine_old = parentBean.getOldRev();
TCComponentItemRevision parentLine_new = parentBean.getNewRev();
System.out.println("比较:" + parentLine_old + "--" + parent_quantity_old + "||" + parentLine_new + "--" System.out.println("比较:" + parentLine_old + "--" + parent_quantity_old + "||" + parentLine_new + "--"
+ parent_quantity_new); + parent_quantity_new);
BOMDifferenceBean bean; BOMDifferenceBean bean;
Map<TCComponentItem, BOMDifferenceBean> map_child_beans = new HashMap<>(); HashMap<String, BOMDifferenceBean> map_child_beans = new HashMap<>();
TCComponentItemRevision oldPartRev = null; TCComponentItemRevision oldPartRev = null;
TCComponentItemRevision newPartRev = null; TCComponentItemRevision newPartRev = null;
// 物料数量 // 物料数量
String bl_quantity; // String bl_quantity;
double quantity; double quantity;
String rev_object_type; String rev_object_type;
if (parentLine_new != null) { if (parentLine_new != null) {
TCComponentItem item = null; TCComponentItem item = null;
TCComponentItemRevision rev = null; TCComponentItemRevision rev = null;
TCComponentBOMLine line; TCComponentBOMLine line;
AIFComponentContext[] childs_new = parentLine_new.getChildren(); // AIFComponentContext[] childs_new = parentLine_new.getChildren();
for (int i = 0, len = childs_new.length; i < len; i++) { // for (int i = 0, len = childs_new.length; i < len; i++) {
line = (TCComponentBOMLine) childs_new[i].getComponent(); String revS = parentLine_new.toString();
rev = line.getItemRevision(); if(newStBomMap.containsKey(revS)) {
item = rev.getItem(); for(Object[] c : newStBomMap.get(revS)) {
bean = map_child_beans.get(item); // line = (TCComponentBOMLine) childs_new[i].getComponent();
newPartRev = SAPUtil.getSAPPart(line, session); line = (TCComponentBOMLine) c[0];
if (newPartRev == null) { rev = (TCComponentItemRevision) c[1];
continue; // bom = (TCComponentBOMLine) c[2];
} item = rev.getItem();
bl_quantity = line.getProperty("bl_quantity"); String id = item.getProperty("item_id");
if (bl_quantity == null || bl_quantity.trim().length() == 0) { bean = map_child_beans.get(id);
bl_quantity = "1"; newPartRev = SAPUtil.getSAPPart(line, session);
} // System.out.println("newPartRev" + rev + "==" + line + ">>" + newPartRev);
quantity = Double.parseDouble(bl_quantity) * parent_quantity_new; if (newPartRev == null) {
if (bean == null) { continue;
bean = new BOMDifferenceBean(); }
bean.setItem(item); // bl_quantity = line.getProperty("bl_quantity");
rev_object_type = rev.getType(); // if (bl_quantity == null || bl_quantity.trim().length() == 0) {
bean.setRev_object_type(rev_object_type); // bl_quantity = "1";
bean.setNewPartRev(newPartRev); // }
// quantity = Double.parseDouble(bl_quantity) * parent_quantity_new;
quantity = (double) c[3];
// System.out.println(revS + "==>" + rev + "*" + quantity);
if (bean == null) {
bean = new BOMDifferenceBean();
bean.setItem(item);
rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type);
bean.setNewPartRev(newPartRev);
}
bean.setNewRev(rev);
// bean.setNewBOMLine(bom);
bean.addNewQuantity(quantity);
map_child_beans.put(id, bean);
} }
bean.setNewRev(rev); }else {
bean.setNewBOMLine(line); System.out.println("newBomMap未添加过:" + revS);
bean.addNewQuantity(quantity);
map_child_beans.put(item, bean);
} }
} }
@ -290,34 +377,47 @@ public class CreateBOMDifference_GKController {
TCComponentItem item = null; TCComponentItem item = null;
TCComponentItemRevision rev = null; TCComponentItemRevision rev = null;
TCComponentBOMLine line; TCComponentBOMLine line;
AIFComponentContext[] childs_old = parentLine_old.getChildren(); // ExpandPSData[] bom;
for (int i = 0, len = childs_old.length; i < len; i++) { // AIFComponentContext[] childs_old = parentLine_old.getChildren();
line = (TCComponentBOMLine) childs_old[i].getComponent(); // for (int i = 0, len = childs_old.length; i < len; i++) {
rev = line.getItemRevision(); String revS = parentLine_old.toString();
item = rev.getItem(); if(oldStBomMap.containsKey(revS)) {
bean = map_child_beans.get(item); for(Object[] c : oldStBomMap.get(revS)) {
oldPartRev = SAPUtil.getSAPPart(line, session); // line = (TCComponentBOMLine) childs_old[i].getComponent();
if (oldPartRev == null) { // rev = line.getItemRevision();
continue; line = (TCComponentBOMLine) c[0];
} rev = (TCComponentItemRevision) c[1];
bl_quantity = line.getProperty("bl_quantity"); // bom = (ExpandPSData[]) c[2];
if (bl_quantity == null || bl_quantity.trim().length() == 0) { item = rev.getItem();
bl_quantity = "1"; String id = item.getProperty("item_id");
} bean = map_child_beans.get(id);
oldPartRev = SAPUtil.getSAPPart(line, session);
quantity = Double.parseDouble(bl_quantity) * parent_quantity_old; // System.out.println("oldPartRev" + rev + "==" + line + ">>" + newPartRev);
if (oldPartRev == null) {
continue;
}
// bl_quantity = line.getProperty("bl_quantity");
// if (bl_quantity == null || bl_quantity.trim().length() == 0) {
// bl_quantity = "1";
// }
// quantity = Double.parseDouble(bl_quantity) * parent_quantity_old;
quantity = (double) c[3];
// System.out.println(revS + "==>" + rev + "*" + quantity);
if (bean == null) { if (bean == null) {
bean = new BOMDifferenceBean(); bean = new BOMDifferenceBean();
bean.setItem(item); bean.setItem(item);
rev_object_type = rev.getType(); rev_object_type = rev.getType();
bean.setRev_object_type(rev_object_type); bean.setRev_object_type(rev_object_type);
}
bean.setOldRev(rev);
// bean.setOldBOMLine(bom);
bean.setOldPartRev(oldPartRev);
bean.addOldQuantity(quantity);
map_child_beans.put(id, bean);
} }
bean.setOldRev(rev); }else {
bean.setOldBOMLine(line); System.out.println("oldBomMap未添加过:" + revS);
bean.setOldPartRev(oldPartRev);
bean.addOldQuantity(quantity);
map_child_beans.put(item, bean);
} }
} }
@ -344,8 +444,10 @@ public class CreateBOMDifference_GKController {
object_desc_Parent = parentBean.getObject_name_Parent(); object_desc_Parent = parentBean.getObject_name_Parent();
} }
for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_child_beans.entrySet()) { // for (Entry<TCComponentItem, BOMDifferenceBean> entry : map_child_beans.entrySet()) {
bean = entry.getValue(); // bean = entry.getValue();
for (String id : map_child_beans.keySet()) {
bean = map_child_beans.get(id);
oldPartRev = bean.getOldPartRev(); oldPartRev = bean.getOldPartRev();
newPartRev = bean.getNewPartRev(); newPartRev = bean.getNewPartRev();
System.out.println(bean.getItem() + " BOMDifferenceBean:" + bean); System.out.println(bean.getItem() + " BOMDifferenceBean:" + bean);
@ -361,19 +463,21 @@ public class CreateBOMDifference_GKController {
// 物料删除 若变更项不为虚拟项则记录 // 物料删除 若变更项不为虚拟项则记录
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) { if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getOldRev().getProperty("zt2_Source"); zt2_Source = bean.getOldRev().getProperty("zt2_Source");
if (bean.getOldBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) { // if (bean.getOldBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
// 到此为止,不继续展开 // 到此为止,不继续展开
compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent, compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo_Old, object_desc_Old, num_Old, "", "", ""); zt2_MaterialNo_Old, object_desc_Old, num_Old, "", "", "");
beans.add(compareBean); beans.add(compareBean);
} else if ("自制".equals(zt2_Source)) { } else if ("自制".equals(zt2_Source)) {
// 实体层 // 实体层
if (isVirtual(rev)) { if (isShiti(rev)) {
compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent, compareBean = new BOMCompareBean("物料删除", zt2_MaterialNo_Parent, object_desc_Parent,
zt2_MaterialNo_Old, object_desc_Old, num_Old, "", "", ""); zt2_MaterialNo_Old, object_desc_Old, num_Old, "", "", "");
beans.add(compareBean); beans.add(compareBean);
bomCompare_M006(bean, session, 1, 1, beans, false, isRepeat, item_compares, map_item_beans, //TODO 删除的实体件不显示子项删除
map_childs, level + 1); // bomCompare_M006(bean, session, 1, 1, beans, false, isRepeat, item_compares, map_item_beans,
// map_childs, level + 1);
} else { } else {
// 虚拟层 // 虚拟层
bean.setParentPartRev(oldPartRev); bean.setParentPartRev(oldPartRev);
@ -405,18 +509,20 @@ public class CreateBOMDifference_GKController {
System.out.println("**物料新增**:" + rev); System.out.println("**物料新增**:" + rev);
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) { if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getNewRev().getProperty("zt2_Source"); zt2_Source = bean.getNewRev().getProperty("zt2_Source");
if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) { // if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "", "", compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "", "",
zt2_MaterialNo_New, object_desc_New, num_New); zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean); beans.add(compareBean);
System.out.println(bean.getItem() + "--新增--" + compareBean); System.out.println(bean.getItem() + "--新增--" + compareBean);
} else if ("自制".equals(zt2_Source)) { } else if ("自制".equals(zt2_Source)) {
if (isVirtual(rev)) { if (isShiti(rev)) {
compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "", compareBean = new BOMCompareBean("物料新增", zt2_MaterialNo_Parent, object_desc_Parent, "", "",
"", zt2_MaterialNo_New, object_desc_New, num_New); "", zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean); beans.add(compareBean);
bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares, //TODO 新增的实体件不显示子项新增
map_item_beans, map_childs, level + 1); // bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
// map_item_beans, map_childs, level + 1);
} else { } else {
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_Parent); bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_Parent);
bean.setObject_desc_Parent(object_desc_Parent); bean.setObject_desc_Parent(object_desc_Parent);
@ -467,22 +573,24 @@ public class CreateBOMDifference_GKController {
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) { if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getNewRev().getProperty("zt2_Source"); zt2_Source = bean.getNewRev().getProperty("zt2_Source");
if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) { // if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
if (compareBean != null) { if (compareBean != null) {
System.out.println(bean.getItem() + "--数量变化新增(实)--" + compareBean); System.out.println(bean.getItem() + "--数量变化新增(实)--" + compareBean);
beans.add(compareBean); beans.add(compareBean);
} }
} else if ("自制".equals(zt2_Source)) { } else if ("自制".equals(zt2_Source)) {
// 实体层 // 实体层
if (isVirtual(rev)) { if (isShiti(rev)) {
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_New); bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_New);
bean.setObject_desc_Parent(object_desc_New); bean.setObject_desc_Parent(object_desc_New);
if (compareBean != null) { if (compareBean != null) {
System.out.println(bean.getItem() + "--数量变化新增(实)--" + compareBean); System.out.println(bean.getItem() + "--数量变化新增(实)--" + compareBean);
beans.add(compareBean); beans.add(compareBean);
} }
bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares, //TODO 实体件不显示子项数量变化
map_item_beans, map_childs, level + 1); // bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
// map_item_beans, map_childs, level + 1);
} else { } else {
if (compareBean != null && isAddVis) { if (compareBean != null && isAddVis) {
@ -523,18 +631,19 @@ public class CreateBOMDifference_GKController {
System.out.println("物料变更"); System.out.println("物料变更");
if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) { if ("ZT2_Design3DRevision".equals(bean.getRev_object_type())) {
zt2_Source = bean.getNewRev().getProperty("zt2_Source"); zt2_Source = bean.getNewRev().getProperty("zt2_Source");
if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) { // if (bean.getNewBOMLine().getChildrenCount() == 0 || "外购".equals(zt2_Source)) {
if (bomMap.get(rev.toString()).length == 0 || "外购".equals(zt2_Source)) {
if (compareBean != null) { if (compareBean != null) {
System.out.println(bean.getItem() + "--物料变更(实)--" + compareBean); System.out.println(bean.getItem() + "--物料变更(实)--" + compareBean);
beans.add(compareBean); beans.add(compareBean);
} }
} else if ("自制".equals(zt2_Source)) { } else if ("自制".equals(zt2_Source)) {
// 实体层 // 实体层
if (isVirtual(rev)) { if (isShiti(rev)) {
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_New); bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_New);
bean.setObject_desc_Parent(object_desc_New); bean.setObject_desc_Parent(object_desc_New);
bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares, // bomCompare_M006(bean, session, 1, 1, beans, isAddVis, isRepeat, item_compares,
map_item_beans, map_childs, level + 1); // map_item_beans, map_childs, level + 1);
} else { } else {
// 虚拟层 // 虚拟层
bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_Parent); bean.setZt2_MaterialNo_Parent(zt2_MaterialNo_Parent);
@ -553,5 +662,127 @@ public class CreateBOMDifference_GKController {
} }
} }
} }
/**
* BOMBOMMap
* @param parent BOM
* @param uid object_string//UID
* @param isOld or
* @param bomWinType BOM
* @param map_item_beans
* @param count
*/
private static void recycleBom(String parent, String uid, boolean isOld, TCComponentBOMWindowType bomWinType,
HashMap<String, BOMDifferenceBean> map_item_beans, Double count, StructureManagement structureService) throws Exception {
// if(isOld && oldBomMap.containsKey(uid) || !isOld && newBomMap.containsKey(uid))
// return;
// System.out.println("recycleBom:" + parent + "==" + parent.getChildren().length);
// for(AIFComponentContext c : parent.getChildren()) {
for(ExpandPSData data : bomMap.get(parent)) {
TCComponentBOMLine line = data.bomLine;//(TCComponentBOMLine) c.getComponent(), bom;
System.out.println("recycleBom:" + uid + "==" + parent + ">>" + line);
ExpandPSData[] bom = new ExpandPSData[0];
TCComponentItemRevision rev;
String id = data.itemRevOfBOMLine.getProperty("item_id");
if(map_item_beans.containsKey(id)) {
//由于BOM可能为非精确因此变更前后关系下的对象版本代替现有版本
if(isOld)
rev = map_item_beans.get(id).getOldRev();
else
rev = map_item_beans.get(id).getNewRev();
getBomLineTreeNodeSOA(rev, structureService, bomWinType);
bom = bomMap.get(rev.toString());
}else {
rev = data.itemRevOfBOMLine;
if(bomMap.containsKey(rev.toString()))
bom = bomMap.get(rev.toString());
}
boolean part = !rev.getType().equals("ZT2_Design3DRevision");
String bl_quantity = line.getProperty("bl_quantity");
Double qty = (bl_quantity.isEmpty() ? 1 : Double.parseDouble(bl_quantity)) * count;
if((part && bom.length == 0) || rev.getProperty("zt2_Source").equals("外购")) {
// System.out.println("bom:" + uid + "==" + bom);
//外购就是实体不用看工艺BOM也不需要展开处理
if(isOld) {
if(!oldStBomMap.containsKey(uid))
oldStBomMap.put(uid, new ArrayList<>());
oldStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
}else {
if(!newStBomMap.containsKey(uid))
newStBomMap.put(uid, new ArrayList<>());
newStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
}
}else if(!part && isShiti(rev)) {
if(isOld) {
if(!oldStBomMap.containsKey(uid))
oldStBomMap.put(uid, new ArrayList<>());
oldStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
// System.out.println("oldBomMap:" + uid + "==" + bom);
//如果图纸或物料的实体件只有变更后一个版本,则当前数据不需要作为变更差异父件,即不体现。
if(!map_item_beans.containsKey(id) || map_item_beans.get(id).getNewRev() != null)
recycleBom(rev.toString(), rev.toString(), isOld, bomWinType, map_item_beans, 1.0, structureService);
}else {
if(!newStBomMap.containsKey(uid))
newStBomMap.put(uid, new ArrayList<>());
newStBomMap.get(uid).add(new Object[] { line, rev, bom, qty });
// System.out.println("newBomMap:" + uid + "==" + bom);
//如果图纸或物料的实体件只有变更后一个版本,则当前数据不需要作为变更差异父件,即不体现。
if(!map_item_beans.containsKey(id) || map_item_beans.get(id).getOldRev() != null)
recycleBom(rev.toString(), rev.toString(), isOld, bomWinType, map_item_beans, 1.0, structureService);
}
}else {
// System.out.println("bom:" + uid + "==" + bom);
//虚拟BOM进行消层
recycleBom(rev.toString(), uid, isOld, bomWinType, map_item_beans, qty, structureService);
}
}
}
/**
* BomMap
* @param map BomMap
* @return BomMap
*/
private static String printBomMap(HashMap<String, ArrayList<Object[]>> map) {
StringBuilder str = new StringBuilder("");
for(String s : map.keySet()) {
str.append(s).append("=[");
for(Object[] bojs : map.get(s)) {
str.append(bojs[1]).append("*").append(bojs[3]).append(";");
}
str.append("]\n");
}
return str.toString();
}
/**
* SOABOMbomMapStructureManagement
* @param bomLine BOM
* @param structureService StructureManagement
*/
private static void getBomLineTreeNodeSOA(TCComponentItemRevision rev, StructureManagement structureService, TCComponentBOMWindowType bomWinType) throws Exception {
if(bomMap.containsKey(rev.toString()))
return;
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentBOMLine bomLine = win.setWindowTopLine(rev.getItem(), rev, null, null);
// 调用SOA方法批量展开BOM
// com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(RACUIUtil.getTCSession());
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo();
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref();
levelInfo.parentBomLines = new TCComponentBOMLine[] { bomLine }; //输入顶层BOMLine对象
levelInfo.excludeFilter = "None";//zt2_BOMMaterial
levelPref.expItemRev = false;
levelPref.info = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelationAndTypesFilter[0];
// levelPref.info[0].relationName = "";
//使用以下方法展开完整的BOM行
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = structureService.expandPSAllLevels(levelInfo, levelPref);
if (levelResp.output.length > 0) {
//将BOM构建成uid父子对关系
for (ExpandPSAllLevelsOutput data : levelResp.output) {
ExpandPSData[] children = data.children;
TCComponentItemRevision parentBomLine = data.parent.itemRevOfBOMLine;
bomMap.put(parentBomLine.toString(), children);
}
}else {
bomMap.put(rev.toString(), new ExpandPSData[0]);
}
win.close();
}
} }

@ -19,6 +19,7 @@ import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener; import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumnModel; import javax.swing.table.TableColumnModel;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog; import com.teamcenter.rac.aif.AbstractAIFDialog;
@ -27,6 +28,11 @@ import com.teamcenter.rac.util.MessageBox;
public class AProjectNoDialog extends AbstractAIFDialog { public class AProjectNoDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private AProjectNoController controller; private AProjectNoController controller;
private JButton assign; private JButton assign;
private JButton b_ok; private JButton b_ok;
@ -35,21 +41,21 @@ public class AProjectNoDialog extends AbstractAIFDialog {
public static final String[] HEADER = new String[] { "产品代号", "产品特征号", "年代号", "顺序号" }; public static final String[] HEADER = new String[] { "产品代号", "产品特征号", "年代号", "顺序号" };
public static final int[] HEADERWIDTH = new int[] { 180, 180, 180, 180 }; public static final int[] HEADERWIDTH = new int[] { 180, 180, 180, 180 };
private AbstractAIFApplication app; // private AbstractAIFApplication app;
private TCSession session; private TCSession session;
public AProjectNoDialog(AbstractAIFApplication app) { public AProjectNoDialog(AbstractAIFApplication app) {
super(false); super(false);
this.app = app; // this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
this.controller = new AProjectNoController(app, this); this.controller = new AProjectNoController(app, this);
} }
public AProjectNoDialog(Frame paramFrame, AbstractAIFApplication app) { public AProjectNoDialog(Frame paramFrame, AbstractAIFApplication app) {
// TODO Auto-generated constructor stub // Auto-generated constructor stub
super(paramFrame, false); super(paramFrame, false);
this.app = app; // this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
this.controller = new AProjectNoController(app, this); this.controller = new AProjectNoController(app, this);
} }
@ -107,7 +113,7 @@ public class AProjectNoDialog extends AbstractAIFDialog {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
try { try {
String cpdh = (String) tm_part.getValueAt(0, 0); String cpdh = (String) tm_part.getValueAt(0, 0);
String cptzz = (String) tm_part.getValueAt(0, 1); String cptzz = (String) tm_part.getValueAt(0, 1);
@ -140,7 +146,7 @@ public class AProjectNoDialog extends AbstractAIFDialog {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
try { try {
String flowNo = (String) tm_part.getValueAt(0, 3); String flowNo = (String) tm_part.getValueAt(0, 3);
String cpdh = (String) tm_part.getValueAt(0, 0); String cpdh = (String) tm_part.getValueAt(0, 0);
@ -174,7 +180,7 @@ public class AProjectNoDialog extends AbstractAIFDialog {
@Override @Override
public void tableChanged(TableModelEvent e) { public void tableChanged(TableModelEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
int col = e.getColumn(); int col = e.getColumn();
int row = e.getFirstRow(); int row = e.getFirstRow();
if (col < 2) { if (col < 2) {
@ -226,25 +232,33 @@ public class AProjectNoDialog extends AbstractAIFDialog {
for (int i = 0; i < colCnt; i++) { for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
} }
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_M006_PROJNO", session);
JComboBox<String> com = new JComboBox<String>(); JComboBox<String> com = new JComboBox<String>();
com.addItem(""); com.addItem("");
com.addItem("H"); for(String s : prefs[0].split(";")) {
com.addItem("CB"); com.addItem(s);
com.addItem("GW"); }
// com.addItem("H");
// com.addItem("CB");
// com.addItem("GW");
t_part.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(com)); t_part.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(com));
JComboBox<String> com2 = new JComboBox<String>(); JComboBox<String> com2 = new JComboBox<String>();
com2.addItem(""); com2.addItem("");
com2.addItem("G"); for(String s : prefs[1].split(";")) {
com2.addItem("F"); com2.addItem(s);
com2.addItem("E"); }
com2.addItem("D"); // com2.addItem("G");
String cpdhs[] = new String[] { "", "H", "CB", "GW" }; // com2.addItem("F");
String cptzhs[] = new String[] { "", "G", "F", "E", "D" }; // com2.addItem("E");
// com2.addItem("D");
// String cpdhs[] = new String[] { "", "H", "CB", "GW" };
// String cptzhs[] = new String[] { "", "G", "F", "E", "D" };
t_part.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(com2)); t_part.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(com2));
tm_part.addRow(new Vector<String>()); tm_part.addRow(new Vector<String>());
JScrollPane scroll = new JScrollPane(t_part); JScrollPane scroll = new JScrollPane(t_part);
scroll.setPreferredSize(new Dimension(452, 48)); scroll.setPreferredSize(new Dimension(452, 120));//48
@SuppressWarnings("deprecation")
int year = new Date().getYear(); int year = new Date().getYear();
year = year % 100; year = year % 100;
tm_part.setValueAt("" + year, 0, 2); tm_part.setValueAt("" + year, 0, 2);
@ -253,9 +267,9 @@ public class AProjectNoDialog extends AbstractAIFDialog {
return panel; return panel;
} }
private void setCompEnabled(boolean b) { // private void setCompEnabled(boolean b) {
assign.setEnabled(b); // assign.setEnabled(b);
b_ok.setEnabled(b); // b_ok.setEnabled(b);
} // }
} }

@ -1,9 +1,7 @@
package com.connor.chint.sap2.lijc; package com.connor.chint.sap2.lijc;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
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;
@ -14,28 +12,15 @@ import com.connor.chint.sap2.dy.createElectricalBOM.WebApiUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.ZYFactoryUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentSchedule; import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCPreferenceService; import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.bom._2008_06.StructureManagement.RemoveChildrenFromParentLineResponse;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2006_03.DataManagement.ReviseResponse;
import com.teamcenter.soa.client.model.ErrorStack;
public class GetDesignDsCommand extends KCommand{ public class GetDesignDsCommand extends KCommand{
@ -168,7 +153,7 @@ public class GetDesignDsCommand extends KCommand{
if (SqlUtil.getTCDataConnection(database_tc) == null) { if (SqlUtil.getTCDataConnection(database_tc) == null) {
throw new Exception("TC数据库连接失败"); throw new Exception("TC数据库连接失败");
} }
Map esbMap=new HashMap(); Map<String, Object> esbMap=new HashMap<>();
try { try {
System.out.println("selectSql==>"+selectSql); System.out.println("selectSql==>"+selectSql);
ResultSet rs = SqlUtil.read(selectSql); ResultSet rs = SqlUtil.read(selectSql);
@ -199,10 +184,15 @@ public class GetDesignDsCommand extends KCommand{
if (pathList.size()>0) { if (pathList.size()>0) {
TCComponent[] relatedComponents = xmzx_folder.getRelatedComponents("contents"); TCComponent[] relatedComponents = xmzx_folder.getRelatedComponents("contents");
TCComponentFolder tptz = null; TCComponentFolder tptz = null;
String folderName = "Í­ÅÅͼֽ";
if(actionInfo.equals("BOM")) {
//TODO lidy20240725
folderName = "Í­ÅÅÉè¼Æ";
}
for(TCComponent relatedComponent:relatedComponents) { for(TCComponent relatedComponent:relatedComponents) {
String cName = relatedComponent.getProperty("object_name"); String cName = relatedComponent.getProperty("object_name");
System.out.println(">> 找到子对象:" + cName); System.out.println(">> 找到子对象:" + cName);
if ((relatedComponent instanceof TCComponentFolder) && "Í­ÅÅͼֽ".contains(cName)) { if ((relatedComponent instanceof TCComponentFolder) && folderName.contains(cName)) {
tptz = (TCComponentFolder) relatedComponent; tptz = (TCComponentFolder) relatedComponent;
} }
} }
@ -224,15 +214,15 @@ public class GetDesignDsCommand extends KCommand{
esbMap.put("xmzx", replaceAll); esbMap.put("xmzx", replaceAll);
esbMap.put("project", projectUid); esbMap.put("project", projectUid);
esbMap.put("wbsno", project.getStringProperty("zt2_WBSNo")); esbMap.put("wbsno", project.getStringProperty("zt2_WBSNo"));
esbMap.put("path",pathList); esbMap.put("path", pathList);
String jsonString = JSON.toJSONString(esbMap); String jsonString = JSON.toJSONString(esbMap);
System.out.println("jsonString==>" + jsonString);
if(actionInfo.equals("BOM")) { if(actionInfo.equals("BOM")) {
WebApiUtil.httpSapRequest(values+"/connor/Clone/createBOM","POST", WebApiUtil.httpSapRequest(values + "/connor/Clone/createBOM", "POST",
jsonString,1); jsonString, 1);
}else { }else {
WebApiUtil.httpSapRequest(values+"/connor/Clone/createDesignDateset","POST", WebApiUtil.httpSapRequest(values + "/connor/Clone/createDesignDateset", "POST",
jsonString,1); jsonString, 1);
} }
}else { }else {

@ -10,10 +10,11 @@ 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.regex.Matcher;
import java.util.regex.Pattern;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.connor.chint.sap2.KCommand; import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.bean.ApplyCodeFactoryBean;
import com.connor.chint.sap2.sap_zy.CodeBean; import com.connor.chint.sap2.sap_zy.CodeBean;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
@ -31,7 +32,6 @@ import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentSchedule; import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException; 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 com.teamcenter.rac.util.MessageBox;
@ -133,7 +133,7 @@ public class SendProjectLcCommand extends KCommand {
} }
TCComponent[] allTasks = schedule.getAllTasks(); TCComponent[] allTasks = schedule.getAllTasks();
if(allTasks== null ||allTasks.length<2) { if(allTasks == null || allTasks.length < 2) {
MessageBox.post(schedule+"时间表下未找到任务,请检查数据","",MessageBox.INFORMATION); MessageBox.post(schedule+"时间表下未找到任务,请检查数据","",MessageBox.INFORMATION);
return; return;
} }
@ -144,7 +144,7 @@ public class SendProjectLcCommand extends KCommand {
tpsjTask = allTask; tpsjTask = allTask;
} }
} }
if(tpsjTask==null) { if(tpsjTask == null) {
MessageBox.post("时间表中没有找到名称为铜排设计的任务","提示",2); MessageBox.post("时间表中没有找到名称为铜排设计的任务","提示",2);
return; return;
} }
@ -153,18 +153,76 @@ public class SendProjectLcCommand extends KCommand {
String userId = user == null ? "" : user.getProperty("user_id"); String userId = user == null ? "" : user.getProperty("user_id");
String userName = user == null ? "" : user.getProperty("user_name"); String userName = user == null ? "" : user.getProperty("user_name");
Map<String,String> lcApplyMap = new HashMap<>(); Map<String, String> lcApplyMap = new HashMap<>();
//获取编码申请的规则 //获取编码申请的规则
String[] preferences = ChintPreferenceUtil.getPreferences("Chint_lcApplyCode", session); String[] preferences = ChintPreferenceUtil.getPreferences("Chint_lcApplyCode", session);
for(String preference:preferences) { for(String preference : preferences) {
String[] split = preference.split(":"); String[] split = preference.split(":");
String[] split2 = split[1].split(";"); String[] split2 = split[1].split(";");
for(String fac:split2) { for(String fac : split2) {
lcApplyMap.put(fac, split[0]); lcApplyMap.put(fac, split[0]);
} }
} }
//出厂编号的前缀进行匹配,得到方案号
Map<String, String> fahMap = new HashMap<>();
String prefs = ChintPreferenceUtil.getPreference("CHINT_FactoryNoTPBOM", session);
for(String pref : prefs.split(";")) {
String split = pref.substring(0, pref.indexOf(":"));
String fah = pref.substring(pref.indexOf("|") + 1);
String[] split2 = split.split("、");
for(String fac : split2) {
fahMap.put(fac, fah);
}
}
StringBuilder err = new StringBuilder("");
AIFComponentContext[] children = ccbh_folder.getChildren();
for(AIFComponentContext c : children) {//TODO ccbh
TCComponent ccbh = (TCComponent) c.getComponent();
System.out.println("ccbh:" + ccbh);
//出厂编号的前缀前缀取ID号第一个数字前的值与首选项CHINT_FactoryNoTPBOM里的值进行匹配得到方案号
String id = ccbh.getProperty("item_id");
Pattern pattern = Pattern.compile("[0-9]");
Matcher matcher = pattern.matcher(id);
int index = 0;
while (matcher.find()) {
index = matcher.start();
break;
}
String key = id.substring(0, index);
if(!fahMap.containsKey(key)) {
err.append(id).append("在首选项中未找到匹配的前缀\n");
continue;
}
//根据获取到的方案号去项目对象下“项目执行”下“铜排设计”文件夹获取所有的方案编码
//检查方案编码版本属性“zt2_MaterialNo”属性值截取“-”前面的值)进行匹配,匹配的上代表方案编码已创建
key = fahMap.get(key) + "-";
boolean check = true;
for(AIFComponentContext t : tpsj.getChildren()) {
TCComponentItemRevision fabm = ((TCComponentItem) t.getComponent()).getLatestItemRevision();
System.out.println("fabm:" + fabm);
String zt2_MaterialNo = fabm.getProperty("zt2_MaterialNo");
if(zt2_MaterialNo.startsWith(key)) {
check = false;
//检查方案编码对象版本下的关系文件夹中是否有“出厂编号”对象
if(KUtil.getPseudoFolder(fabm, "ZT2_FactoryNumber").getChildren().length == 0) {
System.out.println("未关联出厂编号");
if(!err.toString().contains(zt2_MaterialNo))
err.append("当前项目中铜排方案编码").append(zt2_MaterialNo).append("未关联出厂编号\n");
}
break;
}
}
if(check) {
err.append("当前项目").append(id).append("未创建铜排方案编码\n");
continue;
}
}
if(err.length() > 0) {
MessageBox.post(err.toString(), "提示", MessageBox.ERROR);
return;
}
Map esbMap=new HashMap(); Map<String, Object> esbMap = new HashMap<>();
String task_id = tpsjTask.getProperty("item_id"); String task_id = tpsjTask.getProperty("item_id");
esbMap.put("taskid",task_id); esbMap.put("taskid",task_id);
sql1[0] = task_id; sql1[0] = task_id;
@ -207,18 +265,17 @@ public class SendProjectLcCommand extends KCommand {
}else { }else {
esbMap.put("startdate",""); esbMap.put("startdate","");
} }
List<String[]> strsList = new ArrayList<>(); // List<String[]> strsList = new ArrayList<>();
List<Map> factoryNos = new ArrayList<Map>(); List<Map<String, String>> factoryNos = new ArrayList<>();
List<String> factorys_list = new ArrayList<>(); List<String> factorys_list = new ArrayList<>();
List<String> cpbm_list = new ArrayList<>(); List<String> cpbm_list = new ArrayList<>();
AIFComponentContext[] children = ccbh_folder.getChildren();
int lsh = 0; int lsh = 0;
int cno = 1; int cno = 1;
apply_lists.clear(); apply_lists.clear();
// Map<String,Integer> codeNum = new HashMap<>(); // Map<String,Integer> codeNum = new HashMap<>();
for(AIFComponentContext child : children) { for(AIFComponentContext child : children) {
Map facCpMap = new HashMap<>(); Map<String, String> facCpMap = new HashMap<>();
TCComponent ccbhTarget = (TCComponent) child.getComponent(); TCComponent ccbhTarget = (TCComponent) child.getComponent();
//查询出厂编号的引用,判断是否有铜排单元 //查询出厂编号的引用,判断是否有铜排单元
AIFComponentContext[] contexts22 = ccbhTarget.whereReferencedByTypeRelation( AIFComponentContext[] contexts22 = ccbhTarget.whereReferencedByTypeRelation(
@ -227,7 +284,7 @@ public class SendProjectLcCommand extends KCommand {
Boolean hasFabm = false; Boolean hasFabm = false;
List<TCComponentItemRevision> components = new ArrayList<>(); List<TCComponentItemRevision> components = new ArrayList<>();
String id = ""; String id = "";
for(int t=0;t<contexts22.length;t++) { for(int t = 0; t < contexts22.length; t++) {
TCComponentItemRevision component = (TCComponentItemRevision) contexts22[t].getComponent(); TCComponentItemRevision component = (TCComponentItemRevision) contexts22[t].getComponent();
if(tpsjList.contains(component)) { if(tpsjList.contains(component)) {
hasFabm = true; hasFabm = true;
@ -237,22 +294,22 @@ public class SendProjectLcCommand extends KCommand {
} }
if(!hasFabm) { if(!hasFabm) {
Boolean flag = false; Boolean flag = false;
System.out.println("lcApplyMap===>"+lcApplyMap.toString()+"ccbhId==>"+ccbhId); System.out.println("lcApplyMap===>" + lcApplyMap.toString() + "ccbhId==>" + ccbhId);
//编码申请铜排单元 //编码申请铜排单元
for(String fac : lcApplyMap.keySet()) { for(String fac : lcApplyMap.keySet()) {
if(ccbhId.contains(fac)) { if(ccbhId.contains(fac)) {
flag = true; flag = true;
if(apply_lists.size()==0) { if(apply_lists.size() == 0) {
checkTargets(lcApplyMap.get(fac),zt2_WBSNo,session); checkTargets(lcApplyMap.get(fac), zt2_WBSNo, session);
} }
if(apply_lists.size()>0) { if(apply_lists.size( )> 0) {
id = applyPart(apply_lists.get(lsh),session,zt2_WBSNo,tpsj,ccbhTarget); id = applyPart(apply_lists.get(lsh), session, zt2_WBSNo, tpsj, ccbhTarget);
} }
lsh = lsh+1; lsh = lsh + 1;
} }
} }
if(!flag) { if(!flag) {
MessageBox.post("出厂编号"+ccbhId+"在首选项Chint_lcApplyCode中未配置请检查","提示",2); MessageBox.post("出厂编号" + ccbhId + "在首选项Chint_lcApplyCode中未配置请检查","提示",2);
return; return;
} }
} }
@ -410,6 +467,7 @@ public class SendProjectLcCommand extends KCommand {
} }
} }
// 新的方案编码申请 // 新的方案编码申请
@SuppressWarnings("deprecation")
public String applyPart(CodeBean bean,TCSession session,String wbsNo,TCComponentFolder tpsj,TCComponent ccbhTarget) public String applyPart(CodeBean bean,TCSession session,String wbsNo,TCComponentFolder tpsj,TCComponent ccbhTarget)
throws TCException { throws TCException {
@ -442,10 +500,10 @@ public class SendProjectLcCommand extends KCommand {
rev.unlock(); rev.unlock();
item.unlock(); item.unlock();
bean.setRev(rev); bean.setRev(rev);
TCComponentUser user = session.getUser(); // TCComponentUser user = session.getUser();
tpsj.add("contents", item); tpsj.add("contents", item);
//addChildToCcp(rev,bean); //addChildToCcp(rev,bean);
TCComponent target = (TCComponent) app.getTargetComponent(); // TCComponent target = (TCComponent) app.getTargetComponent();
rev.add("ZT2_FactoryNumber", ccbhTarget); rev.add("ZT2_FactoryNumber", ccbhTarget);
// //
return zt2_MaterialNo; return zt2_MaterialNo;

@ -134,6 +134,9 @@ public class SearchMaterialDialog extends AbstractAIFDialog {
stopEd(); stopEd();
controller.doSearch(); controller.doSearch();
pb.disposeDialog(); pb.disposeDialog();
if(table.getRowCount() == 0) {
MessageBox.post(SearchMaterialDialog.this, "查询不到数据", "", MessageBox.INFORMATION);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
pb.disposeDialog(); pb.disposeDialog();

@ -0,0 +1,115 @@
package com.connor.chint.sap2.materialno;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class FactoryChooseDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private boolean update;
public FactoryChooseDialog(AbstractAIFApplication app, TCSession session, String groupID) {
super(true);
try {
String[] database = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(database) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
String user = session.getUser().getUserId();
update = false;
String sql = "select \"factory\" from CHINT_MATERIAL_APPLY_RULE where \"userid\"='" + user + "'";
System.out.println("sql:\n" + sql);
ResultSet rs = SqlUtil.read(sql);
String defaultGroup = "";
if(rs.next()) {
defaultGroup = rs.getString(1);
update = true;
}
String[] applys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_LIST", session);
JComboBox<String> j_Group = new JComboBox<>();
j_Group.setSize(new Dimension(150, 30));
j_Group.setPreferredSize(new Dimension(130, 30));
j_Group.addItem("");
for(String s : applys) {
j_Group.addItem(s);
}
j_Group.setSelectedItem(defaultGroup);
JButton okBtn = new JButton("确定");
okBtn.setSize(new Dimension(100, 30));
okBtn.setPreferredSize(new Dimension(90, 30));
okBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String groupID = j_Group.getSelectedItem().toString();
if(groupID.isEmpty()) {
MessageBox.post(FactoryChooseDialog.this, "请选择组织", "", MessageBox.WARNING);
return;
}
String sql = "insert into CHINT_MATERIAL_APPLY_RULE values ('" + user + "','" + groupID + "')";
if(update)
sql = "update CHINT_MATERIAL_APPLY_RULE set \"factory\"='" + groupID + "' where \"userid\"='" + user + "'";
System.out.println("sql:\n" + sql);
SqlUtil.write(sql);
SqlUtil.freeAll();
groupID = groupID.substring(0, groupID.indexOf(":"));
System.out.println("groupID:" + groupID);
//TODO
// new Thread(new MaterialNoDialog(app, session, groupID)).start();
dispose();
}
});
JButton cancelBtn = new JButton("取消");
cancelBtn.setSize(new Dimension(100, 30));
cancelBtn.setPreferredSize(new Dimension(90, 30));
cancelBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
SqlUtil.freeAll();
dispose();
}
});
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.add(new JLabel("请选择组织:"));
panel.add(j_Group);
JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
btnPanel.add(okBtn);
btnPanel.add(cancelBtn);
this.setPreferredSize(new Dimension(500, 300));
this.setMinimumSize(new Dimension(400, 200));
this.setLayout(new BorderLayout());
this.add(BorderLayout.CENTER, panel);
this.add(BorderLayout.SOUTH, btnPanel);
setDefaultLookAndFeelDecorated(true);
Dimension screen = getToolkit().getScreenSize();
setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
this.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
MessageBox.post("错误:" + e, "", MessageBox.ERROR);
}
}
}

@ -773,6 +773,34 @@ public class MaterialNoDialog extends AbstractAIFDialog {
data.element("GoodsUsed", "3"); data.element("GoodsUsed", "3");
break; break;
} }
// if(true)
//TODO 先组织数据,创建对象,写入数据库,调接口,判断是否保留物料和数据库
System.out.println("开始创建物料");
TCComponentItemRevision rev = createMaterial(goodsName, unitCode, companyCode, spec, teRe, uom,
t_pmcp.getCode());
System.out.println("创建物料结束:" + rev);
uid = rev.getUid();
TXTUtil.writeTXT(txtPath, "申请物料[CODE=" + code + ";PUID[" + uid + "]");
Object params[] = new Object[15];
params[0] = code;
params[1] = uid;
params[2] = t_pmcp.getCode();
params[3] = goodsCode;
params[4] = goodsName;
params[5] = unitCode;
params[6] = companyCode;
params[7] = bpNo;
params[8] = spec;
params[9] = teRe;
params[10] = state;
params[11] = user;
params[12] = time;
params[13] = condition;
params[14] = "";
checkData(params[0], params[1]);
System.out.println("执行的sql语句:" + sql + "\n" + Arrays.toString(params));
SqlUtil.write(sql, params);
JSONArray datas = new JSONArray(); JSONArray datas = new JSONArray();
datas.add(data); datas.add(data);
@ -789,36 +817,18 @@ public class MaterialNoDialog extends AbstractAIFDialog {
TXTUtil.writeTXT(txtPath, "Json:" + obj.toString()); TXTUtil.writeTXT(txtPath, "Json:" + obj.toString());
TXTUtil.writeTXT(txtPath, "返回结果:" + req); TXTUtil.writeTXT(txtPath, "返回结果:" + req);
// if(true) if (req.indexOf(state1) == -1) {
if (req.indexOf(state1) != -1) { System.out.println("删除对象:" + rev.getItem());
rev.getItem().delete();
//rev.delete();
String delete = "delete from chint_material where \"Code\"='" + code + "'";
SqlUtil.delete(delete);
System.out.println("删除记录结束:" + delete);
MessageBox.post("物料申请失败,提示:" + req, "", MessageBox.INFORMATION);
}else {
System.out.println("更新记录"); System.out.println("更新记录");
// TCComponentItemRevision partRev = null; // TCComponentItemRevision partRev = null;
System.out.println("开始创建物料");
TCComponentItemRevision rev = createMaterial(goodsName, unitCode, companyCode, spec, teRe, uom,
t_pmcp.getCode());
uid = rev.getUid();
TXTUtil.writeTXT(txtPath, "申请物料[CODE=" + code + ";PUID[" + uid + "]");
System.out.println("创建物料结束");
Object params[] = new Object[15];
params[0] = code;
params[1] = uid;
params[2] = t_pmcp.getCode();
params[3] = goodsCode;
params[4] = goodsName;
params[5] = unitCode;
params[6] = companyCode;
params[7] = bpNo;
params[8] = spec;
params[9] = teRe;
params[10] = state;
params[11] = user;
params[12] = time;
params[13] = condition;
params[14] = "";
//TODO
checkData(params[0], params[1]);
System.out.println("执行的sql语句:" + sql + "\n" + Arrays.toString(params));
SqlUtil.write(sql, params);
checkData(params[0], params[1]); checkData(params[0], params[1]);
newStuff.add("contents", rev.getItem()); newStuff.add("contents", rev.getItem());
if (!KUtil.isEmpty(design_ID)) { if (!KUtil.isEmpty(design_ID)) {
@ -927,10 +937,6 @@ public class MaterialNoDialog extends AbstractAIFDialog {
if(!userId.equals("")) { if(!userId.equals("")) {
sendMsg(build.toString(),userId); sendMsg(build.toString(),userId);
} }
} else {
MessageBox.post("物料申请失败,提示:" + req, "", MessageBox.INFORMATION);
System.out.println("删除记录");
System.out.println("删除记录结束");
} }
} }
@ -1153,6 +1159,34 @@ public class MaterialNoDialog extends AbstractAIFDialog {
break; break;
} }
//TODO 先组织数据,创建对象,写入数据库,调接口,判断是否保留物料和数据库
TCComponentItemRevision parent = null;
System.out.println("开始创建物料");
parent = createMaterial(goodsName, unitCode, companyCode, spec, teRe, uom, t_pmcp.getCode());
newStuff.add("contents", parent.getItem());
uid = parent.getUid();
TXTUtil.writeTXT(txtPath, "申请物料[CODE=" + code + ";PUID[" + uid + "]");
System.out.println("创建物料结束");
Object params[] = new Object[15];
params[0] = code;
params[1] = uid;
params[2] = t_pmcp.getCode();
params[3] = goodsCode;
params[4] = goodsName;
params[5] = unitCode;
params[6] = companyCode;
params[7] = bpNo;
params[8] = spec;
params[9] = teRe;
params[10] = state;
params[11] = user;
params[12] = time;
params[13] = condition;
params[14] = "";
System.out.println("执行的sql语句:" + sql);
SqlUtil.write(sql, params);
System.out.println("更新结束");
JSONArray datas = new JSONArray(); JSONArray datas = new JSONArray();
datas.add(data); datas.add(data);
System.out.println("feature:" + feature); System.out.println("feature:" + feature);
@ -1169,41 +1203,18 @@ public class MaterialNoDialog extends AbstractAIFDialog {
// String sql2 = "delete from chint_material where \"Code\"=?"; // String sql2 = "delete from chint_material where \"Code\"=?";
String state1 = "\"State\":\"1\""; String state1 = "\"State\":\"1\"";
// String state2 = "\"State\":\"-1\""; // String state2 = "\"State\":\"-1\"";
TCComponentItemRevision parent = null;
TCComponentItemRevision child = null;
TXTUtil.writeTXT(txtPath, "Json:" + obj.toString()); TXTUtil.writeTXT(txtPath, "Json:" + obj.toString());
TXTUtil.writeTXT(txtPath, "返回结果:" + req); TXTUtil.writeTXT(txtPath, "返回结果:" + req);
if (req.indexOf(state1) != -1) { if (req.indexOf(state1) != -1) {
System.out.println("更新记录"); System.out.println("更新记录");
// TCComponentItemRevision partRev = null; // TCComponentItemRevision partRev = null;
System.out.println("开始创建物料");
parent = createMaterial(goodsName, unitCode, companyCode, spec, teRe, uom, t_pmcp.getCode());
newStuff.add("contents", parent.getItem());
uid = parent.getUid();
TXTUtil.writeTXT(txtPath, "申请物料[CODE=" + code + ";PUID[" + uid + "]");
System.out.println("创建物料结束");
Object params[] = new Object[15];
params[0] = code;
params[1] = uid;
params[2] = t_pmcp.getCode();
params[3] = goodsCode;
params[4] = goodsName;
params[5] = unitCode;
params[6] = companyCode;
params[7] = bpNo;
params[8] = spec;
params[9] = teRe;
params[10] = state;
params[11] = user;
params[12] = time;
params[13] = condition;
params[14] = "";
System.out.println("执行的sql语句:" + sql);
SqlUtil.write(sql, params);
System.out.println("更新结束");
} else { } else {
System.out.println("删除记录"); System.out.println("删除记录:" + parent.getItem());
System.out.println("删除记录结束"); parent.getItem().delete();
// parent.delete();
String delete = "delete from chint_material where \"Code\"='" + code + "'";
SqlUtil.delete(delete);
System.out.println("删除记录结束:" + delete);
MessageBox.post("物料申请失败,提示:" + req, "", MessageBox.INFORMATION); MessageBox.post("物料申请失败,提示:" + req, "", MessageBox.INFORMATION);
return; return;
@ -1233,6 +1244,33 @@ public class MaterialNoDialog extends AbstractAIFDialog {
datas2.add(data2); datas2.add(data2);
code = KUtil.getCode(); code = KUtil.getCode();
//TODO 先组织数据,创建对象,写入数据库,调接口,判断是否保留物料和数据库
TCComponentItemRevision child = null;
System.out.println("开始创建物料");
child = createMaterial(goodsName, unitCode, companyCode, spec, teRe2, uom, t_pmcp.getCode());
newStuff.add("contents", child.getItem());
uid = child.getUid();
TXTUtil.writeTXT(txtPath, "申请物料[CODE=" + code + ";PUID[" + uid + "]");
System.out.println("创建物料结束");
params = new Object[15];
params[0] = code;
params[1] = uid;
params[2] = t_pmcp.getCode();
params[3] = goodsCode;
params[4] = goodsName;
params[5] = unitCode;
params[6] = companyCode;
params[7] = bpNo;
params[8] = spec;
params[9] = teRe2;
params[10] = state;
params[11] = user;
params[12] = time;
params[13] = condition;
params[14] = "";
System.out.println("执行的sql语句:" + sql);
SqlUtil.write(sql, params);
JSONObject obj2 = new JSONObject(); JSONObject obj2 = new JSONObject();
obj2.element("Code", code); obj2.element("Code", code);
obj2.element("Data", datas2); obj2.element("Data", datas2);
@ -1245,33 +1283,15 @@ public class MaterialNoDialog extends AbstractAIFDialog {
if (req.indexOf(state1) != -1) { if (req.indexOf(state1) != -1) {
System.out.println("更新记录"); System.out.println("更新记录");
// TCComponentItemRevision partRev = null; // TCComponentItemRevision partRev = null;
System.out.println("开始创建物料");
child = createMaterial(goodsName, unitCode, companyCode, spec, teRe2, uom, t_pmcp.getCode());
newStuff.add("contents", child.getItem());
uid = child.getUid();
TXTUtil.writeTXT(txtPath, "申请物料[CODE=" + code + ";PUID[" + uid + "]");
System.out.println("创建物料结束");
Object params[] = new Object[15];
params[0] = code;
params[1] = uid;
params[2] = t_pmcp.getCode();
params[3] = goodsCode;
params[4] = goodsName;
params[5] = unitCode;
params[6] = companyCode;
params[7] = bpNo;
params[8] = spec;
params[9] = teRe2;
params[10] = state;
params[11] = user;
params[12] = time;
params[13] = condition;
params[14] = "";
System.out.println("执行的sql语句:" + sql);
SqlUtil.write(sql, params);
System.out.println("更新结束"); System.out.println("更新结束");
} else { } else {
System.out.println("删除记录:" + child.getItem());
child.getItem().delete();
// child.delete();
String delete = "delete from chint_material where \"Code\"='" + code + "'";
SqlUtil.delete(delete);
System.out.println("删除记录结束:" + delete);
MessageBox.post("子件申请失败,提示:" + req, "", MessageBox.INFORMATION); MessageBox.post("子件申请失败,提示:" + req, "", MessageBox.INFORMATION);
return; return;
} }

@ -505,7 +505,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
SelfMPartBean bean = self_lists.get(i); SelfMPartBean bean = self_lists.get(i);
String spec = bean.getSpec(); String spec = bean.getSpec();
System.out.println("===============开始新建物料==============="); System.out.println("===============开始新建物料===============");
CreateIn createMaterialYH = createMaterialYH(bean, groupID, spec, m_code); //groupID bean.getSpec(); m_code CreateIn createMaterialYH = createMaterialYH(bean, groupID, spec, m_code); //groupID bean.getSpec(); m_code TODO
if(createMaterialYH!=null) { if(createMaterialYH!=null) {
cIList.add(createMaterialYH); cIList.add(createMaterialYH);
} }

@ -19,7 +19,7 @@ public class BYProcBean {
private int index; private int index;
private TCComponentItemRevision cpgy; private TCComponentItemRevision cpgy;
private TCComponentItemRevision tlgx; private TCComponentItemRevision tlgx;
private String class_Code; // private String class_Code;
private TCComponentItemRevision cptlgx; private TCComponentItemRevision cptlgx;
private boolean isFeeding; private boolean isFeeding;
private List<TCComponentItemRevision> meLists = new ArrayList<TCComponentItemRevision>(); private List<TCComponentItemRevision> meLists = new ArrayList<TCComponentItemRevision>();

@ -670,6 +670,7 @@ public class CreateProcBYQDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
System.out.println("btn_expandAll start");
ProgressBar pb = new ProgressBar(CreateProcBYQDialog.this, new Dimension(350, 50)); ProgressBar pb = new ProgressBar(CreateProcBYQDialog.this, new Dimension(350, 50));
try { try {
if (SqlUtil2.getTCConnection() == null) { if (SqlUtil2.getTCConnection() == null) {

@ -65,6 +65,9 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
// 产品类型 // 产品类型
private JLabel labelProducttype; private JLabel labelProducttype;
private JComboBox<ComboItem> cbbProducttype; private JComboBox<ComboItem> cbbProducttype;
// µçѹµÈ¼¶
private JLabel labelVoltageClasses;
private JComboBox<ComboItem> cbbVoltageClasses;
// 产品型号 // 产品型号
private JLabel labelProductxh; private JLabel labelProductxh;
private JComboBox<ComboItem> cbbProductxh; private JComboBox<ComboItem> cbbProductxh;
@ -85,7 +88,7 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
protected void initGUI() { protected void initGUI() {
this.setTitle("工时计算"); this.setTitle("工时计算");
// 设置显示大小 // 设置显示大小
Dimension dimension = new Dimension(400, 330); Dimension dimension = new Dimension(400, 380);
this.setPreferredSize(dimension); this.setPreferredSize(dimension);
this.setMinimumSize(dimension); this.setMinimumSize(dimension);
this.setMaximumSize(dimension); this.setMaximumSize(dimension);
@ -97,6 +100,9 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
this.add(labelProducttype = ComponentUtils.createLabel(labelProducttype, "labelProducttype", "产品类型", 20, y, 80, 20)); this.add(labelProducttype = ComponentUtils.createLabel(labelProducttype, "labelProducttype", "产品类型", 20, y, 80, 20));
this.add(cbbProducttype = ComponentUtils.createComboBox(cbbProducttype, "cbbProducttype", 120, y, 260, 20)); this.add(cbbProducttype = ComponentUtils.createComboBox(cbbProducttype, "cbbProducttype", 120, y, 260, 20));
y+= 40; y+= 40;
this.add(labelVoltageClasses = ComponentUtils.createLabel(labelVoltageClasses, "labelVoltageClasses", "µçѹµÈ¼¶", 20, y, 80, 20));
this.add(cbbVoltageClasses = ComponentUtils.createComboBox(cbbVoltageClasses, "cbbVoltageClasses", 120, y, 260, 20));
y+= 40;
this.add(labelProductxh = ComponentUtils.createLabel(labelProductxh, "labelProductxh", "产品型号", 20, y, 80, 20)); this.add(labelProductxh = ComponentUtils.createLabel(labelProductxh, "labelProductxh", "产品型号", 20, y, 80, 20));
this.add(cbbProductxh = ComponentUtils.createComboBox(cbbProductxh, "cbbProductxh", 120, y, 260, 20)); this.add(cbbProductxh = ComponentUtils.createComboBox(cbbProductxh, "cbbProductxh", 120, y, 260, 20));
y+= 40; y+= 40;
@ -113,6 +119,7 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
this.add(btnCancel = ComponentUtils.createButton(btnCancel, "btnCancel", "取消", 290, y, 80, 25, this)); this.add(btnCancel = ComponentUtils.createButton(btnCancel, "btnCancel", "取消", 290, y, 80, 25, this));
// 事件监听 // 事件监听
cbbProducttype.addItemListener(this); cbbProducttype.addItemListener(this);
cbbVoltageClasses.addItemListener(this);
cbbProductxh.addItemListener(this); cbbProductxh.addItemListener(this);
// 加载数据 // 加载数据
this.loadData(); this.loadData();
@ -236,17 +243,45 @@ public class CreateProcBYQGSDialog extends AbstractAIFDialog implements ActionLi
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (e.getSource() == cbbProducttype) { if (e.getSource() == cbbProducttype) {
ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem(); ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem();
ComboItem voltageClassesItem = (ComboItem) cbbVoltageClasses.getSelectedItem();
if (producttypeItem!=null) { if (producttypeItem!=null) {
EasyResponse<List<String>> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName()); EasyResponse<List<String>> voltagelevelResult = WorkhourService.getVoltagelevel(groupId, producttypeItem.getName());
if (voltagelevelResult.isSuccess()) {
List<String> list = voltagelevelResult.getData();
if (CollectionUtils.isNotEmpty(list)) {
cbbVoltageClasses.removeAllItems();
cbbVoltageClasses.addItem(new ComboItem(""));
for (String str : list) {
cbbVoltageClasses.addItem(new ComboItem(str));
}
}
}
EasyResponse<List<String>> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName(), voltageClassesItem!=null?voltageClassesItem.getName():"");
if (productxhResult.isSuccess()) { if (productxhResult.isSuccess()) {
List<String> list = productxhResult.getData(); List<String> list = productxhResult.getData();
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
cbbProductxh.removeAllItems();
cbbProductxh.addItem(new ComboItem(""));
for (String str : list) { for (String str : list) {
cbbProductxh.addItem(new ComboItem(str)); cbbProductxh.addItem(new ComboItem(str));
} }
} }
} }
} }
} else if (e.getSource() == cbbVoltageClasses) {
ComboItem producttypeItem = (ComboItem) cbbProducttype.getSelectedItem();
ComboItem voltageClassesItem = (ComboItem) cbbVoltageClasses.getSelectedItem();
EasyResponse<List<String>> productxhResult = WorkhourService.getProductxh(groupId, producttypeItem.getName(), voltageClassesItem!=null?voltageClassesItem.getName():"");
if (productxhResult.isSuccess()) {
List<String> list = productxhResult.getData();
if (CollectionUtils.isNotEmpty(list)) {
cbbProductxh.removeAllItems();
cbbProductxh.addItem(new ComboItem(""));
for (String str : list) {
cbbProductxh.addItem(new ComboItem(str));
}
}
}
} }
} }

@ -245,25 +245,24 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(400, 50));
setCompEnabled(false); setCompEnabled(false);
try { try {
long startTime = System.currentTimeMillis();
value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode"); value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode");
KUtil.setByPass(true); KUtil.setByPass(true);
if (revs.size() == 1) { if (revs.size() == 1) {
tree.setRootVisible(false); tree.setRootVisible(false);
controller.readData(pb, revs); controller.readData(pb, revs);
long startTime = System.currentTimeMillis(); System.out.println("usedTime1:" + (System.currentTimeMillis() - startTime) / 1000);
controller.readData(pb, rev_nodes.get(revs.get(0))); controller.readData(pb, rev_nodes.get(revs.get(0)));
long endTime = System.currentTimeMillis(); System.out.println("usedTime2:" + (System.currentTimeMillis() - startTime) / 1000);
long usedTime = (endTime - startTime) / 1000;
System.out.println("usedTime:" + usedTime);
clickNode = rev_nodes.get(revs.get(0)); clickNode = rev_nodes.get(revs.get(0));
KUtil.expandTree(tree, new TreePath(topNode)); KUtil.expandTree(tree, new TreePath(topNode));
System.out.println("usedTime3:" + (System.currentTimeMillis() - startTime) / 1000);
} else { } else {
controller.readData(pb, revs); controller.readData(pb, revs);
} }
addListeners();
isAllowExpand = true; isAllowExpand = true;
pb.disposeDialog(); pb.disposeDialog();
} catch (Exception e) { } catch (Exception e) {
@ -276,9 +275,10 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
setCompEnabled(true); setCompEnabled(true);
} }
}).start(); }).start();
addListeners();
showDialog(); showDialog();
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
pb2.disposeDialog(); pb2.disposeDialog();
MessageBox.post(CreateProcZYDialog.this, "初始化异常:" + e.getMessage(), "", 2); MessageBox.post(CreateProcZYDialog.this, "初始化异常:" + e.getMessage(), "", 2);
@ -287,7 +287,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
protected void processWindowEvent(WindowEvent e) { protected void processWindowEvent(WindowEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
if (e.getID() == WindowEvent.WINDOW_CLOSING && isSecSpec) { if (e.getID() == WindowEvent.WINDOW_CLOSING && isSecSpec) {
try { try {
AIFComponentContext meops[] = bomrev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, AIFComponentContext meops[] = bomrev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
@ -299,7 +299,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} }
} catch (TCException e1) { } catch (TCException e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
} }
@ -371,73 +371,71 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
if (min != -1) { if (min != -1) {
t_part.scrollRectToVisible(t_part.getCellRect(min, 0, true)); t_part.scrollRectToVisible(t_part.getCellRect(min, 0, true));
} }
} }
} }
}); });
tree.addTreeExpansionListener(new TreeExpansionListener() { tree.addTreeExpansionListener(new TreeExpansionListener() {
@Override @Override
public void treeExpanded(TreeExpansionEvent event) { public void treeExpanded(TreeExpansionEvent event) {
// TODO Auto-generated method stub // Auto-generated method stub
final TreePath path = event.getPath(); final TreePath path = event.getPath();
if (path != null) { if (path != null) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
System.out.println("isAllowExpand:" + isAllowExpand); System.out.println("isAllowExpand:" + isAllowExpand);
if (isAllowExpand && node != null && map_nodes.containsKey(node) if (isAllowExpand && node != null && map_nodes.containsKey(node)) {
&& map_nodes.get(node).size() == 0) { if(map_nodes.get(node).size() == 0) {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override
@Override public void run() {
public void run() { ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50));
ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); setCompEnabled(false);
setCompEnabled(false); try {
try { controller.readData(pb, node);
controller.readData(pb, node); tree.expandPath(path);
tree.expandPath(path); clickNode = node;
clickNode = node; pb.disposeDialog();
pb.disposeDialog(); } catch (Exception e1) {
} catch (Exception e1) { pb.disposeDialog();
pb.disposeDialog(); MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "",
MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.ERROR);
MessageBox.ERROR); e1.printStackTrace();
e1.printStackTrace(); }
setCompEnabled(true);
} }
setCompEnabled(true); }).start();
} }else {
}).start();
} else {
if (map_nodes.containsKey(node)) {
try { try {
controller.refushTable2(map_nodes.get(node)); controller.refushTable2(map_nodes.get(node));
clickNode = node; clickNode = node;
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "",
MessageBox.ERROR); MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
} }
} }
} }
if (isAllowExpand && node != null && map_nodes.containsKey(node)
&& map_nodes.get(node).size() == 0) {
} else {
if (map_nodes.containsKey(node)) {
}
}
} }
} }
@Override @Override
public void treeCollapsed(TreeExpansionEvent event) { public void treeCollapsed(TreeExpansionEvent event) {
// TODO Auto-generated method stub // Auto-generated method stub
DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent();
JTree tree = (JTree) event.getSource(); JTree tree = (JTree) event.getSource();
DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
tree.clearSelection(); tree.clearSelection();
KUtil.recurRemove(model, node, tm_part); KUtil.recurRemove(model, node, tm_part);
} }
}); });
@ -670,7 +668,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
public int compare(String o1, String o2) { public int compare(String o1, String o2) {
// TODO Auto-generated method stub // Auto-generated method stub
return o2.compareTo(o1); return o2.compareTo(o1);
} }
}); });
@ -815,7 +813,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
* MessageBox.post(CreateProcZYDialog.this, "投料异常,ERROR:"+e1.getMessage() , "", * MessageBox.post(CreateProcZYDialog.this, "投料异常,ERROR:"+e1.getMessage() , "",
* MessageBox.ERROR); e1.printStackTrace(); * MessageBox.ERROR); e1.printStackTrace();
* }//如果不关闭会导致BOM被占用乃至包含BOM的版本不能删除除非重启TC System.out.println(sb.toString()); * }//如果不关闭会导致BOM被占用乃至包含BOM的版本不能删除除非重启TC System.out.println(sb.toString());
* //TODO 设置最后一列 setTable(bomMap); * // 设置最后一列 setTable(bomMap);
* *
* if(sb.length()>0) { MessageBox.post(CreateProcZYDialog.this, * if(sb.length()>0) { MessageBox.post(CreateProcZYDialog.this,
* "自动投料完成,请进行手工投料", "", MessageBox.WARNING); }else { * "自动投料完成,请进行手工投料", "", MessageBox.WARNING); }else {
@ -901,7 +899,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} catch (Exception e) { } catch (Exception e) {
pb.disposeDialog(); pb.disposeDialog();
// TODO: handle exception // : handle exception
e.printStackTrace(); e.printStackTrace();
MessageBox.post(CreateProcZYDialog.this, "异常:" + e.getMessage(), "提示", 2); MessageBox.post(CreateProcZYDialog.this, "异常:" + e.getMessage(), "提示", 2);
} }
@ -1022,9 +1020,10 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
if (pb == null) { if (pb == null) {
pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......"); pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......");
} else { }
pb.setShowLabel("工艺路线修改中......"); // else {
} // pb.setShowLabel("工艺路线修改中......");
// }
pb.setVisible(true); pb.setVisible(true);
if (procs == null || procs.size() == 0) { if (procs == null || procs.size() == 0) {
@ -1091,7 +1090,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings, new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings,
session); session);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2); MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2);
} }
@ -1111,7 +1110,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings, new ZYUpdateProcDialog(CreateProcZYDialog.this, revs, rev_Beans, value_strings,
session); session);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2); MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2);
} }
@ -1119,7 +1118,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} }
}); });
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
@ -1197,7 +1196,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
} }
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
MessageBox.post("PDF打开异常:" + e1.getMessage(), "", 2); MessageBox.post("PDF打开异常:" + e1.getMessage(), "", 2);
} }
@ -1209,7 +1208,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
// 清除Table // 清除Table
for (int i = tm_part.getRowCount() - 1; i > -1; i--) { for (int i = tm_part.getRowCount() - 1; i > -1; i--) {
tm_part.removeRow(i); tm_part.removeRow(i);
@ -1668,7 +1667,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
* tm_part.addRow(new Object[] * tm_part.addRow(new Object[]
* {index,item_id,rev.getProperty("object_name"),"","",gy_name}); index++; * {index,item_id,rev.getProperty("object_name"),"","",gy_name}); index++;
* gy=null; groupID=""; } System.out.println("结束"); } catch (Exception e) { // * gy=null; groupID=""; } System.out.println("结束"); } catch (Exception e) { //
* TODO Auto-generated catch block e.printStackTrace(); }finally { * Auto-generated catch block e.printStackTrace(); }finally {
* KUtil.setByPass(false); } * KUtil.setByPass(false); }
* *
* } }).start(); * } }).start();
@ -1692,7 +1691,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50)); ProgressBar pb = new ProgressBar(CreateProcZYDialog.this, new Dimension(250, 50));
setCompEnabled(false); setCompEnabled(false);
try { try {
@ -1742,7 +1741,7 @@ public class CreateProcZYDialog extends AbstractAIFDialog {
controller.refushTable2(map_nodes.get(node)); controller.refushTable2(map_nodes.get(node));
clickNode = node; clickNode = node;
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.post(CreateProcZYDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "",
MessageBox.ERROR); MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();

@ -1,5 +1,6 @@
package com.connor.chint.sap2.proc_zy; package com.connor.chint.sap2.proc_zy;
import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -18,9 +19,11 @@ import com.connor.chint.sap2.proc.CreateProcessController;
import com.connor.chint.sap2.proc_by.BomBean; import com.connor.chint.sap2.proc_by.BomBean;
import com.connor.chint.sap2.proc_by.BYProcBean; import com.connor.chint.sap2.proc_by.BYProcBean;
import com.connor.chint.sap2.proc_by.ProcCellEditor; import com.connor.chint.sap2.proc_by.ProcCellEditor;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar; import com.connor.chint.sap2.util.ProgressBar;
import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.SqlUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
@ -30,12 +33,13 @@ import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentContextList; import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException; 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 com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
import com.teamcenter.services.rac.core.DataManagementService;
public class CreateProcZYDialogController { public class CreateProcZYDialogController {
@ -45,14 +49,16 @@ public class CreateProcZYDialogController {
private TCSession session; private TCSession session;
protected List<BYProcBean> procBeanList = new ArrayList<>(); protected List<BYProcBean> procBeanList = new ArrayList<>();
private ProcCellEditor procEditoe; private ProcCellEditor procEditoe;
private String group;
private TCComponentGroup login_group = null; // private TCComponentGroup login_group = null;
private Map<String, TCComponentItemRevision> mepMap = new HashMap<>();
public CreateProcZYDialogController(CreateProcZYDialog createProcBYDialog, AbstractAIFApplication app) { public CreateProcZYDialogController(CreateProcZYDialog createProcBYDialog, AbstractAIFApplication app) {
this.dialog = createProcBYDialog; this.dialog = createProcBYDialog;
this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
this.login_group = session.getCurrentGroup(); // this.login_group = session.getCurrentGroup();
} }
public void readData(ProgressBar pb) throws Exception { public void readData(ProgressBar pb) throws Exception {
@ -62,6 +68,7 @@ public class CreateProcZYDialogController {
if (target == null || !(target instanceof TCComponentItemRevision)) { if (target == null || !(target instanceof TCComponentItemRevision)) {
return; return;
} }
group = session.getCurrentGroup().getUid();
System.out.println("检查对象:" + target); System.out.println("检查对象:" + target);
TCComponentItemRevision rev = (TCComponentItemRevision) target; TCComponentItemRevision rev = (TCComponentItemRevision) target;
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -71,7 +78,14 @@ public class CreateProcZYDialogController {
topBean = new BomBean(rev, topLine, 1); topBean = new BomBean(rev, topLine, 1);
DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(topBean); DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(topBean);
dialog.topNode.add(topTreeNode); dialog.topNode.add(topTreeNode);
readBom(topTreeNode, topLine, pb, rev, topBean, procBeanList);
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
// readTemplate(topLine, rev, topBean, procBeanList);
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService);
readBom(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList, codeList, noList);
getGY(procBeanList, codeList, noList);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode)); KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
if (procBeanList.size() > 0) { if (procBeanList.size() > 0) {
procEditoe = new ProcCellEditor(procBeanList); procEditoe = new ProcCellEditor(procBeanList);
@ -81,33 +95,33 @@ public class CreateProcZYDialogController {
win.close(); win.close();
} }
private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb, private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, Map<String, ExpandPSData[]> bomLineTree, ProgressBar pb,
TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList) throws Exception { TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {//TODO readBom
readTemplate(topLine, parentRev, parentBean, procBeanList); readTemplate(topLine, parentRev, parentBean, procBeanList, codeList, noList);
BomBean pBean = (BomBean) treeNode.getUserObject(); BomBean pBean = (BomBean) treeNode.getUserObject();
pb.setText("加载数据..." + pBean); pb.setText("加载数据" + pBean);
AIFComponentContext[] cLines = topLine.getChildren(); // AIFComponentContext[] cLines = topLine.getChildren();
TCComponentItemRevision parentRev2 = topLine.getItemRevision(); TCComponentItemRevision parentRev2 = topLine.getItemRevision();
for (int i = 0; i < cLines.length; i++) { for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent(); TCComponentBOMLine cLine = data.bomLine;
if (cLine.getProperty("zt2_Diagram").equals("是")) { if (cLine.getProperty("zt2_Diagram").equals("是")) {
System.out.println(cLine.getProperty("object_string") + "为虚拟项,已过滤!"); System.out.println(cLine.getProperty("object_string") + "为虚拟项,已过滤!");
continue; continue;
} }
TCComponentItemRevision cRev = cLine.getItemRevision(); TCComponentItemRevision cRev = data.itemRevOfBOMLine;
System.out.println("cRev:" + cRev); System.out.println("cRev:" + cRev);
BomBean cBean = new BomBean(cRev, cLine, procBeanList.size() + 1); BomBean cBean = new BomBean(cRev, cLine, procBeanList.size() + 1);
pBean.getChildren().add(cBean); pBean.getChildren().add(cBean);
DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean); DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
treeNode.add(cNode); treeNode.add(cNode);
System.out.println("添加:" + cBean); System.out.println("添加:" + cBean);
readBom(cNode, cLine, pb, parentRev2, cBean, procBeanList); readBom(cNode, cLine, bomLineTree, pb, parentRev2, cBean, procBeanList, codeList, noList);
} }
} }
private void readBom2(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb, private void readBom2(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb,
TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList) throws Exception { TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {
readTemplate(topLine, parentRev, parentBean, procBeanList); readTemplate(topLine, parentRev, parentBean, procBeanList, codeList, noList);
BomBean pBean = (BomBean) treeNode.getUserObject(); BomBean pBean = (BomBean) treeNode.getUserObject();
pb.setText("加载数据..." + pBean); pb.setText("加载数据..." + pBean);
AIFComponentContext[] cLines = topLine.getChildren(); AIFComponentContext[] cLines = topLine.getChildren();
@ -127,23 +141,25 @@ public class CreateProcZYDialogController {
DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean); DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
treeNode.add(cNode); treeNode.add(cNode);
System.out.println("添加:" + cBean); System.out.println("添加:" + cBean);
readBom2(cNode, cLine, pb, parentRev2, cBean, procBeanList); readBom2(cNode, cLine, pb, parentRev2, cBean, procBeanList, codeList, noList);
} }
} }
private void readTemplate(TCComponentBOMLine topLine, TCComponentItemRevision parentRev, BomBean parentBean, private void readTemplate(TCComponentBOMLine topLine, TCComponentItemRevision parentRev, BomBean parentBean,
List<BYProcBean> procBeanList) throws Exception { List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {
TCComponentItemRevision comp = topLine.getItemRevision(); TCComponentItemRevision comp = topLine.getItemRevision();
TCComponentItemRevision rev_standard = null; TCComponentItemRevision rev_standard = null;
TCComponentItemRevision bzgy = null; // TCComponentItemRevision bzgy = null;
TCComponentItemRevision tlgx = null; TCComponentItemRevision tlgx = null;
TCComponentItemRevision cptlgx = null; TCComponentItemRevision cptlgx = null;
boolean flag = true; boolean flag = true;
List<TCComponentItemRevision> bzgys = new ArrayList<TCComponentItemRevision>(); List<TCComponentItemRevision> bzgys = new ArrayList<TCComponentItemRevision>();
String zt2_MaterialMark = ""; String zt2_MaterialMark = "";
System.out.println("type:" + comp.getType()); String type = comp.getType();
System.out.println("type:" + type);
zt2_MaterialMark = comp.getProperty("zt2_MaterialMark"); zt2_MaterialMark = comp.getProperty("zt2_MaterialMark");
if (comp.getType().equals("ZT2_Design3DRevision")) {
if (type.equals("ZT2_Design3DRevision")) {
String drawingNo = comp.getStringProperty("item_id"); String drawingNo = comp.getStringProperty("item_id");
System.out.println("查询标准工艺:" + comp + ", zt2_DrawingNo = " + drawingNo); System.out.println("查询标准工艺:" + comp + ", zt2_DrawingNo = " + drawingNo);
if (KUtil.isEmpty(drawingNo)) { if (KUtil.isEmpty(drawingNo)) {
@ -158,53 +174,9 @@ public class CreateProcZYDialogController {
drawingNo = drawingNo.substring(0, ind); drawingNo = drawingNo.substring(0, ind);
} }
} }
System.out.println("查询图号:" + drawingNo); codeList.add(drawingNo);
// 查询标准图工艺
Map<String, String> fields = new LinkedHashMap<>();
fields.put("DrawingNo", drawingNo);
TCComponentContextList res = KUtil.query(session, "chint_query_TYDH", fields);
if (res != null) {
int len = res.getListCount();
if (len > 1) {
throw new Exception("通过 DrawingNo = " + drawingNo + " 查询到多个对象");
}
if (len == 1) {
TCComponentItemRevision rev = (TCComponentItemRevision) res.get(0).getComponent();
rev_standard = rev;
String zt2_ClassificationCode = rev.getProperty("zt2_ClassificationCode");
if (zt2_ClassificationCode.length() > 0) {
flag = false;
Map<String, String> fields2 = new LinkedHashMap<>();
fields2.put("ID", zt2_ClassificationCode);
TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2);
if (res2 != null) {
int len2 = res2.getListCount();
if (len2 > 1) {
throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象");
}
if (len2 == 1) {
tlgx = (TCComponentItemRevision) res2.get(0).getComponent();
System.out.println("tlgx type:[" + tlgx.getType() + "]");
}
}
}
AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(
new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" });
System.out.println("查询到对象:" + rev + ", 引用数量:" + comps.length);
for (int i = 0; i < comps.length; i++) {
InterfaceAIFComponent cc = comps[i].getComponent();
if (KUtil.isSameGroup((TCComponent) cc, login_group)) {
// 添加到模板
bzgy = (TCComponentItemRevision) cc;
System.out.println("找到标准工艺:" + bzgy);
bzgys.add(bzgy);
}
}
}
}
} // 若未图纸,则取物料编码 } // 若未图纸,则取物料编码
else if (comp.getType().equals("Part Revision")) { else if (type.equals("Part Revision")) {
String drawingNo = comp.getStringProperty("zt2_MaterialNo"); String drawingNo = comp.getStringProperty("zt2_MaterialNo");
System.out.println("查询标准工艺:" + comp + ", zt2_MaterialNo = " + drawingNo); System.out.println("查询标准工艺:" + comp + ", zt2_MaterialNo = " + drawingNo);
if (KUtil.isEmpty(drawingNo)) { if (KUtil.isEmpty(drawingNo)) {
@ -216,82 +188,24 @@ public class CreateProcZYDialogController {
drawingNo = drawingNo.substring(0, ind); drawingNo = drawingNo.substring(0, ind);
} }
// 查询标准图工艺 // 查询标准图工艺
Map<String, String> fields = new LinkedHashMap<>(); codeList.add(drawingNo);
fields.put("零组件 ID", drawingNo); }else {
TCComponentContextList res = KUtil.query(session, "零组件版本...", fields); codeList.add("");
if (res != null) { }/**/
int len = res.getListCount();
if (len > 1) {
throw new Exception("通过 DrawingNo = " + drawingNo + " 查询到多个对象");
}
if (len == 1) {
TCComponentItemRevision rev = (TCComponentItemRevision) res.get(0).getComponent();
rev_standard = rev;
String zt2_ClassificationCode = rev.getProperty("zt2_ClassificationCode");
if (zt2_ClassificationCode.length() > 0) {
flag = false;
Map<String, String> fields2 = new LinkedHashMap<>();
fields2.put("ID", zt2_ClassificationCode);
TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2);
if (res2 != null) {
int len2 = res2.getListCount();
if (len2 > 1) {
throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象");
}
if (len2 == 1) {
tlgx = (TCComponentItemRevision) res2.get(0).getComponent();
System.out.println("tlgx type:[" + tlgx.getType() + "]");
}
}
}
AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(
new String[] { "MEProcessRevision" }, new String[] { "IMAN_METarget" });
System.out.println("查询到对象:" + rev + ", 引用数量:" + comps.length);
for (int i = 0; i < comps.length; i++) {
InterfaceAIFComponent cc = comps[i].getComponent();
if (KUtil.isSameGroup((TCComponent) cc, login_group)) {
// 添加到模板
bzgy = (TCComponentItemRevision) cc;
System.out.println("找到标准工艺:" + bzgy);
bzgys.add(bzgy);
}
}
}
}
}
String zt2_ClassificationCode = topLine.getProperty("ZT2_ClassificationNo"); String zt2_ClassificationCode = topLine.getProperty("ZT2_ClassificationNo");
System.out.println("[ZT2_ClassificationNo=" + zt2_ClassificationCode + "]"); System.out.println("[ZT2_ClassificationNo=" + zt2_ClassificationCode + "]");
if (zt2_ClassificationCode.length() > 0) { noList.add(zt2_ClassificationCode);
flag = false;
Map<String, String> fields2 = new LinkedHashMap<>();
fields2.put("ID", zt2_ClassificationCode);
TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2);
if (res2 != null) {
int len2 = res2.getListCount();
if (len2 > 1) {
throw new Exception("通过 ID = " + zt2_ClassificationCode + " 查询到多个对象");
}
if (len2 == 1) {
cptlgx = (TCComponentItemRevision) res2.get(0).getComponent();
}
}
}
// 查询产品工艺 // 查询产品工艺
TCComponentItemRevision cpgy = null; String uid = comp.getUid();
AIFComponentContext[] refs = comp.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, TCComponentItemRevision cpgy;// = (TCComponentItemRevision) getMeproces(comp.getUid(), session);
new String[] { "IMAN_METarget" }); if(mepMap.containsKey(uid))
System.out.println("查询产品工艺、投料工序:" + comp + ", 引用数量:" + refs.length); cpgy = mepMap.get(uid);
for (int i = 0; i < refs.length; i++) { else {
InterfaceAIFComponent c = refs[i].getComponent(); cpgy = (TCComponentItemRevision) SAPUtil.getMeprocesYh(uid, group, session);
if (KUtil.isSameGroup((TCComponent) c, login_group)) { mepMap.put(uid, cpgy);
// 添加到模板
System.out.println("找到产品工艺:" + c);
cpgy = (TCComponentItemRevision) c;
}
} }
BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, bzgys, cpgy, tlgx, topLine, cptlgx, parentRev); BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, bzgys, cpgy, tlgx, topLine, cptlgx, parentRev);
zt2_ClassificationCode = comp.getProperty("zt2_ClassificationCode"); zt2_ClassificationCode = comp.getProperty("zt2_ClassificationCode");
@ -374,6 +288,7 @@ public class CreateProcZYDialogController {
KUtil.info(dialog, "二次自动投料完成"); KUtil.info(dialog, "二次自动投料完成");
} }
@SuppressWarnings("deprecation")
public void oneAutoFeeding(Map<String, CHINT_ClassificationCode> maps, ProgressBar pb) throws Exception { public void oneAutoFeeding(Map<String, CHINT_ClassificationCode> maps, ProgressBar pb) throws Exception {
KUtil.stopTableEditing(dialog.t_part); KUtil.stopTableEditing(dialog.t_part);
pb.setText("一次自动投料..."); pb.setText("一次自动投料...");
@ -392,6 +307,7 @@ public class CreateProcZYDialogController {
pb.disposeDialog(); pb.disposeDialog();
} }
@SuppressWarnings("deprecation")
private void oneFeedingLine(Map<String, CHINT_ClassificationCode> maps, TCComponentBOMLine line) throws Exception { private void oneFeedingLine(Map<String, CHINT_ClassificationCode> maps, TCComponentBOMLine line) throws Exception {
AIFComponentContext[] children = line.getChildren(); AIFComponentContext[] children = line.getChildren();
String zt2_ClassificationCode; String zt2_ClassificationCode;
@ -411,7 +327,7 @@ public class CreateProcZYDialogController {
} }
} }
private void refushPros(TCComponentBOMLine line, BYProcBean bean) throws TCException { private void refushPros(TCComponentBOMLine line, BYProcBean bean) throws Exception {
System.out.println("line:" + line.getItemRevision() + "|子项:" + bean.getBomRev()); System.out.println("line:" + line.getItemRevision() + "|子项:" + bean.getBomRev());
if (line.getItemRevision().equals(bean.getBomRev())) { if (line.getItemRevision().equals(bean.getBomRev())) {
System.out.println("重新刷新子项可选工序"); System.out.println("重新刷新子项可选工序");
@ -592,13 +508,13 @@ public class CreateProcZYDialogController {
dialog.tm_part.setValueAt(proc.getProperty("object_name"), procBean.getIndex() - 1, BYProcBean.INDEX_CPGY); dialog.tm_part.setValueAt(proc.getProperty("object_name"), procBean.getIndex() - 1, BYProcBean.INDEX_CPGY);
} }
private void getGX(TCComponentBOMLine line, List<TCComponentItemRevision> lists) throws TCException { private void getGX(TCComponentBOMLine line, List<TCComponentItemRevision> lists) throws Exception {
TCComponentBOMLine parent = line.parent(); TCComponentBOMLine parent = line.parent();
if (parent == null) { if (parent == null) {
return; return;
} }
boolean flag = false; boolean flag = false;
AIFComponentContext[] contexts22 = (parent.getItemRevision()).whereReferencedByTypeRelation(null, null); /*AIFComponentContext[] contexts22 = (parent.getItemRevision()).whereReferencedByTypeRelation(null, null);
for (int i = 0; i < contexts22.length; i++) { for (int i = 0; i < contexts22.length; i++) {
String type = contexts22[i].getComponent().getType(); String type = contexts22[i].getComponent().getType();
System.out.println("type:" + type); System.out.println("type:" + type);
@ -616,11 +532,24 @@ public class CreateProcZYDialogController {
} }
} }
}*/
// TCComponent meop = getMeproces(parent.getItemRevision().getUid(), session);
String uid = parent.getItemRevision().getUid();
TCComponentItemRevision meop;// = (TCComponentItemRevision) getMeproces(comp.getUid(), session);
if(mepMap.containsKey(uid))
meop = mepMap.get(uid);
else {
meop = (TCComponentItemRevision) SAPUtil.getMeprocesYh(uid, group, session);
mepMap.put(uid, meop);
}
if(meop != null) {
flag = true;
if(!lists.contains(meop) && (meop instanceof TCComponentItemRevision))
lists.add((TCComponentItemRevision) meop);
} }
if (!flag) { if (!flag) {
getGX(parent, lists); getGX(parent, lists);
} }
} }
public void assignProcess(ProgressBar pb) throws Exception { public void assignProcess(ProgressBar pb) throws Exception {
@ -682,6 +611,7 @@ public class CreateProcZYDialogController {
} }
// 创建工艺 // 创建工艺
@SuppressWarnings("deprecation")
public void createProcess(ProgressBar pb, MEProcessBean bean, TCSession session, List<TCComponentItemRevision> revs) public void createProcess(ProgressBar pb, MEProcessBean bean, TCSession session, List<TCComponentItemRevision> revs)
throws Exception { throws Exception {
if (revs.size() == 0) if (revs.size() == 0)
@ -725,8 +655,8 @@ public class CreateProcZYDialogController {
TCComponentItemRevision rev; TCComponentItemRevision rev;
TCComponentItemRevision newProc = null; TCComponentItemRevision newProc = null;
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
DefaultMutableTreeNode node; // DefaultMutableTreeNode node;
String object_name = proc.getProperty("object_name"); // String object_name = proc.getProperty("object_name");
// pb.setText("工艺路线创建......"); // pb.setText("工艺路线创建......");
int len = revs.size(); int len = revs.size();
List<BYProcBean> cout_beans = new ArrayList<>(); List<BYProcBean> cout_beans = new ArrayList<>();
@ -756,7 +686,8 @@ public class CreateProcZYDialogController {
BYProcBean.INDEX_CPGY); BYProcBean.INDEX_CPGY);
} }
if (procBean.getRev_standard() == procBean.getBomRev()) { if (procBean.getRev_standard() == procBean.getBomRev()) {
procBean.getBzgys().add(newProc); if(!procBean.getBzgys().contains(newProc))
procBean.getBzgys().add(newProc);
procBean.setTemplate(newProc); procBean.setTemplate(newProc);
if (procBean.isVisible) { if (procBean.isVisible) {
dialog.tm_part.setValueAt(newProc.getProperty("object_name"), procBean.getIndex() - 1, dialog.tm_part.setValueAt(newProc.getProperty("object_name"), procBean.getIndex() - 1,
@ -775,7 +706,8 @@ public class CreateProcZYDialogController {
procBean = beans.get(j); procBean = beans.get(j);
procBean.setCpgy(proc); procBean.setCpgy(proc);
if (procBean.getRev_standard() == procBean.getBomRev()) { if (procBean.getRev_standard() == procBean.getBomRev()) {
procBean.getBzgys().add(proc); if(!procBean.getBzgys().contains(proc))
procBean.getBzgys().add(proc);
procBean.setTemplate(proc); procBean.setTemplate(proc);
} }
} }
@ -805,14 +737,19 @@ public class CreateProcZYDialogController {
} }
public void refushTable2(List<BYProcBean> list) throws Exception { public void refushTable2(List<BYProcBean> list) throws Exception {
dialog.tm_part.getDataVector().clear(); // dialog.tm_part.getDataVector().clear();
dialog.t_part.clearSelection(); // dialog.t_part.clearSelection();
dialog.t_part.revalidate(); // dialog.t_part.revalidate();
dialog.t_part.repaint(); // dialog.t_part.repaint();
for(int i = dialog.t_part.getRowCount() - 1; i >= 0; i--) {
dialog.tm_part.removeRow(i);
}
for (int i = 0, len = list.size(); i < len; i++) { for (int i = 0, len = list.size(); i < len; i++) {
// long startTime = System.currentTimeMillis();
list.get(i).isVisible = true; list.get(i).isVisible = true;
dialog.tm_part.addRow(list.get(i).getRowData()); dialog.tm_part.addRow(list.get(i).getRowData());
// System.out.println("addRow:" + (System.currentTimeMillis() - startTime));
} }
} }
@ -875,10 +812,12 @@ public class CreateProcZYDialogController {
} }
public void readData(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception { public void readData(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception {
long startTime = System.currentTimeMillis();
pb.startProgress(); pb.startProgress();
pb.setText("加载数据..."); pb.setText("加载数据...");
dialog.rev_Beans.clear(); dialog.rev_Beans.clear();
// 预先加入的假节点 // 预先加入的假节点
group = session.getCurrentGroup().getUid();
int cout = topTreeNode.getChildCount(); int cout = topTreeNode.getChildCount();
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
@ -895,12 +834,53 @@ public class CreateProcZYDialogController {
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
List<BYProcBean> procBeanList2 = new ArrayList<>(); List<BYProcBean> procBeanList2 = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
List<TCComponent> bomList = new ArrayList<>();
List<TCComponent> bomRevList = new ArrayList<>();
readBom(topTreeNode, topLine, pb, rev, topBean, procBeanList2); // getBomLineTreeNodeSOA
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
MessageBox.post("数据库连接失败,请检查数据库连接配置!", "", 2);
return;
}
//预加载BOM及版本属性优化速度
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService);
getBOMList(topLine, bomLineTree, bomList, bomRevList);
DataManagementService dmService = DataManagementService.getService(session);
dmService.getProperties(bomList.toArray(new TCComponent[0]), new String[] { "zt2_Diagram", "object_string", "ZT2_ClassificationNo", "bl_sequence_no" });
dmService.getProperties(bomRevList.toArray(new TCComponent[0]), new String[] { "object_type", "item_id", "zt2_MaterialNo", "zt2_MaterialMark", "zt2_ClassificationCode" });
System.out.println("readData1:" + (System.currentTimeMillis() - startTime) / 1000);
readBom(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList2, codeList, noList);
System.out.println("readData2:" + (System.currentTimeMillis() - startTime) / 1000);
getGY(procBeanList2, codeList, noList);
System.out.println("readData3:" + (System.currentTimeMillis() - startTime) / 1000);
procBeanList.clear(); procBeanList.clear();
procBeanList.addAll(procBeanList2); procBeanList.addAll(procBeanList2);
dialog.map_nodes.put(topTreeNode, procBeanList2); dialog.map_nodes.put(topTreeNode, procBeanList2);
TCComponent[] revs = new TCComponent[procBeanList2.size()];
ArrayList<TCComponent> gyList = new ArrayList<>();
for(int i = 0; i < revs.length; i++) {
BYProcBean bean = procBeanList2.get(i);
revs[i] = bean.getBomRev();
if(bean.getTemplate() != null)
gyList.add(bean.getTemplate());
if(bean.getCpgy() != null)
gyList.add(bean.getCpgy());
if(bean.getCptlgx() != null)
gyList.add(bean.getCptlgx());
if(bean.getTlgx() != null)
gyList.add(bean.getTlgx());
}
dmService.getProperties(revs, new String[] { "object_type", "item_id", "zt2_MaterialNo", "object_name", "zt2_Source" });
dmService.getProperties(gyList.toArray(new TCComponent[gyList.size()]), new String[] { "object_name" });
refushTable2(procBeanList2); refushTable2(procBeanList2);
System.out.println("readData4:" + (System.currentTimeMillis() - startTime) / 1000);
for (int i = cout - 1; i > -1; i--) { for (int i = cout - 1; i > -1; i--) {
topTreeNode.remove(i); topTreeNode.remove(i);
} }
@ -910,7 +890,118 @@ public class CreateProcZYDialogController {
dialog.t_part.getColumnModel().getColumn(4).setCellEditor(procEditoe); dialog.t_part.getColumnModel().getColumn(4).setCellEditor(procEditoe);
} }
win.close(); win.close();
SqlUtil.free();
System.out.println("readData5:" + (System.currentTimeMillis() - startTime) / 1000);
}
private void getBOMList(TCComponentBOMLine parentLine, Map<String, ExpandPSData[]> bomLineTree, List<TCComponent> bomList, List<TCComponent> bomRevList) {
for (ExpandPSData data : bomLineTree.get(parentLine.getUid())) {
TCComponentBOMLine cLine = data.bomLine;
bomList.add(cLine);
bomRevList.add(data.itemRevOfBOMLine);
getBOMList(cLine, bomLineTree, bomList, bomRevList);
}
}
private void getGY(List<BYProcBean> procBeanList, List<String> codeList, List<String> noList) throws Exception {
//TODO getGY
StringBuilder codes = new StringBuilder("");
ArrayList<String> noSet = new ArrayList<>();
for(String s : codeList) {
if(noSet.contains(s))
continue;
noSet.add(s);
codes.append("','").append(s);
}
//查询标准图投料工序和标准图工艺
StringBuilder sql1 = new StringBuilder("select b.puid,a.pitem_id,b.PZT2_CLASSIFICATIONCODE,t1.puid as tlgx,t2.bzgy from pitem a,pitemrevision b0,PPOM_APPLICATION_OBJECT b1,");
sql1.append("(select puid,PZT2_CLASSIFICATIONCODE from PZT2_DESIGN3DREVISION union select puid,PZT2_CLASSIFICATIONCODE from PPART_0_REVISION_ALT) b ")
.append("left join (select a2.puid,a1.PITEM_ID from pitem a1,pitemrevision a2 where a2.ritems_tagu=a1.puid) t1 on t1.pitem_id=b.PZT2_CLASSIFICATIONCODE ")
.append("left join (select cV.puid,V.puid as bzgy,ITRO.Pobject_Name as supItemName ")
.append("from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g ")
.append("where g.puid=V.puid and V.Puid=R.Rprimary_Objectu and r.rrelation_typeu=RT.puid and P.Puid=V.Ritems_Tagu and ITRO.Puid=V.Puid and R.Rsecondary_Objectu=cV.Puid ")
.append("and cP.Puid=cV.Ritems_Tagu and cV.Puid=cITRO.Puid and ITRO.Pactive_Seq<>0 and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "') t2 on t2.puid=b.puid ")
.append("where b1.PCREATION_DATE in (select max(r3.PCREATION_DATE) from pitem r1,PITEMREVISION r2,PPOM_APPLICATION_OBJECT r3 where r1.puid=r2.ritems_tagu and r2.puid=r3.puid and r1.pitem_id=a.pitem_id) ")
.append("and b.puid=b1.puid and b.puid=b0.puid and b0.ritems_tagu=a.puid and a.pitem_id in (")
.append(codes.substring(2))
.append("') order by b.puid");
System.out.println("sql1\n" + sql1);
ResultSet read = SqlUtil.read(sql1.toString());
String last = "";
HashMap<String, TCComponentItemRevision> uidMap = new HashMap<>();
while (read.next()) {
String uid = read.getString(1);
String code = read.getString(2);
String classification = read.getString(3);
if(classification == null)
classification = "";
// System.out.println("code" + code);
String tlgx = read.getString(4);
String bzgy = read.getString(5);
String one = uid + bzgy;
if(one.equals(last))
throw new Exception("通过 DrawingNo = " + code + " 查询到多个对象");
// BYProcBean bean = procBeanList.get(codeList.indexOf(code));
for(int i = 0; i < codeList.size(); i++) {
if(codeList.get(i).equals(code)) {
BYProcBean bean = procBeanList.get(i);
if(tlgx != null && !tlgx.isEmpty()) {
if(uidMap.containsKey(tlgx))
bean.setTlgx(uidMap.get(tlgx));
else {
TCComponentItemRevision tlgxRev = (TCComponentItemRevision) session.stringToComponent(tlgx);
bean.setTlgx(tlgxRev);
uidMap.put(tlgx, tlgxRev);
}
}
if(bzgy != null && !bzgy.isEmpty()) {
TCComponentItemRevision bzgyRev;
if(uidMap.containsKey(bzgy))
bzgyRev = uidMap.get(bzgy);
else {
bzgyRev = (TCComponentItemRevision) session.stringToComponent(bzgy);
uidMap.put(bzgy, bzgyRev);
}
bean.setTemplate(bzgyRev);
if(!bean.getBzgys().contains(bzgyRev))
bean.getBzgys().add(bzgyRev);
}
bean.setFeeding(classification.length() <= 0);
bean.setRev_standard((TCComponentItemRevision) session.stringToComponent(uid));
}
}
last = one;
}
// SqlUtil.free();
StringBuilder nos = new StringBuilder("");
noSet.clear();
for(String s : noList) {
if(noSet.contains(s))
continue;
noSet.add(s);
nos.append("','").append(s);
}
//查询产品图投料工序
String sql2 = "select b.puid,a.pitem_id from pitem a,pitemrevision b where b.ritems_tagu=a.puid and a.PITEM_ID in (" + nos.substring(2) + "') order by a.pitem_id";
System.out.println("sql2\n" + sql2);
read = SqlUtil.read(sql2.toString());
last = "";
while (read.next()) {
String id = read.getString(2);
if(id.equals(last))
throw new Exception("通过 ID = " + id + " 查询到多个对象");
String uid = read.getString(1);
for(int i = 0; i < noList.size(); i++) {
if(noList.get(i).equals(id)) {
BYProcBean bean = procBeanList.get(i);
bean.setCptlgx((TCComponentItemRevision) session.stringToComponent(uid));
}
}
last = id;
}
// SqlUtil.free();
} }
public void readData2(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception { public void readData2(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception {
@ -923,6 +1014,7 @@ public class CreateProcZYDialogController {
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
BomBean topBean = (BomBean) topTreeNode.getUserObject(); BomBean topBean = (BomBean) topTreeNode.getUserObject();
TCComponentItemRevision rev = topBean.getRev(); TCComponentItemRevision rev = topBean.getRev();
group = session.getCurrentGroup().getUid();
dialog.bomrev = rev; dialog.bomrev = rev;
if (dialog.bomrev.getType().equals("Part Revision") if (dialog.bomrev.getType().equals("Part Revision")
@ -934,8 +1026,11 @@ public class CreateProcZYDialogController {
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
List<BYProcBean> procBeanList2 = new ArrayList<>(); List<BYProcBean> procBeanList2 = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
readBom2(topTreeNode, topLine, pb, rev, topBean, procBeanList2); readBom2(topTreeNode, topLine, pb, rev, topBean, procBeanList2, codeList, noList);
getGY(procBeanList2, codeList, noList);
procBeanList.clear(); procBeanList.clear();
procBeanList.addAll(procBeanList2); procBeanList.addAll(procBeanList2);
dialog.map_nodes.put(topTreeNode, procBeanList2); dialog.map_nodes.put(topTreeNode, procBeanList2);
@ -971,6 +1066,7 @@ public class CreateProcZYDialogController {
return nodes; return nodes;
} }
@SuppressWarnings("deprecation")
public void createProcess(ProgressBar pb, MEProcessBean bean, List<BomBean> beans) throws Exception { public void createProcess(ProgressBar pb, MEProcessBean bean, List<BomBean> beans) throws Exception {
TCComponentItemRevision template = bean.getMepRevision(); TCComponentItemRevision template = bean.getMepRevision();
TCComponentItemRevision proc = null; TCComponentItemRevision proc = null;
@ -1011,8 +1107,8 @@ public class CreateProcZYDialogController {
TCComponentItemRevision newProc = null; TCComponentItemRevision newProc = null;
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
DefaultMutableTreeNode node; // DefaultMutableTreeNode node;
String object_name = proc.getProperty("object_name"); // String object_name = proc.getProperty("object_name");
pb.setText("工艺路线创建......"); pb.setText("工艺路线创建......");
int len = beans.size(); int len = beans.size();
BYProcBean dyccBean; BYProcBean dyccBean;
@ -1037,7 +1133,7 @@ public class CreateProcZYDialogController {
newProc.add("IMAN_METarget", bomBean.getRev()); newProc.add("IMAN_METarget", bomBean.getRev());
} }
node = dialog.rev_nodes.get(bomBean.getRev()); // node = dialog.rev_nodes.get(bomBean.getRev());
if (dialog.bomLink_maps.containsKey(bomBean)) { if (dialog.bomLink_maps.containsKey(bomBean)) {
dyccBean = dialog.bomLink_maps.get(bomBean); dyccBean = dialog.bomLink_maps.get(bomBean);
dyccBean.setCpgy(newProc); dyccBean.setCpgy(newProc);
@ -1048,7 +1144,8 @@ public class CreateProcZYDialogController {
BYProcBean.INDEX_CPGY); BYProcBean.INDEX_CPGY);
} }
if (dyccBean.getRev_standard() == dyccBean.getBomRev()) { if (dyccBean.getRev_standard() == dyccBean.getBomRev()) {
dyccBean.getBzgys().add(newProc); if(!dyccBean.getBzgys().contains(newProc))
dyccBean.getBzgys().add(newProc);
dyccBean.setTemplate(newProc); dyccBean.setTemplate(newProc);
if (dyccBean.isVisible) { if (dyccBean.isVisible) {
dialog.tm_part.setValueAt(newProc.getProperty("object_name"), dyccBean.getIndex() - 1, dialog.tm_part.setValueAt(newProc.getProperty("object_name"), dyccBean.getIndex() - 1,
@ -1062,7 +1159,7 @@ public class CreateProcZYDialogController {
System.out.println("正在为" + bomBean.getRev() + "创建工艺路线"); System.out.println("正在为" + bomBean.getRev() + "创建工艺路线");
pb.setText("正在为" + len + "/" + len + " " + bomBean.getRev() + "创建工艺路线"); pb.setText("正在为" + len + "/" + len + " " + bomBean.getRev() + "创建工艺路线");
proc.add("IMAN_METarget", bomBean.getRev()); proc.add("IMAN_METarget", bomBean.getRev());
node = dialog.rev_nodes.get(bomBean.getRev()); // node = dialog.rev_nodes.get(bomBean.getRev());
if (dialog.bomLink_maps.containsKey(bomBean)) { if (dialog.bomLink_maps.containsKey(bomBean)) {
dyccBean = dialog.bomLink_maps.get(bomBean); dyccBean = dialog.bomLink_maps.get(bomBean);
@ -1074,7 +1171,8 @@ public class CreateProcZYDialogController {
BYProcBean.INDEX_CPGY); BYProcBean.INDEX_CPGY);
} }
if (dyccBean.getRev_standard() == dyccBean.getBomRev()) { if (dyccBean.getRev_standard() == dyccBean.getBomRev()) {
dyccBean.getBzgys().add(proc); if(!dyccBean.getBzgys().contains(proc))
dyccBean.getBzgys().add(proc);
dyccBean.setTemplate(proc); dyccBean.setTemplate(proc);
if (dyccBean.isVisible) { if (dyccBean.isVisible) {
dialog.tm_part.setValueAt(proc.getProperty("object_name"), dyccBean.getIndex() - 1, dialog.tm_part.setValueAt(proc.getProperty("object_name"), dyccBean.getIndex() - 1,

@ -18,8 +18,6 @@ import javax.swing.table.TableColumnModel;
import com.connor.chint.sap2.create_proc.CreateProcBean; import com.connor.chint.sap2.create_proc.CreateProcBean;
import com.connor.chint.sap2.create_proc.CreateProcController; import com.connor.chint.sap2.create_proc.CreateProcController;
import com.connor.chint.sap2.sap_zy.PartBean;
import com.connor.chint.sap2.sap_zy.SAPZYDialogzt;
import com.connor.chint.sap2.util.ConfirmDialogUtil; import com.connor.chint.sap2.util.ConfirmDialogUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
@ -42,9 +40,14 @@ import plm.xi.com.chintelectric.SI_PUSH_BOM_PLM_OUT_SYNServiceLocator;
public class SAPZZDialog extends AbstractAIFDialog { public class SAPZZDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private SAPZZDialogController controller; private SAPZZDialogController controller;
private JButton b_check; private JButton b_check;
private JButton b_bom; private JButton b_bom;
private JButton b_qr3;// 异步传递;
protected DefaultTableModel tm_part; protected DefaultTableModel tm_part;
protected JTable t_part; protected JTable t_part;
@ -54,7 +57,7 @@ public class SAPZZDialog extends AbstractAIFDialog {
public static final String[] HEADER = new String[] { "", "序号", "出厂编号", "物料编码", "总装图样代号", "BOM确认状态", "确认人", "确认时间" }; public static final String[] HEADER = new String[] { "", "序号", "出厂编号", "物料编码", "总装图样代号", "BOM确认状态", "确认人", "确认时间" };
public static final int[] HEADERWIDTH = new int[] { 50, 60, 120, 180, 180, 100, 100, 100 }; public static final int[] HEADERWIDTH = new int[] { 50, 60, 120, 180, 180, 100, 100, 100 };
private AbstractAIFApplication app; // private AbstractAIFApplication app;
private TCSession session; private TCSession session;
protected JButton pushBOM_btn; // BOM确认 protected JButton pushBOM_btn; // BOM确认
protected String materialCode = ""; protected String materialCode = "";
@ -62,7 +65,7 @@ public class SAPZZDialog extends AbstractAIFDialog {
public SAPZZDialog(AbstractAIFApplication app) { public SAPZZDialog(AbstractAIFApplication app) {
super(false); super(false);
this.controller = new SAPZZDialogController(this, app); this.controller = new SAPZZDialogController(this, app);
this.app = app; // this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
} }
@ -140,6 +143,7 @@ public class SAPZZDialog extends AbstractAIFDialog {
b_bom.setEnabled(b); b_bom.setEnabled(b);
t_part.setEnabled(b); t_part.setEnabled(b);
pushBOM_btn.setEnabled(b); pushBOM_btn.setEnabled(b);
b_qr3.setEnabled(b);
} }
private void addListeners() { private void addListeners() {
@ -273,12 +277,34 @@ public class SAPZZDialog extends AbstractAIFDialog {
} }
}); });
b_qr3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
// String selectedItem = (String) comb.getSelectedItem();
try {
controller.sendToSapYHAsyn("产成品BOM传递", false);
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
}).start();
}
});
} }
private JPanel getTablePanel() { private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel(); tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) { t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override @Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑 public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if (column == 0) if (column == 0)
@ -314,8 +340,11 @@ public class SAPZZDialog extends AbstractAIFDialog {
b_check = new JButton("检查"); b_check = new JButton("检查");
b_bom = new JButton("BOM传递"); b_bom = new JButton("BOM传递");
pushBOM_btn = new JButton("BOM确认"); pushBOM_btn = new JButton("BOM确认");
b_qr3 = new JButton("异步传递");
panel.add(b_check); panel.add(b_check);
panel.add(b_bom); panel.add(b_bom);
//TODO
// panel.add(b_qr3);
// panel.add(pushBOM_btn); // panel.add(pushBOM_btn);
// 变压器BOM确认调整 // 变压器BOM确认调整
JPanel panelt = new JPanel(new BorderLayout()); JPanel panelt = new JPanel(new BorderLayout());

@ -1,15 +1,21 @@
package com.connor.chint.sap2.sap_by; package com.connor.chint.sap2.sap_by;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
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 com.alibaba.fastjson2.JSONArray;
import com.connor.chint.sap2.sap.SAPPushBOMBean; import com.connor.chint.sap2.sap.SAPPushBOMBean;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil; import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.TXTUtil; import com.connor.chint.sap2.util.TXTUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
@ -191,6 +197,7 @@ public class SAPZZDialogController {
dialog.t_part.repaint(); dialog.t_part.repaint();
} }
@SuppressWarnings("deprecation")
public void sendToSap() throws Exception { public void sendToSap() throws Exception {
List<ZZPartBean> selectedParts = getSelectedParts(); List<ZZPartBean> selectedParts = getSelectedParts();
int len = selectedParts == null ? 0 : selectedParts.size(); int len = selectedParts == null ? 0 : selectedParts.size();
@ -281,5 +288,83 @@ public class SAPZZDialogController {
} }
return selectedParts; return selectedParts;
} }
// 获取传递BOM中最大的序列
private int getCode() throws SQLException {
String sql = "select Tab_SendBom_Sequence.nextval as sid from dual";
ResultSet rs = SqlUtil.read(sql);
// Object objs[] = new Object[1];
int code = 0;
if (rs.next()) {
code = rs.getInt(1);
System.out.println("code:" + code);
}
SqlUtil.free();
return code;
}
// 第二次优化异步传递
protected void sendToSapYHAsyn(String ban, boolean isCheckProduct) throws Exception {
List<ZZPartBean> selectedParts = getSelectedParts();
MyProgressBarCompent my = new MyProgressBarCompent("", "智能电气BOM传递SAP......");
try {
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
String groupID2 = SAPUtil.getGroupID();
String userId = session.getUser().getUserId();
String userName = session.getUser().getProperty("user_name");
String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
String zt2_WBSNo = project.getStringProperty("zt2_WBSNo");
String object_name = project.getStringProperty("object_name");
int code = getCode();
JSONArray array = new JSONArray();
StringBuilder uids = new StringBuilder("");
for (int i = 0; i < selectedParts.size(); i++) {
String uid = selectedParts.get(i).part.getUid();
array.add(uid);
uids.append(uid).append(":");
}
// obj.put("uid", array);
// OkHttpClient client = new OkHttpClient();
String substring = uids.substring(0, uids.length() - 1);
// 新增字段 项目UID执行人改成定时执行不调用接口
String serverHostname = session.getServerHostname();
System.out.println("serverHostname===>" + serverHostname);
String sql = "insert into CHINT_BOM_TO_SAP_SUM (code,factory,\"USER\",starttime,wbsno,projectno,taskstauts"
+ ",plmresult,transfer,keymsg,sapresult,PROJECTUID,SERVERHOST,USERID) values "
+ "(?,?,?,to_date(?,'yyyy-mm-ddhh24:mi:ss')" + ",?,?,'等待组织','未处理',?,?,'未返回',?,?,?)"; // to_date(?,'yyyy-mm-ddhh24:mi:ss')
SqlUtil.write(sql, new String[] { code + "", groupID2, userName, dataTime, zt2_WBSNo, object_name,
ban.replaceAll("方案传递", ""), substring, project.getUid(), serverHostname, userId });
// MediaType mediaType = MediaType.parse("application/json");
// RequestBody body = RequestBody.create(mediaType, obj.toString());
//// String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session);
// Request request = new Request.Builder().url("http://10.128.10.203:8081/plm/sendBomXB") // http://10.128.10.203:8081/plm/sendBomXB
// .method("POST", body)
// // .addHeader("Cookie", "")
//// .addHeader("Authorization", "Bearer "+token)
// // .addHeader("Connection", "keep-alive")
// .addHeader("Content-Type", "application/json").build();
// Response response = client.newCall(request).execute();
// // response.body().byteStream()
// // System.out.println(response.body().string());
// String string = response.body().string();
// System.out.println("string==>" + string);
// JSONObject parseObject = JSON.parseObject(string);
//
// my.setVisible(false);
// System.out.println("parseObject==>" + parseObject);
MessageBox.post(dialog, "传递请求已记录,请等待飞书通知.", "", MessageBox.INFORMATION);
} catch (Exception e) {
MessageBox.post(dialog, "发生错误:" + e.getMessage(), "", MessageBox.ERROR);
e.printStackTrace();
my.setVisible(false);
} finally {
SqlUtil.freeAll();
my.setVisible(false);
}
}
} }

@ -226,4 +226,46 @@ public class BomToSapUtil {
} }
return bomLineMap; return bomLineMap;
} }
/**
* SOABOMStructureManagement
* @param bomLine BOM
* @param structureService StructureManagement
* @return BOMuid
*/
public static Map<String, ExpandPSData[]> getBomLineTreeNodeSOA(TCComponentBOMLine bomLine, StructureManagement structureService) {
long startTime = System.currentTimeMillis();
// List<String> bomLineNodes = list;
//预定义BOM父子对map及ItemRev map
Map<String, ExpandPSData[]> bomLineMap = new HashMap<>();
// Map<String, TCComponentItemRevision> bomLineItemRevMap = new HashMap();
try {
// 调用SOA方法批量展开BOM
// com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(RACUIUtil.getTCSession());
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo();
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref();
levelInfo.parentBomLines = new TCComponentBOMLine[] { bomLine }; //输入顶层BOMLine对象
levelInfo.excludeFilter = "None";//zt2_BOMMaterial
levelPref.expItemRev = false;
levelPref.info = new com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelationAndTypesFilter[0];
// levelPref.info[0].relationName = "";
System.out.println("getBomLineTreeNodeSOA1:" + (System.currentTimeMillis() - startTime) / 1000);
//使用以下方法展开完整的BOM行
com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = structureService.expandPSAllLevels(levelInfo, levelPref);
System.out.println("getBomLineTreeNodeSOA2:" + (System.currentTimeMillis() - startTime) / 1000);
if (levelResp.output.length > 0) {
//将BOM构建成uid父子对关系
for (ExpandPSAllLevelsOutput data : levelResp.output) {
ExpandPSData[] children = data.children;
TCComponentBOMLine parentBomLine = (TCComponentBOMLine) data.parent.bomLine;
bomLineMap.put(parentBomLine.getUid(), children);
}
}
System.out.println("getBomLineTreeNodeSOA3:" + (System.currentTimeMillis() - startTime) / 1000);
} catch (Exception e) {
e.printStackTrace();
}
return bomLineMap;
}
} }

@ -86,6 +86,7 @@ import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues; import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType; import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
import com.teamcenter.rac.kernel.TCComponentQuery; import com.teamcenter.rac.kernel.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType; import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCComponentRevisionRule; import com.teamcenter.rac.kernel.TCComponentRevisionRule;
@ -2203,4 +2204,30 @@ public class KUtil {
t_part.setValueAt(i + 1, i, 0); t_part.setValueAt(i + 1, i, 0);
} }
} }
/**
*
*
* @param parent
* @param relation
* @return
*/
public static TCComponentPseudoFolder getPseudoFolder(TCComponent parent, String relation) throws Exception {
TCComponentPseudoFolder pseudoFolder = null;
AIFComponentContext[] comps = parent.getChildren();
if (comps != null && comps.length > 0 && comps[0] != null) {
for (int i = 0; i < comps.length; i++) {
TCComponent comp = (TCComponent) comps[i].getComponent();
if (comp instanceof TCComponentPseudoFolder) {
if (comp.isTypeOf("PseudoFolder")) {
// System.out.println("PseudoFolder type:" + comp.getDefaultPasteRelation());
if (comp.getDefaultPasteRelation().equalsIgnoreCase(relation)) {
pseudoFolder = (TCComponentPseudoFolder) comp;
break;
}
}
}
}
}
return pseudoFolder;
}
} }

@ -5449,7 +5449,7 @@ public class SAPUtil {
} }
/* /*
* TODO *
*/ */
public static void recurSAP2(TCComponentBOMLine line, TCComponentItemRevision rev, TCComponentItemRevision partRev, public static void recurSAP2(TCComponentBOMLine line, TCComponentItemRevision rev, TCComponentItemRevision partRev,
boolean isStruct, TCSession session, String groupName, String now, String txtPath, boolean isStruct, TCSession session, String groupName, String now, String txtPath,
@ -6505,5 +6505,56 @@ public class SAPUtil {
} }
return null; return null;
} }
/**
*
*
* @param uid
* @param group
* @param session session
* @return
* @throws Exception
*/
public static TCComponent getMeprocesYh(String uid, String group, TCSession session) throws Exception {
// String sql = SAPUtil.sqlRef.replace("\\?", "'" + uid + "'");
String sql = "select P.puid as supItemUID,V.puid as supRevUID,P.pitem_id as supItemID,ITRO.Pobject_Name as supItemName,"
+ "V.Pitem_Revision_Id as supRevID,cP.pitem_id as subItemID,cV.puid as subRevUID,RT.partifactname as 版本与版本关系 "
+ "from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g "
+ "where g.puid=V.puid and V.Puid = R.Rprimary_Objectu and r.rrelation_typeu = RT.puid and P.Puid = V.Ritems_Tagu and ITRO.Puid = V.Puid "
+ "and R.Rsecondary_Objectu = cV.Puid and cP.Puid = cV.Ritems_Tagu and cV.Puid = cITRO.Puid and ITRO.Pactive_Seq<>0 "
+ "and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "' and cV.PUID = '" + uid + "'";
try {
ResultSet read = SqlUtil.read(sql);//SAPUtil.sqlRef, new Object[] { uid }
// boolean next = read.next();
while (read.next()) {
String string = read.getString("supRevUID");
TCComponent mpComp = session.stringToComponent(string);
// TCComponent mpComp = SAPUtil.getSameGroupProcYH(meops, session);
if(mpComp != null) {
// mepMap.put(uid, mpComp);
// SqlUtil.free();
return mpComp;
}
}
// SqlUtil.free();
}catch(Exception e) {
System.out.println("sql==>" + sql);
e.printStackTrace();
}
return null;
}
/**
*
*
* @param array
* @param str
* @return
*/
public static boolean contains(Object[] array, Object str) {
for(Object s : array) {
// System.out.println("contains:"+s+"="+str);
if(s.equals(str))
return true;
}
return false;
}
} }

@ -705,9 +705,9 @@ public class SqlUtil {
*/ */
public final static ResultSet read(String sql, Object[] argments) throws SQLException { public final static ResultSet read(String sql, Object[] argments) throws SQLException {
PreparedStatement ps = SqlUtil.getPs(argments, sql); PreparedStatement ps = SqlUtil.getPs(argments, sql);
System.out.println("read1"); // System.out.println("read1");
SqlUtil.rs = ps.executeQuery(); SqlUtil.rs = ps.executeQuery();
System.out.println("read2"); // System.out.println("read2");
return SqlUtil.rs; return SqlUtil.rs;
} }
@ -872,4 +872,46 @@ public class SqlUtil {
} }
return connection; return connection;
} }
public static Connection SRMGetTCDataConnection(String[] prefs) {
// System.out.println("getTCDataConnection(String[] prefs)");
String driver = reg.getString("SQL.TCDATA.DRIVER");
String url = reg.getString("SQL.TCDATA.URL");
String user = reg.getString("SQL.TCDATA.USER");
String password = reg.getString("SQL.TCDATA.PASSWORD");
if (prefs != null) {
url = "jdbc:oracle:thin:@" + prefs[5] + ":" + prefs[3] + ":" + prefs[4];
user = prefs[1];
password = prefs[2];
}
// System.out.println("连接数据库信息:");
// System.out.println("DRIVER: " + driver);
// System.out.println("URL: " + url);
// System.out.println("USER: " + user);
if (connection != null) {
try {
connection.close();
} catch (Exception e1) {
e1.printStackTrace();
}
connection = null;
}
try {
// 加载驱动程序
Class.forName(driver);
// 1.getConnection()方法连接MySQL数据库
connection = DriverManager.getConnection(url, user, password);
connection.setAutoCommit(false);
} catch (ClassNotFoundException e) {
// 数据库驱动类异常处理
System.out.println("未找到数据库驱动");
e.printStackTrace();
} catch (SQLException e) {
// 数据库连接失败异常处理
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return connection;
}
} }

@ -262,9 +262,15 @@ public class TableBuilder {
//查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。 //查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。
sql.append(" and \"GoodsFullInfo\" not like '%停用%'"); sql.append(" and \"GoodsFullInfo\" not like '%停用%'");
} }
System.out.println("SQL:" + sql); System.out.println("SQL1:\n" + sql);
ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", String sql2 = sql.toString();//.replace("?", "'" + input + "'") + " order by \"GoodsUsed\"";
params.toArray(new Object[] {})); for(String s : params) {
sql2 = sql2.replaceFirst("\\?", "'" + s + "'");
}
sql2 += " order by \"GoodsUsed\"";
System.out.println("SQL2:\n" + sql2);
ResultSet rs = SqlUtil.read(sql2);//, params.toArray(new Object[] {})
while (rs.next()) { while (rs.next()) {
System.out.println("rs:" + rs.getRow()); System.out.println("rs:" + rs.getRow());
TableBean bean = new TableBean(rs.getString(1), ind_index); TableBean bean = new TableBean(rs.getString(1), ind_index);
@ -301,10 +307,18 @@ public class TableBuilder {
//查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。 //查询界面增加“停用”勾选项默认不勾选进行模糊查询时自动过滤掉“GoodsFullInfo”中包含“停用”的物料若勾选则不过滤。
sql.append(" and \"GoodsFullInfo\" not like '%停用%'"); sql.append(" and \"GoodsFullInfo\" not like '%停用%'");
} }
System.out.println("SQL:" + sql); System.out.println("SQL1:" + sql);
System.out.println("PARAMS:" + params); System.out.println("PARAMS:" + params);
ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", params.toArray(new Object[] {})); String sql2 = sql.toString();//.replace("?", "'" + input + "'") + " order by \"GoodsUsed\"";
for(String s : params) {
sql2 = sql2.replaceFirst("\\?", "'" + s + "'");
}
sql2 += " order by \"GoodsUsed\"";
System.out.println("SQL2:\n" + sql2);
// ResultSet rs = SqlUtil.read(sql.toString() + " order by \"GoodsUsed\"", params.toArray(new Object[] {}));
ResultSet rs = SqlUtil.read(sql2);
System.out.println("index:" + index + " <---> cnt:" + cnt); System.out.println("index:" + index + " <---> cnt:" + cnt);
while (rs.next()) { while (rs.next()) {
System.out.println("rs:" + rs.getRow()); System.out.println("rs:" + rs.getRow());

Loading…
Cancel
Save