20240911分发代码上传

master
李冬阳 9 months ago
parent 167f989baf
commit d0f3c58b6f

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="poi/neethi-3.0.2.jar"/>
<classpathentry exported="true" kind="lib" path="poi/backport-util-concurrent-3.1.jar"/>
<classpathentry exported="true" kind="lib" path="poi/axiom-dom-1.2.7.jar"/>
<classpathentry exported="true" kind="lib" path="poi/okhttp-2.7.4.jar"/> <classpathentry exported="true" kind="lib" path="poi/okhttp-2.7.4.jar"/>
<classpathentry exported="true" kind="lib" path="poi/okio-1.13.0.jar"/> <classpathentry exported="true" kind="lib" path="poi/okio-1.13.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mysql-connector-java-8.0.12.jar"/> <classpathentry exported="true" kind="lib" path="lib/mysql-connector-java-8.0.12.jar"/>
@ -54,5 +57,7 @@
<classpathentry kind="lib" path="poi/axiom-api-1.2.7.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="poi/axis2-kernel-1.4.1.jar"/>
<classpathentry kind="lib" path="json_lib/jfxrt.jar"/> <classpathentry kind="lib" path="json_lib/jfxrt.jar"/>
<classpathentry kind="lib" path="poi/XmlSchema-1.4.7.jar"/>
<classpathentry kind="lib" path="poi/axiom-impl-1.2.7.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

@ -80,7 +80,14 @@ Bundle-ClassPath: .,
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 json_lib/jfxrt.jar,
poi/axiom-dom-1.2.7.jar,
poi/axiom-api-1.2.7.jar,
poi/axis2-kernel-1.4.1.jar,
poi/XmlSchema-1.4.7.jar,
poi/axiom-impl-1.2.7.jar,
poi/backport-util-concurrent-3.1.jar,
poi/neethi-3.0.2.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,

@ -32,7 +32,14 @@ bin.includes = plugin.xml,\
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 json_lib/jfxrt.jar,\
poi/axiom-dom-1.2.7.jar,\
poi/axiom-api-1.2.7.jar,\
poi/axis2-kernel-1.4.1.jar,\
poi/XmlSchema-1.4.7.jar,\
poi/axiom-impl-1.2.7.jar,\
poi/backport-util-concurrent-3.1.jar,\
poi/neethi-3.0.2.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,\

@ -112,8 +112,8 @@
<!--物料管理--> <!--物料管理-->
<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"/>
@ -139,6 +139,7 @@
<command name="编码清单查询" id="com.connor.chint.sap2.commands.DesignQueryCommand"/> <command name="编码清单查询" id="com.connor.chint.sap2.commands.DesignQueryCommand"/>
<command name="整体BOM传递SAP" id="com.connor.chint.sap2.commands.SAPZYZTCommand"/> <command name="整体BOM传递SAP" id="com.connor.chint.sap2.commands.SAPZYZTCommand"/>
<command name="批量导入工艺路线与工时" id="com.connor.chint.sap2.gylxgs.GylxGsBatchImportCommand"/> <command name="批量导入工艺路线与工时" id="com.connor.chint.sap2.gylxgs.GylxGsBatchImportCommand"/>
<command name="部件BOM传递SAP异步" id="com.connor.chint.sap2.commands.SAPBJYBCommand"/>
<!--报表导出--> <!--报表导出-->
<command name="项目方案清单导出" id="com.connor.chint.sap2.commands.ExportCommand#Proposal"/> <command name="项目方案清单导出" id="com.connor.chint.sap2.commands.ExportCommand#Proposal"/>
@ -388,7 +389,7 @@
<handler commandId="com.connor.chint.sap2.commands.WLQGSAPCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.WLQGSAPCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SAPZZCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.SAPZZCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.MaterialAssignCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.MaterialAssignCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" class="com.connor.chint.sap2.KHandler"/> <!--handler commandId="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" class="com.connor.chint.sap2.KHandler"/-->
<handler commandId="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.SelfMPartNoBatchCommand" class="com.connor.chint.sap2.KHandler"/>
@ -467,6 +468,7 @@
<handler commandId="com.connor.chint.sap2.commands.ExportCommand#EEDrawing" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.ExportCommand#EEDrawing" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SAPZYZTCommand" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.commands.SAPZYZTCommand" class="com.connor.chint.sap2.KHandler"/>
<handler commandId="com.connor.chint.sap2.commands.SAPBJYBCommand" class="com.connor.chint.sap2.KHandler"/>
<!--高压开关--> <!--高压开关-->
<handler commandId="com.connor.chint.sap2.gk.commands.AProjectNoCommand#ZDK008" class="com.connor.chint.sap2.KHandler"/> <handler commandId="com.connor.chint.sap2.gk.commands.AProjectNoCommand#ZDK008" class="com.connor.chint.sap2.KHandler"/>
@ -2062,7 +2064,7 @@
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<!-- <!---->
<command commandId = "com.connor.chint.sap2.createKjBom.CreateKjBomCommand" id = "com.connor.chint.sap2.menu.cgdexport"> <command commandId = "com.connor.chint.sap2.createKjBom.CreateKjBomCommand" id = "com.connor.chint.sap2.menu.cgdexport">
<visibleWhen> <visibleWhen>
<and> <and>
@ -2079,7 +2081,7 @@
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command>--> </command>
</menuContribution> </menuContribution>
@ -4061,7 +4063,7 @@
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" id = "com.connor.chint.sap2.menu.wlgl.zzjbmplsq#GCT"> <!--command commandId = "com.connor.chint.sap2.commands.SelfMPartNoBatchCommand#GCT" id = "com.connor.chint.sap2.menu.wlgl.zzjbmplsq#GCT">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
@ -4081,7 +4083,7 @@
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command-->
<command commandId = "com.connor.chint.sap2.commands.MaterialQueryCommand" id = "com.connor.chint.sap2.commands.MaterialQueryCommand"> <command commandId = "com.connor.chint.sap2.commands.MaterialQueryCommand" id = "com.connor.chint.sap2.commands.MaterialQueryCommand">
<visibleWhen> <visibleWhen>
<and> <and>
@ -4685,8 +4687,30 @@
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<!-->
<command commandId = "com.connor.chint.sap2.commands.SAPBJYBCommand" id = "com.connor.chint.sap2.menu.SAPBJYBCommand">
<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.connor.chint.sap2.commands.SAPBJYBCommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<!--><!--> <!-->
<command commandId = "com.chint.plm.createEcn.CreateEcnCommond" id = "com.chint.plm.createEcn.CreateEcnCommond"> <command commandId = "com.chint.plm.createEcn.CreateEcnCommond" id = "com.chint.plm.createEcn.CreateEcnCommond">
<visibleWhen> <visibleWhen>
<and> <and>
@ -4730,6 +4754,28 @@
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.sap2.gykg.commands.CreateEDCGYommand" id = "com.connor.chint.sap2.gykg.menu.createECNGY">
<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.connor.chint.sap2.gykg.commands.CreateEDCGYommand">
</equals>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId = "com.connor.chint.sap2.projectTest.VersionCommand" id = "com.connor.chint.sap2.menu.distributionversion"> <command commandId = "com.connor.chint.sap2.projectTest.VersionCommand" id = "com.connor.chint.sap2.menu.distributionversion">
<visibleWhen> <visibleWhen>
<and> <and>

@ -40,14 +40,18 @@ import java.util.Map;
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.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.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.aifrcp.AIFUtility; import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList; import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentGroup; import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentGroupMember;
import com.teamcenter.rac.kernel.TCComponentGroupType; import com.teamcenter.rac.kernel.TCComponentGroupType;
import com.teamcenter.rac.kernel.TCComponentProject; import com.teamcenter.rac.kernel.TCComponentProject;
import com.teamcenter.rac.kernel.TCComponentProjectType; import com.teamcenter.rac.kernel.TCComponentProjectType;
@ -57,10 +61,12 @@ 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 javafx.application.Platform;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
@ -80,6 +86,7 @@ import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class RdmCreateController extends KFXPanelController { public class RdmCreateController extends KFXPanelController {
@ -90,7 +97,7 @@ public class RdmCreateController extends KFXPanelController {
private String[] prefs = null; private String[] prefs = null;
private double paneWidth; private double paneWidth;
private double paneHight; private double paneHight;
TCComponentFolder folder = null;
@FXML @FXML
private Button cxButton; private Button cxButton;
@ -195,6 +202,27 @@ public class RdmCreateController extends KFXPanelController {
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
this.prefs = session.getPreferenceService().getStringValues("CHINT_SRM_SQL_CONNECT"); this.prefs = session.getPreferenceService().getStringValues("CHINT_SRM_SQL_CONNECT");
InterfaceAIFComponent targetComponent = app.getTargetComponent();
System.out.println("targetComponent=============="+targetComponent.getType());
if(targetComponent == null || !(targetComponent instanceof TCComponentFolder)) {
Platform.runLater(new Runnable() {
@Override
public void run() {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示");
alert.setHeaderText("请选择公共文件夹类型!");
//alert.setContentText("导入完成");
alert.showAndWait();
}
});
return;
}
folder = (TCComponentFolder) targetComponent;
System.out.println("===============开始连接tc数据库==============="); System.out.println("===============开始连接tc数据库===============");
frame = (RdmCreateFrame) paramKFXPanel.getParentDialog(); frame = (RdmCreateFrame) paramKFXPanel.getParentDialog();
addWindListener(frame); addWindListener(frame);
@ -212,12 +240,16 @@ public class RdmCreateController extends KFXPanelController {
//根据首选项初始化table //根据首选项初始化table
String[] chint_tcproject_result_rule = session.getPreferenceService().getStringValues("CHINT_TCPROJECT_RESULT_RULE"); String[] chint_tcproject_result_rule = session.getPreferenceService().getStringValues("CHINT_TCPROJECT_RESULT_RULE");
if(chint_tcproject_result_rule == null || chint_tcproject_result_rule.length <= 0) { if(chint_tcproject_result_rule == null || chint_tcproject_result_rule.length <= 0) {
Platform.runLater(new Runnable() {
@Override
public void run() {
Alert alert = new Alert(AlertType.INFORMATION); Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示"); alert.setTitle("提示");
alert.setHeaderText("请正确配置“CHINT_TCPROJECT_RESULT_RULE”首选项"); alert.setHeaderText("请正确配置“CHINT_TCPROJECT_RESULT_RULE”首选项");
//alert.setContentText("导入完成"); //alert.setContentText("导入完成");
alert.showAndWait(); alert.showAndWait();
return; }
});
} }
for (int i = 0; i < chint_tcproject_result_rule.length; i++) { for (int i = 0; i < chint_tcproject_result_rule.length; i++) {
String[] split = chint_tcproject_result_rule[i].split(":"); String[] split = chint_tcproject_result_rule[i].split(":");
@ -404,7 +436,7 @@ public class RdmCreateController extends KFXPanelController {
.getTypeComponent("User"); .getTypeComponent("User");
TCComponentGroupType groupType = (TCComponentGroupType) session.getTypeComponent("Group"); TCComponentGroupType groupType = (TCComponentGroupType) session.getTypeComponent("Group");
StringBuffer sbInfo = new StringBuffer(); StringBuffer sbInfo = new StringBuffer();
MyProgressBarCompent comp = new MyProgressBarCompent("", "正在进行创建...");
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
RdmCreateBean rdmCreateBean = items.get(i); RdmCreateBean rdmCreateBean = items.get(i);
boolean selected = rdmCreateBean.getCheckBox().isSelected(); boolean selected = rdmCreateBean.getCheckBox().isSelected();
@ -413,10 +445,11 @@ public class RdmCreateController extends KFXPanelController {
List<TCComponentUser> members = new ArrayList();//指派的用户id List<TCComponentUser> members = new ArrayList();//指派的用户id
List<String> exitUserName = new ArrayList();//存在的用户名称 List<String> exitUserName = new ArrayList();//存在的用户名称
List<String> notExitUserName = new ArrayList();//不存在的用户名称 List<String> notExitUserName = new ArrayList();//不存在的用户名称
List<TCComponent> groupMembers = new ArrayList<>();//
//判断tc是否已经创建过项目 //判断tc是否已经创建过项目
Map<String, String> field = new HashMap<String, String>(); Map<String, String> field = new HashMap<String, String>();
String ordernumber = rdmCreateBean.getOrdernumber().getText(); String ordernumber = rdmCreateBean.getOrdernumber().getText();
String id = ordernumber+"-"+rdmCreateBean.getProjectno().getText(); String id = ordernumber+"-"+rdmCreateBean.getProjectname().getText();
System.out.println("id="+id); System.out.println("id="+id);
field.put("ordernumber", ordernumber); field.put("ordernumber", ordernumber);
TCComponentContextList contxt = KUtil.query(session, "chint_query_tcproject", field); TCComponentContextList contxt = KUtil.query(session, "chint_query_tcproject", field);
@ -429,12 +462,26 @@ public class RdmCreateController extends KFXPanelController {
ResultSet res = SqlUtil.read(selectSql); ResultSet res = SqlUtil.read(selectSql);
//处理查询数据结果集
while (res.next()) { while (res.next()) {
TCComponentUser userT = null; TCComponentUser userT = null;
try { try {
System.out.println("res.getString(1)=="+res.getString(1)); System.out.println("res.getString(1)=="+res.getString(1));
userT = userType.find(res.getString(1)); userT = userType.find(res.getString(1));
TCComponentGroupMember[] gms = userT.getGroupMembers();
for (int j = 0; j < gms.length; j++) {
TCComponentGroupMember gm = gms[j];
String gr = gm.getGroup().getTCProperty("name").getStringValue();
System.out.println("gr======================"+gr);
if (gr.equals(res.getString(3))) {
groupMembers.add(gm);
break;
}
}
}catch (Exception e) { }catch (Exception e) {
// TODO: handle exception // TODO: handle exception
notExitUserName.add(res.getString(2));//找不到人报错 notExitUserName.add(res.getString(2));//找不到人报错
@ -455,6 +502,41 @@ public class RdmCreateController extends KFXPanelController {
} }
} }
TCComponent[] groupMemberArray = groupMembers.toArray(new TCComponent[] {});
//处理查询数据结果集
// 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) { // if(members.size() <= 0) {
// sbInfo.append("项目创建失败:内部订单号:"+ordernumber+"项目ID为"+id+lineSeparator); // sbInfo.append("项目创建失败:内部订单号:"+ordernumber+"项目ID为"+id+lineSeparator);
@ -475,10 +557,16 @@ public class RdmCreateController extends KFXPanelController {
//把自己加进去 //把自己加进去
members.add(user); members.add(user);
exitUserName.add(session.getUserName()); 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 = projecttype.create(id, proj = projecttype.create(id,
id, "", id, "",
(TCComponent[])members.toArray( groupMemberArray, user,//把人员指派到项目
new TCComponent[members.size()]), user,//把人员指派到项目
(TCComponentUser[])members.toArray( (TCComponentUser[])members.toArray(
new TCComponentUser[members.size()])); new TCComponentUser[members.size()]));
@ -521,6 +609,7 @@ public class RdmCreateController extends KFXPanelController {
} }
sbInfo.append(lineSeparator); sbInfo.append(lineSeparator);
sbInfo.append(lineSeparator); sbInfo.append(lineSeparator);
folder.add("ZT2_SmartFolderRelation",proj);
}else { }else {
//获取查询查到的项目 //获取查询查到的项目
TCComponentProject proj = (TCComponentProject)contxt.get(0).getComponent(); TCComponentProject proj = (TCComponentProject)contxt.get(0).getComponent();
@ -546,23 +635,32 @@ public class RdmCreateController extends KFXPanelController {
// TODO: handle exception // TODO: handle exception
e.printStackTrace(); e.printStackTrace();
} }
try {
folder.add("ZT2_SmartFolderRelation",proj);
} catch (Exception e) {
// TODO: handle exception
}
} }
} }
} }
if (comp != null) {
comp.setVisible(false);
}
if(count == 0) { if(count == 0) {
Alert alert = new Alert(AlertType.INFORMATION); Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示"); alert.setTitle("提示");
alert.setHeaderText("请勾选数据!"); alert.setHeaderText("请勾选数据!");
//alert.setContentText("导入完成"); //alert.setContentText("导入完成");
alert.showAndWait(); alert.showAndWait();
}else { }else {
Alert alert = new Alert(AlertType.INFORMATION); Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("提示"); alert.setTitle("提示");
alert.setHeaderText(sbInfo.toString()); alert.setHeaderText(sbInfo.toString());
//alert.setContentText("导入完成"); //alert.setContentText("导入完成");
alert.showAndWait(); alert.showAndWait();
frame.dispose();
} }
} }
@ -601,7 +699,10 @@ public class RdmCreateController extends KFXPanelController {
alert.setHeaderText("项目关闭完成!"); alert.setHeaderText("项目关闭完成!");
//alert.setContentText("导入完成"); //alert.setContentText("导入完成");
alert.showAndWait(); alert.showAndWait();
frame.dispose();
} }
} }
//查询 //查询
@ -709,6 +810,7 @@ public class RdmCreateController extends KFXPanelController {
alert.setHeaderText("未查到数据!"); alert.setHeaderText("未查到数据!");
//alert.setContentText("导入完成"); //alert.setContentText("导入完成");
alert.showAndWait(); alert.showAndWait();
} }
} }

@ -11,11 +11,17 @@ import org.eclipse.core.commands.ExecutionEvent;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentFolder;
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 javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
/** /**
* ³É±¾µ¥¹ÜÀí * ³É±¾µ¥¹ÜÀí
* @author admin * @author admin
@ -63,8 +69,26 @@ public class RdmCreateHandler extends AbstractHandler{
return; return;
} }
InterfaceAIFComponent targetComponent = app.getTargetComponent();
String type = "";
if(targetComponent != null) {
System.out.println("targetComponent=============="+targetComponent.getType());
type = targetComponent.getType();
}
if(type == null || type.isEmpty() || !type.equals("ZT2_ProjectFolder")) {
MessageBox.post("请选择公共文件夹类型!", "提示", MessageBox.INFORMATION);
return;
}else {
new RdmCreateFrame(); new RdmCreateFrame();
} }
}
}.start(); }.start();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

@ -1,14 +1,31 @@
package com.connor.chint.sap2.commands; package com.connor.chint.sap2.commands;
import com.connor.chint.sap2.KCommand; import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.materialno.FactoryChooseDialog;
import com.connor.chint.sap2.materialno.MaterialNoDialog; import com.connor.chint.sap2.materialno.MaterialNoDialog;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class MaterialNoCommand extends KCommand { public class MaterialNoCommand extends KCommand {
public MaterialNoCommand(AbstractAIFApplication app, String commandId, String actionInfo) { public MaterialNoCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo); super(app, commandId, actionInfo);
this.setRunnable(new MaterialNoDialog(app)); try {
TCSession session = (TCSession) app.getSession();
String groupID = SAPUtil.getGroupID(session);
String[] factorys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_FACTORY_RULE", session);
if(SAPUtil.contains(factorys, groupID)) {
new FactoryChooseDialog(app, session, "no");
}else {
this.setRunnable(new MaterialNoDialog(app, session, groupID));
}
} catch (Exception e) {
e.printStackTrace();
MessageBox.post("´íÎó£º" + e, "", MessageBox.ERROR);
}
// KUtil.setByPass(false); // KUtil.setByPass(false);
} }

@ -0,0 +1,54 @@
package com.connor.chint.sap2.commands;
import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.sap.SAPBJYBOperation;
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;
/**
* : SAP
* :2024-09-06
* @author
*
*
* 2024-09-06
*/
public class SAPBJYBCommand extends KCommand {
public SAPBJYBCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
}
@Override
public void executeModal() {
try {
TCSession session = (TCSession) app.getSession();
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_TYBOMTOSAP", session);
String groupID = SAPUtil.getGroupID(session);
String fa = "";
for(String pref:prefs) {
String[] split = pref.split(":");
String type = split[0];
String[] split2 = split[1].split(";");
for(String grpId : split2) {
if(grpId.equals(groupID)) {
fa = type;
break;
}
}
}
System.out.println("fa==>" + fa);
if(fa.equals("B") || fa.equals("D") || fa.equals("C")) {
new SAPBJYBOperation(app, session, groupID, fa).executeOperation();
}else if(fa.equals("A") || fa.equals("E")) {
MessageBox.post("当前组不可使用该功能", "警告", MessageBox.INFORMATION);
}
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e);
}
}
}

@ -1,9 +1,17 @@
package com.connor.chint.sap2.commands; package com.connor.chint.sap2.commands;
import javax.swing.JOptionPane;
import com.chint.plm.applyMatnr.ApplyMatnrOp;
import com.chint.plm.applyMatnr.ApplyMatnrOp2;
import com.connor.chint.sap2.KCommand; import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.materialno.FactoryChooseDialog;
import com.connor.chint.sap2.operation.OutMPartNoBatchDialog; import com.connor.chint.sap2.operation.OutMPartNoBatchDialog;
import com.connor.chint.sap2.operation.SelfMPartNoBatchOperation; import com.connor.chint.sap2.operation.SelfMPartNoBatchOperation;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
public class SelfMPartNoBatchCommand extends KCommand { public class SelfMPartNoBatchCommand extends KCommand {
@ -13,22 +21,47 @@ public class SelfMPartNoBatchCommand extends KCommand {
public SelfMPartNoBatchCommand(AbstractAIFApplication app, String commandId, String actionInfo) { public SelfMPartNoBatchCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo); super(app, commandId, actionInfo);
this.actionInfo = actionInfo; this.actionInfo = actionInfo;
} }
@Override @Override
public void executeModal() { public void executeModal() {
try { try {
TCSession session = (TCSession) app.getSession();
String groupID = SAPUtil.getGroupID(session);
if(groupID.equals("M060")) {
new Thread() {
public void run(){
try {
String[] array = new String[] { "全部图纸", "个人图纸" };
Object type = JOptionPane.showInputDialog(null, "请选择申请方式", "INFO",
JOptionPane.QUESTION_MESSAGE, null, array, array[0]);
if(type.equals("全部图纸")) {
new ApplyMatnrOp(app, "all").executeOperation();
}else {
new ApplyMatnrOp2(app, "user").executeOperation();
}
} catch (Exception e) {
e.printStackTrace();
MessageBox.post("错误:" + e, "", MessageBox.ERROR);
}
}
}.start();
}else {
String[] factorys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_FACTORY_RULE", session);
if(SAPUtil.contains(factorys, groupID)) {
new FactoryChooseDialog(app, session, actionInfo);
}else {
if ("M007_2".equals(actionInfo)) { if ("M007_2".equals(actionInfo)) {
System.out.println("Åä±äÍ⹺¼þÎïÁÏÉêÇë"); System.out.println("Åä±äÍ⹺¼þÎïÁÏÉêÇë");
new Thread(new OutMPartNoBatchDialog(app)).start(); new Thread(new OutMPartNoBatchDialog(app, groupID)).start();
} else { } else {
new SelfMPartNoBatchOperation(app, actionInfo).executeOperation(); new SelfMPartNoBatchOperation(app, actionInfo, groupID).executeOperation();
}
}
} }
} catch (Exception e) { } catch (Exception e) {
MessageBox.post(e);
e.printStackTrace(); e.printStackTrace();
MessageBox.post(e);
} }
} }

@ -22,8 +22,9 @@ public class CreateKjBomCommand extends KCommand {
try { try {
TCSession session = (TCSession)app.getSession(); TCSession session = (TCSession)app.getSession();
String groupID = SAPUtil.getGroupID(session);// String groupID = SAPUtil.getGroupID(session);
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_kjbomTemp", session); //变压器原首选项CHINT_kjbomTemp改为CHINT_kjbom_M005
String[] prefs = ChintPreferenceUtil.getPreferences("CHINT_kjbom_M005", session);
List<KjBean> kjList = new ArrayList<KjBean>(); List<KjBean> kjList = new ArrayList<KjBean>();
for(String pref : prefs) { for(String pref : prefs) {
// 1ZDB300000P-xxx|1ZDB300000P=2-组件布置图;1ZDB400000T=3-铁心图纸&H铁心 // 1ZDB300000P-xxx|1ZDB300000P=2-组件布置图;1ZDB400000T=3-铁心图纸&H铁心

@ -108,15 +108,15 @@ public class KjController {
byqCCPFromProject = getByqCCPFromProject(project, session); byqCCPFromProject = getByqCCPFromProject(project, session);
AIFComponentContext[] childFolders = xmzxFolder.getChildren(); AIFComponentContext[] childFolders = xmzxFolder.getChildren();
TCComponentFolder bztFolder = null; TCComponentFolder bztFolder = null;
TCComponentFolder dcsjFolder = null; // TCComponentFolder dcsjFolder = null;
for(AIFComponentContext context : childFolders) { for(AIFComponentContext context : childFolders) {
InterfaceAIFComponent c = context.getComponent(); InterfaceAIFComponent c = context.getComponent();
if(c instanceof TCComponentFolder) { if(c instanceof TCComponentFolder) {
String cName = c.getProperty("object_name"); String cName = c.getProperty("object_name");
if(cName.equals("2-组件布置图")) { if(cName.equals("2-组件布置图")) {
bztFolder = (TCComponentFolder)c; bztFolder = (TCComponentFolder)c;
}else if(cName.equals("1-电磁设计")) { // }else if(cName.equals("1-电磁设计")) {
dcsjFolder = (TCComponentFolder)c; // dcsjFolder = (TCComponentFolder)c;
} }
fodlers.put(cName, (TCComponentFolder)c); fodlers.put(cName, (TCComponentFolder)c);
} }
@ -131,6 +131,8 @@ public class KjController {
} }
} }
} }
//lidy20240909取消检查是否创建提前请购和主材采购
/*
TCComponentItem dcsjItem = null;; TCComponentItem dcsjItem = null;;
if(dcsjFolder != null) { if(dcsjFolder != null) {
AIFComponentContext[] children = dcsjFolder.getChildren(); AIFComponentContext[] children = dcsjFolder.getChildren();
@ -141,8 +143,7 @@ public class KjController {
dcsjItem = (TCComponentItem)component; dcsjItem = (TCComponentItem)component;
} }
} }
} }if(dcsjItem == null) {
if(dcsjItem == null) {
errBuff.append("当前项目中未创建物主材采购单,不允许创建框架BOM.\n"); errBuff.append("当前项目中未创建物主材采购单,不允许创建框架BOM.\n");
flag = false; flag = false;
}else { }else {
@ -166,7 +167,7 @@ public class KjController {
if(!KUtil.isTCM(KUtil.getRevBOMView(latestItemRevision))) { if(!KUtil.isTCM(KUtil.getRevBOMView(latestItemRevision))) {
errBuff.append("当前项目中物料提前请购单BOM视图版本未发布,不允许创建框架BOM.\n");flag = false; errBuff.append("当前项目中物料提前请购单BOM视图版本未发布,不允许创建框架BOM.\n");flag = false;
} }
} }*/
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session); String preference = ChintPreferenceUtil.getPreference("CHINT_PIUrl", session);
Request request = new Request.Builder() Request request = new Request.Builder()
@ -203,8 +204,8 @@ public class KjController {
} }
} }
if(!fodlers.containsKey(folderName)) { if(!fodlers.containsKey(folderName)) {
errBuff.append("项目执行下没有找到名称为:"+folderName+"的文件夹"); // errBuff.append("项目执行下没有找到名称为:"+folderName+"的文件夹");//lidy20240829去掉检查没有跳过
return false; // return false;
}else { }else {
fMap.put(bean.cId, fodlers.get(folderName)); fMap.put(bean.cId, fodlers.get(folderName));
} }
@ -384,6 +385,7 @@ public class KjController {
continue; continue;
classID = pref.substring(pref.indexOf("|") + 1); classID = pref.substring(pref.indexOf("|") + 1);
} }
System.out.println("classID==>" + classID);
if(classID.isEmpty()) { if(classID.isEmpty()) {
MessageBox.post(prefId + "未找到对应分类库", "提示", MessageBox.WARNING); MessageBox.post(prefId + "未找到对应分类库", "提示", MessageBox.WARNING);
}else }else

@ -5,6 +5,8 @@ import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.ResultSet; import java.sql.ResultSet;
import javax.swing.JButton; import javax.swing.JButton;
@ -12,6 +14,10 @@ import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import com.chint.plm.applyMatnr.ApplyMatnrOp;
import com.chint.plm.applyMatnr.ApplyMatnrOp2;
import com.connor.chint.sap2.operation.OutMPartNoBatchDialog;
import com.connor.chint.sap2.operation.SelfMPartNoBatchOperation;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
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;
@ -19,6 +25,14 @@ import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
/**
* :
* :2024-08-14
* @author
*
*
* 2024-08-27
*/
public class FactoryChooseDialog extends AbstractAIFDialog { public class FactoryChooseDialog extends AbstractAIFDialog {
/** /**
@ -26,11 +40,32 @@ public class FactoryChooseDialog extends AbstractAIFDialog {
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private AbstractAIFApplication app;
private TCSession session;
private String actionInfo;
private boolean update; private boolean update;
public FactoryChooseDialog(AbstractAIFApplication app, TCSession session, String groupID) { private JComboBox<String> j_Group;
private JPanel btnPanel;
private JButton okBtn;
private JButton allBtn;
private JButton userBtn;
private JButton cancelBtn;
/**
*
* @param app AbstractAIFApplication
* @param session TCSession
* @param batch
*/
public FactoryChooseDialog(AbstractAIFApplication app, TCSession session, String actionInfo) {
super(true); super(true);
try { try {
this.app = app;
this.session = session;
this.actionInfo = actionInfo;
boolean batch = !actionInfo.equals("no");
String[] database = ChintPreferenceUtil.getPreferences("database_tc", session); String[] database = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(database) == null) { if (SqlUtil.getTCDataConnection(database) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2); MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
@ -47,55 +82,45 @@ public class FactoryChooseDialog extends AbstractAIFDialog {
update = true; update = true;
} }
String[] applys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_LIST", session); String[] applys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_LIST", session);
JComboBox<String> j_Group = new JComboBox<>(); j_Group = new JComboBox<>();
j_Group.setSize(new Dimension(150, 30)); j_Group.setSize(new Dimension(250, 30));
j_Group.setPreferredSize(new Dimension(130, 30)); j_Group.setPreferredSize(new Dimension(230, 30));
j_Group.addItem(""); j_Group.addItem("");
for(String s : applys) { for(String s : applys) {
j_Group.addItem(s); j_Group.addItem(s);
} }
j_Group.setSelectedItem(defaultGroup); j_Group.setSelectedItem(defaultGroup);
JButton okBtn = new JButton("È·¶¨"); okBtn = new JButton("确定");
okBtn.setSize(new Dimension(100, 30)); okBtn.setSize(new Dimension(100, 30));
okBtn.setPreferredSize(new Dimension(90, 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(":")); if(batch) {
System.out.println("groupID:" + groupID); allBtn = new JButton("全部图纸");
//TODO allBtn.setSize(new Dimension(100, 30));
// new Thread(new MaterialNoDialog(app, session, groupID)).start(); allBtn.setPreferredSize(new Dimension(90, 30));
dispose();
userBtn = new JButton("个人图纸");
userBtn.setSize(new Dimension(100, 30));
userBtn.setPreferredSize(new Dimension(90, 30));
} }
});
JButton cancelBtn = new JButton("È¡Ïû"); cancelBtn = new JButton("取消");
cancelBtn.setSize(new Dimension(100, 30)); cancelBtn.setSize(new Dimension(100, 30));
cancelBtn.setPreferredSize(new Dimension(90, 30)); cancelBtn.setPreferredSize(new Dimension(90, 30));
cancelBtn.addActionListener(new ActionListener() {
@Override addActionListener(batch, user);
public void actionPerformed(ActionEvent arg0) {
SqlUtil.freeAll();
dispose();
}
});
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.add(new JLabel("请选择组织:")); panel.add(new JLabel("请选择组织:"));
panel.add(j_Group); panel.add(j_Group);
JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
if(batch && defaultGroup.startsWith("M060")) {
btnPanel.add(allBtn);
btnPanel.add(userBtn);
}else {
btnPanel.add(okBtn); btnPanel.add(okBtn);
}
btnPanel.add(cancelBtn); btnPanel.add(cancelBtn);
this.setPreferredSize(new Dimension(500, 300)); this.setPreferredSize(new Dimension(500, 300));
@ -112,4 +137,113 @@ public class FactoryChooseDialog extends AbstractAIFDialog {
MessageBox.post("错误:" + e, "", MessageBox.ERROR); MessageBox.post("错误:" + e, "", MessageBox.ERROR);
} }
} }
private void addActionListener(boolean batch, String user) {
if(batch) {
j_Group.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent arg0) {
if(arg0.getItem().toString().startsWith("M060")) {
//如果选了M060需要按武汉的逻辑选择个人还是全部
btnPanel.removeAll();
btnPanel.add(allBtn);
btnPanel.add(userBtn);
btnPanel.add(cancelBtn);
}else {
btnPanel.removeAll();
btnPanel.add(okBtn);
btnPanel.add(cancelBtn);
}
}
});
//TODO
allBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
try {
String groupID = j_Group.getSelectedItem().toString();
if(groupID.isEmpty()) {
MessageBox.post(FactoryChooseDialog.this, "请选择组织", "", MessageBox.WARNING);
return;
}
groupID = updateGroup(groupID, user);
new ApplyMatnrOp(app, "all").executeOperation();
dispose();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(FactoryChooseDialog.this, "错误:" + e, "", MessageBox.ERROR);
}
}
});
userBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
try {
String groupID = j_Group.getSelectedItem().toString();
if(groupID.isEmpty()) {
MessageBox.post(FactoryChooseDialog.this, "请选择组织", "", MessageBox.WARNING);
return;
}
groupID = updateGroup(groupID, user);
new ApplyMatnrOp2(app, "user").executeOperation();
dispose();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(FactoryChooseDialog.this, "错误:" + e, "", MessageBox.ERROR);
}
}
});
}
okBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
try {
String groupID = j_Group.getSelectedItem().toString();
if(groupID.isEmpty()) {
MessageBox.post(FactoryChooseDialog.this, "请选择组织", "", MessageBox.WARNING);
return;
}
groupID = updateGroup(groupID, user);
if ("no".equals(actionInfo)) {
new Thread(new MaterialNoDialog(app, session, groupID)).start();
} else if ("M007_2".equals(actionInfo)) {
System.out.println("配变外购件物料申请");
new Thread(new OutMPartNoBatchDialog(app, groupID)).start();
} else {
new SelfMPartNoBatchOperation(app, actionInfo, groupID).executeOperation();
}
dispose();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(FactoryChooseDialog.this, "错误:" + e, "", MessageBox.ERROR);
}
}
});
cancelBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
SqlUtil.freeAll();
dispose();
}
});
}
private String updateGroup(String groupID, String user) {
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();
String res = groupID.substring(0, groupID.indexOf(":"));
System.out.println("groupID:" + res);
return res;
}
} }

@ -10,6 +10,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.rmi.RemoteException; import java.rmi.RemoteException;
@ -69,7 +70,6 @@ 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.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentFolder;
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.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentItemType;
@ -109,6 +109,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
public static final int[] HEADERWIDTH = new int[] { 50, 50, 50, 50, 120, 180, 50, 50, 50 }; public static final int[] HEADERWIDTH = new int[] { 50, 50, 50, 50, 120, 180, 50, 50, 50 };
private TCSession session; private TCSession session;
private TCComponentUser user; private TCComponentUser user;
private String groupID;
private PMPC t_pmcp; private PMPC t_pmcp;
protected List<FEATURE> features = new ArrayList<FEATURE>(); protected List<FEATURE> features = new ArrayList<FEATURE>();
protected List<String> codes = new ArrayList<String>(); protected List<String> codes = new ArrayList<String>();
@ -156,14 +157,15 @@ public class MaterialNoDialog extends AbstractAIFDialog {
private List<TCComponent> copy_list = new ArrayList<TCComponent>(); private List<TCComponent> copy_list = new ArrayList<TCComponent>();
public MaterialNoDialog(AbstractAIFApplication app) { public MaterialNoDialog(AbstractAIFApplication app, TCSession session, String groupID) {
super(false); super(false);
KUtil.setByPass(true); KUtil.setByPass(true);
this.controller = new MaterialNoDialogController(this); this.controller = new MaterialNoDialogController(this);
this.session = (TCSession) app.getSession(); this.session = session;
this.user = session.getUser(); this.user = session.getUser();
this.groupID = groupID;
this.app = app; this.app = app;
SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// String now = format2.format(new Date()); // String now = format2.format(new Date());
txtName = "物料申请-" + format2.format(new Date()); txtName = "物料申请-" + format2.format(new Date());
@ -222,7 +224,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} }
uom_kg = KUtil.getUom("kg", session); uom_kg = KUtil.getUom("kg", session);
txtPath = TXTUtil.createTxt(txtName); txtPath = TXTUtil.createTxt(txtName);
String groupID = SAPUtil.getGroupID(session); // String groupID = SAPUtil.getGroupID(session);
String BOMClassificationNos[] = ChintPreferenceUtil String BOMClassificationNos[] = ChintPreferenceUtil
.getPreferences(ChintPreferenceUtil.CHINT_MaterialBOMClassificationNo, session); .getPreferences(ChintPreferenceUtil.CHINT_MaterialBOMClassificationNo, session);
if (BOMClassificationNos != null && BOMClassificationNos.length > 0) { if (BOMClassificationNos != null && BOMClassificationNos.length > 0) {
@ -492,13 +494,17 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
SqlUtil.free(); SqlUtil.free();
TXTUtil.writeTXT(txtPath, "error:" + e1.getMessage()); TXTUtil.writeTXT(txtPath, "error:\n" + KUtil.getStackTrace(e1));
MessageBox.post("ERROR:" + e1.getMessage(), "Ìáʾ", MessageBox.WARNING); MessageBox.post("ERROR:" + e1, "提示", MessageBox.WARNING);
return; return;
} finally { } finally {
KUtil.setByPass(false); KUtil.setByPass(false);
//TODO 上传日志
File log = new File(txtPath);
String[] pref = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_LOG_URL");
SimpleDateFormat sdf = new SimpleDateFormat("\\yyyy\\MM");
TXTUtil.writeTXT(txtPath, "上传日志:" + SAPUtil.uploadFile(log, pref[1] + sdf.format(new Date()), pref[0]));
} }
} }
}); });
this.f_add.addActionListener(new ActionListener() { this.f_add.addActionListener(new ActionListener() {
@ -701,12 +707,12 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} }
String userID = ""; String userID = "";
String userName = ""; String userName = "";
String groupName = ""; // String groupName = "";
try { try {
userID = user.getUserId(); userID = user.getUserId();
userName = user.getProperty("user_name"); userName = user.getProperty("user_name");
TCComponentGroup group = session.getCurrentGroup(); // TCComponentGroup group = session.getCurrentGroup();
groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue(); // groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue();
} catch (TCException e1) { } catch (TCException e1) {
MessageBox.post(MaterialNoDialog.this, "获取用户信息失败", "", MessageBox.ERROR); MessageBox.post(MaterialNoDialog.this, "获取用户信息失败", "", MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
@ -724,7 +730,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
String unitCode = uom == null ? "" : uom; String unitCode = uom == null ? "" : uom;
String goodsCode = ""; // 申请时为空 String goodsCode = ""; // 申请时为空
String companyCode = groupName; String companyCode = groupID;//groupName;
// companyCode= groupName=="变压器事业部"?"M005":companyCode; // companyCode= groupName=="变压器事业部"?"M005":companyCode;
// companyCode= groupName=="中压设备事业部"?"M008":companyCode; // companyCode= groupName=="中压设备事业部"?"M008":companyCode;
String state = ""; // 申请时为空 String state = ""; // 申请时为空
@ -922,7 +928,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} else { } else {
MessageBox.post("物料申请成功", "", MessageBox.INFORMATION); MessageBox.post("物料申请成功", "", MessageBox.INFORMATION);
} }
String groupID = SAPUtil.getGroupID(session); // String groupID = SAPUtil.getGroupID(session);
String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_NOTIFY", session); String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_NOTIFY", session);
String userId = ""; String userId = "";
for(String pref:preferences) { for(String pref:preferences) {
@ -1091,12 +1097,12 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} }
String userID = ""; String userID = "";
String userName = ""; String userName = "";
String groupName = ""; // String groupName = "";
try { try {
userID = user.getUserId(); userID = user.getUserId();
userName = user.getProperty("user_name"); userName = user.getProperty("user_name");
TCComponentGroup group = session.getCurrentGroup(); // TCComponentGroup group = session.getCurrentGroup();
groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue(); // groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue();
} catch (TCException e1) { } catch (TCException e1) {
MessageBox.post(MaterialNoDialog.this, "获取用户信息失败", "", MessageBox.ERROR); MessageBox.post(MaterialNoDialog.this, "获取用户信息失败", "", MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
@ -1114,7 +1120,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
String unitCode = uom == null ? "" : uom; String unitCode = uom == null ? "" : uom;
String goodsCode = ""; // 申请时为空 String goodsCode = ""; // 申请时为空
String companyCode = groupName; String companyCode = groupID;//groupName;
// companyCode= groupName=="变压器事业部"?"M005":companyCode; // companyCode= groupName=="变压器事业部"?"M005":companyCode;
// companyCode= groupName=="中压设备事业部"?"M008":companyCode; // companyCode= groupName=="中压设备事业部"?"M008":companyCode;
String state = ""; // 申请时为空 String state = ""; // 申请时为空
@ -1388,7 +1394,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} else { } else {
MessageBox.post("物料申请成功", "", MessageBox.INFORMATION); MessageBox.post("物料申请成功", "", MessageBox.INFORMATION);
} }
String groupID = SAPUtil.getGroupID(session); // String groupID = SAPUtil.getGroupID(session);
String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_NOTIFY", session); String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_NOTIFY", session);
String userId = ""; String userId = "";
for(String pref:preferences) { for(String pref:preferences) {

@ -14,9 +14,7 @@ import java.io.InputStream;
import java.sql.Connection; import java.sql.Connection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Vector; import java.util.Vector;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -40,7 +38,6 @@ import com.connor.chint.sap2.util.HttpUtil;
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.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.AbstractAIFDialog; import com.teamcenter.rac.aif.AbstractAIFDialog;
@ -90,12 +87,13 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
private List<TCComponentItemRevision> design_revs = null; private List<TCComponentItemRevision> design_revs = null;
private TCComponent uom_kg = null; private TCComponent uom_kg = null;
private TCComponentUser dcproxy; private TCComponentUser dcproxy;
private Map<TCComponentItemRevision,List<String>> desing_rev_spec_map = null; // private Map<TCComponentItemRevision,List<String>> desing_rev_spec_map = null;
public OutMPartNoBatchDialog(AbstractAIFApplication app) { public OutMPartNoBatchDialog(AbstractAIFApplication app, String groupID) {
super(false); super(false);
this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
this.groupID = groupID;
this.controller = new OutMPartNoBatchController(OutMPartNoBatchDialog.this); this.controller = new OutMPartNoBatchController(OutMPartNoBatchDialog.this);
} }
@ -103,8 +101,8 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
public void run() { public void run() {
try { try {
groupID = SAPUtil.getGroupID(session); // groupID = SAPUtil.getGroupID(session);
desing_rev_spec_map = new HashMap<TCComponentItemRevision,List<String>>(); // desing_rev_spec_map = new HashMap<TCComponentItemRevision,List<String>>();
/* /*
* if(!"M007".equals(groupID)) { * if(!"M007".equals(groupID)) {
* MessageBox.post("此功能仅适用于配变制造部","警告",MessageBox.INFORMATION); return; } * MessageBox.post("此功能仅适用于配变制造部","警告",MessageBox.INFORMATION); return; }
@ -337,7 +335,7 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
* *
*/ */
my = new MyProgressBarCompent("自制件编码申请", "正在读取BOM......"); my = new MyProgressBarCompent("自制件编码申请", "正在读取BOM......");
groupID = SAPUtil.getGroupID(session); // groupID = SAPUtil.getGroupID(session);
System.out.println("groupID:" + groupID); System.out.println("groupID:" + groupID);
setCompEnabled(false); setCompEnabled(false);
if (m_pmpc == null) { if (m_pmpc == null) {
@ -363,36 +361,43 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
List<SelfMPartBean> self_lists = new ArrayList<>(); List<SelfMPartBean> self_lists = new ArrayList<>();
TCComponentUser userComp = session.getUser(); TCComponentUser userComp = session.getUser();
controller.apply(groupID, design_revs, m_pmpc, prds, userComp, drequests, self_lists); controller.apply(groupID, design_revs, m_pmpc, prds, userComp, drequests, self_lists);
StringBuffer req_mess = new StringBuffer(); //TODO 先组织数据,创建对象,写入数据库,调接口,判断是否保留物料和数据库
List<String> mess = new ArrayList<String>(); List<TCComponentItemRevision> partList = new ArrayList<>();
String url = "http://10.128.20.35:9002/Post/PLM_Goods";
for (int i = 0; i < drequests.size(); i++) {
System.out.println("[" + i + "]ÇëÇóÄÚÈÝ:" + drequests.get(i));
String req = HttpUtil.sendJsonHttpPost(url, drequests.get(i));
mess.add(req);
System.out.println("[" + i + "]·µ»ØÖµ:" + req);
}
String state1 = "\"State\":\"1\"";
SelfMPartBean bean; SelfMPartBean bean;
for (int i = 0; i < self_lists.size(); i++) { for (int i = 0; i < self_lists.size(); i++) {
bean = self_lists.get(i); bean = self_lists.get(i);
if (mess.get(i).indexOf(state1) != -1) {
System.out.println("更新记录"); System.out.println("更新记录");
TCComponentItemRevision partRev = null;
String spec = bean.getSpec(); String spec = bean.getSpec();
partRev = controller.createMaterial(bean.getRev(), groupID, spec, m_pmpc.getCode(), TCComponentItemRevision partRev = controller.createMaterial(bean.getRev(), groupID, spec, m_pmpc.getCode(),
session, uom_kg, dcproxy, userComp); session, uom_kg, dcproxy, userComp);
partRev.add("TC_Is_Represented_By", bean.getRev()); partRev.add("TC_Is_Represented_By", bean.getRev());
partRev.refresh(); partRev.refresh();
partList.add(partRev);
bean.getRev().refresh(); bean.getRev().refresh();
String uid = partRev.getUid(); String uid = partRev.getUid();
Object[] params = bean.getParams(); Object[] params = bean.getParams();
params[1] = uid; params[1] = uid;
System.out.println("params:" + Arrays.toString(params)); System.out.println("params:" + Arrays.toString(params));
SqlUtil.write(SelfMPartNoBatchOperation.INSERT_SQL, params); SqlUtil.write(SelfMPartNoBatchOperation.INSERT_SQL, params);
} else { }
StringBuffer req_mess = new StringBuffer();
List<String> mess = new ArrayList<String>();
String url = "http://10.128.20.35:9002/Post/PLM_Goods";
for (int i = 0; i < drequests.size(); i++) {
System.out.println("[" + i + "]请求内容:" + drequests.get(i));
String req = HttpUtil.sendJsonHttpPost(url, drequests.get(i));
mess.add(req);
System.out.println("[" + i + "]返回值:" + req);
}
String state1 = "\"State\":\"1\"";
for (int i = 0; i < self_lists.size(); i++) {
bean = self_lists.get(i);
if (mess.get(i).indexOf(state1) == -1) {
req_mess.append("\n").append("物料" + bean.getRev() + "存在异常ERROR:" + mess.get(i)); req_mess.append("\n").append("物料" + bean.getRev() + "存在异常ERROR:" + mess.get(i));
System.out.println("ɾ³ý¼Ç¼"); TCComponentItemRevision part = partList.get(i);
System.out.println("删除记录:" + part + "\n" + bean.getCode());
part.getItem().delete();
SqlUtil.delete(SelfMPartNoBatchOperation.DELETE_SQL, new Object[] { bean.getCode() });
} }
} }

@ -1,8 +1,7 @@
package com.connor.chint.sap2.operation; package com.connor.chint.sap2.operation;
import java.awt.Dimension; import java.awt.Dimension;
import java.io.IOException; import java.io.File;
import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -26,6 +25,7 @@ import com.connor.chint.sap2.util.ProgressBar;
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.SqlUtil;
import com.connor.chint.sap2.util.TXTUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation; import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
@ -119,15 +119,22 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
Map<String,SelfMPartBean> idBeanMap = new HashMap<String,SelfMPartBean>(); Map<String,SelfMPartBean> idBeanMap = new HashMap<String,SelfMPartBean>();
private String actionInfo; private String actionInfo;
private TCComponentItemType itemType; private TCComponentItemType itemType;
public SelfMPartNoBatchOperation(AbstractAIFApplication app, String actionInfo) { private String txtPath = "";
private String txtName = "";
public SelfMPartNoBatchOperation(AbstractAIFApplication app, String actionInfo, String groupID) {
this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
this.groupName = groupID;
this.user = session.getUser(); this.user = session.getUser();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
now = format.format(new Date()); now = format.format(new Date());
format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// String now = format2.format(new Date());
try { try {
txtName = "物料编码批量申请-" + user.getUserId() + "-" + format.format(new Date());
itemType = (TCComponentItemType) this.session.getTypeComponent("Part"); itemType = (TCComponentItemType) this.session.getTypeComponent("Part");
groupID = SAPUtil.getGroupID(session); this.groupID = groupID;//SAPUtil.getGroupID(session);
} catch (Exception e) { } catch (Exception e) {
// Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -137,6 +144,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
@Override @Override
public void executeOperation() throws Exception { public void executeOperation() throws Exception {
txtPath = TXTUtil.createTxt(txtName);
List<String> nameList = new ArrayList<String>(); List<String> nameList = new ArrayList<String>();
InterfaceAIFComponent[] comps = app.getTargetComponents(); InterfaceAIFComponent[] comps = app.getTargetComponents();
TCComponent target = null; TCComponent target = null;
@ -250,7 +258,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
long time6 = System.nanoTime(); long time6 = System.nanoTime();
System.out.println("===============第一次查询数据库用时(ms) " + ((time6 - time5) / 1000000L)+"==============="); System.out.println("===============第一次查询数据库用时(ms) " + ((time6 - time5) / 1000000L)+"===============");
System.out.println("Sql1:" + Sql1); System.out.println("Sql1:" + Sql1);
TXTUtil.writeTXT(txtPath, "Sql1:\n" + Sql1);
System.out.println("params:" + Arrays.toString(obj1)); System.out.println("params:" + Arrays.toString(obj1));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj1));
if (rs.next()) { if (rs.next()) {
String pmpcPrhCode = rs.getString(1); String pmpcPrhCode = rs.getString(1);
System.out.println("pmpcPrhCode" + pmpcPrhCode); System.out.println("pmpcPrhCode" + pmpcPrhCode);
@ -271,7 +281,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
long time8 = System.nanoTime(); long time8 = System.nanoTime();
System.out.println("===============第二次查询数据库用时(ms) " + ((time8 - time7) / 1000000L)+"==============="); System.out.println("===============第二次查询数据库用时(ms) " + ((time8 - time7) / 1000000L)+"===============");
System.out.println("Sql2:" + Sql2); System.out.println("Sql2:" + Sql2);
TXTUtil.writeTXT(txtPath, "Sql2:\n" + Sql2);
System.out.println("params:" + Arrays.toString(obj2)); System.out.println("params:" + Arrays.toString(obj2));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj2));
System.out.println("===============开始遍历第二次查询数据库的信息==============="); System.out.println("===============开始遍历第二次查询数据库的信息===============");
long time9 = System.nanoTime(); long time9 = System.nanoTime();
while (rs2.next()) { while (rs2.next()) {
@ -344,7 +356,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
tempNum++; tempNum++;
System.out.println("Sql1:" + Sql1); System.out.println("Sql1:" + Sql1);
TXTUtil.writeTXT(txtPath, "Sql1:\n" + Sql1);
System.out.println("params:" + Arrays.toString(obj1)); System.out.println("params:" + Arrays.toString(obj1));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj1));
if (rs.next()) { if (rs.next()) {
String pmpcPrhCode = rs.getString(1); String pmpcPrhCode = rs.getString(1);
System.out.println("pmpcPrhCode" + pmpcPrhCode); System.out.println("pmpcPrhCode" + pmpcPrhCode);
@ -360,7 +374,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
long time24 = System.nanoTime(); long time24 = System.nanoTime();
System.out.println("===============第"+tempNum+"次查询数据库用时(ms) " + ((time24 - time23) / 1000000L)+"==============="); System.out.println("===============第"+tempNum+"次查询数据库用时(ms) " + ((time24 - time23) / 1000000L)+"===============");
System.out.println("Sql2:" + Sql2); System.out.println("Sql2:" + Sql2);
TXTUtil.writeTXT(txtPath, "Sql2:\n" + Sql2);
System.out.println("params:" + Arrays.toString(obj2)); System.out.println("params:" + Arrays.toString(obj2));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj2));
prds_Standard = new ArrayList<PRD>(); prds_Standard = new ArrayList<PRD>();
System.out.println("===============开始遍历第"+tempNum+"次查询数据库的信息==============="); System.out.println("===============开始遍历第"+tempNum+"次查询数据库的信息===============");
long time25 = System.nanoTime(); long time25 = System.nanoTime();
@ -427,8 +443,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
} }
userID = user.getUserId(); userID = user.getUserId();
userName = user.getProperty("user_name"); userName = user.getProperty("user_name");
TCComponentGroup group = session.getCurrentGroup(); // TCComponentGroup group = session.getCurrentGroup();
groupName = group.getProperty(TCComponentGroup.PROP_GROUP_NAME); // groupName = group.getProperty(TCComponentGroup.PROP_GROUP_NAME);
System.out.println("groupName:" + groupName); System.out.println("groupName:" + groupName);
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
@ -575,16 +591,19 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
System.out.println("一共需要发送的请求数量:"+drequests.size()); System.out.println("一共需要发送的请求数量:"+drequests.size());
long time37 = System.nanoTime(); long time37 = System.nanoTime();
for (int i = 0; i < drequests.size(); i++) { for (int i = 0; i < drequests.size(); i++) {
System.out.println("[" + i + "]请求内容:" + drequests.get(i)); System.out.println("[" + i + "]请求内容:\n" + drequests.get(i));
TXTUtil.writeTXT(txtPath, "[" + i + "]请求内容:\n" + drequests.get(i));
String req = HttpUtil.sendJsonHttpPost(url, drequests.get(i)); String req = HttpUtil.sendJsonHttpPost(url, drequests.get(i));
mess.add(req); mess.add(req);
System.out.println("[" + i + "]返回值:" + req); System.out.println("[" + i + "]返回值:\n" + req);
TXTUtil.writeTXT(txtPath, "[" + i + "]返回值:\n" + req);
} }
long time38 = System.nanoTime(); long time38 = System.nanoTime();
System.out.println("===============发送请求用时(ms) " + ((time38 - time37) / 1000000L)+"==============="); System.out.println("===============发送请求用时(ms) " + ((time38 - time37) / 1000000L)+"===============");
System.out.println("根据返回结果判断是否需要新建物料"); System.out.println("根据返回结果判断是否需要新建物料");
System.out.println("INSERT_SQL:" + INSERT_SQL); System.out.println("INSERT_SQL:" + INSERT_SQL);
TXTUtil.writeTXT(txtPath, "INSERT_SQL:" + INSERT_SQL);
String state1 = "\"State\":\"1\""; String state1 = "\"State\":\"1\"";
// String state2 = "\"State\":\"-1\""; // String state2 = "\"State\":\"-1\"";
System.out.println("===============开始解析返回结果==============="); System.out.println("===============开始解析返回结果===============");
@ -632,7 +651,6 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
SqlUtil.delete(DELETE_SQL, new Object[] { selfMPartBean.getCode() }); SqlUtil.delete(DELETE_SQL, new Object[] { selfMPartBean.getCode() });
KUtil.setByPass(false); KUtil.setByPass(false);
} }
} }
long time40 = System.nanoTime(); long time40 = System.nanoTime();
System.out.println("===============解析返回结果用时(ms) " + ((time40 - time39) / 1000000L) + "==============="); System.out.println("===============解析返回结果用时(ms) " + ((time40 - time39) / 1000000L) + "===============");
@ -662,17 +680,23 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
} catch (Exception e1) { } catch (Exception e1) {
KUtil.closeMyProgressBar(my); KUtil.closeMyProgressBar(my);
KUtil.setByPass(false); KUtil.setByPass(false);
MessageBox.post("", "自制件编码批量申请异常:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
TXTUtil.writeTXT(txtPath, "自制件编码批量申请异常:\n" + KUtil.getStackTrace(e1));
MessageBox.post("", "自制件编码批量申请异常:" + e1, "", MessageBox.ERROR);
} finally { } finally {
pb.disposeDialog(); pb.disposeDialog();
KUtil.setByPass(false); KUtil.setByPass(false);
PartSqlUtil.freeAll(); PartSqlUtil.freeAll();
SqlUtil.freeAll(); SqlUtil.freeAll();
//TODO 上传日志
File log = new File(txtPath);
String[] pref = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_LOG_URL");
SimpleDateFormat sdf = new SimpleDateFormat("\\yyyy\\MM");
TXTUtil.writeTXT(txtPath, "上传日志:" + SAPUtil.uploadFile(log, pref[1] + sdf.format(new Date()), pref[0]));
} }
} }
public static void sendMsg(String mess, String userID) throws IOException {
public void sendMsg(String mess, String userID) throws Exception {
try { try {
// TXTUtil.writeTXT(logPath, "开始AM消息推送"); // TXTUtil.writeTXT(logPath, "开始AM消息推送");
// TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess); // TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess);
@ -680,10 +704,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http(); ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http();
String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM"); String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM");
// TXTUtil.writeTXT(logPath, "返回信息:" + mess2); // TXTUtil.writeTXT(logPath, "返回信息:" + mess2);
System.out.println("返回信息:" + mess2); System.out.println("返回信息:\n" + mess2);
} catch (javax.xml.rpc.ServiceException e) { TXTUtil.writeTXT(txtPath, "返回信息:\n" + mess2);
e.printStackTrace(); } catch (Exception e) {
} catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
} }
// TXTUtil.writeTXT(logPath, "AM消息推送结束"); // TXTUtil.writeTXT(logPath, "AM消息推送结束");
@ -803,7 +826,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
String uid = s.getUid(); String uid = s.getUid();
Object[] params = selfMPartBean.getParams(); Object[] params = selfMPartBean.getParams();
params[1] = uid; params[1] = uid;
TXTUtil.writeTXT(txtPath, INSERT_SQL);
System.out.println("params:" + Arrays.toString(params)); System.out.println("params:" + Arrays.toString(params));
TXTUtil.writeTXT(txtPath, "params:" + Arrays.toString(params));
SqlUtil.write(INSERT_SQL, params); SqlUtil.write(INSERT_SQL, params);
SAPUtil.changeOwner(s, dcproxy); SAPUtil.changeOwner(s, dcproxy);
TCComponentUser o_user = (TCComponentUser) s.getRelatedComponent("owning_user"); TCComponentUser o_user = (TCComponentUser) s.getRelatedComponent("owning_user");
@ -1006,7 +1031,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
System.out.println("自制件[" + item_id + "]"); System.out.println("自制件[" + item_id + "]");
if (item_id.length() >= 4) { if (item_id.length() >= 4) {
String stuf = item_id.substring(0, 4); String stuf = item_id.substring(0, 4);
if (stuf.equalsIgnoreCase("2ZDB") || stuf.equalsIgnoreCase("4ZDB")) { if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD")) {
System.out.println("调整模板"); System.out.println("调整模板");
m_pmpc = pmpc2; m_pmpc = pmpc2;
m_prds = prds2; m_prds = prds2;
@ -1041,7 +1066,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
} }
String goodsCode = ""; // 申请时为空 String goodsCode = ""; // 申请时为空
String goodsName = properties[1];// rev.getProperty("object_name"); String goodsName = properties[1];// rev.getProperty("object_name");
String unitCode = "ST"; // 默认件真实值ST //TODO 需要获取图纸对象上的zt2_unit 真实值
String unitCode = rev.getItem().getStringProperty("zt2_unit");//"ST"; // 默认件真实值ST
String companyCode = groupID; String companyCode = groupID;
String mp = "M"; String mp = "M";
if(groupID.equals("M046") && properties[7].equals("外购")) { if(groupID.equals("M046") && properties[7].equals("外购")) {
@ -1161,7 +1187,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
String item_id = rev.getProperty("item_id"); String item_id = rev.getProperty("item_id");
if (item_id.length() >= 4) { if (item_id.length() >= 4) {
String stuf = item_id.substring(0, 4); String stuf = item_id.substring(0, 4);
if (stuf.equalsIgnoreCase("2ZDB") || stuf.equalsIgnoreCase("4ZDB")) { if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD")) {
flag = false; flag = false;
// 开始根据通用件规格属性来判断是否需要申请物料 // 开始根据通用件规格属性来判断是否需要申请物料
String zt2_TYJSpec = line.getProperty("ZT2_TYSpecifications"); String zt2_TYJSpec = line.getProperty("ZT2_TYSpecifications");
@ -1179,7 +1205,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
specs.add(spec); specs.add(spec);
general_maps.put(rev, specs); general_maps.put(rev, specs);
} }
//lidy20240830没有通用件规格的且没关联物料的就去申请一个
flag = true;
generalRevs.add(rev); generalRevs.add(rev);
gens.add(spec); gens.add(spec);
} }
@ -1311,7 +1338,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
return false; return false;
} }
}else { }else {
return false; //lidy20240830取消外购的限制自制外购都允许申请
// return false;
} }
} }

@ -30,6 +30,7 @@ import com.connor.chint.sap2.util.BomToSapUtil;
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.SAPUtil;
//import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.SqlUtil2; import com.connor.chint.sap2.util.SqlUtil2;
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;
@ -46,6 +47,7 @@ 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.cad._2007_01.StructureManagement.ExpandPSData;
import com.teamcenter.services.rac.core.DataManagementService;
public class CreateProcBYQController { public class CreateProcBYQController {
@ -54,16 +56,15 @@ public class CreateProcBYQController {
private TCSession session; private TCSession session;
// 节点与表格对象 // 节点与表格对象
protected Map<BYQBomBean, BYQProcBean> maps_tree_table = new HashMap<>(64); protected Map<BYQBomBean, BYQProcBean> maps_tree_table = new HashMap<>();
// 表格与节点关系 // 表格与节点关系
protected Map<BYQProcBean, DefaultMutableTreeNode> maps_table_tree = new HashMap<BYQProcBean, DefaultMutableTreeNode>( protected Map<BYQProcBean, DefaultMutableTreeNode> maps_table_tree = new HashMap<BYQProcBean, DefaultMutableTreeNode>();
64);
// 表格与BOM视图的关系 // 表格与BOM视图的关系
protected Map<BYQProcBean, TCComponentBOMLine> maps_table_line_maps = new HashMap<>(64); protected Map<BYQProcBean, TCComponentBOMLine> maps_table_line_maps = new HashMap<>();
// 版本-表格 // 版本-表格
protected Map<TCComponentItemRevision, List<BYQProcBean>> list_rev_procBean = new HashMap<>(64); protected Map<TCComponentItemRevision, List<BYQProcBean>> list_rev_procBean = new HashMap<>();
// table数据集合 // table数据集合
protected List<BYQProcBean> procBeanList = new ArrayList<>(64); protected List<BYQProcBean> procBeanList = new ArrayList<>();
// 需要重新获取子项的节点 // 需要重新获取子项的节点
protected List<DefaultMutableTreeNode> node_need_expands = new ArrayList<>(); protected List<DefaultMutableTreeNode> node_need_expands = new ArrayList<>();
@ -77,6 +78,9 @@ public class CreateProcBYQController {
// 展开的节点 // 展开的节点
protected Vector<TreePath> expandPaths = new Vector<>(); protected Vector<TreePath> expandPaths = new Vector<>();
private List<String> codeList = new ArrayList<>();
private List<String> noList = new ArrayList<>();
public CreateProcBYQController(CreateProcBYQDialog dialog, AbstractAIFApplication app) { public CreateProcBYQController(CreateProcBYQDialog dialog, AbstractAIFApplication app) {
this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
@ -88,8 +92,9 @@ public class CreateProcBYQController {
win = bomWinType.create(null); win = bomWinType.create(null);
} }
// 读取对象的BOM 展开未读取节点 //TODO 读取对象的BOM 展开未读取节点
public void readData(ProgressBar pb, TCComponentItemRevision topRev) throws Exception { protected void readData(ProgressBar pb, TCComponentItemRevision topRev) throws Exception {
long startTime = System.currentTimeMillis();
isCanExpand = false; isCanExpand = false;
pb.startProgress(); pb.startProgress();
pb.setText("加载数据..."); pb.setText("加载数据...");
@ -99,13 +104,14 @@ public class CreateProcBYQController {
DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(bomBean); DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(bomBean);
BYQProcBean proBean; BYQProcBean proBean;
System.out.println("topRev==>"+topRev); System.out.println("topRev==>"+topRev);
proBean = readTemplateYH(topLine, bomBean, topRev);
proBean = readTemplateYH(topLine, bomBean, topRev, codeList, noList);
maps_table_tree.put(proBean, topTreeNode); maps_table_tree.put(proBean, topTreeNode);
int size = 1; int size = 1;
proBean.setIndex(size); proBean.setIndex(size);
procBeanList.add(proBean); procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData()); // dialog.tm_part.addRow(proBean.getRowData());
size++; size++;
// AIFComponentContext[] children = topLine.getChildren(); // AIFComponentContext[] children = topLine.getChildren();
TCComponentBOMLine childLine; TCComponentBOMLine childLine;
@ -115,21 +121,28 @@ public class CreateProcBYQController {
List<TreePath> paths = new ArrayList<>(); List<TreePath> paths = new ArrayList<>();
TreePath path; TreePath path;
bomLineTreeNodeSOA = BomToSapUtil.getBomLineTreeNodeSOA(topLine); System.out.println("readData:" + (System.currentTimeMillis() - startTime) / 1000);
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(topLine.getUid()); // com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
// bomLineTreeNodeSOA = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService);
//// bomLineTreeNodeSOA = BomToSapUtil.getBomLineTreeNodeSOA(topLine);
// ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(topLine.getUid());
// SAPUtil.getMeproces(rev.getUid(), session); // SAPUtil.getMeproces(rev.getUid(), session);
for (int i = 0, len = expandPSDatas.length; i < len; i++) { // for (int i = 0, len = expandPSDatas.length; i < len; i++) {
childLine = expandPSDatas[i].bomLine; for (AIFComponentContext c : topLine.getChildren()) {
childRev = expandPSDatas[i].itemRevOfBOMLine; // childLine = expandPSDatas[i].bomLine;
// childRev = expandPSDatas[i].itemRevOfBOMLine;
childLine = (TCComponentBOMLine) c.getComponent();
childRev = childLine.getItemRevision();
childBomBean = new BYQBomBean(childRev); childBomBean = new BYQBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean); childNode = new DefaultMutableTreeNode(childBomBean);
proBean = readTemplateYH(childLine, childBomBean, childRev); proBean = readTemplateYH(childLine, childBomBean, childRev, codeList, noList);
proBean.setIndex(size); proBean.setIndex(size);
procBeanList.add(proBean); procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData()); // dialog.tm_part.addRow(proBean.getRowData());
size++; size++;
if (bomLineTreeNodeSOA.get(childLine.getUid()).length>0) { // if (bomLineTreeNodeSOA.get(childLine.getUid()).length > 0) {
if (childLine.getChildrenCount() > 0) {
node_need_expands.add(childNode); node_need_expands.add(childNode);
childBomBean = new BYQBomBean(childRev); childBomBean = new BYQBomBean(childRev);
node = new DefaultMutableTreeNode(childBomBean); node = new DefaultMutableTreeNode(childBomBean);
@ -142,6 +155,12 @@ public class CreateProcBYQController {
maps_table_tree.put(proBean, childNode); maps_table_tree.put(proBean, childNode);
maps_tree_table.put(childBomBean, proBean); maps_tree_table.put(childBomBean, proBean);
} }
System.out.println("readData2:" + (System.currentTimeMillis() - startTime) / 1000);
getGY(procBeanList, codeList, noList);
for(BYQProcBean bean : procBeanList) {
dialog.tm_part.addRow(bean.getRowData());
}
System.out.println("readData3:" + (System.currentTimeMillis() - startTime) / 1000);
dialog.topNode.add(topTreeNode); dialog.topNode.add(topTreeNode);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode)); KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
@ -162,11 +181,13 @@ public class CreateProcBYQController {
expandPaths.add(new TreePath(t_node)); expandPaths.add(new TreePath(t_node));
} }
}); });
SqlUtil2.free();
System.out.println("readData4:" + (System.currentTimeMillis() - startTime) / 1000);
pb.disposeDialog(); pb.disposeDialog();
} }
// 关闭节点 // 关闭节点
public void collapsed(TreePath parent) { protected void collapsed(TreePath parent) {
// System.out.println("关闭"); // System.out.println("关闭");
List<BYQProcBean> beans = new ArrayList<>(64); List<BYQProcBean> beans = new ArrayList<>(64);
getNodeChild(dialog.tree, parent, beans); getNodeChild(dialog.tree, parent, beans);
@ -192,7 +213,7 @@ public class CreateProcBYQController {
} }
// 获得子项节点 // 获得子项节点
public void getNodeChild(JTree tree, TreePath parent, List<BYQProcBean> beans) { private void getNodeChild(JTree tree, TreePath parent, List<BYQProcBean> beans) {
TreeNode node = (TreeNode) parent.getLastPathComponent(); TreeNode node = (TreeNode) parent.getLastPathComponent();
if (expandPaths.indexOf(parent) != -1) { if (expandPaths.indexOf(parent) != -1) {
BYQBomBean bomBean; BYQBomBean bomBean;
@ -211,7 +232,7 @@ public class CreateProcBYQController {
} }
// 展开 第一次展开未读子项节点 // 展开 第一次展开未读子项节点
public void expandNodeFirst(DefaultMutableTreeNode topNode) throws Exception { protected void expandNodeFirst(DefaultMutableTreeNode topNode) throws Exception {
// System.out.println("开始展开子项"); // System.out.println("开始展开子项");
int cout = topNode.getChildCount(); int cout = topNode.getChildCount();
BYQBomBean bomBean = (BYQBomBean) topNode.getUserObject(); BYQBomBean bomBean = (BYQBomBean) topNode.getUserObject();
@ -265,37 +286,74 @@ public class CreateProcBYQController {
System.out.println("结束"); System.out.println("结束");
} }
// 一键展开 //TODO 一键展开
public void expandAllNodes(List<DefaultMutableTreeNode> nodes, ProgressBar pb) throws Exception { protected void expandAllNodes(List<DefaultMutableTreeNode> nodes, ProgressBar pb) throws Exception {
// 所有未展开节点 // 所有未展开节点
long startTime = System.currentTimeMillis();
isCanExpand = false; isCanExpand = false;
List<BYQProcBean> beans = new ArrayList<>(); List<BYQProcBean> beans = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
DefaultMutableTreeNode node; DefaultMutableTreeNode node;
int cout, index; int cout, index;
BYQBomBean bomBean; BYQBomBean bomBean;
BYQProcBean procBean; BYQProcBean procBean;
pb.startProgress(); pb.startProgress();
pb.setText("正在展开......"); pb.setText("正在展开......");
if(bomLineTreeNodeSOA == null || bomLineTreeNodeSOA.size() == 0) {
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
bomLineTreeNodeSOA = BomToSapUtil.getBomLineTreeNodeSOA(topLine, structureService);
}
System.out.println("expandAllNodes0:" + (System.currentTimeMillis() - startTime) / 1000);
/*预加载BOM及版本属性优化速度*/
List<TCComponent> bomList = new ArrayList<>();
List<TCComponent> bomRevList = new ArrayList<>();
getBOMList(topLine, bomLineTreeNodeSOA, bomList, bomRevList);
DataManagementService dmService = DataManagementService.getService(session);
dmService.getProperties(bomList.toArray(new TCComponent[0]), new String[] { "ZT2_ClassificationNo" });
dmService.getProperties(bomRevList.toArray(new TCComponent[0]), new String[] { "object_type", "item_id", "zt2_Source", "zt2_MaterialNo", "object_name" });
System.out.println("expandAllNodes1:" + (System.currentTimeMillis() - startTime) / 1000);
for (int i = 0, len = nodes.size(); i < len; i++) { for (int i = 0, len = nodes.size(); i < len; i++) {
beans.clear(); beans.clear();
codeList.clear();
noList.clear();
node = nodes.get(i); node = nodes.get(i);
cout = node.getChildCount(); cout = node.getChildCount();
bomBean = (BYQBomBean) node.getUserObject(); bomBean = (BYQBomBean) node.getUserObject();
pb.setText("正在展开子项" + bomBean + "......"); pb.setText("正在展开子项" + bomBean + "......");
procBean = maps_tree_table.get(bomBean); procBean = maps_tree_table.get(bomBean);
expandAllNode(node, beans, bomBean, procBean); expandAllNode(node, beans, bomBean, procBean, codeList, noList);
index = procBeanList.indexOf(procBean); index = procBeanList.indexOf(procBean);
for (int j = 0, len2 = beans.size(); j < len2; j++) { for (int j = 0, len2 = beans.size(); j < len2; j++) {
beans.get(j).setIndex(index + j + 2); beans.get(j).setIndex(index + j + 2);
} }
procBeanList.addAll(index + 1, beans); procBeanList.addAll(index + 1, beans);
this.codeList.addAll(index + 1, codeList);
this.noList.addAll(index + 1, noList);
for (int j = cout - 1; j >= 0; j--) { for (int j = cout - 1; j >= 0; j--) {
node.remove(j); node.remove(j);
} }
} }
System.out.println("expandAllNodes2:" + (System.currentTimeMillis() - startTime) / 1000);
getGY(procBeanList, this.codeList, this.noList);
System.out.println("expandAllNodes3:" + (System.currentTimeMillis() - startTime) / 1000);
ArrayList<TCComponent> gyList = new ArrayList<>();
for(BYQProcBean bean : procBeanList) {
if(bean.getRev_cp_gx() != null)
gyList.add(bean.getRev_cp_gx());
if(bean.getRev_cp_gy() != null)
gyList.add(bean.getRev_cp_gy());
if(bean.getRev_standard_gx() != null)
gyList.add(bean.getRev_standard_gx());
if(bean.getRev_standard_gy() != null)
gyList.add(bean.getRev_standard_gy());
}
dmService.getProperties(gyList.toArray(new TCComponent[gyList.size()]), new String[] { "object_name" });
refreshTable(procBeanList); refreshTable(procBeanList);
System.out.println("expandAllNodes4:" + (System.currentTimeMillis() - startTime) / 1000);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode)); KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
@ -306,11 +364,12 @@ public class CreateProcBYQController {
}); });
nodes.clear(); nodes.clear();
pb.disposeDialog(); pb.disposeDialog();
System.out.println("expandAllNodes5:" + (System.currentTimeMillis() - startTime) / 1000);
} }
// 展开 // 展开
public void expandAllNode(DefaultMutableTreeNode topNode, List<BYQProcBean> beans, BYQBomBean bomBean, private void expandAllNode(DefaultMutableTreeNode topNode, List<BYQProcBean> beans, BYQBomBean bomBean,
BYQProcBean procBean) throws Exception { BYQProcBean procBean, List<String> codeList, List<String> noList) throws Exception {
TCComponentBOMLine topLine = maps_table_line_maps.get(procBean); TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
// AIFComponentContext[] children = topLine.getChildren(); // AIFComponentContext[] children = topLine.getChildren();
TCComponentBOMLine childLine; TCComponentBOMLine childLine;
@ -325,10 +384,10 @@ public class CreateProcBYQController {
childRev = expandPSDatas[i].itemRevOfBOMLine; childRev = expandPSDatas[i].itemRevOfBOMLine;
childBomBean = new BYQBomBean(childRev); childBomBean = new BYQBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean); childNode = new DefaultMutableTreeNode(childBomBean);
procBean = readTemplateYH(childLine, childBomBean, childRev); procBean = readTemplateYH(childLine, childBomBean, childRev, codeList, noList);
beans.add(procBean); beans.add(procBean);
if (bomLineTreeNodeSOA.get(childLine.getUid()).length>0) { if (bomLineTreeNodeSOA.get(childLine.getUid()).length>0) {
expandAllNode(childNode, beans, childBomBean, procBean); expandAllNode(childNode, beans, childBomBean, procBean, codeList, noList);
} }
topNode.add(childNode); topNode.add(childNode);
bomBean.addChild(childBomBean); bomBean.addChild(childBomBean);
@ -339,7 +398,7 @@ public class CreateProcBYQController {
} }
// 普通展开节点 // 普通展开节点
public void expandNode(DefaultMutableTreeNode topNode, TreePath path) throws Exception { protected void expandNode(DefaultMutableTreeNode topNode, TreePath path) throws Exception {
BYQBomBean bomBean = (BYQBomBean) topNode.getUserObject(); BYQBomBean bomBean = (BYQBomBean) topNode.getUserObject();
BYQProcBean procBean = maps_tree_table.get(bomBean); BYQProcBean procBean = maps_tree_table.get(bomBean);
// TCComponentBOMLine topLine = maps_table_line_maps.get(procBean); // TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
@ -357,7 +416,7 @@ public class CreateProcBYQController {
} }
// 从beans的第index加到表格的第index格 // 从beans的第index加到表格的第index格
public void refreshTable(List<BYQProcBean> beans, int index) throws Exception { private void refreshTable(List<BYQProcBean> beans, int index) throws Exception {
int cout = dialog.t_part.getRowCount(); int cout = dialog.t_part.getRowCount();
for (int i = cout - 1; i > index; i--) { for (int i = cout - 1; i > index; i--) {
dialog.tm_part.removeRow(i); dialog.tm_part.removeRow(i);
@ -369,7 +428,7 @@ public class CreateProcBYQController {
} }
} }
public void refreshTable(List<BYQProcBean> beans) throws Exception { private void refreshTable(List<BYQProcBean> beans) throws Exception {
dialog.t_part.clearSelection(); dialog.t_part.clearSelection();
dialog.tm_part.getDataVector().clear(); dialog.tm_part.getDataVector().clear();
dialog.t_part.revalidate(); dialog.t_part.revalidate();
@ -519,30 +578,33 @@ public class CreateProcBYQController {
return proBean; return proBean;
} }
private HashMap<String, TCComponentItemRevision> classCodeMap = new HashMap<>(); // private HashMap<String, TCComponentItemRevision> classCodeMap = new HashMap<>();
private HashMap<String, BYQProcBean> beanMap = new HashMap<>(); private HashMap<String, Object[]> beanMap = new HashMap<>();
// 读取具体信息 // 读取具体信息
private BYQProcBean readTemplateYH(TCComponentBOMLine line, BYQBomBean bean, TCComponentItemRevision rev) private BYQProcBean readTemplateYH(TCComponentBOMLine line, BYQBomBean bean, TCComponentItemRevision rev,
throws Exception { List<String> codeList, List<String> noList) throws Exception {//TODO
String type = rev.getType();// 类型 String type = rev.getType();// 类型
String drawNo; // 图样代号 String drawNo; // 图样代号
TCComponentItemRevision rev_standard = null; // 标准图版本 TCComponentItemRevision rev_standard = null; // 标准图版本
TCComponentItemRevision tlgx_standard = null; // 标准图工序 TCComponentItemRevision tlgx_standard = null; // 标准图工序
TCComponentItemRevision cp_gx_rev = null, cp_gy_rev = null; // 产品工序、产品工 TCComponentItemRevision cp_gx_rev = null, cp_gy_rev = null; // 产品工序、产品工
List<TCComponentItemRevision> list_standard = new ArrayList<>(4); // 标准图工艺 List<TCComponentItemRevision> list_standard = new ArrayList<>(4); // 标准图工艺
Map<String, String> fields = new LinkedHashMap<>(); // Map<String, String> fields = new LinkedHashMap<>();
String zt2_ClassificationCode; // 工序编码 String zt2_ClassificationCode; // 工序编码
TCComponentContextList res; // TCComponentContextList res;
String drawingNo = ""; String drawingNo = "";
String zt2_Source = ""; String zt2_Source = "";
TCComponentBOMLine parent = line.parent(); TCComponentBOMLine parent = line.parent();
String uid = (parent == null ? "" : parent.getItemRevision().getUid()) + "@" + rev.getUid(); String uid = (parent == null ? "" : parent.getItemRevision().getUid()) + "@" + rev.getUid();
if(beanMap.containsKey(uid)) { if(beanMap.containsKey(uid)) {
BYQProcBean byqProcBean = beanMap.get(uid); Object[] bObjects = beanMap.get(uid);
BYQProcBean byqProcBean = (BYQProcBean) bObjects[0];
BYQProcBean cloneBean = (BYQProcBean) BeanUtils.cloneBean(byqProcBean); BYQProcBean cloneBean = (BYQProcBean) BeanUtils.cloneBean(byqProcBean);
maps_table_line_maps.put(cloneBean, line); maps_table_line_maps.put(cloneBean, line);
maps_tree_table.put(bean, cloneBean); maps_tree_table.put(bean, cloneBean);
// maps_tree_table.put(bean, beanMap.get(rev.getUid())); // maps_tree_table.put(bean, beanMap.get(rev.getUid()));
codeList.add((String) bObjects[1]);
noList.add((String) bObjects[2]);
return cloneBean; return cloneBean;
} }
if (type.equals("ZT2_Design3DRevision")) { if (type.equals("ZT2_Design3DRevision")) {
@ -559,7 +621,8 @@ public class CreateProcBYQController {
drawingNo = drawNo.substring(0, ind); drawingNo = drawNo.substring(0, ind);
} }
} }
// 查询标准图对象 codeList.add(drawingNo);
/*
fields.put("DrawingNo", drawingNo); fields.put("DrawingNo", drawingNo);
// System.out.println("图号:"+drawingNo); // System.out.println("图号:"+drawingNo);
// 查询的是版本对象 // 查询的是版本对象
@ -590,7 +653,6 @@ public class CreateProcBYQController {
} }
} }
TCComponent meproces = getMeproces(rev_standard.getUid(), session); TCComponent meproces = getMeproces(rev_standard.getUid(), session);
SqlUtil2.free();
TCComponentItemRevision meopRev; TCComponentItemRevision meopRev;
if(meproces!=null) { if(meproces!=null) {
meopRev = (TCComponentItemRevision)meproces; meopRev = (TCComponentItemRevision)meproces;
@ -601,7 +663,7 @@ public class CreateProcBYQController {
// list_standard.add(meopRev); // list_standard.add(meopRev);
// } // }
} }
} }*/
} else if (type.equals("Part Revision")) { } else if (type.equals("Part Revision")) {
drawNo = rev.getProperty("zt2_MaterialNo"); drawNo = rev.getProperty("zt2_MaterialNo");
@ -612,7 +674,8 @@ public class CreateProcBYQController {
if (ind > 0) { if (ind > 0) {
drawingNo = drawingNo.substring(0, ind); drawingNo = drawingNo.substring(0, ind);
} }
// 查询标准图对象 codeList.add(drawingNo);
/*
fields.put("零组件 ID", drawingNo); fields.put("零组件 ID", drawingNo);
// 查询的是版本对象 // 查询的是版本对象
res = KUtil.query(session, "零组件...", fields); res = KUtil.query(session, "零组件...", fields);
@ -639,23 +702,24 @@ public class CreateProcBYQController {
} }
} }
TCComponent meproces = getMeproces(rev_standard.getUid(), session); TCComponent meproces = getMeproces(rev_standard.getUid(), session);
SqlUtil2.free(); // SqlUtil2.free();
TCComponentItemRevision meopRev; TCComponentItemRevision meopRev;
if(meproces!=null) { if(meproces!=null) {
meopRev = (TCComponentItemRevision)meproces; meopRev = (TCComponentItemRevision)meproces;
list_standard.add(meopRev); list_standard.add(meopRev);
} }
} }
} }*/
} else { } else {
throw new Exception("BOM中存在非图纸/物料对象"); throw new Exception("BOM中存在非图纸/物料对象");
} }
//TODO 开始查找自身工艺以及工序 // 开始查找自身工艺以及工序
zt2_ClassificationCode = line.getProperty("ZT2_ClassificationNo"); zt2_ClassificationCode = line.getProperty("ZT2_ClassificationNo");
System.out.println("zt2_ClassificationCode:" + line + "==>" + zt2_ClassificationCode); System.out.println("zt2_ClassificationCode:" + line + "==>" + zt2_ClassificationCode);
if (!KUtil.isEmpty(zt2_ClassificationCode)) { noList.add(zt2_ClassificationCode);
/*if (!KUtil.isEmpty(zt2_ClassificationCode)) {
if(classCodeMap.containsKey(zt2_ClassificationCode)) { if(classCodeMap.containsKey(zt2_ClassificationCode)) {
@ -673,10 +737,11 @@ public class CreateProcBYQController {
classCodeMap.put(zt2_ClassificationCode, cp_gx_rev); classCodeMap.put(zt2_ClassificationCode, cp_gx_rev);
} }
} }*/
System.out.println("tlgx_standard:" + tlgx_standard);
System.out.println("cp_gx_rev:" + cp_gx_rev); System.out.println("cp_gx_rev:" + cp_gx_rev);
TCComponent meproces = getMeproces(rev.getUid(), session); TCComponent meproces = getMeproces(rev.getUid(), session);
SqlUtil2.free(); // SqlUtil2.free();
// AIFComponentContext[] refs = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, // AIFComponentContext[] refs = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
// new String[] { "IMAN_METarget" }); // new String[] { "IMAN_METarget" });
@ -694,11 +759,11 @@ public class CreateProcBYQController {
proBean.setRev_standard(rev_standard); proBean.setRev_standard(rev_standard);
maps_table_line_maps.put(proBean, line); maps_table_line_maps.put(proBean, line);
maps_tree_table.put(bean, proBean); maps_tree_table.put(bean, proBean);
beanMap.put(uid, proBean); beanMap.put(uid, new Object[] { proBean, drawingNo, zt2_ClassificationCode });
return proBean; return proBean;
} }
private Map<String,TCComponent> mepMap = new HashMap<String,TCComponent>(); private Map<String,TCComponent> mepMap = new HashMap<String,TCComponent>();
public TCComponent getMeproces(String uid, TCSession session) throws Exception { private TCComponent getMeproces(String uid, TCSession session) throws Exception {
if(mepMap.containsKey(uid)) { if(mepMap.containsKey(uid)) {
return mepMap.get(uid); return mepMap.get(uid);
@ -717,7 +782,7 @@ public class CreateProcBYQController {
return mpComp; return mpComp;
} }
} }
SqlUtil2.free(); // SqlUtil2.free();
// else { // else {
// SqlUtil2.free(); // SqlUtil2.free();
// } // }
@ -725,7 +790,7 @@ public class CreateProcBYQController {
} }
// 手动投料 投料前过滤掉只选了BOM首行的 // 手动投料 投料前过滤掉只选了BOM首行的
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void manualFeeding(int[] rows, TCComponent gx_comp) throws Exception { protected void manualFeeding(int[] rows, TCComponent gx_comp) throws Exception {
String item_id = gx_comp.getProperty("item_id"); String item_id = gx_comp.getProperty("item_id");
String object_name = gx_comp.getProperty("object_name"); String object_name = gx_comp.getProperty("object_name");
BYQProcBean procBean; BYQProcBean procBean;
@ -763,7 +828,7 @@ public class CreateProcBYQController {
} }
// 自动投料 // 自动投料
public void autoFeeding(ProgressBar pb) throws Exception { protected void autoFeeding(ProgressBar pb) throws Exception {
int cout = dialog.t_part.getRowCount(); int cout = dialog.t_part.getRowCount();
BYQProcBean procBean; BYQProcBean procBean;
String item_id, object_name; String item_id, object_name;
@ -796,7 +861,7 @@ public class CreateProcBYQController {
// 修改工艺 // 修改工艺
@SuppressWarnings("unlikely-arg-type") @SuppressWarnings("unlikely-arg-type")
public void updateProcess(ProgressBar pb) throws Exception { protected void updateProcess(ProgressBar pb) throws Exception {
int[] sels = dialog.t_part.getSelectedRows(); int[] sels = dialog.t_part.getSelectedRows();
if (sels != null && sels.length == 1) { if (sels != null && sels.length == 1) {
BYQProcBean proBean = (BYQProcBean) dialog.t_part.getValueAt(sels[0], 0); BYQProcBean proBean = (BYQProcBean) dialog.t_part.getValueAt(sels[0], 0);
@ -856,7 +921,7 @@ public class CreateProcBYQController {
} }
} }
public void autoCreateProc(ProgressBar pb) throws Exception { /*public void autoCreateProc(ProgressBar pb) throws Exception {
int cout = dialog.t_part.getRowCount(); int cout = dialog.t_part.getRowCount();
BYQProcBean procBean; BYQProcBean procBean;
pb.startProgress(); pb.startProgress();
@ -880,9 +945,9 @@ public class CreateProcBYQController {
pb.disposeDialog(); pb.disposeDialog();
MessageBox.post(dialog, "自动指派工艺成功!", "", 2); MessageBox.post(dialog, "自动指派工艺成功!", "", 2);
} }*/
public void autoCreateProc(ProgressBar pb, Map<String, Map<String, Object>> gygxMap, double ndxs) throws Exception { protected void autoCreateProc(ProgressBar pb, Map<String, Map<String, Object>> gygxMap, double ndxs) throws Exception {
int cout = dialog.t_part.getRowCount(); int cout = dialog.t_part.getRowCount();
BYQProcBean procBean; BYQProcBean procBean;
pb.startProgress(); pb.startProgress();
@ -971,7 +1036,7 @@ public class CreateProcBYQController {
} }
// 判断有没有选中树 // 判断有没有选中树
public List<DefaultMutableTreeNode> getSelectNodes() { protected List<DefaultMutableTreeNode> getSelectNodes() {
List<DefaultMutableTreeNode> nodes = new ArrayList<>(); List<DefaultMutableTreeNode> nodes = new ArrayList<>();
TreePath[] path = dialog.tree.getSelectionPaths(); TreePath[] path = dialog.tree.getSelectionPaths();
if (path == null || path.length == 0) { if (path == null || path.length == 0) {
@ -999,4 +1064,100 @@ public class CreateProcBYQController {
System.out.println("list:" + list); System.out.println("list:" + list);
System.out.println(list.indexOf("ddd")); System.out.println(list.indexOf("ddd"));
} }
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<BYQProcBean> procBeanList2, 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,");
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 ")
.append("where 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') t2 on t2.puid=b.puid ")
.append("where 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 = SqlUtil2.read(sql1.toString());
// String last = "";
HashMap<String, TCComponent> uidMap = new HashMap<>();
while (read.next()) {
String uid = read.getString(1);
String code = read.getString(2);
// System.out.println("code" + code);
// if(uid.equals(last))
// throw new Exception("通过 DrawingNo = " + code + " 查询到多个对象");
String tlgx = read.getString(4);
String bzgy = read.getString(5);
// BYProcBean bean = procBeanList.get(codeList.indexOf(code));
for(int i = 0; i < codeList.size(); i++) {
if(codeList.get(i).equals(code)) {
BYQProcBean bean = procBeanList2.get(i);
if(tlgx != null && !tlgx.isEmpty()) {
bean.setRev_standard_gx(getUidRev(tlgx, uidMap));
}
if(bzgy != null && !bzgy.isEmpty()) {
bean.setRev_standard_gy(getUidRev(bzgy, uidMap));
}
bean.setRev_standard(getUidRev(uid, uidMap));
}
}
// last = uid;
}
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 = SqlUtil2.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)) {
BYQProcBean bean = procBeanList2.get(i);
bean.setRev_cp_gx(getUidRev(uid, uidMap));
}
}
// last = id;
}
}
private TCComponentItemRevision getUidRev(String uid, HashMap<String, TCComponent> uidMap) throws Exception {
if(uidMap.containsKey(uid)) {
return (TCComponentItemRevision) uidMap.get(uid);
}else {
TCComponent standardRev = session.stringToComponent(uid);
uidMap.put(uid, standardRev);
return (TCComponentItemRevision) standardRev;
}
}
} }

@ -1,7 +1,6 @@
package com.connor.chint.sap2.proc_dyccFolder; package com.connor.chint.sap2.proc_dyccFolder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
@ -9,9 +8,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern;
import javax.swing.JComboBox;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
@ -22,11 +19,13 @@ import com.connor.chint.sap2.create_proc.CreateProcController;
import com.connor.chint.sap2.create_proc.ProcessChangeDialog; import com.connor.chint.sap2.create_proc.ProcessChangeDialog;
import com.connor.chint.sap2.proc.CreateProcessController; 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.util.BomToSapUtil;
import com.connor.chint.sap2.proc_by.ProcCellEditor; 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.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
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.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;
@ -59,13 +58,15 @@ public class CreateProcDYCCFolderController {
private AbstractAIFApplication app; private AbstractAIFApplication app;
private TCSession session; private TCSession session;
private ProcCellEditor procEditoe; // private ProcCellEditor procEditoe;
private DYCCFolderProcCellEditor cellEditor; // private DYCCFolderProcCellEditor cellEditor;
private String[] sources = { "×ÔÖÆ", "Í⹺" }; // private String[] sources = { "自制", "外购" };
private String group;
private HashMap<String, TCComponentItemRevision> mepMap = new HashMap<>();
public void sortList(List<TCComponentItemRevision> revs) { protected void sortList(List<TCComponentItemRevision> revs) {
Collections.sort(revs, new Comparator<TCComponentItemRevision>() { Collections.sort(revs, new Comparator<TCComponentItemRevision>() {
@Override @Override
@ -73,8 +74,8 @@ public class CreateProcDYCCFolderController {
try { try {
return o1.getProperty("zt2_MaterialNo").compareTo(o2.getProperty("zt2_MaterialNo")); return o1.getProperty("zt2_MaterialNo").compareTo(o2.getProperty("zt2_MaterialNo"));
} catch (TCException e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return 0; return 0;
@ -83,7 +84,7 @@ public class CreateProcDYCCFolderController {
} }
// 判断有没有选中树 // 判断有没有选中树
public List<DefaultMutableTreeNode> getSelectNodes() { protected List<DefaultMutableTreeNode> getSelectNodes() {
List<DefaultMutableTreeNode> nodes = new ArrayList<>(); List<DefaultMutableTreeNode> nodes = new ArrayList<>();
TreePath[] path = dialog.tree.getSelectionPaths(); TreePath[] path = dialog.tree.getSelectionPaths();
if (path == null || path.length == 0) { if (path == null || path.length == 0) {
@ -100,11 +101,11 @@ public class CreateProcDYCCFolderController {
return nodes; return nodes;
} }
public void updateProcess(DefaultMutableTreeNode node, MyProgressBarCompent pb) throws Exception { protected void updateProcess(DefaultMutableTreeNode node, MyProgressBarCompent pb) throws Exception {
BomBean bean = (BomBean) node.getUserObject(); BomBean bean = (BomBean) node.getUserObject();
DYCCProcBean procBean; DYCCProcBean procBean;
List<MEProcessBean> lists = new ArrayList<>(); List<MEProcessBean> lists = new ArrayList<>();
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) node.getRoot(); // DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) node.getRoot();
// System.out.println("root:"+rootNode); // System.out.println("root:"+rootNode);
TCComponentItemRevision rev; TCComponentItemRevision rev;
TCComponentItemRevision part; TCComponentItemRevision part;
@ -184,7 +185,7 @@ public class CreateProcDYCCFolderController {
} }
KUtil.setByPass(true); KUtil.setByPass(true);
List<MEProcessBean> procs = new ProcessChangeDialog(dialog, app, "", lists, rev).getResult(); new ProcessChangeDialog(dialog, app, "", lists, rev).getResult();
if (pb == null) { if (pb == null) {
pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......"); pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......");
} else { } else {
@ -198,15 +199,16 @@ public class CreateProcDYCCFolderController {
} }
public CreateProcDYCCFolderController(AbstractAIFApplication app, CreateProcDYCCFolderDialog dialog) { public CreateProcDYCCFolderController(AbstractAIFApplication app, CreateProcDYCCFolderDialog dialog) {
// TODO Auto-generated constructor stub // Auto-generated constructor stub
this.app = app; this.app = app;
this.dialog = dialog; this.dialog = dialog;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
} }
public void readData(ProgressBar pb, List<TCComponentItemRevision> revs) throws Exception { protected void readData(ProgressBar pb, List<TCComponentItemRevision> revs) throws Exception {//TODO
long startTime = System.currentTimeMillis();
pb.startProgress(); pb.startProgress();
pb.setText("¼ÓÔØÊý¾Ý..."); pb.setText("加载数据..." + revs.size());
TCComponentItemRevision rev; TCComponentItemRevision rev;
@ -221,11 +223,14 @@ public class CreateProcDYCCFolderController {
List<TreePath> paths = new ArrayList<>(); List<TreePath> paths = new ArrayList<>();
TreePath path; TreePath path;
System.out.println("read1:" + (System.currentTimeMillis() - startTime) / 1000);
for (int i = 0, len = revs.size(); i < len; i++) { for (int i = 0, len = revs.size(); i < len; i++) {
long start = System.currentTimeMillis();
rev = revs.get(i); rev = revs.get(i);
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
topLine = win.getTopBOMLine(); topLine = win.getTopBOMLine();
topBean = new BomBean(rev, topLine, 1); topBean = new BomBean(rev, topLine, 1);
System.out.println("revs1:" + (System.currentTimeMillis() - start));
factoryNos = rev.getRelatedComponents("ZT2_FactoryNumber"); factoryNos = rev.getRelatedComponents("ZT2_FactoryNumber");
if (factoryNos != null && factoryNos.length > 0) { if (factoryNos != null && factoryNos.length > 0) {
@ -233,7 +238,9 @@ public class CreateProcDYCCFolderController {
topBean.addFactoryID(factoryNos[j].getProperty("item_id")); topBean.addFactoryID(factoryNos[j].getProperty("item_id"));
} }
} }
System.out.println("revs2:" + (System.currentTimeMillis() - start));
topBean.getFactoryNo(); topBean.getFactoryNo();
System.out.println("revs3:" + (System.currentTimeMillis() - start));
topTreeNode = new DefaultMutableTreeNode(topBean); topTreeNode = new DefaultMutableTreeNode(topBean);
if (topLine.hasChildren()) { if (topLine.hasChildren()) {
childNode = new DefaultMutableTreeNode(new BomBean(rev, topLine, 1)); childNode = new DefaultMutableTreeNode(new BomBean(rev, topLine, 1));
@ -245,13 +252,16 @@ public class CreateProcDYCCFolderController {
list = new ArrayList<>(64); list = new ArrayList<>(64);
dialog.map_nodes.put(topTreeNode, list); dialog.map_nodes.put(topTreeNode, list);
dialog.rev_nodes.put(rev, topTreeNode); dialog.rev_nodes.put(rev, topTreeNode);
System.out.println("revs4:" + (System.currentTimeMillis() - start));
} }
System.out.println("read2:" + (System.currentTimeMillis() - startTime) / 1000);
for (int i = 0; i < paths.size(); i++) { for (int i = 0; i < paths.size(); i++) {
dialog.tree.collapsePath(paths.get(i)); dialog.tree.collapsePath(paths.get(i));
} }
dialog.t_model.reload(dialog.topNode); dialog.t_model.reload(dialog.topNode);
win.refresh(); win.refresh();
win.close(); win.close();
System.out.println("read3:" + (System.currentTimeMillis() - startTime) / 1000);
} }
public void refushTable(List<DYCCProcBean> list) throws Exception { public void refushTable(List<DYCCProcBean> list) throws Exception {
@ -272,6 +282,7 @@ public class CreateProcDYCCFolderController {
} }
} }
@SuppressWarnings("deprecation")
public void manualFeeding(ProgressBar pb, List<TCComponentItemRevision> revs, TCComponent comp) throws Exception { public void manualFeeding(ProgressBar pb, List<TCComponentItemRevision> revs, TCComponent comp) throws Exception {
long time = new Date().getTime(); long time = new Date().getTime();
pb.startProgress(); pb.startProgress();
@ -317,7 +328,7 @@ public class CreateProcDYCCFolderController {
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
TCComponentBOMLine topLine; TCComponentBOMLine topLine;
// 投料工序ID // 投料工序ID
AIFComponentContext[] cLines; // AIFComponentContext[] cLines;
TCComponent[] children; TCComponent[] children;
Map<String, VecStruct> fields = new LinkedHashMap<String, VecStruct>(); Map<String, VecStruct> fields = new LinkedHashMap<String, VecStruct>();
String item_id = comp.getProperty("item_id"); String item_id = comp.getProperty("item_id");
@ -348,14 +359,14 @@ public class CreateProcDYCCFolderController {
// KUtil.info(dialog, "投料完成"); // KUtil.info(dialog, "投料完成");
} }
private int num_current = 0; // private int num_current = 0;
private int num_cout = 0; // private int num_cout = 0;
public void manualFeeding3(ProgressBar pb, List<TCComponentItemRevision> revs, TCComponent comp) throws Exception { public void manualFeeding3(ProgressBar pb, List<TCComponentItemRevision> revs, TCComponent comp) throws Exception {
long time = new Date().getTime(); long time = new Date().getTime();
TCComponentItem item; TCComponentItem item;
TCComponentItemRevision rev; TCComponentItemRevision rev;
num_cout = revs.size(); // num_cout = revs.size();
pb.startProgress(); pb.startProgress();
pb.setText("投料..."); pb.setText("投料...");
Map<String, VecStruct> fields = new LinkedHashMap<String, VecStruct>(); Map<String, VecStruct> fields = new LinkedHashMap<String, VecStruct>();
@ -369,8 +380,8 @@ public class CreateProcDYCCFolderController {
CreateBOMWindowsResponse bomResp; CreateBOMWindowsResponse bomResp;
DataManagementService dmService = DataManagementService.getService(session); DataManagementService dmService = DataManagementService.getService(session);
StructureManagementService structureService = StructureManagementService.getService(session); StructureManagementService structureService = StructureManagementService.getService(session);
com.teamcenter.services.rac.bom.StructureManagementService bomService = com.teamcenter.services.rac.bom.StructureManagementService com.teamcenter.services.rac.bom.StructureManagementService bomService
.getService(session); = com.teamcenter.services.rac.bom.StructureManagementService.getService(session);
AddOrUpdateChildrenToParentLineInfo[] chindInfo = new AddOrUpdateChildrenToParentLineInfo[1]; AddOrUpdateChildrenToParentLineInfo[] chindInfo = new AddOrUpdateChildrenToParentLineInfo[1];
bomService.addOrUpdateChildrenToParentLine(chindInfo); bomService.addOrUpdateChildrenToParentLine(chindInfo);
@ -444,6 +455,7 @@ public class CreateProcDYCCFolderController {
} }
} }
@SuppressWarnings("deprecation")
public void manualFeeding(ProgressBar pb, List<TCComponentItemRevision> revs, String pmpcCode) throws Exception { public void manualFeeding(ProgressBar pb, List<TCComponentItemRevision> revs, String pmpcCode) throws Exception {
pb.startProgress(); pb.startProgress();
pb.setText("投料..."); pb.setText("投料...");
@ -475,6 +487,7 @@ public class CreateProcDYCCFolderController {
} }
// 批量投料 // 批量投料
@SuppressWarnings("deprecation")
public void serBomLine(TCComponentBOMLine line, Map<String, String> fileds) throws Exception { public void serBomLine(TCComponentBOMLine line, Map<String, String> fileds) throws Exception {
line.setProperties(fileds); line.setProperties(fileds);
if (line.isPacked()) { if (line.isPacked()) {
@ -494,7 +507,8 @@ public class CreateProcDYCCFolderController {
} }
} }
public void readData(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception { protected 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();
@ -507,7 +521,30 @@ public class CreateProcDYCCFolderController {
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
List<DYCCProcBean> procBeanList = new ArrayList<>(); List<DYCCProcBean> procBeanList = new ArrayList<>();
readBom(topTreeNode, topLine, pb, rev, topBean, procBeanList); List<TCComponent> bomList = new ArrayList<>();
List<TCComponent> bomRevList = new ArrayList<>();
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
MessageBox.post("数据库连接失败,请检查数据库连接配置!", "", 2);
return;
}
System.out.println("readData1:" + (System.currentTimeMillis() - startTime) / 1000);
//TODO 预加载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);
System.out.println("readData2:" + (System.currentTimeMillis() - startTime) / 1000);
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", "ZT2_TYSpecifications" });
dmService.getProperties(bomRevList.toArray(new TCComponent[0]), new String[] { "object_type", "item_id",
"zt2_Source", "zt2_MaterialNo", "zt2_MaterialMark", "zt2_ClassificationCode", "representation_for" });
group = session.getCurrentGroup().getUid();
System.out.println("readData3:" + (System.currentTimeMillis() - startTime) / 1000);
readBom(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList);
System.out.println("readData4:" + (System.currentTimeMillis() - startTime) / 1000);
dialog.map_nodes.put(topTreeNode, procBeanList); dialog.map_nodes.put(topTreeNode, procBeanList);
refushTable(procBeanList); refushTable(procBeanList);
for (int i = cout - 1; i > -1; i--) { for (int i = cout - 1; i > -1; i--) {
@ -519,25 +556,27 @@ public class CreateProcDYCCFolderController {
}catch(Exception e) { }catch(Exception e) {
} }
SqlUtil.freeAll();
System.out.println("readData5:" + (System.currentTimeMillis() - startTime) / 1000);
win.close(); win.close();
} }
private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb, private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine,
TCComponentItemRevision parentRev, BomBean parentBean, List<DYCCProcBean> procBeanList) throws Exception { Map<String, ExpandPSData[]> bomLineTree, ProgressBar pb, TCComponentItemRevision parentRev,
BomBean parentBean, List<DYCCProcBean> procBeanList) throws Exception {
readTemplate(topLine, parentRev, parentBean, procBeanList); readTemplate(topLine, parentRev, parentBean, procBeanList);
BomBean pBean = (BomBean) treeNode.getUserObject(); BomBean pBean = (BomBean) treeNode.getUserObject();
pb.setText("加载数据..." + pBean); pb.setText("加载数据..." + pBean);
AIFComponentContext[] cLines = topLine.getChildren(); ExpandPSData[] cLines = bomLineTree.get(topLine.getUid());
TCComponentItemRevision parentRev2 = topLine.getItemRevision(); TCComponentItemRevision parentRev2 = topLine.getItemRevision();
for (int i = 0; i < cLines.length; i++) { for (int i = 0; i < cLines.length; i++) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent(); TCComponentBOMLine cLine = cLines[i].bomLine;
TCComponentItemRevision cRev = cLine.getItemRevision(); TCComponentItemRevision cRev = cLines[i].itemRevOfBOMLine;
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);
readBom(cNode, cLine, pb, parentRev2, cBean, procBeanList); readBom(cNode, cLine, bomLineTree, pb, parentRev2, cBean, procBeanList);
} }
} }
@ -554,8 +593,9 @@ public class CreateProcDYCCFolderController {
String type = rev.getType(); String type = rev.getType();
DYCCProcBean bean; DYCCProcBean bean;
AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, // AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" }); // new String[] { "IMAN_METarget" });
TCComponentItemRevision cpgy = getMeproces(rev);
System.out.println("rev:" + rev); System.out.println("rev:" + rev);
if ("ZT2_Design3DRevision".equals(type)) { if ("ZT2_Design3DRevision".equals(type)) {
drawingNo = rev.getProperty("item_id"); drawingNo = rev.getProperty("item_id");
@ -563,26 +603,24 @@ public class CreateProcDYCCFolderController {
zt2_MaterialMark = rev.getProperty("zt2_MaterialMark"); zt2_MaterialMark = rev.getProperty("zt2_MaterialMark");
System.out.println("zt2_MaterialMark:" + zt2_MaterialMark); System.out.println("zt2_MaterialMark:" + zt2_MaterialMark);
// 如果图纸未关联工艺,查看关联物料是否关联工艺 // 如果图纸未关联工艺,查看关联物料是否关联工艺
if (comps == null || comps.length == 0) { if (cpgy == null) {
part = getPart(topLine, session); part = getPart(topLine, session);
if (part != null) { if (part != null) {
comps = part.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, // comps = part.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" }); // new String[] { "IMAN_METarget" });
if (comps != null && comps.length > 0) { cpgy = getMeproces(part);
gy = (TCComponent) comps[0].getComponent(); if (cpgy != null) {
gy = cpgy;
} }
} }
} else if (comps.length > 0) { } else {
gy = (TCComponent) comps[0].getComponent(); gy = cpgy;
part = rev; part = rev;
} }
} else if ("Part Revision".equals(type)) { } else if ("Part Revision".equals(type)) {
drawingNo = rev.getProperty("zt2_MaterialNo"); drawingNo = rev.getProperty("zt2_MaterialNo");
if (cpgy != null) {
if (comps != null && comps.length > 0) { gy = cpgy;
gy = (TCComponent) comps[0].getComponent();
} }
} }
@ -594,10 +632,8 @@ public class CreateProcDYCCFolderController {
if (res2.getListCount() > 0) { if (res2.getListCount() > 0) {
gx = (TCComponent) res2.get(0).getComponent(); gx = (TCComponent) res2.get(0).getComponent();
} }
} }
bean = new DYCCProcBean(procBeanList.size() + 1, drawingNo, object_name, zt2_Source, gy, gx, zt2_MaterialMark, bean = new DYCCProcBean(procBeanList.size() + 1, drawingNo, object_name, zt2_Source, gy, gx, zt2_MaterialMark, rev);
rev);
String bl_sequence_no = topLine.getProperty("bl_sequence_no"); String bl_sequence_no = topLine.getProperty("bl_sequence_no");
bean.setBl_sequence_no(bl_sequence_no); bean.setBl_sequence_no(bl_sequence_no);
bean.setParentRev(parentRev); bean.setParentRev(parentRev);
@ -614,22 +650,19 @@ public class CreateProcDYCCFolderController {
list2.add(bean); list2.add(bean);
dialog.rev_Beans.put(rev, list2); dialog.rev_Beans.put(rev, list2);
} }
dialog.bomLink_maps.put(parentBean, bean); dialog.bomLink_maps.put(parentBean, bean);
} }
public TCComponentItemRevision getPart(TCComponentBOMLine line, TCSession session) throws TCException { private TCComponentItemRevision getPart(TCComponentBOMLine line, TCSession session) throws TCException {
TCComponent comp = line.getItemRevision(); TCComponent comp = line.getItemRevision();
// comp.refresh(); // comp.refresh();
if (comp.getType().equals("Part Revision")) { if (comp.getType().equals("Part Revision")) {
return (TCComponentItemRevision) comp; return (TCComponentItemRevision) comp;
} }
String zt2_Diagram = comp.getTCProperty("zt2_Diagram").getStringValue(); // String zt2_Diagram = comp.getTCProperty("zt2_Diagram").getStringValue();
String spec = comp.getProperty("zt2_Specifications"); String spec = comp.getProperty("zt2_Specifications");
try { try {
TCComponent[] comps = comp.getReferenceListProperty("representation_for"); TCComponent[] comps = comp.getReferenceListProperty("representation_for");
List<TCComponentItemRevision> parts = new ArrayList<TCComponentItemRevision>(); List<TCComponentItemRevision> parts = new ArrayList<TCComponentItemRevision>();
for (int i = 0; i < comps.length; i++) { for (int i = 0; i < comps.length; i++) {
@ -661,15 +694,12 @@ public class CreateProcDYCCFolderController {
} else { } else {
return null; return null;
} }
} else if (size > 1) { } else if (size > 1) {
List<InterfaceAIFComponent> materials = context.toComponentVector(); List<InterfaceAIFComponent> materials = context.toComponentVector();
Collections.sort(materials, new Comparator<InterfaceAIFComponent>() { Collections.sort(materials, new Comparator<InterfaceAIFComponent>() {
@Override @Override
public int compare(InterfaceAIFComponent o1, InterfaceAIFComponent o2) { public int compare(InterfaceAIFComponent o1, InterfaceAIFComponent o2) {
// TODO Auto-generated method stub // Auto-generated method stub
try { try {
String zt2_MaterialNo1 = o1.getProperty("zt2_MaterialNo"); String zt2_MaterialNo1 = o1.getProperty("zt2_MaterialNo");
String zt2_MaterialNo2 = o2.getProperty("zt2_MaterialNo"); String zt2_MaterialNo2 = o2.getProperty("zt2_MaterialNo");
@ -683,7 +713,6 @@ public class CreateProcDYCCFolderController {
} }
return 0; return 0;
} }
}); });
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (KUtil.isTCM((TCComponent) materials.get(i))) { if (KUtil.isTCM((TCComponent) materials.get(i))) {
@ -698,14 +727,12 @@ public class CreateProcDYCCFolderController {
if (parts.size() == 1) { if (parts.size() == 1) {
return parts.get(0); return parts.get(0);
} else { } else {
for (int i = 0; i < parts.size(); i++) { for (int i = 0; i < parts.size(); i++) {
String spec2 = parts.get(i).getProperty("zt2_Specifications"); String spec2 = parts.get(i).getProperty("zt2_Specifications");
if (spec.equals(spec2)) { if (spec.equals(spec2)) {
return parts.get(i); return parts.get(i);
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -713,7 +740,7 @@ public class CreateProcDYCCFolderController {
return null; return null;
} }
private void getGX(TCComponentBOMLine line, List<TCComponentItemRevision> lists) throws TCException { /*private void getGX(TCComponentBOMLine line, List<TCComponentItemRevision> lists) throws TCException {
TCComponentBOMLine parent = line.parent(); TCComponentBOMLine parent = line.parent();
if (parent == null) { if (parent == null) {
return; return;
@ -742,7 +769,7 @@ public class CreateProcDYCCFolderController {
getGX(parent, lists); getGX(parent, lists);
} }
} }*/
public void manualFeeding(ProgressBar pb, int[] sels, TCComponentItemRevision rev, TCComponent comp) public void manualFeeding(ProgressBar pb, int[] sels, TCComponentItemRevision rev, TCComponent comp)
throws Exception { throws Exception {
@ -753,13 +780,13 @@ public class CreateProcDYCCFolderController {
String item_id = comp.getProperty("item_id"); String item_id = comp.getProperty("item_id");
String object_name = comp.getProperty("object_name"); String object_name = comp.getProperty("object_name");
DYCCProcBean bean; DYCCProcBean bean;
TCComponentItemRevision rev2; // TCComponentItemRevision rev2;
String design_item_id; // String design_item_id;
String zt2_ClassificationCode; // String zt2_ClassificationCode;
List<DYCCProcBean> beans = new ArrayList<>(8); List<DYCCProcBean> beans = new ArrayList<>(8);
for (int i = 0; i < sels.length; i++) { for (int i = 0; i < sels.length; i++) {
bean = (DYCCProcBean) dialog.t_part.getValueAt(sels[i], 0); bean = (DYCCProcBean) dialog.t_part.getValueAt(sels[i], 0);
rev2 = bean.getRev(); // rev2 = bean.getRev();
/* /*
* if(rev2.getType().equals("ZT2_Design3DRevision")) { * if(rev2.getType().equals("ZT2_Design3DRevision")) {
* design_item_id = rev2.getProperty("item_id"); zt2_ClassificationCode = * design_item_id = rev2.getProperty("item_id"); zt2_ClassificationCode =
@ -821,6 +848,7 @@ public class CreateProcDYCCFolderController {
} }
// 创建工艺 // 创建工艺
@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)
@ -906,6 +934,7 @@ public class CreateProcDYCCFolderController {
pb.disposeDialog(); pb.disposeDialog();
} }
@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;
@ -938,7 +967,7 @@ public class CreateProcDYCCFolderController {
win.save(); win.save();
win.refresh(); win.refresh();
win.close(); win.close();
} catch (TCException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -946,8 +975,8 @@ public class CreateProcDYCCFolderController {
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();
DYCCProcBean dyccBean; DYCCProcBean dyccBean;
@ -972,7 +1001,7 @@ public class CreateProcDYCCFolderController {
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.setGy(newProc); dyccBean.setGy(newProc);
@ -986,7 +1015,7 @@ public class CreateProcDYCCFolderController {
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);
@ -1076,7 +1105,7 @@ public class CreateProcDYCCFolderController {
String type = ""; String type = "";
List<TCComponentItemRevision> list; List<TCComponentItemRevision> list;
int cout = 0; // int cout = 0;
for (int i = 0, len = revs.size(); i < len; i++) { for (int i = 0, len = revs.size(); i < len; i++) {
rev = revs.get(i); rev = revs.get(i);
if (!KUtil.isHaveMeProcess(rev)) { if (!KUtil.isHaveMeProcess(rev)) {
@ -1103,22 +1132,22 @@ public class CreateProcDYCCFolderController {
if ("DX1".equals(type)) { if ("DX1".equals(type)) {
if (maps_DX1.containsKey(zt2_MaterialNo)) { if (maps_DX1.containsKey(zt2_MaterialNo)) {
maps_DX1.get(zt2_MaterialNo).add(rev); maps_DX1.get(zt2_MaterialNo).add(rev);
cout++; // cout++;
} else { } else {
list = new ArrayList<TCComponentItemRevision>(); list = new ArrayList<TCComponentItemRevision>();
list.add(rev); list.add(rev);
maps_DX1.put(zt2_MaterialNo, list); maps_DX1.put(zt2_MaterialNo, list);
cout++; // cout++;
} }
} else if ("DX3".equals("type")) { } else if ("DX3".equals("type")) {
if (maps_DX3.containsKey(zt2_MaterialNo)) { if (maps_DX3.containsKey(zt2_MaterialNo)) {
maps_DX3.get(zt2_MaterialNo).add(rev); maps_DX3.get(zt2_MaterialNo).add(rev);
cout++; // cout++;
} else { } else {
list = new ArrayList<TCComponentItemRevision>(); list = new ArrayList<TCComponentItemRevision>();
list.add(rev); list.add(rev);
maps_DX3.put(zt2_MaterialNo, list); maps_DX3.put(zt2_MaterialNo, list);
cout++; // cout++;
} }
} }
@ -1217,4 +1246,23 @@ public class CreateProcDYCCFolderController {
} }
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 TCComponentItemRevision getMeproces(TCComponent rev) throws Exception {
String uid = rev.getUid();
TCComponentItemRevision cpgy;// = (TCComponentItemRevision) getMeproces(comp.getUid(), session);
if(mepMap.containsKey(uid))
cpgy = mepMap.get(uid);
else {
cpgy = (TCComponentItemRevision) SAPUtil.getMeprocesYh(uid, group, session);
mepMap.put(uid, cpgy);
}
return cpgy;
}
} }

@ -72,6 +72,8 @@ import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
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.core.DataManagementService;
import sun.swing.table.DefaultTableCellHeaderRenderer; import sun.swing.table.DefaultTableCellHeaderRenderer;
/** /**
@ -165,15 +167,13 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
long startTime = System.currentTimeMillis();
try { try {
final InterfaceAIFComponent comp = app.getTargetComponent(); final InterfaceAIFComponent comp = app.getTargetComponent();
revs = new ArrayList<>(16); revs = new ArrayList<>();
TCComponentItem item; TCComponentItem item;
TCComponentItemRevision rev;
// String zt2_MaterialNo; // String zt2_MaterialNo;
CreateProcBean bean = CreateProcController.getProcPres(session, "CHINT_ORG_TechnologyClassification", CreateProcBean bean = CreateProcController.getProcPres(session, "CHINT_ORG_TechnologyClassification", groupID);
groupID);
if (bean == null) { if (bean == null) {
MessageBox.post("未找到[" + groupID + "]配置,请检查首选项<CHINT_ORG_TechnologyClassification>", "", 2); MessageBox.post("未找到[" + groupID + "]配置,请检查首选项<CHINT_ORG_TechnologyClassification>", "", 2);
return; return;
@ -182,48 +182,42 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
codeRemark_Technology = bean.getCodeRemark_Technology(); codeRemark_Technology = bean.getCodeRemark_Technology();
} }
System.out.println("initUI:" + (System.currentTimeMillis() - startTime) / 1000);
// Command处已过滤掉Folder和TCComponentItemRevision外的其他对象 // Command处已过滤掉Folder和TCComponentItemRevision外的其他对象
String object_name; String object_name;
if (comp instanceof TCComponentFolder) { if (comp instanceof TCComponentFolder) {
folder = (TCComponentFolder) comp; folder = (TCComponentFolder) comp;
AIFComponentContext[] childs = folder.getChildren(); AIFComponentContext[] childs = folder.getChildren();
ArrayList<TCComponentItem> itemList = new ArrayList<>();
ArrayList<TCComponentItemRevision> revList = new ArrayList<>();
for (int i = 0, len = childs.length; i < len; i++) { for (int i = 0, len = childs.length; i < len; i++) {
TCComponentItemRevision rev;
if (childs[i].getComponent() instanceof TCComponentItem) { if (childs[i].getComponent() instanceof TCComponentItem) {
item = (TCComponentItem) childs[i].getComponent(); item = (TCComponentItem) childs[i].getComponent();
rev = item.getLatestItemRevision(); // rev = item.getLatestItemRevision();
if(!itemList.contains(item))
// revs.add(rev); itemList.add(item);
} else if (childs[i].getComponent() instanceof TCComponentItemRevision) {
if (rev.getType().equals("Part Revision")) { rev = (TCComponentItemRevision) childs[i].getComponent();
/* if(!revList.contains(rev))
* zt2_MaterialNo = rev.getProperty("zt2_MaterialNo"); revList.add(rev);
* if(zt2_MaterialNo.contains("9900000135")) { gddy_revs.add(rev); }else
* if(zt2_MaterialNo.contains("9900000608")) { ctdy_revs.add(rev); }else
* if(zt2_MaterialNo.contains("3000042680")||zt2_MaterialNo.contains(
* "3000042679")||zt2_MaterialNo.contains("3000042678")) { jgkt_revs.add(rev);
* }else { revs.add(rev); }
*/
object_name = rev.getProperty("object_name");
if (object_name.contains("미땍데禱")) {
gddy_revs.add(rev);
} else if (object_name.contains("녜脛데禱")) {
ctdy_revs.add(rev);
} else if (object_name.contains("든都데禱")) {
dydy_revs.add(rev);
} else if (object_name.contains("老똥데禱")) {
zddy_revs.add(rev);
} else if (object_name.contains("옳竟")) {
jgkt_revs.add(rev);
} else {
revs.add(rev);
} }
} else {
revs.add(rev);
} }
DataManagementService dmService = DataManagementService.getService(session);
dmService.getProperties(itemList.toArray(new TCComponent[0]),
new String[] { "revision_list" });
for(TCComponentItem i : itemList) {
TCComponent[] revs = i.getReferenceListProperty("revision_list");
TCComponentItemRevision rev = (TCComponentItemRevision) revs[revs.length - 1];
if(!revList.contains(rev))
revList.add(rev);
}
dmService.getProperties(revList.toArray(new TCComponent[0]),
new String[] { "object_type", "object_name", "zt2_MaterialNo", "items_tag", "ZT2_FactoryNumber" });
System.out.println("folder:" + (System.currentTimeMillis() - startTime) / 1000);
} else if (childs[i].getComponent() instanceof TCComponentItemRevision) { for (TCComponentItemRevision rev : revList) {
rev = (TCComponentItemRevision) childs[i].getComponent();
if (!revs.contains(rev)) {
if (rev.getType().equals("Part Revision")) { if (rev.getType().equals("Part Revision")) {
object_name = rev.getProperty("object_name"); object_name = rev.getProperty("object_name");
if (object_name.contains("固定单元")) { if (object_name.contains("固定单元")) {
@ -242,12 +236,9 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
} else { } else {
revs.add(rev); revs.add(rev);
} }
}
}
} }
} else { } else {
rev = (TCComponentItemRevision) comp; TCComponentItemRevision rev = (TCComponentItemRevision) comp;
// zt2_MaterialNo = rev.getProperty("zt2_MaterialNo"); // zt2_MaterialNo = rev.getProperty("zt2_MaterialNo");
object_name = rev.getProperty("object_name"); object_name = rev.getProperty("object_name");
if (object_name.contains("固定单元")) { if (object_name.contains("固定单元")) {
@ -282,6 +273,7 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
MessageBox.post(CreateProcDYCCFolderDialog.this, "未找到版本信息,请检查选择的文件夹对象", "", 2); MessageBox.post(CreateProcDYCCFolderDialog.this, "未找到版本信息,请检查选择的文件夹对象", "", 2);
return; return;
} }
System.out.println("initUI1:" + (System.currentTimeMillis() - startTime) / 1000);
initUI(); initUI();
@ -292,6 +284,7 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
b_autoAssign.setEnabled(true); b_autoAssign.setEnabled(true);
} }
} }
System.out.println("initUI2:" + (System.currentTimeMillis() - startTime) / 1000);
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override

@ -48,7 +48,6 @@ import com.connor.chint.sap2.proc_by.BYProcBean;
import com.connor.chint.sap2.proc_by.BYProduceDialog; import com.connor.chint.sap2.proc_by.BYProduceDialog;
import com.connor.chint.sap2.proc_by.BomBean; import com.connor.chint.sap2.proc_by.BomBean;
import com.connor.chint.sap2.proc_by.MEProDialog; import com.connor.chint.sap2.proc_by.MEProDialog;
import com.connor.chint.sap2.proc_dyccFolder.DYCCProcBean;
import com.connor.chint.sap2.util.ChintConfirmDialogUtil; import com.connor.chint.sap2.util.ChintConfirmDialogUtil;
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;
@ -65,11 +64,17 @@ 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.core.DataManagementService;
import sun.swing.table.DefaultTableCellHeaderRenderer; import sun.swing.table.DefaultTableCellHeaderRenderer;
public class CreateProcGYKGDialog extends AbstractAIFDialog { public class CreateProcGYKGDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private CreateProcGYKGDialogController controller; private CreateProcGYKGDialogController controller;
private AbstractAIFApplication app; private AbstractAIFApplication app;
@ -105,7 +110,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
// 工序 // 工序
private List<TCComponent> by_lists; private List<TCComponent> by_lists;
// 工艺 // 工艺
private List<MEProcessBean> meprocs = new ArrayList(50); private List<MEProcessBean> meprocs = new ArrayList<>();
protected TCComponentFolder folder_target = null; // 选中的文件夹 protected TCComponentFolder folder_target = null; // 选中的文件夹
protected List<TCComponentItemRevision> revs = null; protected List<TCComponentItemRevision> revs = null;
@ -137,8 +142,8 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
groupID = actioninfo; groupID = actioninfo;
} }
} catch (TCException e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -160,7 +165,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
codeRemark_Process = bean.getCodeRemark_Process(); codeRemark_Process = bean.getCodeRemark_Process();
codeRemark_Technology = bean.getCodeRemark_Technology(); codeRemark_Technology = bean.getCodeRemark_Technology();
} }
revs = new ArrayList(); revs = new ArrayList<>();
TCComponentItem item; TCComponentItem item;
TCComponentItemRevision rev; TCComponentItemRevision rev;
if (target instanceof TCComponentItemRevision) { if (target instanceof TCComponentItemRevision) {
@ -170,6 +175,17 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} else if (target instanceof TCComponentFolder) { } else if (target instanceof TCComponentFolder) {
folder_target = (TCComponentFolder) target; folder_target = (TCComponentFolder) target;
AIFComponentContext[] childs = folder_target.getChildren(); AIFComponentContext[] childs = folder_target.getChildren();
ArrayList<TCComponentItem> itemList = new ArrayList<>();
for (int i = 0, len = childs.length; i < len; i++) {
if (childs[i].getComponent() instanceof TCComponentItem) {
item = (TCComponentItem) childs[i].getComponent();
// rev = item.getLatestItemRevision();
if(!itemList.contains(item))
itemList.add(item);
}
}
DataManagementService dmService = DataManagementService.getService(session);
dmService.getProperties(itemList.toArray(new TCComponent[0]), new String[] { "revision_list" });
for (int i = 0, len = childs.length; i < len; i++) { for (int i = 0, len = childs.length; i < len; i++) {
if (childs[i].getComponent() instanceof TCComponentItem) { if (childs[i].getComponent() instanceof TCComponentItem) {
item = (TCComponentItem) childs[i].getComponent(); item = (TCComponentItem) childs[i].getComponent();
@ -193,7 +209,6 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
initUI(); initUI();
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this, new Dimension(250, 50)); ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this, new Dimension(250, 50));
@ -207,24 +222,30 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
if (current_bean != null) { if (current_bean != null) {
controller.readData(pb, rev_nodes.get(current_bean)); controller.readData(pb, rev_nodes.get(current_bean));
} }
// current_bean = (BomBean) rev_nodes.get(current_bean).getUserObject(); // current_bean = (BomBean) rev_nodes.get(current_bean).getUserObject();
} else { } else {
controller.readData(pb, revs); controller.readData(pb, revs);
} }
addListeners();
isAllowExpand = true; isAllowExpand = true;
pb.disposeDialog(); pb.disposeDialog();
by_lists = KUtil.getClassObjects(codeRemark_Process, session);
} catch (Exception e) { } catch (Exception e) {
pb.disposeDialog(); pb.disposeDialog();
MessageBox.post(CreateProcGYKGDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "", MessageBox.post(CreateProcGYKGDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "",
MessageBox.ERROR); MessageBox.ERROR);
e.printStackTrace(); e.printStackTrace();
} }
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
try {
addListeners();
by_lists = KUtil.getClassObjects(codeRemark_Process, session);
} catch (Exception e) {
e.printStackTrace();
}
} }
}).start(); }).start();
@ -263,6 +284,11 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
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 == 3 || column == 7) { if (column == 3 || column == 7) {
@ -307,6 +333,11 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
tree.putClientProperty("JTree.lineStyle", "Horizontal");// 使JTree的文件夹间具有水平分隔线。 tree.putClientProperty("JTree.lineStyle", "Horizontal");// 使JTree的文件夹间具有水平分隔线。
this.treeCellRenderer = new DefaultTreeCellRenderer() { this.treeCellRenderer = new DefaultTreeCellRenderer() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override @Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
boolean leaf, int row, boolean hasFocus) { boolean leaf, int row, boolean hasFocus) {
@ -386,8 +417,8 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} }
} }
System.out.println("版本个数:" + revs.size()); System.out.println("版本个数:" + revs.size());
File[] tcFiles; // File[] tcFiles;
File fmsFile; // File fmsFile;
List<String> paths = new ArrayList<>(); List<String> paths = new ArrayList<>();
// List<TCComponentDataset> datasets = new ArrayList<>(); // List<TCComponentDataset> datasets = new ArrayList<>();
try { try {
@ -410,7 +441,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
for (int j = 0; j < comps.length; j++) { for (int j = 0; j < comps.length; j++) {
if (comps[j] instanceof TCComponentDataset && comps[j].getType().equals("PDF")) { if (comps[j] instanceof TCComponentDataset && comps[j].getType().equals("PDF")) {
dataset = ((TCComponentDataset) comps[j]); dataset = ((TCComponentDataset) comps[j]);
String d_type = dataset.getType(); // String d_type = dataset.getType();
String type = dataset.getProperty("ref_names"); String type = dataset.getProperty("ref_names");
String[] types = type.split(","); String[] types = type.split(",");
for (int l = 0; l < types.length; l++) { for (int l = 0; l < types.length; l++) {
@ -433,7 +464,7 @@ public class CreateProcGYKGDialog 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);
} }
@ -446,7 +477,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // Auto-generated method stub
ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this, new Dimension(250, 50)); ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this, new Dimension(250, 50));
setCompEnabled(false); setCompEnabled(false);
try { try {
@ -519,7 +550,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} }
if (nodes.size() > 0) { if (nodes.size() > 0) {
List<TCComponentItemRevision> revs = new ArrayList<>(); List<TCComponentItemRevision> revs = new ArrayList<>();
BomBean bomBean; // BomBean bomBean;
TCComponentItemRevision rev; TCComponentItemRevision rev;
for (int i = 0; i < nodes.size(); i++) { for (int i = 0; i < nodes.size(); i++) {
rev = ((BomBean) nodes.get(i).getUserObject()).getRev(); rev = ((BomBean) nodes.get(i).getUserObject()).getRev();
@ -533,7 +564,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
new GYKGUpdateProcDialog(CreateProcGYKGDialog.this, revs, rev_Beans, value_strings, new GYKGUpdateProcDialog(CreateProcGYKGDialog.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);
} }
@ -553,7 +584,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
new GYKGUpdateProcDialog(CreateProcGYKGDialog.this, revs, rev_Beans, value_strings, new GYKGUpdateProcDialog(CreateProcGYKGDialog.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);
} }
@ -562,7 +593,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} }
}); });
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
@ -572,9 +603,10 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
// 修改材料定额和自制外购 // 修改材料定额和自制外购
t_part.getModel().addTableModelListener(new TableModelListener() { t_part.getModel().addTableModelListener(new TableModelListener() {
@SuppressWarnings("deprecation")
@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 (row < 0 || col < 0) { if (row < 0 || col < 0) {
@ -661,7 +693,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} }
} catch (Exception e1) { } catch (Exception e1) {
KUtil.setByPass(false); KUtil.setByPass(false);
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
MessageBox.post(CreateProcGYKGDialog.this, "投料异常,ERROR:" + e1.getMessage(), "", MessageBox.post(CreateProcGYKGDialog.this, "投料异常,ERROR:" + e1.getMessage(), "",
MessageBox.ERROR); MessageBox.ERROR);
@ -695,10 +727,10 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
if (nodes.size() > 0) { if (nodes.size() > 0) {
pb.startProgress(); pb.startProgress();
pb.setText("开始校验对象工艺信息......"); pb.setText("开始校验对象工艺信息......");
List<DYCCProcBean> procBeans = new ArrayList<>(); // List<DYCCProcBean> procBeans = new ArrayList<>();
List<BomBean> bomBeans = new ArrayList<>(); List<BomBean> bomBeans = new ArrayList<>();
BomBean bomBean; BomBean bomBean;
DYCCProcBean procBean; // DYCCProcBean procBean;
List<BomBean> allBeans = new ArrayList<>(); List<BomBean> allBeans = new ArrayList<>();
try { try {
for (int i = 0, len = nodes.size(); i < len; i++) { for (int i = 0, len = nodes.size(); i < len; i++) {
@ -738,7 +770,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
return; return;
} }
KUtil.setByPass(true); KUtil.setByPass(true);
TCComponentItemRevision meop; // TCComponentItemRevision meop;
pb.startProgress(); pb.startProgress();
pb.showDialog(); pb.showDialog();
pb.setText("工艺模板准备中..."); pb.setText("工艺模板准备中...");
@ -748,7 +780,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} catch (Exception e) { } catch (Exception e) {
pb.disposeDialog(); pb.disposeDialog();
// TODO: handle exception // : handle exception
e.printStackTrace(); e.printStackTrace();
MessageBox.post(CreateProcGYKGDialog.this, "异常:" + e.getMessage(), "提示", 2); MessageBox.post(CreateProcGYKGDialog.this, "异常:" + e.getMessage(), "提示", 2);
} }
@ -839,7 +871,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this, ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this,
new Dimension(250, 50)); new Dimension(250, 50));
setCompEnabled(false); setCompEnabled(false);
@ -862,7 +894,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
controller.refushTable(map_nodes.get(node)); controller.refushTable(map_nodes.get(node));
current_bean = (BomBean) node.getUserObject(); current_bean = (BomBean) node.getUserObject();
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
MessageBox.post(CreateProcGYKGDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "", MessageBox.post(CreateProcGYKGDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "",
MessageBox.ERROR); MessageBox.ERROR);
e1.printStackTrace(); e1.printStackTrace();
@ -874,7 +906,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
/* /*
* tree.clearSelection(); try { * tree.clearSelection(); try {
* KUtil.recurAdd(tree,path,t_model,node,node,tm_part,bomLink_maps); * KUtil.recurAdd(tree,path,t_model,node,node,tm_part,bomLink_maps);
* controller.refushTable2(); } catch (Exception e) { // TODO Auto-generated * controller.refushTable2(); } catch (Exception e) { // Auto-generated
* catch block e.printStackTrace(); } * catch block e.printStackTrace(); }
*/ */
} }
@ -896,7 +928,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
// controller.recurRemove(model,node,tm_part,bomLink_maps); // controller.recurRemove(model,node,tm_part,bomLink_maps);
// controller.refushTable2(); // controller.refushTable2();
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }

@ -1,7 +1,8 @@
package com.connor.chint.sap2.proc_gykg; package com.connor.chint.sap2.proc_gykg;
import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -18,23 +19,27 @@ import com.connor.chint.sap2.bean.MEProcGXBean;
import com.connor.chint.sap2.bean.MEProcessBean; import com.connor.chint.sap2.bean.MEProcessBean;
import com.connor.chint.sap2.create_proc.CreateProcController; import com.connor.chint.sap2.create_proc.CreateProcController;
import com.connor.chint.sap2.proc.CreateProcessController; import com.connor.chint.sap2.proc.CreateProcessController;
import com.connor.chint.sap2.proc.ProcBean;
import com.connor.chint.sap2.proc_by.BYProcBean; import com.connor.chint.sap2.proc_by.BYProcBean;
import com.connor.chint.sap2.proc_by.BomBean; import com.connor.chint.sap2.proc_by.BomBean;
import com.connor.chint.sap2.proc_gy.GYProcCellEditor; import com.connor.chint.sap2.proc_gy.GYProcCellEditor;
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.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.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.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.TCComponentContextList;
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.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
import com.teamcenter.services.rac.core.DataManagementService;
public class CreateProcGYKGDialogController { public class CreateProcGYKGDialogController {
@ -50,8 +55,8 @@ public class CreateProcGYKGDialogController {
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
try { try {
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
} catch (TCException e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -107,6 +112,7 @@ public class CreateProcGYKGDialogController {
// 单独打开一个子项 // 单独打开一个子项
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();
@ -118,17 +124,46 @@ public class CreateProcGYKGDialogController {
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> idList = new ArrayList<>();
List<TCComponent> bomList = new ArrayList<>();
List<TCComponent> bomRevList = new ArrayList<>();
List<TCComponent> meopList = new ArrayList<>();
// readBom(topTreeNode, topLine, pb,rev,topBean,procBeanList2); // readBom(topTreeNode, topLine, pb,rev,topBean,procBeanList2);
// 20220418改 // 20220418改 TODO
readTemplate(topLine, rev, topBean, procBeanList2); String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
getChilds(topTreeNode, topLine, pb, rev, topBean, procBeanList2); if (SqlUtil.getTCDataConnection(prefs) == null) {
MessageBox.post("数据库连接失败,请检查数据库连接配置!", "", 2);
win.refresh(); return;
}
System.out.println("readData1:" + (System.currentTimeMillis() - startTime) / 1000);
//预加载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",
"object_name", "zt2_Diagram", "zt2_MaterialNo", "zt2_Source", "zt2_MaterialNorm",
"zt2_MaterialMark" });
System.out.println("readData2:" + (System.currentTimeMillis() - startTime) / 1000);
readTemplate(topLine, rev, topBean, procBeanList2, codeList, idList);
getChilds(topTreeNode, topLine, bomLineTree, pb, rev, topBean, procBeanList2, codeList, idList);
System.out.println("readData2.5:" + (System.currentTimeMillis() - startTime) / 1000);
getGY(procBeanList2, codeList, idList, meopList);
System.out.println("readData3:" + (System.currentTimeMillis() - startTime) / 1000);
dmService.getProperties(meopList.toArray(new TCComponent[0]), new String[] { "object_name" });
// win.refresh();
win.close(); win.close();
procBeanList.clear(); procBeanList.clear();
procBeanList.addAll(procBeanList2); procBeanList.addAll(procBeanList2);
dialog.map_nodes.put(topTreeNode, procBeanList2); dialog.map_nodes.put(topTreeNode, procBeanList2);
refushTable(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);
} }
@ -139,56 +174,61 @@ public class CreateProcGYKGDialogController {
dialog.t_part.getColumnModel().getColumn(3).setCellEditor(procEditoe); dialog.t_part.getColumnModel().getColumn(3).setCellEditor(procEditoe);
} }
dialog.t_model.reload(); dialog.t_model.reload();
SqlUtil.freeAll();
System.out.println("readData5:" + (System.currentTimeMillis() - startTime) / 1000);
} }
/* /*
* //读取数据 private void readBom(DefaultMutableTreeNode treeNode, * //读取数据
* TCComponentBOMLine topLine, ProgressBar pb,TCComponentItemRevision * private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb,
* parentRev,BomBean parentBean ,List<BYProcBean> beanList) throws Exception { * TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> beanList) throws Exception {
* readTemplate(topLine,parentRev,parentBean,beanList); BomBean pBean = * readTemplate(topLine,parentRev,parentBean,beanList);
* (BomBean) treeNode.getUserObject(); pb.setText("加载数据..."+pBean); * BomBean pBean = (BomBean) treeNode.getUserObject();
* AIFComponentContext[] cLines = topLine.getChildren(); TCComponentItemRevision * pb.setText("加载数据..."+pBean);
* parentRev2 = topLine.getItemRevision(); for (int i = 0; i < cLines.length; * AIFComponentContext[] cLines = topLine.getChildren();
* i++) { TCComponentBOMLine cLine = (TCComponentBOMLine) * TCComponentItemRevision parentRev2 = topLine.getItemRevision();
* cLines[i].getComponent(); TCComponentItemRevision cRev = * for (int i = 0; i < cLines.length; i++) {
* cLine.getItemRevision(); BomBean cBean = new * TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent();
* BomBean(cRev,cLine,procBeanList.size()+1); pBean.getChildren().add(cBean); * TCComponentItemRevision cRev = cLine.getItemRevision();
* BomBean cBean = new BomBean(cRev, cLine,procBeanList.size() + 1);
* pBean.getChildren().add(cBean);
* DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean); * DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
* treeNode.add(cNode); System.out.println("添加:" + cBean); readBom(cNode, cLine, * treeNode.add(cNode);
* pb,parentRev2,cBean,beanList); } } * System.out.println("添加:" + cBean);
* * readBom(cNode, cLine, pb, parentRev2, cBean, beanList);
* * }
* }
*/ */
public void getChilds(DefaultMutableTreeNode topNode, TCComponentBOMLine line, ProgressBar pb, public void getChilds(DefaultMutableTreeNode topNode, TCComponentBOMLine line,
TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> beanList) throws Exception { Map<String, ExpandPSData[]> bomLineTree, ProgressBar pb, TCComponentItemRevision parentRev,
BomBean parentBean, List<BYProcBean> beanList, List<String> codeList, List<String> idList) throws Exception {
// pb.setText("加载数据..."+pBean); // pb.setText("加载数据..."+pBean);
AIFComponentContext[] childs = line.getChildren(); // AIFComponentContext[] childs = line.getChildren();
TCComponentBOMLine childLine; TCComponentBOMLine childLine;
TCComponentItemRevision rev; TCComponentItemRevision rev;
BomBean bean; BomBean bean;
DefaultMutableTreeNode cNode; DefaultMutableTreeNode cNode;
TCComponentItemRevision parentRev2 = line.getItemRevision(); TCComponentItemRevision parentRev2 = line.getItemRevision();
for (int i = 0, len = childs.length; i < len; i++) { for (ExpandPSData data : bomLineTree.get(line.getUid())) {
childLine = (TCComponentBOMLine) childs[i].getComponent(); childLine = data.bomLine;//(TCComponentBOMLine) childs[i].getComponent();
rev = childLine.getItemRevision(); rev = data.itemRevOfBOMLine;
// 若为虚拟项,则过滤,并把虚拟项下面的子项往上提升 // 若为虚拟项,则过滤,并把虚拟项下面的子项往上提升
// 0714改 若为虚拟项,则过滤,并把虚拟项下面的子项都过滤 // 0714改 若为虚拟项,则过滤,并把虚拟项下面的子项都过滤
if ("是".equals(rev.getProperty("zt2_Diagram"))) { if ("是".equals(rev.getProperty("zt2_Diagram"))) {
// getChilds(topNode,childLine, pb,parentRev2,parentBean,beanList); // getChilds(topNode,childLine, pb,parentRev2,parentBean,beanList);
} else { } else {
bean = new BomBean(rev, childLine, 1); bean = new BomBean(rev, childLine, 1);
readTemplate(childLine, parentRev2, bean, beanList); readTemplate(childLine, parentRev2, bean, beanList, codeList, idList);
cNode = new DefaultMutableTreeNode(bean); cNode = new DefaultMutableTreeNode(bean);
topNode.add(cNode); topNode.add(cNode);
getChilds(cNode, childLine, pb, parentRev2, bean, beanList); getChilds(cNode, childLine, bomLineTree, pb, parentRev2, bean, beanList, codeList, idList);
} }
} }
} }
private BYProcBean readTemplate(TCComponentBOMLine topLine, TCComponentItemRevision parentRev, BomBean parentBean, private BYProcBean readTemplate(TCComponentBOMLine topLine, TCComponentItemRevision parentRev, BomBean parentBean,
List<BYProcBean> beanList) throws Exception { List<BYProcBean> beanList, List<String> codeList, List<String> idList) throws Exception {
TCComponentItemRevision comp = topLine.getItemRevision(); TCComponentItemRevision comp = topLine.getItemRevision();
String bl_sequence_no = topLine.getProperty("bl_sequence_no"); String bl_sequence_no = topLine.getProperty("bl_sequence_no");
String drawNo = ""; String drawNo = "";
@ -205,7 +245,7 @@ public class CreateProcGYKGDialogController {
String zt2_MaterialMark = comp.getProperty("zt2_MaterialMark"); String zt2_MaterialMark = comp.getProperty("zt2_MaterialMark");
TCComponentItemRevision meop = null; TCComponentItemRevision meop = null;
TCComponentItemRevision meopress = null; TCComponentItemRevision meopress = null;
AIFComponentContext[] refs = comp.whereReferencedByTypeRelation(null, null); /*AIFComponentContext[] refs = comp.whereReferencedByTypeRelation(null, null);
System.out.println("查询产品工艺、投料工序:" + comp + ", 引用数量:" + refs.length); System.out.println("查询产品工艺、投料工序:" + comp + ", 引用数量:" + refs.length);
for (int i = 0; i < refs.length; i++) { for (int i = 0; i < refs.length; i++) {
InterfaceAIFComponent c = refs[i].getComponent(); InterfaceAIFComponent c = refs[i].getComponent();
@ -216,12 +256,16 @@ public class CreateProcGYKGDialogController {
break; break;
} }
} }
*/
// System.out.println("meop=" + comp.getUid() + "==" + group);
// meop = (TCComponentItemRevision) SAPUtil.getMeprocesYh(comp.getUid(), group, session);
codeList.add(comp.getUid());
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) { /*if (zt2_ClassificationCode.length() > 0) {
Map<String, String> fields2 = new LinkedHashMap<>(); Map<String, String> fields2 = new LinkedHashMap<>();
fields2.put("ID", zt2_ClassificationCode); fields2.put("ID", zt2_ClassificationCode);
TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2); TCComponentContextList res2 = KUtil.query(session, "chint_query_item", fields2);//TODO
if (res2 != null) { if (res2 != null) {
int len2 = res2.getListCount(); int len2 = res2.getListCount();
@ -232,7 +276,8 @@ public class CreateProcGYKGDialogController {
meopress = (TCComponentItemRevision) res2.get(0).getComponent(); meopress = (TCComponentItemRevision) res2.get(0).getComponent();
} }
} }
} }*/
idList.add(zt2_ClassificationCode);
BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, parentRev, drawNo, object_name, zt2_Source, BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, parentRev, drawNo, object_name, zt2_Source,
meop, meopress, zt2_MaterialNorm, zt2_MaterialMark); meop, meopress, zt2_MaterialNorm, zt2_MaterialMark);
bean.setBl_sequence_no(bl_sequence_no); bean.setBl_sequence_no(bl_sequence_no);
@ -248,7 +293,7 @@ public class CreateProcGYKGDialogController {
return bean; return bean;
} }
public void refushTable(List<BYProcBean> list) throws Exception { protected void refushTable(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();
@ -259,13 +304,100 @@ public class CreateProcGYKGDialogController {
} }
} }
public void refushTable2() throws Exception { private void refushTable2(List<BYProcBean> list) throws Exception {
int cout = dialog.t_part.getRowCount(); for(int i = dialog.t_part.getRowCount() - 1; i >= 0; i--) {
BYProcBean bean; dialog.tm_part.removeRow(i);
for (int i = 0, len = cout; i < len; i++) { }
bean = (BYProcBean) dialog.t_part.getValueAt(i, 0); for (int i = 0, len = list.size(); i < len; i++) {
bean.setIndex(i + 1); list.get(i).setIndex(i + 1);
dialog.t_part.setValueAt(bean, i, 0); dialog.tm_part.addRow(list.get(i).getGYRowData());
}
}
private void getGY(List<BYProcBean> procBeanList, List<String> codeList, List<String> idList, List<TCComponent> meopList) throws Exception {
HashMap<String, TCComponentItemRevision> uidMap = new HashMap<>();
//查询工艺路线
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 P.puid as supItemUID,V.puid as supRevUID,");
sql1.append("P.pitem_id as supItemID,ITRO.Pobject_Name as supItemName,V.Pitem_Revision_Id as supRevID,")
.append("cP.pitem_id as subItemID,cV.puid as subRevUID,RT.partifactname as 版本与版本关系 ")
.append("from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,")
.append("PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g,PPOM_GROUP g1 ")
.append("where g.ROWNING_GROUPU=g1.PUID and g.puid=V.puid and V.Puid = R.Rprimary_Objectu ")
.append("and r.rrelation_typeu = RT.puid and P.Puid = V.Ritems_Tagu and ITRO.Puid = V.Puid ")
.append("and R.Rsecondary_Objectu = cV.Puid and cP.Puid = cV.Ritems_Tagu and cV.Puid = cITRO.Puid ")
.append("and ITRO.Pactive_Seq<>0 and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' ")
.append("and g1.pname='").append(SAPUtil.getGroupID(session)).append("' and cV.PUID in (")
.append(codes.substring(2))
.append("') order by cV.puid");
System.out.println("sql1\n" + sql1);
ResultSet read = SqlUtil.read(sql1.toString());
String last = "";
while (read.next()) {
String id = read.getString("subRevUID");
if(id.equals(last))
continue;
String uid = read.getString("supRevUID");
for(int i = 0; i < codeList.size(); i++) {
if(codeList.get(i).equals(id)) {
BYProcBean bean = procBeanList.get(i);
if(uidMap.containsKey(uid))
bean.setMeop(uidMap.get(uid));
else {
TCComponentItemRevision tlgxRev = (TCComponentItemRevision) session.stringToComponent(uid);
bean.setMeop(tlgxRev);
meopList.add(tlgxRev);
uidMap.put(uid, tlgxRev);
}
}
}
last = id;
}
//查询投料工序
codes = new StringBuilder("");
noSet = new ArrayList<>();
for(String s : idList) {
if(noSet.contains(s))
continue;
noSet.add(s);
codes.append("','").append(s);
}
sql1 = new StringBuilder("select a.pitem_id,b.puid ");
sql1.append("from PITEM a,PITEMREVISION b,PPOM_APPLICATION_OBJECT b1 ")
.append("where a.puid=b.RITEMS_TAGU and b.puid=b1.puid and b1.PCREATION_DATE in ")
.append("(select max(r3.PCREATION_DATE) from pitem r1,PITEMREVISION r2,PPOM_APPLICATION_OBJECT r3 ")
.append("where r1.puid=r2.ritems_tagu and r2.puid=r3.puid and r1.pitem_id=a.pitem_id) and a.pitem_id in (")
.append(codes.substring(2))
.append("') order by b.puid");
System.out.println("sql2\n" + sql1);
read = SqlUtil.read(sql1.toString());
last = "";
while (read.next()) {
String id = read.getString(1);
if(id.equals(last))
throw new Exception("通过 ID = " + id + " 查询到多个对象");
String uid = read.getString(2);
for(int i = 0; i < idList.size(); i++) {
if(idList.get(i).equals(id)) {
BYProcBean bean = procBeanList.get(i);
if(uidMap.containsKey(uid))
bean.setMeopress(uidMap.get(uid));
else {
TCComponentItemRevision tlgxRev = (TCComponentItemRevision) session.stringToComponent(uid);
bean.setMeopress(tlgxRev);
meopList.add(tlgxRev);
uidMap.put(uid, tlgxRev);
}
}
}
last = id;
} }
} }
@ -287,6 +419,7 @@ public class CreateProcGYKGDialogController {
return nodes; return nodes;
} }
@SuppressWarnings("deprecation")
public void manualFeeding2(BYProcBean bean, String ZT2_ClassificationNo) throws Exception { public void manualFeeding2(BYProcBean bean, String ZT2_ClassificationNo) throws Exception {
StringBuilder err = new StringBuilder(); StringBuilder err = new StringBuilder();
TCComponentItemRevision rev = dialog.current_bean.getRev(); TCComponentItemRevision rev = dialog.current_bean.getRev();
@ -295,7 +428,7 @@ public class CreateProcGYKGDialogController {
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
BomBean topBean = new BomBean(rev, topLine, 1); // BomBean topBean = new BomBean(rev, topLine, 1);
Map<String, String> fields = new LinkedHashMap<String, String>(); Map<String, String> fields = new LinkedHashMap<String, String>();
fields.put("ZT2_ClassificationNo", ZT2_ClassificationNo); fields.put("ZT2_ClassificationNo", ZT2_ClassificationNo);
serBomLine(topLine, bean, false, fields, 0, rev); serBomLine(topLine, bean, false, fields, 0, rev);
@ -324,7 +457,7 @@ public class CreateProcGYKGDialogController {
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
win.setWindowTopLine(bom_Rev.getItem(), bom_Rev, null, null); win.setWindowTopLine(bom_Rev.getItem(), bom_Rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
BomBean topBean = new BomBean(bom_Rev, topLine, 1); // BomBean topBean = new BomBean(bom_Rev, topLine, 1);
for (int i = 1; i < len; i++) { for (int i = 1; i < len; i++) {
BYProcBean procBean = procBeanList.get(i); BYProcBean procBean = procBeanList.get(i);
@ -395,7 +528,7 @@ public class CreateProcGYKGDialogController {
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
win.setWindowTopLine(rev.getItem(), rev, null, null); win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine(); TCComponentBOMLine topLine = win.getTopBOMLine();
BomBean topBean = new BomBean(rev, topLine, 1); // BomBean topBean = new BomBean(rev, topLine, 1);
String item_id = comp.getProperty("item_id"); String item_id = comp.getProperty("item_id");
for (int i = 0; i < sels.length; i++) { for (int i = 0; i < sels.length; i++) {
BYProcBean bean = (BYProcBean) dialog.t_part.getValueAt(sels[i], 0); BYProcBean bean = (BYProcBean) dialog.t_part.getValueAt(sels[i], 0);
@ -433,6 +566,7 @@ public class CreateProcGYKGDialogController {
} }
// 创建工艺 // 创建工艺
@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;
@ -471,17 +605,17 @@ public class CreateProcGYKGDialogController {
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;
BomBean bomBean; BomBean bomBean;
List<BYProcBean> proList = new ArrayList<>(); // List<BYProcBean> proList = new ArrayList<>();
List<BYProcBean> procBeans; List<BYProcBean> procBeans;
if (dialog.current_bean != null) { if (dialog.current_bean != null) {
proList = dialog.map_nodes.get(dialog.current_bean); // proList = dialog.map_nodes.get(dialog.current_bean);
} }
for (int i = 1; i < len; i++) { for (int i = 1; i < len; i++) {
@ -498,13 +632,13 @@ public class CreateProcGYKGDialogController {
} else { } else {
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.setMeop(newProc); dyccBean.setMeop(newProc);
procBeans = dialog.rev_Beans.get(bomBean.getRev()); procBeans = dialog.rev_Beans.get(bomBean.getRev());
if (procBeans != null) { if (procBeans != null) {
for (int j = 0, len2 = procBeans.size(); j < len; j++) { for (int j = 0, len2 = procBeans.size(); j < len2; j++) {
dyccBean = procBeans.get(j); dyccBean = procBeans.get(j);
dyccBean.setMeop(newProc); dyccBean.setMeop(newProc);
if (dyccBean.isVisible) if (dyccBean.isVisible)
@ -518,14 +652,14 @@ public class CreateProcGYKGDialogController {
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);
procBeans = dialog.rev_Beans.get(bomBean.getRev()); procBeans = dialog.rev_Beans.get(bomBean.getRev());
dyccBean.setMeop(newProc); dyccBean.setMeop(newProc);
if (procBeans != null) { if (procBeans != null) {
for (int j = 0, len2 = procBeans.size(); j < len; j++) { for (int j = 0, len2 = procBeans.size(); j < len2; j++) {
dyccBean = procBeans.get(j); dyccBean = procBeans.get(j);
dyccBean.setMeop(proc); dyccBean.setMeop(proc);
if (dyccBean.isVisible) if (dyccBean.isVisible)
@ -538,6 +672,7 @@ public class CreateProcGYKGDialogController {
} }
// 创建工艺 // 创建工艺
@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)
@ -581,8 +716,8 @@ public class CreateProcGYKGDialogController {
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<>();
@ -667,6 +802,7 @@ public class CreateProcGYKGDialogController {
int rowCount = tm_part.getRowCount(); int rowCount = tm_part.getRowCount();
int index = -1; int index = -1;
// BomBean bean = (BomBean) parent.getUserObject(); // BomBean bean = (BomBean) parent.getUserObject();
@SuppressWarnings("unlikely-arg-type")
BYProcBean procBean = bomLink_maps.get(parent); BYProcBean procBean = bomLink_maps.get(parent);
if (procBean != null) { if (procBean != null) {
for (int i = 0; i < rowCount; i++) { for (int i = 0; i < rowCount; i++) {
@ -696,4 +832,13 @@ public class CreateProcGYKGDialogController {
} }
} }
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);
}
}
} }

@ -1,11 +1,11 @@
package com.connor.chint.sap2.proc_xb; package com.connor.chint.sap2.proc_xb;
import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Vector; import java.util.Vector;
@ -23,10 +23,12 @@ import com.connor.chint.sap2.bean.MEProcessBean;
import com.connor.chint.sap2.create_proc.CreateProcController; import com.connor.chint.sap2.create_proc.CreateProcController;
import com.connor.chint.sap2.create_proc.ProcessChangeDialog; import com.connor.chint.sap2.create_proc.ProcessChangeDialog;
import com.connor.chint.sap2.proc.CreateProcessController; import com.connor.chint.sap2.proc.CreateProcessController;
import com.connor.chint.sap2.proc_byq.BYQProcBean; 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.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.SAPUtil;
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;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
@ -34,13 +36,14 @@ 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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentMEOPRevisionType; import com.teamcenter.rac.kernel.TCComponentMEOPRevisionType;
import com.teamcenter.rac.kernel.TCComponentType; import com.teamcenter.rac.kernel.TCComponentType;
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 CreateProcXBController { public class CreateProcXBController {
@ -75,6 +78,9 @@ public class CreateProcXBController {
// 展开的节点 // 展开的节点
protected Vector<TreePath> expandPaths = new Vector<>(); protected Vector<TreePath> expandPaths = new Vector<>();
private String group;
private Map<String, ExpandPSData[]> bomLineTree;
public CreateProcXBController(CreateProcXBDialog dialog, AbstractAIFApplication app) { public CreateProcXBController(CreateProcXBDialog dialog, AbstractAIFApplication app) {
this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
@ -89,6 +95,7 @@ public class CreateProcXBController {
// 读取对象的BOM 展开未读取节点 // 读取对象的BOM 展开未读取节点
public void readData(ProgressBar pb, TCComponentItemRevision topRev) throws Exception { public void readData(ProgressBar pb, TCComponentItemRevision topRev) throws Exception {
isCanExpand = false; isCanExpand = false;
group = session.getCurrentGroup().getUid();
pb.startProgress(); pb.startProgress();
pb.setText("加载数据..."); pb.setText("加载数据...");
win.setWindowTopLine(topRev.getItem(), topRev, null, null); win.setWindowTopLine(topRev.getItem(), topRev, null, null);
@ -96,32 +103,50 @@ public class CreateProcXBController {
XBBomBean bomBean = new XBBomBean(topRev); XBBomBean bomBean = new XBBomBean(topRev);
DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(bomBean); DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(bomBean);
XBProcBean proBean; XBProcBean proBean;
proBean = readTemplate(topLine, bomBean, topRev); List<String> noList = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<TCComponent> bomList = new ArrayList<>();
List<TCComponent> bomRevList = new ArrayList<>();
proBean = readTemplate(topLine, bomBean, topRev, noList, codeList);
maps_table_tree.put(proBean, topTreeNode); maps_table_tree.put(proBean, topTreeNode);
int size = 1; int size = 1;
proBean.setIndex(size); proBean.setIndex(size);
procBeanList.add(proBean); procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData()); // dialog.tm_part.addRow(proBean.getRowData());
size++; size++;
AIFComponentContext[] children = topLine.getChildren(); //TODO 预加载BOM及版本属性优化速度
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
MessageBox.post("数据库连接失败,请检查数据库连接配置!", "", 2);
return;
}
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService
= com.teamcenter.services.rac.cad.StructureManagementService.getService(session);
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", "zt2_Source", "zt2_Diagram" });
// AIFComponentContext[] children = topLine.getChildren();
TCComponentBOMLine childLine; TCComponentBOMLine childLine;
DefaultMutableTreeNode childNode, node; DefaultMutableTreeNode childNode, node;
XBBomBean childBomBean; XBBomBean childBomBean;
TCComponentItemRevision childRev; TCComponentItemRevision childRev;
List<TreePath> paths = new ArrayList<>(); List<TreePath> paths = new ArrayList<>();
TreePath path; TreePath path;
for (int i = 0, len = children.length; i < len; i++) { for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
childLine = (TCComponentBOMLine) children[i].getComponent(); childLine = data.bomLine;
childRev = childLine.getItemRevision(); childRev = data.itemRevOfBOMLine;
// 读取最新零组件版本 20230630 by yudy // 读取最新零组件版本 20230630 by yudy
// childRev = childLine.getItem().getLatestItemRevision(); // childRev = childLine.getItem().getLatestItemRevision();
childBomBean = new XBBomBean(childRev); childBomBean = new XBBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean); childNode = new DefaultMutableTreeNode(childBomBean);
proBean = readTemplate(childLine, childBomBean, childRev); proBean = readTemplate(childLine, childBomBean, childRev, noList, codeList);
proBean.setIndex(size); proBean.setIndex(size);
procBeanList.add(proBean); procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData());
size++; size++;
if (childLine.hasChildren()) { if (childLine.hasChildren()) {
node_need_expands.add(childNode); node_need_expands.add(childNode);
@ -136,6 +161,10 @@ public class CreateProcXBController {
maps_table_tree.put(proBean, childNode); maps_table_tree.put(proBean, childNode);
maps_tree_table.put(childBomBean, proBean); maps_tree_table.put(childBomBean, proBean);
} }
getGY(procBeanList, noList, codeList);
for(XBProcBean bean : procBeanList) {
dialog.tm_part.addRow(bean.getRowData());
}
dialog.topNode.add(topTreeNode); dialog.topNode.add(topTreeNode);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode)); KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
@ -149,13 +178,14 @@ public class CreateProcXBController {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
dialog.tree.updateUI(); dialog.tree.updateUI();
TreeNode t_node = dialog.topNode.getChildAt(0); TreeNode t_node = dialog.topNode.getChildAt(0);
System.out.println("t_node:" + t_node); System.out.println("t_node:" + t_node);
expandPaths.add(new TreePath(t_node)); expandPaths.add(new TreePath(t_node));
} }
}); });
SqlUtil.free();
pb.disposeDialog(); pb.disposeDialog();
} }
@ -214,19 +244,22 @@ public class CreateProcXBController {
TCComponentBOMLine topLine = maps_table_line_maps.get(procBean); TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
// procBeanList 这个是按index大小拍过序的 // procBeanList 这个是按index大小拍过序的
int index = procBeanList.indexOf(procBean); int index = procBeanList.indexOf(procBean);
AIFComponentContext[] children = topLine.getChildren(); // AIFComponentContext[] children = topLine.getChildren();
TCComponentBOMLine childLine; TCComponentBOMLine childLine;
XBBomBean childBomBean; XBBomBean childBomBean;
TCComponentItemRevision childRev; TCComponentItemRevision childRev;
DefaultMutableTreeNode childNode, node; DefaultMutableTreeNode childNode, node;
List<String> noList = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<TreePath> paths = new ArrayList<>(); List<TreePath> paths = new ArrayList<>();
TreePath path; TreePath path;
for (int i = 0, len = children.length; i < len; i++) { int i = 0;
childLine = (TCComponentBOMLine) children[i].getComponent(); for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
childRev = childLine.getItemRevision(); childLine = data.bomLine;
childRev = data.itemRevOfBOMLine;
childBomBean = new XBBomBean(childRev); childBomBean = new XBBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean); childNode = new DefaultMutableTreeNode(childBomBean);
procBean = readTemplate(childLine, childBomBean, childRev); procBean = readTemplate(childLine, childBomBean, childRev, noList, codeList);
procBean.setIndex(index + i + 2); procBean.setIndex(index + i + 2);
procBeanList.add(index + i + 1, procBean); procBeanList.add(index + i + 1, procBean);
if (childLine.hasChildren()) { if (childLine.hasChildren()) {
@ -243,8 +276,9 @@ public class CreateProcXBController {
map_line_table_maps.put(childLine, procBean); map_line_table_maps.put(childLine, procBean);
maps_tree_table.put(childBomBean, procBean); maps_tree_table.put(childBomBean, procBean);
maps_table_tree.put(procBean, childNode); maps_table_tree.put(procBean, childNode);
i++;
} }
for (int i = cout - 1; i >= 0; i--) { for (i = cout - 1; i >= 0; i--) {
topNode.remove(i); topNode.remove(i);
} }
@ -253,7 +287,7 @@ public class CreateProcXBController {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
dialog.tree.updateUI(); dialog.tree.updateUI();
} }
}); });
@ -270,20 +304,24 @@ public class CreateProcXBController {
int cout, index; int cout, index;
XBBomBean bomBean; XBBomBean bomBean;
XBProcBean procBean; XBProcBean procBean;
List<String> noList = new ArrayList<>();
List<String> codeList = new ArrayList<>();
pb.startProgress(); pb.startProgress();
pb.setText("正在展开......"); pb.setText("正在展开......");
for (int i = 0, len = nodes.size(); i < len; i++) { for (int i = 0, len = nodes.size(); i < len; i++) {
beans.clear(); beans.clear();
noList.clear();
codeList.clear();
node = nodes.get(i); node = nodes.get(i);
cout = node.getChildCount(); cout = node.getChildCount();
bomBean = (XBBomBean) node.getUserObject(); bomBean = (XBBomBean) node.getUserObject();
pb.setText("正在展开子项" + bomBean + "......"); pb.setText("正在展开子项" + bomBean + "......");
procBean = maps_tree_table.get(bomBean); procBean = maps_tree_table.get(bomBean);
expandAllNode(node, beans, bomBean, procBean); expandAllNode(node, beans, bomBean, procBean, noList, codeList);
getGY(beans, noList, codeList);
index = procBeanList.indexOf(procBean); index = procBeanList.indexOf(procBean);
for (int j = 0, len2 = beans.size(); j < len2; j++) { for (int j = 0, len2 = beans.size(); j < len2; j++) {
beans.get(j).setIndex(index + j + 2); beans.get(j).setIndex(index + j + 2);
} }
procBeanList.addAll(index + 1, beans); procBeanList.addAll(index + 1, beans);
for (int j = cout - 1; j >= 0; j--) { for (int j = cout - 1; j >= 0; j--) {
@ -293,7 +331,7 @@ public class CreateProcXBController {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
dialog.tree.updateUI(); dialog.tree.updateUI();
} }
}); });
@ -305,9 +343,9 @@ public class CreateProcXBController {
// 展开 // 展开
public void expandAllNode(DefaultMutableTreeNode topNode, List<XBProcBean> beans, XBBomBean bomBean, public void expandAllNode(DefaultMutableTreeNode topNode, List<XBProcBean> beans, XBBomBean bomBean,
XBProcBean procBean) throws Exception { XBProcBean procBean, List<String> noList, List<String> codeList) throws Exception {
TCComponentBOMLine topLine = maps_table_line_maps.get(procBean); TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
AIFComponentContext[] children = topLine.getChildren(); // AIFComponentContext[] children = topLine.getChildren();
TCComponentItemRevision itemRevision = topLine.getItemRevision(); TCComponentItemRevision itemRevision = topLine.getItemRevision();
if(!isWgOrXn(itemRevision)) { if(!isWgOrXn(itemRevision)) {
return; return;
@ -315,16 +353,16 @@ public class CreateProcXBController {
TCComponentBOMLine childLine; TCComponentBOMLine childLine;
XBBomBean childBomBean; XBBomBean childBomBean;
TCComponentItemRevision childRev; TCComponentItemRevision childRev;
DefaultMutableTreeNode childNode, node; DefaultMutableTreeNode childNode;
for (int i = 0, len = children.length; i < len; i++) { for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
childLine = (TCComponentBOMLine) children[i].getComponent(); childLine = data.bomLine;
childRev = childLine.getItemRevision(); childRev = data.itemRevOfBOMLine;
childBomBean = new XBBomBean(childRev); childBomBean = new XBBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean); childNode = new DefaultMutableTreeNode(childBomBean);
procBean = readTemplate(childLine, childBomBean, childRev); procBean = readTemplate(childLine, childBomBean, childRev, noList, codeList);
beans.add(procBean); beans.add(procBean);
if (childLine.hasChildren() && isWgOrXn(childRev)) { if (childLine.hasChildren() && isWgOrXn(childRev)) {
expandAllNode(childNode, beans, childBomBean, procBean); expandAllNode(childNode, beans, childBomBean, procBean, noList, codeList);
} }
topNode.add(childNode); topNode.add(childNode);
bomBean.addChild(childBomBean); bomBean.addChild(childBomBean);
@ -352,7 +390,7 @@ public class CreateProcXBController {
public void expandNode(DefaultMutableTreeNode topNode, TreePath path) throws Exception { public void expandNode(DefaultMutableTreeNode topNode, TreePath path) throws Exception {
XBBomBean bomBean = (XBBomBean) topNode.getUserObject(); XBBomBean bomBean = (XBBomBean) topNode.getUserObject();
XBProcBean procBean = maps_tree_table.get(bomBean); XBProcBean procBean = maps_tree_table.get(bomBean);
TCComponentBOMLine topLine = maps_table_line_maps.get(procBean); // TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
// procBeanList 这个是按index大小拍过序的 // procBeanList 这个是按index大小拍过序的
int index = procBeanList.indexOf(procBean); int index = procBeanList.indexOf(procBean);
System.out.println("index:" + index); System.out.println("index:" + index);
@ -391,18 +429,18 @@ public class CreateProcXBController {
} }
// ¶ÁÈ¡¾ßÌåÐÅÏ¢ //TODO 读取具体信息
private XBProcBean readTemplate(TCComponentBOMLine line, XBBomBean bean, TCComponentItemRevision rev) private XBProcBean readTemplate(TCComponentBOMLine line, XBBomBean bean, TCComponentItemRevision rev,
throws Exception { List<String> noList, List<String> codeList) throws Exception {
String type = rev.getType();// 类型 String type = rev.getType();// 类型
String drawNo; // 图样代号 String drawNo; // 图样代号
TCComponentItemRevision rev_standard = null; // 标准图版本 TCComponentItemRevision rev_standard = null; // 标准图版本
TCComponentItemRevision tlgx_standard = null; // 标准图工序 TCComponentItemRevision tlgx_standard = null; // 标准图工序
TCComponentItemRevision cp_gx_rev = null, cp_gy_rev = null; // 产品工序、产品工 TCComponentItemRevision cp_gx_rev = null, cp_gy_rev = null; // 产品工序、产品工
List<TCComponentItemRevision> list_standard = new ArrayList<>(4); // 标准图工艺 List<TCComponentItemRevision> list_standard = new ArrayList<>(4); // 标准图工艺
Map<String, String> fields = new LinkedHashMap<>(); // Map<String, String> fields = new LinkedHashMap<>();
String zt2_ClassificationCode; // 工序编码 String zt2_ClassificationCode; // 工序编码
TCComponentContextList res; // TCComponentContextList res;
String drawingNo = ""; String drawingNo = "";
String zt2_Source = ""; String zt2_Source = "";
if (type.equals("ZT2_Design3DRevision")) { if (type.equals("ZT2_Design3DRevision")) {
@ -420,7 +458,8 @@ public class CreateProcXBController {
} }
} }
// 查询标准图对象 // 查询标准图对象
fields.put("DrawingNo", drawingNo); noList.add(drawingNo);
/*fields.put("DrawingNo", drawingNo);
System.out.println("图号:"+drawingNo); System.out.println("图号:"+drawingNo);
// 查询的是版本对象 // 查询的是版本对象
res = KUtil.query(session, "chint_query_TYDH", fields); res = KUtil.query(session, "chint_query_TYDH", fields);
@ -452,8 +491,7 @@ public class CreateProcXBController {
list_standard.add(meopRev); list_standard.add(meopRev);
} }
} }
} }*/
} else if (type.equals("Part Revision")) { } else if (type.equals("Part Revision")) {
drawNo = rev.getProperty("zt2_MaterialNo"); drawNo = rev.getProperty("zt2_MaterialNo");
if (KUtil.isEmpty(drawNo)) { if (KUtil.isEmpty(drawNo)) {
@ -464,7 +502,8 @@ public class CreateProcXBController {
drawingNo = drawingNo.substring(0, ind); drawingNo = drawingNo.substring(0, ind);
} }
// 查询标准图对象 // 查询标准图对象
fields.put("Áã×é¼þ ID", drawingNo); noList.add(drawingNo);
/*fields.put("零组件 ID", drawingNo);
// 查询的是版本对象 // 查询的是版本对象
res = KUtil.query(session, "零组件...", fields); res = KUtil.query(session, "零组件...", fields);
if (res != null) { if (res != null) {
@ -493,15 +532,15 @@ public class CreateProcXBController {
list_standard.add(meopRev); list_standard.add(meopRev);
} }
} }
} }*/
} else { } else {
throw new Exception("BOM中存在非图纸/物料对象"); throw new Exception("BOM中存在非图纸/物料对象");
} }
// 开始查找自身工艺以及工序 // 开始查找自身工艺以及工序
zt2_ClassificationCode = line.getProperty("ZT2_ClassificationNo"); zt2_ClassificationCode = line.getProperty("ZT2_ClassificationNo");
if (!KUtil.isEmpty(zt2_ClassificationCode)) { codeList.add(zt2_ClassificationCode);
/*if (!KUtil.isEmpty(zt2_ClassificationCode)) {
fields.clear(); fields.clear();
fields.put("ID", zt2_ClassificationCode); fields.put("ID", zt2_ClassificationCode);
res = KUtil.query(session, "chint_query_item", fields); res = KUtil.query(session, "chint_query_item", fields);
@ -511,10 +550,10 @@ public class CreateProcXBController {
} }
cp_gx_rev = (TCComponentItemRevision) res.get(0).getComponent(); cp_gx_rev = (TCComponentItemRevision) res.get(0).getComponent();
} }
} }*/
AIFComponentContext[] refs = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, AIFComponentContext[] refs = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" }); new String[] { "IMAN_METarget" });
if (res != null && refs.length > 0) { if (refs != null && refs.length > 0) {
cp_gy_rev = (TCComponentItemRevision) refs[0].getComponent(); cp_gy_rev = (TCComponentItemRevision) refs[0].getComponent();
} }
@ -543,7 +582,7 @@ public class CreateProcXBController {
// 自动投料 // 自动投料
public void autoFeeding(ProgressBar pb, TCComponent comp) throws Exception { public void autoFeeding(ProgressBar pb, TCComponent comp) throws Exception {
int cout = dialog.t_part.getRowCount(); // int cout = dialog.t_part.getRowCount();
XBProcBean procBean; XBProcBean procBean;
String item_id, object_name; String item_id, object_name;
TCComponentBOMLine line; TCComponentBOMLine line;
@ -585,7 +624,7 @@ public class CreateProcXBController {
private void autoFeeding(TCSession session, TCComponentBOMLine line, TCComponentBOMLine parent, String feedNo, private void autoFeeding(TCSession session, TCComponentBOMLine line, TCComponentBOMLine parent, String feedNo,
Map<String, String> map_feed_maps, StringBuilder sbuild, StringBuilder sb) throws Exception { Map<String, String> map_feed_maps, StringBuilder sbuild, StringBuilder sb) throws Exception {
XBProcBean procBean; XBProcBean procBean;
AIFComponentContext[] children = line.getChildren(); // AIFComponentContext[] children = line.getChildren();
TCComponentBOMLine child; TCComponentBOMLine child;
TCComponent proc; TCComponent proc;
TCComponentItemRevision rev; TCComponentItemRevision rev;
@ -595,9 +634,9 @@ public class CreateProcXBController {
int index; int index;
TCComponentContextList res; TCComponentContextList res;
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
for (int i = 0, len = children.length; i < len; i++) { for (ExpandPSData data : bomLineTree.get(line.getUid())) {
child = (TCComponentBOMLine) children[i].getComponent(); child = data.bomLine;
procBean = map_line_table_maps.get(child); procBean = map_line_table_maps.get(child);
CreateProcessController.feeding(child, feedNo); CreateProcessController.feeding(child, feedNo);
proc = null; proc = null;
@ -649,6 +688,7 @@ public class CreateProcXBController {
} }
// 手动投料 投料前过滤掉只选了BOM首行的 // 手动投料 投料前过滤掉只选了BOM首行的
@SuppressWarnings("deprecation")
public void manualFeeding(int[] rows, TCComponent gx_comp) throws Exception { public void manualFeeding(int[] rows, TCComponent gx_comp) throws Exception {
String item_id = gx_comp.getProperty("item_id"); String item_id = gx_comp.getProperty("item_id");
String object_name = gx_comp.getProperty("object_name"); String object_name = gx_comp.getProperty("object_name");
@ -680,6 +720,7 @@ public class CreateProcXBController {
} }
// 修改工艺 // 修改工艺
@SuppressWarnings("unlikely-arg-type")
public void updateProcess(ProgressBar pb) throws Exception { public void updateProcess(ProgressBar pb) throws Exception {
int[] sels = dialog.t_part.getSelectedRows(); int[] sels = dialog.t_part.getSelectedRows();
if (sels != null && sels.length == 1) { if (sels != null && sels.length == 1) {
@ -796,6 +837,7 @@ public class CreateProcXBController {
MessageBox.post(dialog, "自动指派工艺成功!", "", 2); MessageBox.post(dialog, "自动指派工艺成功!", "", 2);
} }
@SuppressWarnings("deprecation")
private void match(String gyid, TCComponentItemRevision proc, Map<String, Map<String, Object>> gygxMap, double ndxs) { private void match(String gyid, TCComponentItemRevision proc, Map<String, Map<String, Object>> gygxMap, double ndxs) {
try { try {
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -803,9 +845,9 @@ public class CreateProcXBController {
win.lock(); win.lock();
win.setWindowTopLine(proc.getItem(), proc, null, null); win.setWindowTopLine(proc.getItem(), proc, null, null);
TCComponentBOMLine componentbomline = win.getTopBOMLine(); TCComponentBOMLine componentbomline = win.getTopBOMLine();
AIFComponentContext[] childs = componentbomline.getChildren(); // AIFComponentContext[] childs = componentbomline.getChildren();
for (AIFComponentContext child : childs) { for (ExpandPSData data : bomLineTree.get(componentbomline.getUid())) {
match(gyid, (TCComponentBOMLine) child.getComponent(), gygxMap, ndxs); match(gyid, data.bomLine, gygxMap, ndxs);
} }
win.save(); win.save();
win.refresh(); win.refresh();
@ -815,6 +857,7 @@ public class CreateProcXBController {
} }
} }
@SuppressWarnings("deprecation")
private void match(String gyid, TCComponentBOMLine line, Map<String, Map<String, Object>> gygxMap, double ndxs) throws TCException { private void match(String gyid, TCComponentBOMLine line, Map<String, Map<String, Object>> gygxMap, double ndxs) throws TCException {
// String type = line.getItemRevision().getType(); // String type = line.getItemRevision().getType();
TCComponentType type = line.getItemRevision().getTypeComponent(); TCComponentType type = line.getItemRevision().getTypeComponent();
@ -845,9 +888,9 @@ public class CreateProcXBController {
LoggerUtils.debug("匹配为空。"); LoggerUtils.debug("匹配为空。");
} }
} }
AIFComponentContext[] lineChilds = line.getChildren(); // AIFComponentContext[] lineChilds = line.getChildren();
for (AIFComponentContext lineChild: lineChilds) { for (ExpandPSData data : bomLineTree.get(line.getUid())) {
match(gyid, (TCComponentBOMLine) lineChild.getComponent(), gygxMap, ndxs); match(gyid, data.bomLine, gygxMap, ndxs);
} }
} }
@ -869,6 +912,7 @@ public class CreateProcXBController {
return nodes; return nodes;
} }
@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)
@ -898,8 +942,9 @@ public class CreateProcXBController {
win.setWindowTopLine(proc.getItem(), proc, null, null); win.setWindowTopLine(proc.getItem(), proc, null, null);
TCComponentBOMLine componentbomline = win.getTopBOMLine(); TCComponentBOMLine componentbomline = win.getTopBOMLine();
AIFComponentContext[] childs = componentbomline.getChildren(); AIFComponentContext[] childs = componentbomline.getChildren();
for (int i = 0, len = childs.length; i < len; i++) { for (AIFComponentContext data : childs) {
CreateProcController.readClsss((TCComponentBOMLine) childs[i].getComponent(), gxs, nos); // for (ExpandPSData data : bomLineTree.get(componentbomline.getUid())) {
CreateProcController.readClsss((TCComponentBOMLine) data.getComponent(), gxs, nos);
} }
win.save(); win.save();
win.refresh(); win.refresh();
@ -975,4 +1020,128 @@ public class CreateProcXBController {
System.out.println("list:" + list); System.out.println("list:" + list);
System.out.println(list.indexOf("ddd")); System.out.println(list.indexOf("ddd"));
} }
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<XBProcBean> procBeanList2, 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,");
sql1.append("t1.puid as tlgx,t2.bzgy from pitem a,pitemrevision b0,PPOM_APPLICATION_OBJECT b1,")
.append("(select puid,PZT2_CLASSIFICATIONCODE from PZT2_DESIGN3DREVISION union ")
.append("select puid,PZT2_CLASSIFICATIONCODE from PPART_0_REVISION_ALT) b ")
.append("left join (select a2.puid,a1.PITEM_ID from pitem a1,pitemrevision a2 ")
.append("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,")
.append("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 ")
.append("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 ")
.append("and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='")
.append(group)
.append("') t2 on t2.puid=b.puid where b1.PCREATION_DATE in ")
.append("(select max(r3.PCREATION_DATE) from pitem r1,PITEMREVISION r2,PPOM_APPLICATION_OBJECT r3 ")
.append("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)) {
try {
XBProcBean bean = procBeanList2.get(i);
if(tlgx != null && !tlgx.isEmpty()) {
if(uidMap.containsKey(tlgx))
bean.setRev_standard_gx(uidMap.get(tlgx));
else {
TCComponentItemRevision tlgxRev = (TCComponentItemRevision) session.stringToComponent(tlgx);
bean.setRev_standard_gx(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.setRev_standard_gy(bzgyRev);
if(!bean.getRev_standard_lists().contains(bzgyRev))
bean.getRev_standard_lists().add(bzgyRev);
}
// bean.setFeeding(classification.length() <= 0);
bean.setRev_standard((TCComponentItemRevision) session.stringToComponent(uid));
}catch(Exception e) {
System.out.println(uid + "|" + code + "|" + classification + "|" + tlgx + "|" + bzgy);
e.printStackTrace();
}
}
}
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)) {
XBProcBean bean = procBeanList2.get(i);
bean.setRev_cp_gx((TCComponentItemRevision) session.stringToComponent(uid));
}
}
last = id;
}
// SqlUtil.free();
}
} }

@ -11,7 +11,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
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;
@ -50,14 +49,8 @@ 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.create_proc.ProcessDialog; import com.connor.chint.sap2.create_proc.ProcessDialog;
import com.connor.chint.sap2.proc.CreateProcessController; import com.connor.chint.sap2.proc.CreateProcessController;
import com.connor.chint.sap2.proc_by.BYProcBean;
import com.connor.chint.sap2.proc_by.BYProduceDialog; import com.connor.chint.sap2.proc_by.BYProduceDialog;
import com.connor.chint.sap2.proc_by.BomBean;
import com.connor.chint.sap2.proc_by.CreateProcBYDialog;
import com.connor.chint.sap2.proc_byq.CreateProcBYQDialog;
import com.connor.chint.sap2.proc_byq.CreateProcBYQGSDialog; import com.connor.chint.sap2.proc_byq.CreateProcBYQGSDialog;
import com.connor.chint.sap2.proc_gykg.CreateProcGYKGDialog;
import com.connor.chint.sap2.proc_gykg.GYKGUpdateProcDialog;
import com.connor.chint.sap2.util.ChintConfirmDialogUtil; import com.connor.chint.sap2.util.ChintConfirmDialogUtil;
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;
@ -78,6 +71,10 @@ import sun.swing.table.DefaultTableCellHeaderRenderer;
public class CreateProcXBDialog extends AbstractAIFDialog { public class CreateProcXBDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private CreateProcXBController controller; private CreateProcXBController controller;
private AbstractAIFApplication app; private AbstractAIFApplication app;
private TCSession session; private TCSession session;
@ -127,8 +124,8 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
if (groupID.equalsIgnoreCase("dba")) { if (groupID.equalsIgnoreCase("dba")) {
groupID = actionInfo; groupID = actionInfo;
} }
} catch (TCException e) { } catch (Exception e) {
// TODO Auto-generated catch block // Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -149,7 +146,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
codeRemark_Technology = bean.getCodeRemark_Technology(); codeRemark_Technology = bean.getCodeRemark_Technology();
} }
long time = new Date().getTime(); // long time = new Date().getTime();
this.bomRev = (TCComponentItemRevision) app.getTargetComponent(); this.bomRev = (TCComponentItemRevision) app.getTargetComponent();
try { try {
initUI(); initUI();
@ -163,7 +160,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode"); value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode");
controller.readData(pb, bomRev); controller.readData(pb, bomRev);
addListener(); addListener();
byq_gx_lists = KUtil.getClassObjects(codeRemark_Process, session); // byq_gx_lists = KUtil.getClassObjects(codeRemark_Process, session);
} catch (Exception e) { } catch (Exception e) {
pb.disposeDialog(); pb.disposeDialog();
MessageBox.post(CreateProcXBDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "", MessageBox.ERROR); MessageBox.post(CreateProcXBDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "", MessageBox.ERROR);
@ -176,12 +173,12 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
try { try {
// KUtil.setByPass(true); // KUtil.setByPass(true);
byq_gx_lists = KUtil.getClassObjects(codeRemark_Process, session); byq_gx_lists = KUtil.getClassObjects(codeRemark_Process, session);
meprocs = cpController.getMEProcs(session, codeRemark_Technology); meprocs = cpController.getMEProcs(session, codeRemark_Technology);
} catch (TCException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
MessageBox.post(CreateProcXBDialog.this, "获取工序时发生异常:" + e.getMessage(), "", MessageBox.ERROR); MessageBox.post(CreateProcXBDialog.this, "获取工序时发生异常:" + e.getMessage(), "", MessageBox.ERROR);
} finally { } finally {
@ -191,7 +188,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
}).start(); }).start();
showDialog(); showDialog();
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // : handle exception
e.printStackTrace(); e.printStackTrace();
MessageBox.post("初始化异常:" + e.getMessage(), "", 2); MessageBox.post("初始化异常:" + e.getMessage(), "", 2);
} }
@ -210,14 +207,14 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
// 界面关闭的时候关掉BOMWindow // 界面关闭的时候关掉BOMWindow
@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) { if (e.getID() == WindowEvent.WINDOW_CLOSING) {
if (controller.win != null) { if (controller.win != null) {
try { try {
controller.win.save(); controller.win.save();
controller.win.close(); controller.win.close();
} catch (TCException e1) { } catch (TCException e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
} }
@ -261,8 +258,8 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
} }
} }
System.out.println("版本个数:" + revs.size()); System.out.println("版本个数:" + revs.size());
File[] tcFiles; // File[] tcFiles;
File fmsFile; // File fmsFile;
List<String> paths = new ArrayList<>(); List<String> paths = new ArrayList<>();
try { try {
TCComponent[] comps; TCComponent[] comps;
@ -284,7 +281,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
for (int j = 0; j < comps.length; j++) { for (int j = 0; j < comps.length; j++) {
if (comps[j] instanceof TCComponentDataset && comps[j].getType().equals("PDF")) { if (comps[j] instanceof TCComponentDataset && comps[j].getType().equals("PDF")) {
dataset = ((TCComponentDataset) comps[j]); dataset = ((TCComponentDataset) comps[j]);
String d_type = dataset.getType(); // String d_type = dataset.getType();
String type = dataset.getProperty("ref_names"); String type = dataset.getProperty("ref_names");
String[] types = type.split(","); String[] types = type.split(",");
for (int l = 0; l < types.length; l++) { for (int l = 0; l < types.length; l++) {
@ -307,7 +304,7 @@ public class CreateProcXBDialog 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);
} }
@ -326,7 +323,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
ProgressBar pb = new ProgressBar(CreateProcXBDialog.this, new Dimension(350, 50)); ProgressBar pb = new ProgressBar(CreateProcXBDialog.this, new Dimension(350, 50));
try { try {
KUtil.stopTableEditing(t_part); KUtil.stopTableEditing(t_part);
List<DefaultMutableTreeNode> nodes = null;// controller.getSelectNodes(); // List<DefaultMutableTreeNode> nodes = null;// controller.getSelectNodes();
int[] rows = t_part.getSelectedRows(); int[] rows = t_part.getSelectedRows();
if (rows.length == 0) { if (rows.length == 0) {
MessageBox.post(CreateProcXBDialog.this, "请选择需要创建工艺的对象", "", 2); MessageBox.post(CreateProcXBDialog.this, "请选择需要创建工艺的对象", "", 2);
@ -466,14 +463,14 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
new XBUpdateProcDialog(CreateProcXBDialog.this, revs, rev_Beans, value_strings, new XBUpdateProcDialog(CreateProcXBDialog.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);
} }
} }
}); });
} catch (Exception e1) { } catch (Exception e1) {
// TODO Auto-generated catch block // Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
@ -577,10 +574,11 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@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 && path.getLastPathComponent() != null) { if (path != null && path.getLastPathComponent() != null) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
@SuppressWarnings("unlikely-arg-type")
int index = controller.expandPaths.indexOf(node); int index = controller.expandPaths.indexOf(node);
if (index == -1) { if (index == -1) {
controller.expandPaths.add(path); controller.expandPaths.add(path);
@ -591,7 +589,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@Override @Override
public void run() { public void run() {
// TODO Auto-generated method stub // Auto-generated method stub
try { try {
KUtil.stopTableEditing(t_part); KUtil.stopTableEditing(t_part);
if (controller.node_need_expands.contains(node)) { if (controller.node_need_expands.contains(node)) {
@ -613,10 +611,10 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@Override @Override
public void treeCollapsed(TreeExpansionEvent event) { public void treeCollapsed(TreeExpansionEvent event) {
// TODO Auto-generated method stub // Auto-generated method stub
final TreePath path = event.getPath(); final TreePath path = event.getPath();
if (path != null && path.getLastPathComponent() != null) { if (path != null && path.getLastPathComponent() != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); // DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
int index = controller.expandPaths.indexOf(path); int index = controller.expandPaths.indexOf(path);
KUtil.stopTableEditing(t_part); KUtil.stopTableEditing(t_part);
if (controller.isCanExpand) { if (controller.isCanExpand) {
@ -813,6 +811,11 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
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 == 3 || column == 4) { if (column == 3 || column == 4) {
@ -858,6 +861,11 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
tree.putClientProperty("JTree.lineStyle", "Horizontal");// 使JTree的文件夹间具有水平分隔线。 tree.putClientProperty("JTree.lineStyle", "Horizontal");// 使JTree的文件夹间具有水平分隔线。
this.treeCellRenderer = new DefaultTreeCellRenderer() { this.treeCellRenderer = new DefaultTreeCellRenderer() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override @Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
boolean leaf, int row, boolean hasFocus) { boolean leaf, int row, boolean hasFocus) {

@ -0,0 +1,94 @@
package com.connor.chint.sap2.sap;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.connor.chint.sap2.create_proc.CreateProcBean;
import com.connor.chint.sap2.create_proc.CreateProcController;
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.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* : SAP
* :2024-09-06
* @author
*
*
* 2024-09-06
*/
public class SAPBJYBOperation extends AbstractAIFOperation {
private AbstractAIFApplication app;
private TCSession session;
private String groupID;
private String fa;
public SAPBJYBOperation(AbstractAIFApplication app, TCSession session, String groupID, String fa) {
this.app = app;
this.session = session;
this.groupID = groupID;
this.fa = fa;
}
@Override
public void executeOperation() throws Exception {
InterfaceAIFComponent target = app.getTargetComponent();// 必须选中版本
// String groupID = SAPUtil.getGroupID(session);
if (KUtil.isEmpty(groupID) || groupID.equalsIgnoreCase("dba")) {
MessageBox.post("当前组不可使用该功能", "警告", MessageBox.INFORMATION);
return;
}
CreateProcBean bean = CreateProcController.getProcPres(session, "CHINT_ORG_TechnologyClassification", groupID);
if (bean == null) {
System.out.println("groupID:" + groupID);
MessageBox.post("未找到[" + groupID + "]配置,请检查首选项<CHINT_ORG_TechnologyClassification>", "", 2);
return;
}
if (target == null || !(target instanceof TCComponentItemRevision)) {
MessageBox.post("请选择图纸版本", "警告", MessageBox.INFORMATION);
return;
}
if(fa.equals("B") || fa.equals("D")) {
if (!target.getType().equals("ZT2_Design3DRevision") && !target.getType().equals("Part Revision")) {
MessageBox.post("请选择图纸/物料版本", "", MessageBox.INFORMATION);
return;
}
}else if(fa.equals("C")) {
if (!KUtil.isTCM((TCComponent) target)) {
MessageBox.post("图纸未发布,不能执行传递操作", "警告", MessageBox.INFORMATION);
return;
}
}
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
int code = SAPUtil.getCode();
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 = ((TCComponentItemRevision)target).getStringProperty("zt2_WBSNo");
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-dd hh24:mi:ss')" + ",?,?,'等待组织','未处理',?,?,'未返回',?,?,?)"; // to_date(?,'yyyy-mm-ddhh24:mi:ss')
SqlUtil.write(sql, new String[] { code + "", groupID, userName, dataTime, zt2_WBSNo, "",
"部件传递", target.getUid(), "", serverHostname, userId });
SqlUtil.freeAll();
MessageBox.post("传递请求已记录,请等待飞书通知.", "", MessageBox.INFORMATION);
}
}

@ -2230,4 +2230,17 @@ public class KUtil {
} }
return pseudoFolder; return pseudoFolder;
} }
/**
*
*
* @param e
* @return
*/
public static String getStackTrace(Exception e) {
StringBuilder rError = new StringBuilder("" + e.getMessage());
for(StackTraceElement ste : e.getStackTrace()) {
rError.append("\n\t" + ste.toString());
}
return rError.toString();
}
} }

@ -1,10 +1,14 @@
package com.connor.chint.sap2.util; package com.connor.chint.sap2.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Base64;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
@ -32,6 +36,11 @@ import com.connor.chint.sap2.sap.YCLMaterialBean;
import com.connor.chint.sap2.sap_dy.DYSAPBOMBean; import com.connor.chint.sap2.sap_dy.DYSAPBOMBean;
import com.connor.chint.sap2.sap_zy.FlowBean; import com.connor.chint.sap2.sap_zy.FlowBean;
import com.connor.chint.sap2.sap_zy.PartBean; import com.connor.chint.sap2.sap_zy.PartBean;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.teamcenter.rac.aif.AbstractAIFUIApplication; import com.teamcenter.rac.aif.AbstractAIFUIApplication;
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;
@ -6516,11 +6525,14 @@ public class SAPUtil {
*/ */
public static TCComponent getMeprocesYh(String uid, String group, TCSession session) throws Exception { public static TCComponent getMeprocesYh(String uid, String group, TCSession session) throws Exception {
// String sql = SAPUtil.sqlRef.replace("\\?", "'" + uid + "'"); // 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," String sql = "select P.puid as supItemUID,V.puid as supRevUID,P.pitem_id as supItemID,"
+ "V.Pitem_Revision_Id as supRevID,cP.pitem_id as subItemID,cV.puid as subRevUID,RT.partifactname as °æ±¾Óë°æ±¾¹ØÏµ " + "ITRO.Pobject_Name as supItemName,V.Pitem_Revision_Id as supRevID,cP.pitem_id as subItemID,"
+ "from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g " + "cV.puid as subRevUID,RT.partifactname as 版本与版本关系 "
+ "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 " + "from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,"
+ "and R.Rsecondary_Objectu = cV.Puid and cP.Puid = cV.Ritems_Tagu and cV.Puid = cITRO.Puid and ITRO.Pactive_Seq<>0 " + "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 + "'"; + "and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "' and cV.PUID = '" + uid + "'";
try { try {
ResultSet read = SqlUtil.read(sql);//SAPUtil.sqlRef, new Object[] { uid } ResultSet read = SqlUtil.read(sql);//SAPUtil.sqlRef, new Object[] { uid }
@ -6557,4 +6569,65 @@ public class SAPUtil {
} }
return false; return false;
} }
/**
* 8089
*
* @param file
* @param path
* @param url
* @return
*/
public static String uploadFile(File file, String path, String url) {
String res = "";
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
byte[] buffer = new byte[fis.available()];
fis.read(buffer, 0, buffer.length);
String base64String = Base64.getEncoder().encodeToString(buffer);
//System.out.println(path + "==" + path.replaceAll("\\\\", "\\\\\\\\"));
//System.out.println(path + "==" + path.replaceAll("\\\\", "\\\\"));
String json = "{\"name\":\"" + file.getName() + "\",\"path\":\"" + path.replaceAll("\\\\", "\\\\\\\\")
+ "\",\"base64String\":\"" + base64String + "\"}";
System.out.println("uploadFile:\n" + json);
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, json);
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
res = response.message();
}catch(Exception e) {
e.printStackTrace();
}finally {
try {
fis.close();
}catch(Exception e) {
e.printStackTrace();
}
}
return res;
}
/**
* BOM
*
* @return
*/
public static 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;
}
} }

Loading…
Cancel
Save