20240911分发代码上传

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

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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/okio-1.13.0.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/axis2-kernel-1.4.1.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"/>
</classpath>

@ -80,7 +80,14 @@ Bundle-ClassPath: .,
poi/okio-1.13.0.jar,
lib/json-org.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,
com.connor.chint.sap2.assignfactoryno,
com.connor.chint.sap2.bombuilder,

@ -32,7 +32,14 @@ bin.includes = plugin.xml,\
poi/okhttp-2.7.4.jar,\
poi/okio-1.13.0.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/,\
poi/jacob-1.20-x64.dll,\
poi/jacob-1.20-x86.dll,\

@ -112,8 +112,8 @@
<!--物料管理-->
<command name="物料编码申请" id="com.connor.chint.sap2.commands.MaterialNoCommand"/>
<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#GCT"/>
<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#M007_2"/>
@ -139,6 +139,7 @@
<command name="编码清单查询" id="com.connor.chint.sap2.commands.DesignQueryCommand"/>
<command name="整体BOM传递SAP" id="com.connor.chint.sap2.commands.SAPZYZTCommand"/>
<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"/>
@ -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.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.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"/>
@ -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.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"/>
@ -2062,7 +2064,7 @@
</and>
</visibleWhen>
</command>
<!--
<!---->
<command commandId = "com.connor.chint.sap2.createKjBom.CreateKjBomCommand" id = "com.connor.chint.sap2.menu.cgdexport">
<visibleWhen>
<and>
@ -2079,7 +2081,7 @@
</with>
</and>
</visibleWhen>
</command>-->
</command>
</menuContribution>
@ -4061,7 +4063,7 @@
</and>
</visibleWhen>
</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>
<and>
<or>
@ -4081,7 +4083,7 @@
</with>
</and>
</visibleWhen>
</command>
</command-->
<command commandId = "com.connor.chint.sap2.commands.MaterialQueryCommand" id = "com.connor.chint.sap2.commands.MaterialQueryCommand">
<visibleWhen>
<and>
@ -4685,8 +4687,30 @@
</and>
</visibleWhen>
</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">
<visibleWhen>
<and>
@ -4730,6 +4754,28 @@
</visibleWhen>
</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">
<visibleWhen>
<and>

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

@ -11,11 +11,17 @@ import org.eclipse.core.commands.ExecutionEvent;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
/**
* ³É±¾µ¥¹ÜÀí
* @author admin
@ -63,7 +69,25 @@ public class RdmCreateHandler extends AbstractHandler{
return;
}
new RdmCreateFrame();
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();
}
}
}.start();
} catch (Exception e) {

@ -1,14 +1,31 @@
package com.connor.chint.sap2.commands;
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.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class MaterialNoCommand extends KCommand {
public MaterialNoCommand(AbstractAIFApplication app, String commandId, String 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);
}

@ -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;
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.materialno.FactoryChooseDialog;
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.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class SelfMPartNoBatchCommand extends KCommand {
@ -13,22 +21,47 @@ public class SelfMPartNoBatchCommand extends KCommand {
public SelfMPartNoBatchCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
this.actionInfo = actionInfo;
}
@Override
public void executeModal() {
try {
if ("M007_2".equals(actionInfo)) {
System.out.println("配变外购件物料申请");
new Thread(new OutMPartNoBatchDialog(app)).start();
} else {
new SelfMPartNoBatchOperation(app, actionInfo).executeOperation();
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)) {
System.out.println("配变外购件物料申请");
new Thread(new OutMPartNoBatchDialog(app, groupID)).start();
} else {
new SelfMPartNoBatchOperation(app, actionInfo, groupID).executeOperation();
}
}
}
} catch (Exception e) {
MessageBox.post(e);
e.printStackTrace();
MessageBox.post(e);
}
}

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

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

@ -5,6 +5,8 @@ import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.ResultSet;
import javax.swing.JButton;
@ -12,6 +14,10 @@ import javax.swing.JComboBox;
import javax.swing.JLabel;
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.SqlUtil;
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.util.MessageBox;
/**
* :
* :2024-08-14
* @author
*
*
* 2024-08-27
*/
public class FactoryChooseDialog extends AbstractAIFDialog {
/**
@ -26,11 +40,32 @@ public class FactoryChooseDialog extends AbstractAIFDialog {
*/
private static final long serialVersionUID = 1L;
private AbstractAIFApplication app;
private TCSession session;
private String actionInfo;
private boolean update;
private JComboBox<String> j_Group;
private JPanel btnPanel;
private JButton okBtn;
private JButton allBtn;
private JButton userBtn;
private JButton cancelBtn;
public FactoryChooseDialog(AbstractAIFApplication app, TCSession session, String groupID) {
/**
*
* @param app AbstractAIFApplication
* @param session TCSession
* @param batch
*/
public FactoryChooseDialog(AbstractAIFApplication app, TCSession session, String actionInfo) {
super(true);
try {
this.app = app;
this.session = session;
this.actionInfo = actionInfo;
boolean batch = !actionInfo.equals("no");
String[] database = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(database) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
@ -47,55 +82,45 @@ public class FactoryChooseDialog extends AbstractAIFDialog {
update = true;
}
String[] applys = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_APPLY_LIST", session);
JComboBox<String> j_Group = new JComboBox<>();
j_Group.setSize(new Dimension(150, 30));
j_Group.setPreferredSize(new Dimension(130, 30));
j_Group = new JComboBox<>();
j_Group.setSize(new Dimension(250, 30));
j_Group.setPreferredSize(new Dimension(230, 30));
j_Group.addItem("");
for(String s : applys) {
j_Group.addItem(s);
}
j_Group.setSelectedItem(defaultGroup);
JButton okBtn = new JButton("È·¶¨");
okBtn = new JButton("确定");
okBtn.setSize(new Dimension(100, 30));
okBtn.setPreferredSize(new Dimension(90, 30));
okBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String groupID = j_Group.getSelectedItem().toString();
if(groupID.isEmpty()) {
MessageBox.post(FactoryChooseDialog.this, "ÇëÑ¡Ôñ×éÖ¯", "", MessageBox.WARNING);
return;
}
String sql = "insert into CHINT_MATERIAL_APPLY_RULE values ('" + user + "','" + groupID + "')";
if(update)
sql = "update CHINT_MATERIAL_APPLY_RULE set \"factory\"='" + groupID + "' where \"userid\"='" + user + "'";
System.out.println("sql:\n" + sql);
SqlUtil.write(sql);
SqlUtil.freeAll();
groupID = groupID.substring(0, groupID.indexOf(":"));
System.out.println("groupID:" + groupID);
//TODO
// new Thread(new MaterialNoDialog(app, session, groupID)).start();
dispose();
}
});
JButton cancelBtn = new JButton("È¡Ïû");
if(batch) {
allBtn = new JButton("全部图纸");
allBtn.setSize(new Dimension(100, 30));
allBtn.setPreferredSize(new Dimension(90, 30));
userBtn = new JButton("个人图纸");
userBtn.setSize(new Dimension(100, 30));
userBtn.setPreferredSize(new Dimension(90, 30));
}
cancelBtn = new JButton("取消");
cancelBtn.setSize(new Dimension(100, 30));
cancelBtn.setPreferredSize(new Dimension(90, 30));
cancelBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
SqlUtil.freeAll();
dispose();
}
});
addActionListener(batch, user);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.add(new JLabel("请选择组织:"));
panel.add(j_Group);
JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
btnPanel.add(okBtn);
btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
if(batch && defaultGroup.startsWith("M060")) {
btnPanel.add(allBtn);
btnPanel.add(userBtn);
}else {
btnPanel.add(okBtn);
}
btnPanel.add(cancelBtn);
this.setPreferredSize(new Dimension(500, 300));
@ -112,4 +137,113 @@ public class FactoryChooseDialog extends AbstractAIFDialog {
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.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
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.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentGroup;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
@ -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 };
private TCSession session;
private TCComponentUser user;
private String groupID;
private PMPC t_pmcp;
protected List<FEATURE> features = new ArrayList<FEATURE>();
protected List<String> codes = new ArrayList<String>();
@ -156,14 +157,15 @@ public class MaterialNoDialog extends AbstractAIFDialog {
private List<TCComponent> copy_list = new ArrayList<TCComponent>();
public MaterialNoDialog(AbstractAIFApplication app) {
public MaterialNoDialog(AbstractAIFApplication app, TCSession session, String groupID) {
super(false);
KUtil.setByPass(true);
this.controller = new MaterialNoDialogController(this);
this.session = (TCSession) app.getSession();
this.session = session;
this.user = session.getUser();
this.groupID = groupID;
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());
txtName = "物料申请-" + format2.format(new Date());
@ -222,7 +224,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
}
uom_kg = KUtil.getUom("kg", session);
txtPath = TXTUtil.createTxt(txtName);
String groupID = SAPUtil.getGroupID(session);
// String groupID = SAPUtil.getGroupID(session);
String BOMClassificationNos[] = ChintPreferenceUtil
.getPreferences(ChintPreferenceUtil.CHINT_MaterialBOMClassificationNo, session);
if (BOMClassificationNos != null && BOMClassificationNos.length > 0) {
@ -492,13 +494,17 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} catch (Exception e1) {
e1.printStackTrace();
SqlUtil.free();
TXTUtil.writeTXT(txtPath, "error:" + e1.getMessage());
MessageBox.post("ERROR:" + e1.getMessage(), "Ìáʾ", MessageBox.WARNING);
TXTUtil.writeTXT(txtPath, "error:\n" + KUtil.getStackTrace(e1));
MessageBox.post("ERROR:" + e1, "提示", MessageBox.WARNING);
return;
} finally {
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() {
@ -701,12 +707,12 @@ public class MaterialNoDialog extends AbstractAIFDialog {
}
String userID = "";
String userName = "";
String groupName = "";
// String groupName = "";
try {
userID = user.getUserId();
userName = user.getProperty("user_name");
TCComponentGroup group = session.getCurrentGroup();
groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue();
// TCComponentGroup group = session.getCurrentGroup();
// groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue();
} catch (TCException e1) {
MessageBox.post(MaterialNoDialog.this, "获取用户信息失败", "", MessageBox.ERROR);
e1.printStackTrace();
@ -724,7 +730,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
String unitCode = uom == null ? "" : uom;
String goodsCode = ""; // 申请时为空
String companyCode = groupName;
String companyCode = groupID;//groupName;
// companyCode= groupName=="变压器事业部"?"M005":companyCode;
// companyCode= groupName=="中压设备事业部"?"M008":companyCode;
String state = ""; // 申请时为空
@ -820,7 +826,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
if (req.indexOf(state1) == -1) {
System.out.println("删除对象:" + rev.getItem());
rev.getItem().delete();
//rev.delete();
// rev.delete();
String delete = "delete from chint_material where \"Code\"='" + code + "'";
SqlUtil.delete(delete);
System.out.println("删除记录结束:" + delete);
@ -922,7 +928,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} else {
MessageBox.post("物料申请成功", "", MessageBox.INFORMATION);
}
String groupID = SAPUtil.getGroupID(session);
// String groupID = SAPUtil.getGroupID(session);
String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_NOTIFY", session);
String userId = "";
for(String pref:preferences) {
@ -1091,12 +1097,12 @@ public class MaterialNoDialog extends AbstractAIFDialog {
}
String userID = "";
String userName = "";
String groupName = "";
// String groupName = "";
try {
userID = user.getUserId();
userName = user.getProperty("user_name");
TCComponentGroup group = session.getCurrentGroup();
groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue();
// TCComponentGroup group = session.getCurrentGroup();
// groupName = group.getTCProperty(TCComponentGroup.PROP_GROUP_NAME).getStringValue();
} catch (TCException e1) {
MessageBox.post(MaterialNoDialog.this, "获取用户信息失败", "", MessageBox.ERROR);
e1.printStackTrace();
@ -1114,7 +1120,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
String unitCode = uom == null ? "" : uom;
String goodsCode = ""; // 申请时为空
String companyCode = groupName;
String companyCode = groupID;//groupName;
// companyCode= groupName=="变压器事业部"?"M005":companyCode;
// companyCode= groupName=="中压设备事业部"?"M008":companyCode;
String state = ""; // 申请时为空
@ -1388,7 +1394,7 @@ public class MaterialNoDialog extends AbstractAIFDialog {
} else {
MessageBox.post("物料申请成功", "", MessageBox.INFORMATION);
}
String groupID = SAPUtil.getGroupID(session);
// String groupID = SAPUtil.getGroupID(session);
String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_NOTIFY", session);
String userId = "";
for(String pref:preferences) {

@ -14,9 +14,7 @@ import java.io.InputStream;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
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.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil;
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.AbstractAIFDialog;
@ -90,12 +87,13 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
private List<TCComponentItemRevision> design_revs = null;
private TCComponent uom_kg = null;
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);
this.app = app;
this.session = (TCSession) app.getSession();
this.groupID = groupID;
this.controller = new OutMPartNoBatchController(OutMPartNoBatchDialog.this);
}
@ -103,8 +101,8 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
public void run() {
try {
groupID = SAPUtil.getGroupID(session);
desing_rev_spec_map = new HashMap<TCComponentItemRevision,List<String>>();
// groupID = SAPUtil.getGroupID(session);
// desing_rev_spec_map = new HashMap<TCComponentItemRevision,List<String>>();
/*
* if(!"M007".equals(groupID)) {
* MessageBox.post("此功能仅适用于配变制造部","警告",MessageBox.INFORMATION); return; }
@ -337,7 +335,7 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
*
*/
my = new MyProgressBarCompent("自制件编码申请", "正在读取BOM......");
groupID = SAPUtil.getGroupID(session);
// groupID = SAPUtil.getGroupID(session);
System.out.println("groupID:" + groupID);
setCompEnabled(false);
if (m_pmpc == null) {
@ -363,6 +361,25 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
List<SelfMPartBean> self_lists = new ArrayList<>();
TCComponentUser userComp = session.getUser();
controller.apply(groupID, design_revs, m_pmpc, prds, userComp, drequests, self_lists);
//TODO 先组织数据,创建对象,写入数据库,调接口,判断是否保留物料和数据库
List<TCComponentItemRevision> partList = new ArrayList<>();
SelfMPartBean bean;
for (int i = 0; i < self_lists.size(); i++) {
bean = self_lists.get(i);
System.out.println("更新记录");
String spec = bean.getSpec();
TCComponentItemRevision partRev = controller.createMaterial(bean.getRev(), groupID, spec, m_pmpc.getCode(),
session, uom_kg, dcproxy, userComp);
partRev.add("TC_Is_Represented_By", bean.getRev());
partRev.refresh();
partList.add(partRev);
bean.getRev().refresh();
String uid = partRev.getUid();
Object[] params = bean.getParams();
params[1] = uid;
System.out.println("params:" + Arrays.toString(params));
SqlUtil.write(SelfMPartNoBatchOperation.INSERT_SQL, params);
}
StringBuffer req_mess = new StringBuffer();
List<String> mess = new ArrayList<String>();
String url = "http://10.128.20.35:9002/Post/PLM_Goods";
@ -373,26 +390,14 @@ public class OutMPartNoBatchDialog extends AbstractAIFDialog {
System.out.println("[" + i + "]返回值:" + req);
}
String state1 = "\"State\":\"1\"";
SelfMPartBean bean;
for (int i = 0; i < self_lists.size(); i++) {
bean = self_lists.get(i);
if (mess.get(i).indexOf(state1) != -1) {
System.out.println("¸üмǼ");
TCComponentItemRevision partRev = null;
String spec = bean.getSpec();
partRev = controller.createMaterial(bean.getRev(), groupID, spec, m_pmpc.getCode(),
session, uom_kg, dcproxy, userComp);
partRev.add("TC_Is_Represented_By", bean.getRev());
partRev.refresh();
bean.getRev().refresh();
String uid = partRev.getUid();
Object[] params = bean.getParams();
params[1] = uid;
System.out.println("params:" + Arrays.toString(params));
SqlUtil.write(SelfMPartNoBatchOperation.INSERT_SQL, params);
} else {
if (mess.get(i).indexOf(state1) == -1) {
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;
import java.awt.Dimension;
import java.io.IOException;
import java.rmi.RemoteException;
import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
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.SAPUtil;
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.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
@ -119,15 +119,22 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
Map<String,SelfMPartBean> idBeanMap = new HashMap<String,SelfMPartBean>();
private String actionInfo;
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.session = (TCSession) app.getSession();
this.groupName = groupID;
this.user = session.getUser();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
now = format.format(new Date());
format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// String now = format2.format(new Date());
try {
txtName = "物料编码批量申请-" + user.getUserId() + "-" + format.format(new Date());
itemType = (TCComponentItemType) this.session.getTypeComponent("Part");
groupID = SAPUtil.getGroupID(session);
this.groupID = groupID;//SAPUtil.getGroupID(session);
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
@ -137,6 +144,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
@Override
public void executeOperation() throws Exception {
txtPath = TXTUtil.createTxt(txtName);
List<String> nameList = new ArrayList<String>();
InterfaceAIFComponent[] comps = app.getTargetComponents();
TCComponent target = null;
@ -250,7 +258,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
long time6 = System.nanoTime();
System.out.println("===============第一次查询数据库用时(ms) " + ((time6 - time5) / 1000000L)+"===============");
System.out.println("Sql1:" + Sql1);
TXTUtil.writeTXT(txtPath, "Sql1:\n" + Sql1);
System.out.println("params:" + Arrays.toString(obj1));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj1));
if (rs.next()) {
String pmpcPrhCode = rs.getString(1);
System.out.println("pmpcPrhCode" + pmpcPrhCode);
@ -271,7 +281,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
long time8 = System.nanoTime();
System.out.println("===============第二次查询数据库用时(ms) " + ((time8 - time7) / 1000000L)+"===============");
System.out.println("Sql2:" + Sql2);
TXTUtil.writeTXT(txtPath, "Sql2:\n" + Sql2);
System.out.println("params:" + Arrays.toString(obj2));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj2));
System.out.println("===============开始遍历第二次查询数据库的信息===============");
long time9 = System.nanoTime();
while (rs2.next()) {
@ -342,9 +354,11 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
long time22 = System.nanoTime();
System.out.println("===============第"+tempNum+"次查询数据库用时(ms) " + ((time22 - time21) / 1000000L)+"===============");
tempNum++;
System.out.println("Sql1:" + Sql1);
TXTUtil.writeTXT(txtPath, "Sql1:\n" + Sql1);
System.out.println("params:" + Arrays.toString(obj1));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj1));
if (rs.next()) {
String pmpcPrhCode = rs.getString(1);
System.out.println("pmpcPrhCode" + pmpcPrhCode);
@ -360,7 +374,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
long time24 = System.nanoTime();
System.out.println("===============第"+tempNum+"次查询数据库用时(ms) " + ((time24 - time23) / 1000000L)+"===============");
System.out.println("Sql2:" + Sql2);
TXTUtil.writeTXT(txtPath, "Sql2:\n" + Sql2);
System.out.println("params:" + Arrays.toString(obj2));
TXTUtil.writeTXT(txtPath, Arrays.toString(obj2));
prds_Standard = new ArrayList<PRD>();
System.out.println("===============开始遍历第"+tempNum+"次查询数据库的信息===============");
long time25 = System.nanoTime();
@ -427,8 +443,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
}
userID = user.getUserId();
userName = user.getProperty("user_name");
TCComponentGroup group = session.getCurrentGroup();
groupName = group.getProperty(TCComponentGroup.PROP_GROUP_NAME);
// TCComponentGroup group = session.getCurrentGroup();
// groupName = group.getProperty(TCComponentGroup.PROP_GROUP_NAME);
System.out.println("groupName:" + groupName);
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
@ -575,16 +591,19 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
System.out.println("一共需要发送的请求数量:"+drequests.size());
long time37 = System.nanoTime();
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));
mess.add(req);
System.out.println("[" + i + "]返回值:" + req);
System.out.println("[" + i + "]返回值:\n" + req);
TXTUtil.writeTXT(txtPath, "[" + i + "]返回值:\n" + req);
}
long time38 = System.nanoTime();
System.out.println("===============发送请求用时(ms) " + ((time38 - time37) / 1000000L)+"===============");
System.out.println("根据返回结果判断是否需要新建物料");
System.out.println("INSERT_SQL:" + INSERT_SQL);
TXTUtil.writeTXT(txtPath, "INSERT_SQL:" + INSERT_SQL);
String state1 = "\"State\":\"1\"";
// String state2 = "\"State\":\"-1\"";
System.out.println("===============开始解析返回结果===============");
@ -629,13 +648,12 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
TCComponentItem item = cRev.getItem();
newStuFolder.remove("contents", item);
item.delete();
SqlUtil.delete(DELETE_SQL, new Object[] {selfMPartBean.getCode()});
SqlUtil.delete(DELETE_SQL, new Object[] { selfMPartBean.getCode() });
KUtil.setByPass(false);
}
}
long time40 = System.nanoTime();
System.out.println("===============解析返回结果用时(ms) " + ((time40 - time39) / 1000000L)+"===============");
System.out.println("===============解析返回结果用时(ms) " + ((time40 - time39) / 1000000L) + "===============");
KUtil.closeMyProgressBar(my);
KUtil.setByPass(false);
@ -646,7 +664,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
}
String[] preferences = ChintPreferenceUtil.getPreferences("CHINT_MATERIAL_NOTIFY", session);
String userId = "";
for(String pref:preferences) {
for(String pref : preferences) {
String[] split = pref.split(":");
if(split[0].equals(groupID)) {
userId = split[1];
@ -654,25 +672,31 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
}
StringBuilder build = new StringBuilder("");
build.append(userName).append("已申请物料,请及时审批。");
System.out.println("userId==》"+userId);
System.out.println("userId==》" + userId);
if(!userId.equals("")) {
sendMsg(build.toString(),userId);
sendMsg(build.toString(), userId);
}
} catch (Exception e1) {
KUtil.closeMyProgressBar(my);
KUtil.setByPass(false);
MessageBox.post("", "自制件编码批量申请异常:" + e1.getMessage(), "", MessageBox.ERROR);
e1.printStackTrace();
TXTUtil.writeTXT(txtPath, "自制件编码批量申请异常:\n" + KUtil.getStackTrace(e1));
MessageBox.post("", "自制件编码批量申请异常:" + e1, "", MessageBox.ERROR);
} finally {
pb.disposeDialog();
KUtil.setByPass(false);
PartSqlUtil.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 {
// TXTUtil.writeTXT(logPath, "开始AM消息推送");
// TXTUtil.writeTXT(logPath, "用户:" + userID + ";信息:" + mess);
@ -680,10 +704,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
ISendMsgServicesPortType stub2 = service2.getISendMsgServicesSOAP11port_http();
String mess2 = stub2.chintSendMsgServices(userID, "", mess, "PLM");
// TXTUtil.writeTXT(logPath, "返回信息:" + mess2);
System.out.println("返回信息:" + mess2);
} catch (javax.xml.rpc.ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
System.out.println("返回信息:\n" + mess2);
TXTUtil.writeTXT(txtPath, "返回信息:\n" + mess2);
} catch (Exception e) {
e.printStackTrace();
}
// TXTUtil.writeTXT(logPath, "AM消息推送结束");
@ -803,7 +826,9 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
String uid = s.getUid();
Object[] params = selfMPartBean.getParams();
params[1] = uid;
TXTUtil.writeTXT(txtPath, INSERT_SQL);
System.out.println("params:" + Arrays.toString(params));
TXTUtil.writeTXT(txtPath, "params:" + Arrays.toString(params));
SqlUtil.write(INSERT_SQL, params);
SAPUtil.changeOwner(s, dcproxy);
TCComponentUser o_user = (TCComponentUser) s.getRelatedComponent("owning_user");
@ -1006,7 +1031,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
System.out.println("自制件[" + item_id + "]");
if (item_id.length() >= 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("调整模板");
m_pmpc = pmpc2;
m_prds = prds2;
@ -1041,7 +1066,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
}
String goodsCode = ""; // 申请时为空
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 mp = "M";
if(groupID.equals("M046") && properties[7].equals("外购")) {
@ -1161,7 +1187,7 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
String item_id = rev.getProperty("item_id");
if (item_id.length() >= 4) {
String stuf = item_id.substring(0, 4);
if (stuf.equalsIgnoreCase("2ZDB") || stuf.equalsIgnoreCase("4ZDB")) {
if (stuf.equalsIgnoreCase("2ZD") || stuf.equalsIgnoreCase("4ZD")) {
flag = false;
// 开始根据通用件规格属性来判断是否需要申请物料
String zt2_TYJSpec = line.getProperty("ZT2_TYSpecifications");
@ -1179,7 +1205,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
specs.add(spec);
general_maps.put(rev, specs);
}
//lidy20240830没有通用件规格的且没关联物料的就去申请一个
flag = true;
generalRevs.add(rev);
gens.add(spec);
}
@ -1311,7 +1338,8 @@ public class SelfMPartNoBatchOperation extends AbstractAIFOperation {
return false;
}
}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.ProgressBar;
import com.connor.chint.sap2.util.SAPUtil;
//import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.SqlUtil2;
import com.teamcenter.rac.aif.AbstractAIFApplication;
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.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
import com.teamcenter.services.rac.core.DataManagementService;
public class CreateProcBYQController {
@ -54,16 +56,15 @@ public class CreateProcBYQController {
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>(
64);
protected Map<BYQProcBean, DefaultMutableTreeNode> maps_table_tree = new HashMap<BYQProcBean, DefaultMutableTreeNode>();
// 表格与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数据集合
protected List<BYQProcBean> procBeanList = new ArrayList<>(64);
protected List<BYQProcBean> procBeanList = new ArrayList<>();
// 需要重新获取子项的节点
protected List<DefaultMutableTreeNode> node_need_expands = new ArrayList<>();
@ -77,6 +78,9 @@ public class CreateProcBYQController {
// 展开的节点
protected Vector<TreePath> expandPaths = new Vector<>();
private List<String> codeList = new ArrayList<>();
private List<String> noList = new ArrayList<>();
public CreateProcBYQController(CreateProcBYQDialog dialog, AbstractAIFApplication app) {
this.app = app;
this.session = (TCSession) app.getSession();
@ -88,8 +92,9 @@ public class CreateProcBYQController {
win = bomWinType.create(null);
}
// 读取对象的BOM 展开未读取节点
public void readData(ProgressBar pb, TCComponentItemRevision topRev) throws Exception {
//TODO 读取对象的BOM 展开未读取节点
protected void readData(ProgressBar pb, TCComponentItemRevision topRev) throws Exception {
long startTime = System.currentTimeMillis();
isCanExpand = false;
pb.startProgress();
pb.setText("加载数据...");
@ -99,13 +104,14 @@ public class CreateProcBYQController {
DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(bomBean);
BYQProcBean proBean;
System.out.println("topRev==>"+topRev);
proBean = readTemplateYH(topLine, bomBean, topRev);
proBean = readTemplateYH(topLine, bomBean, topRev, codeList, noList);
maps_table_tree.put(proBean, topTreeNode);
int size = 1;
proBean.setIndex(size);
procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData());
// dialog.tm_part.addRow(proBean.getRowData());
size++;
// AIFComponentContext[] children = topLine.getChildren();
TCComponentBOMLine childLine;
@ -114,22 +120,29 @@ public class CreateProcBYQController {
TCComponentItemRevision childRev;
List<TreePath> paths = new ArrayList<>();
TreePath path;
bomLineTreeNodeSOA = BomToSapUtil.getBomLineTreeNodeSOA(topLine);
ExpandPSData[] expandPSDatas = bomLineTreeNodeSOA.get(topLine.getUid());
System.out.println("readData:" + (System.currentTimeMillis() - startTime) / 1000);
// 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);
for (int i = 0, len = expandPSDatas.length; i < len; i++) {
childLine = expandPSDatas[i].bomLine;
childRev = expandPSDatas[i].itemRevOfBOMLine;
// for (int i = 0, len = expandPSDatas.length; i < len; i++) {
for (AIFComponentContext c : topLine.getChildren()) {
// childLine = expandPSDatas[i].bomLine;
// childRev = expandPSDatas[i].itemRevOfBOMLine;
childLine = (TCComponentBOMLine) c.getComponent();
childRev = childLine.getItemRevision();
childBomBean = new BYQBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean);
proBean = readTemplateYH(childLine, childBomBean, childRev);
proBean = readTemplateYH(childLine, childBomBean, childRev, codeList, noList);
proBean.setIndex(size);
procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData());
// dialog.tm_part.addRow(proBean.getRowData());
size++;
if (bomLineTreeNodeSOA.get(childLine.getUid()).length>0) {
// if (bomLineTreeNodeSOA.get(childLine.getUid()).length > 0) {
if (childLine.getChildrenCount() > 0) {
node_need_expands.add(childNode);
childBomBean = new BYQBomBean(childRev);
node = new DefaultMutableTreeNode(childBomBean);
@ -142,6 +155,12 @@ public class CreateProcBYQController {
maps_table_tree.put(proBean, childNode);
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);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
@ -162,11 +181,13 @@ public class CreateProcBYQController {
expandPaths.add(new TreePath(t_node));
}
});
SqlUtil2.free();
System.out.println("readData4:" + (System.currentTimeMillis() - startTime) / 1000);
pb.disposeDialog();
}
// 关闭节点
public void collapsed(TreePath parent) {
protected void collapsed(TreePath parent) {
// System.out.println("关闭");
List<BYQProcBean> beans = new ArrayList<>(64);
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();
if (expandPaths.indexOf(parent) != -1) {
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("开始展开子项");
int cout = topNode.getChildCount();
BYQBomBean bomBean = (BYQBomBean) topNode.getUserObject();
@ -265,37 +286,74 @@ public class CreateProcBYQController {
System.out.println("结束");
}
// 一键展开
public void expandAllNodes(List<DefaultMutableTreeNode> nodes, ProgressBar pb) throws Exception {
//TODO 一键展开
protected void expandAllNodes(List<DefaultMutableTreeNode> nodes, ProgressBar pb) throws Exception {
// 所有未展开节点
long startTime = System.currentTimeMillis();
isCanExpand = false;
List<BYQProcBean> beans = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<String> noList = new ArrayList<>();
DefaultMutableTreeNode node;
int cout, index;
BYQBomBean bomBean;
BYQProcBean procBean;
pb.startProgress();
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++) {
beans.clear();
codeList.clear();
noList.clear();
node = nodes.get(i);
cout = node.getChildCount();
bomBean = (BYQBomBean) node.getUserObject();
pb.setText("正在展开子项" + bomBean + "......");
procBean = maps_tree_table.get(bomBean);
expandAllNode(node, beans, bomBean, procBean);
expandAllNode(node, beans, bomBean, procBean, codeList, noList);
index = procBeanList.indexOf(procBean);
for (int j = 0, len2 = beans.size(); j < len2; j++) {
beans.get(j).setIndex(index + j + 2);
}
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--) {
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);
System.out.println("expandAllNodes4:" + (System.currentTimeMillis() - startTime) / 1000);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -306,11 +364,12 @@ public class CreateProcBYQController {
});
nodes.clear();
pb.disposeDialog();
System.out.println("expandAllNodes5:" + (System.currentTimeMillis() - startTime) / 1000);
}
// 展开
public void expandAllNode(DefaultMutableTreeNode topNode, List<BYQProcBean> beans, BYQBomBean bomBean,
BYQProcBean procBean) throws Exception {
private void expandAllNode(DefaultMutableTreeNode topNode, List<BYQProcBean> beans, BYQBomBean bomBean,
BYQProcBean procBean, List<String> codeList, List<String> noList) throws Exception {
TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
// AIFComponentContext[] children = topLine.getChildren();
TCComponentBOMLine childLine;
@ -325,10 +384,10 @@ public class CreateProcBYQController {
childRev = expandPSDatas[i].itemRevOfBOMLine;
childBomBean = new BYQBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean);
procBean = readTemplateYH(childLine, childBomBean, childRev);
procBean = readTemplateYH(childLine, childBomBean, childRev, codeList, noList);
beans.add(procBean);
if (bomLineTreeNodeSOA.get(childLine.getUid()).length>0) {
expandAllNode(childNode, beans, childBomBean, procBean);
expandAllNode(childNode, beans, childBomBean, procBean, codeList, noList);
}
topNode.add(childNode);
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();
BYQProcBean procBean = maps_tree_table.get(bomBean);
// TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
@ -357,7 +416,7 @@ public class CreateProcBYQController {
}
// 从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();
for (int i = cout - 1; i > index; 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.tm_part.getDataVector().clear();
dialog.t_part.revalidate();
@ -519,30 +578,33 @@ public class CreateProcBYQController {
return proBean;
}
private HashMap<String, TCComponentItemRevision> classCodeMap = new HashMap<>();
private HashMap<String, BYQProcBean> beanMap = new HashMap<>();
// private HashMap<String, TCComponentItemRevision> classCodeMap = new HashMap<>();
private HashMap<String, Object[]> beanMap = new HashMap<>();
// 读取具体信息
private BYQProcBean readTemplateYH(TCComponentBOMLine line, BYQBomBean bean, TCComponentItemRevision rev)
throws Exception {
private BYQProcBean readTemplateYH(TCComponentBOMLine line, BYQBomBean bean, TCComponentItemRevision rev,
List<String> codeList, List<String> noList) throws Exception {//TODO
String type = rev.getType();// 类型
String drawNo; // 图样代号
TCComponentItemRevision rev_standard = null; // 标准图版本
TCComponentItemRevision tlgx_standard = null; // 标准图工序
TCComponentItemRevision cp_gx_rev = null, cp_gy_rev = null; // 产品工序、产品工
List<TCComponentItemRevision> list_standard = new ArrayList<>(4); // 标准图工艺
Map<String, String> fields = new LinkedHashMap<>();
// Map<String, String> fields = new LinkedHashMap<>();
String zt2_ClassificationCode; // 工序编码
TCComponentContextList res;
// TCComponentContextList res;
String drawingNo = "";
String zt2_Source = "";
TCComponentBOMLine parent = line.parent();
String uid = (parent == null ? "" : parent.getItemRevision().getUid()) + "@" + rev.getUid();
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);
maps_table_line_maps.put(cloneBean, line);
maps_tree_table.put(bean, cloneBean);
// maps_tree_table.put(bean, beanMap.get(rev.getUid()));
codeList.add((String) bObjects[1]);
noList.add((String) bObjects[2]);
return cloneBean;
}
if (type.equals("ZT2_Design3DRevision")) {
@ -559,7 +621,8 @@ public class CreateProcBYQController {
drawingNo = drawNo.substring(0, ind);
}
}
// 查询标准图对象
codeList.add(drawingNo);
/*
fields.put("DrawingNo", drawingNo);
// System.out.println("图号:"+drawingNo);
// 查询的是版本对象
@ -590,7 +653,6 @@ public class CreateProcBYQController {
}
}
TCComponent meproces = getMeproces(rev_standard.getUid(), session);
SqlUtil2.free();
TCComponentItemRevision meopRev;
if(meproces!=null) {
meopRev = (TCComponentItemRevision)meproces;
@ -601,7 +663,7 @@ public class CreateProcBYQController {
// list_standard.add(meopRev);
// }
}
}
}*/
} else if (type.equals("Part Revision")) {
drawNo = rev.getProperty("zt2_MaterialNo");
@ -612,7 +674,8 @@ public class CreateProcBYQController {
if (ind > 0) {
drawingNo = drawingNo.substring(0, ind);
}
// 查询标准图对象
codeList.add(drawingNo);
/*
fields.put("零组件 ID", drawingNo);
// 查询的是版本对象
res = KUtil.query(session, "零组件...", fields);
@ -639,23 +702,24 @@ public class CreateProcBYQController {
}
}
TCComponent meproces = getMeproces(rev_standard.getUid(), session);
SqlUtil2.free();
// SqlUtil2.free();
TCComponentItemRevision meopRev;
if(meproces!=null) {
meopRev = (TCComponentItemRevision)meproces;
list_standard.add(meopRev);
}
}
}
}*/
} else {
throw new Exception("BOM中存在非图纸/物料对象");
}
//TODO 开始查找自身工艺以及工序
// 开始查找自身工艺以及工序
zt2_ClassificationCode = line.getProperty("ZT2_ClassificationNo");
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)) {
@ -673,10 +737,11 @@ public class CreateProcBYQController {
classCodeMap.put(zt2_ClassificationCode, cp_gx_rev);
}
}
}*/
System.out.println("tlgx_standard:" + tlgx_standard);
System.out.println("cp_gx_rev:" + cp_gx_rev);
TCComponent meproces = getMeproces(rev.getUid(), session);
SqlUtil2.free();
// SqlUtil2.free();
// AIFComponentContext[] refs = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
// new String[] { "IMAN_METarget" });
@ -694,11 +759,11 @@ public class CreateProcBYQController {
proBean.setRev_standard(rev_standard);
maps_table_line_maps.put(proBean, line);
maps_tree_table.put(bean, proBean);
beanMap.put(uid, proBean);
beanMap.put(uid, new Object[] { proBean, drawingNo, zt2_ClassificationCode });
return proBean;
}
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)) {
return mepMap.get(uid);
@ -717,7 +782,7 @@ public class CreateProcBYQController {
return mpComp;
}
}
SqlUtil2.free();
// SqlUtil2.free();
// else {
// SqlUtil2.free();
// }
@ -725,7 +790,7 @@ public class CreateProcBYQController {
}
// 手动投料 投料前过滤掉只选了BOM首行的
@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 object_name = gx_comp.getProperty("object_name");
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();
BYQProcBean procBean;
String item_id, object_name;
@ -796,7 +861,7 @@ public class CreateProcBYQController {
// 修改工艺
@SuppressWarnings("unlikely-arg-type")
public void updateProcess(ProgressBar pb) throws Exception {
protected void updateProcess(ProgressBar pb) throws Exception {
int[] sels = dialog.t_part.getSelectedRows();
if (sels != null && sels.length == 1) {
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();
BYQProcBean procBean;
pb.startProgress();
@ -880,9 +945,9 @@ public class CreateProcBYQController {
pb.disposeDialog();
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();
BYQProcBean procBean;
pb.startProgress();
@ -971,7 +1036,7 @@ public class CreateProcBYQController {
}
// 判断有没有选中树
public List<DefaultMutableTreeNode> getSelectNodes() {
protected List<DefaultMutableTreeNode> getSelectNodes() {
List<DefaultMutableTreeNode> nodes = new ArrayList<>();
TreePath[] path = dialog.tree.getSelectionPaths();
if (path == null || path.length == 0) {
@ -999,4 +1064,100 @@ public class CreateProcBYQController {
System.out.println("list:" + list);
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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
@ -9,9 +8,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import javax.swing.JComboBox;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
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.proc.CreateProcessController;
import com.connor.chint.sap2.proc_by.BomBean;
import com.connor.chint.sap2.proc_by.BYProcBean;
import com.connor.chint.sap2.proc_by.ProcCellEditor;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
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.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
@ -59,13 +58,15 @@ public class CreateProcDYCCFolderController {
private AbstractAIFApplication app;
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>() {
@Override
@ -73,8 +74,8 @@ public class CreateProcDYCCFolderController {
try {
return o1.getProperty("zt2_MaterialNo").compareTo(o2.getProperty("zt2_MaterialNo"));
} catch (TCException e) {
// TODO Auto-generated catch block
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
return 0;
@ -83,7 +84,7 @@ public class CreateProcDYCCFolderController {
}
// 判断有没有选中树
public List<DefaultMutableTreeNode> getSelectNodes() {
protected List<DefaultMutableTreeNode> getSelectNodes() {
List<DefaultMutableTreeNode> nodes = new ArrayList<>();
TreePath[] path = dialog.tree.getSelectionPaths();
if (path == null || path.length == 0) {
@ -100,11 +101,11 @@ public class CreateProcDYCCFolderController {
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();
DYCCProcBean procBean;
List<MEProcessBean> lists = new ArrayList<>();
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) node.getRoot();
// DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) node.getRoot();
// System.out.println("root:"+rootNode);
TCComponentItemRevision rev;
TCComponentItemRevision part;
@ -184,7 +185,7 @@ public class CreateProcDYCCFolderController {
}
KUtil.setByPass(true);
List<MEProcessBean> procs = new ProcessChangeDialog(dialog, app, "", lists, rev).getResult();
new ProcessChangeDialog(dialog, app, "", lists, rev).getResult();
if (pb == null) {
pb = new MyProgressBarCompent("工艺修改", "工艺路线修改中......");
} else {
@ -198,15 +199,16 @@ public class CreateProcDYCCFolderController {
}
public CreateProcDYCCFolderController(AbstractAIFApplication app, CreateProcDYCCFolderDialog dialog) {
// TODO Auto-generated constructor stub
// Auto-generated constructor stub
this.app = app;
this.dialog = dialog;
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.setText("¼ÓÔØÊý¾Ý...");
pb.setText("加载数据..." + revs.size());
TCComponentItemRevision rev;
@ -221,11 +223,14 @@ public class CreateProcDYCCFolderController {
List<TreePath> paths = new ArrayList<>();
TreePath path;
System.out.println("read1:" + (System.currentTimeMillis() - startTime) / 1000);
for (int i = 0, len = revs.size(); i < len; i++) {
long start = System.currentTimeMillis();
rev = revs.get(i);
win.setWindowTopLine(rev.getItem(), rev, null, null);
topLine = win.getTopBOMLine();
topBean = new BomBean(rev, topLine, 1);
System.out.println("revs1:" + (System.currentTimeMillis() - start));
factoryNos = rev.getRelatedComponents("ZT2_FactoryNumber");
if (factoryNos != null && factoryNos.length > 0) {
@ -233,7 +238,9 @@ public class CreateProcDYCCFolderController {
topBean.addFactoryID(factoryNos[j].getProperty("item_id"));
}
}
System.out.println("revs2:" + (System.currentTimeMillis() - start));
topBean.getFactoryNo();
System.out.println("revs3:" + (System.currentTimeMillis() - start));
topTreeNode = new DefaultMutableTreeNode(topBean);
if (topLine.hasChildren()) {
childNode = new DefaultMutableTreeNode(new BomBean(rev, topLine, 1));
@ -245,13 +252,16 @@ public class CreateProcDYCCFolderController {
list = new ArrayList<>(64);
dialog.map_nodes.put(topTreeNode, list);
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++) {
dialog.tree.collapsePath(paths.get(i));
}
dialog.t_model.reload(dialog.topNode);
win.refresh();
win.close();
System.out.println("read3:" + (System.currentTimeMillis() - startTime) / 1000);
}
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 {
long time = new Date().getTime();
pb.startProgress();
@ -317,7 +328,7 @@ public class CreateProcDYCCFolderController {
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentBOMLine topLine;
// 投料工序ID
AIFComponentContext[] cLines;
// AIFComponentContext[] cLines;
TCComponent[] children;
Map<String, VecStruct> fields = new LinkedHashMap<String, VecStruct>();
String item_id = comp.getProperty("item_id");
@ -348,14 +359,14 @@ public class CreateProcDYCCFolderController {
// KUtil.info(dialog, "投料完成");
}
private int num_current = 0;
private int num_cout = 0;
// private int num_current = 0;
// private int num_cout = 0;
public void manualFeeding3(ProgressBar pb, List<TCComponentItemRevision> revs, TCComponent comp) throws Exception {
long time = new Date().getTime();
TCComponentItem item;
TCComponentItemRevision rev;
num_cout = revs.size();
// num_cout = revs.size();
pb.startProgress();
pb.setText("投料...");
Map<String, VecStruct> fields = new LinkedHashMap<String, VecStruct>();
@ -369,8 +380,8 @@ public class CreateProcDYCCFolderController {
CreateBOMWindowsResponse bomResp;
DataManagementService dmService = DataManagementService.getService(session);
StructureManagementService structureService = StructureManagementService.getService(session);
com.teamcenter.services.rac.bom.StructureManagementService bomService = com.teamcenter.services.rac.bom.StructureManagementService
.getService(session);
com.teamcenter.services.rac.bom.StructureManagementService bomService
= com.teamcenter.services.rac.bom.StructureManagementService.getService(session);
AddOrUpdateChildrenToParentLineInfo[] chindInfo = new AddOrUpdateChildrenToParentLineInfo[1];
bomService.addOrUpdateChildrenToParentLine(chindInfo);
@ -444,6 +455,7 @@ public class CreateProcDYCCFolderController {
}
}
@SuppressWarnings("deprecation")
public void manualFeeding(ProgressBar pb, List<TCComponentItemRevision> revs, String pmpcCode) throws Exception {
pb.startProgress();
pb.setText("投料...");
@ -475,6 +487,7 @@ public class CreateProcDYCCFolderController {
}
// 批量投料
@SuppressWarnings("deprecation")
public void serBomLine(TCComponentBOMLine line, Map<String, String> fileds) throws Exception {
line.setProperties(fileds);
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.setText("加载数据...");
dialog.rev_Beans.clear();
@ -507,7 +521,30 @@ public class CreateProcDYCCFolderController {
win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine();
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);
refushTable(procBeanList);
for (int i = cout - 1; i > -1; i--) {
@ -519,25 +556,27 @@ public class CreateProcDYCCFolderController {
}catch(Exception e) {
}
SqlUtil.freeAll();
System.out.println("readData5:" + (System.currentTimeMillis() - startTime) / 1000);
win.close();
}
private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb,
TCComponentItemRevision parentRev, BomBean parentBean, List<DYCCProcBean> procBeanList) throws Exception {
private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine,
Map<String, ExpandPSData[]> bomLineTree, ProgressBar pb, TCComponentItemRevision parentRev,
BomBean parentBean, List<DYCCProcBean> procBeanList) throws Exception {
readTemplate(topLine, parentRev, parentBean, procBeanList);
BomBean pBean = (BomBean) treeNode.getUserObject();
pb.setText("加载数据..." + pBean);
AIFComponentContext[] cLines = topLine.getChildren();
ExpandPSData[] cLines = bomLineTree.get(topLine.getUid());
TCComponentItemRevision parentRev2 = topLine.getItemRevision();
for (int i = 0; i < cLines.length; i++) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent();
TCComponentItemRevision cRev = cLine.getItemRevision();
TCComponentBOMLine cLine = cLines[i].bomLine;
TCComponentItemRevision cRev = cLines[i].itemRevOfBOMLine;
BomBean cBean = new BomBean(cRev, cLine, procBeanList.size() + 1);
pBean.getChildren().add(cBean);
DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
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();
DYCCProcBean bean;
AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" });
// AIFComponentContext[] comps = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
// new String[] { "IMAN_METarget" });
TCComponentItemRevision cpgy = getMeproces(rev);
System.out.println("rev:" + rev);
if ("ZT2_Design3DRevision".equals(type)) {
drawingNo = rev.getProperty("item_id");
@ -563,26 +603,24 @@ public class CreateProcDYCCFolderController {
zt2_MaterialMark = rev.getProperty("zt2_MaterialMark");
System.out.println("zt2_MaterialMark:" + zt2_MaterialMark);
// 如果图纸未关联工艺,查看关联物料是否关联工艺
if (comps == null || comps.length == 0) {
if (cpgy == null) {
part = getPart(topLine, session);
if (part != null) {
comps = part.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" });
if (comps != null && comps.length > 0) {
gy = (TCComponent) comps[0].getComponent();
// comps = part.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
// new String[] { "IMAN_METarget" });
cpgy = getMeproces(part);
if (cpgy != null) {
gy = cpgy;
}
}
} else if (comps.length > 0) {
gy = (TCComponent) comps[0].getComponent();
} else {
gy = cpgy;
part = rev;
}
} else if ("Part Revision".equals(type)) {
drawingNo = rev.getProperty("zt2_MaterialNo");
if (comps != null && comps.length > 0) {
gy = (TCComponent) comps[0].getComponent();
if (cpgy != null) {
gy = cpgy;
}
}
@ -594,10 +632,8 @@ public class CreateProcDYCCFolderController {
if (res2.getListCount() > 0) {
gx = (TCComponent) res2.get(0).getComponent();
}
}
bean = new DYCCProcBean(procBeanList.size() + 1, drawingNo, object_name, zt2_Source, gy, gx, zt2_MaterialMark,
rev);
bean = new DYCCProcBean(procBeanList.size() + 1, drawingNo, object_name, zt2_Source, gy, gx, zt2_MaterialMark, rev);
String bl_sequence_no = topLine.getProperty("bl_sequence_no");
bean.setBl_sequence_no(bl_sequence_no);
bean.setParentRev(parentRev);
@ -614,22 +650,19 @@ public class CreateProcDYCCFolderController {
list2.add(bean);
dialog.rev_Beans.put(rev, list2);
}
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();
// comp.refresh();
if (comp.getType().equals("Part Revision")) {
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");
try {
TCComponent[] comps = comp.getReferenceListProperty("representation_for");
List<TCComponentItemRevision> parts = new ArrayList<TCComponentItemRevision>();
for (int i = 0; i < comps.length; i++) {
@ -661,15 +694,12 @@ public class CreateProcDYCCFolderController {
} else {
return null;
}
} else if (size > 1) {
List<InterfaceAIFComponent> materials = context.toComponentVector();
Collections.sort(materials, new Comparator<InterfaceAIFComponent>() {
@Override
public int compare(InterfaceAIFComponent o1, InterfaceAIFComponent o2) {
// TODO Auto-generated method stub
// Auto-generated method stub
try {
String zt2_MaterialNo1 = o1.getProperty("zt2_MaterialNo");
String zt2_MaterialNo2 = o2.getProperty("zt2_MaterialNo");
@ -683,7 +713,6 @@ public class CreateProcDYCCFolderController {
}
return 0;
}
});
for (int i = 0; i < size; i++) {
if (KUtil.isTCM((TCComponent) materials.get(i))) {
@ -698,14 +727,12 @@ public class CreateProcDYCCFolderController {
if (parts.size() == 1) {
return parts.get(0);
} else {
for (int i = 0; i < parts.size(); i++) {
String spec2 = parts.get(i).getProperty("zt2_Specifications");
if (spec.equals(spec2)) {
return parts.get(i);
}
}
}
} catch (Exception e) {
e.printStackTrace();
@ -713,7 +740,7 @@ public class CreateProcDYCCFolderController {
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();
if (parent == null) {
return;
@ -742,7 +769,7 @@ public class CreateProcDYCCFolderController {
getGX(parent, lists);
}
}
}*/
public void manualFeeding(ProgressBar pb, int[] sels, TCComponentItemRevision rev, TCComponent comp)
throws Exception {
@ -753,13 +780,13 @@ public class CreateProcDYCCFolderController {
String item_id = comp.getProperty("item_id");
String object_name = comp.getProperty("object_name");
DYCCProcBean bean;
TCComponentItemRevision rev2;
String design_item_id;
String zt2_ClassificationCode;
// TCComponentItemRevision rev2;
// String design_item_id;
// String zt2_ClassificationCode;
List<DYCCProcBean> beans = new ArrayList<>(8);
for (int i = 0; i < sels.length; i++) {
bean = (DYCCProcBean) dialog.t_part.getValueAt(sels[i], 0);
rev2 = bean.getRev();
// rev2 = bean.getRev();
/*
* if(rev2.getType().equals("ZT2_Design3DRevision")) {
* 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)
throws Exception {
if (revs.size() == 0)
@ -906,6 +934,7 @@ public class CreateProcDYCCFolderController {
pb.disposeDialog();
}
@SuppressWarnings("deprecation")
public void createProcess(ProgressBar pb, MEProcessBean bean, List<BomBean> beans) throws Exception {
TCComponentItemRevision template = bean.getMepRevision();
TCComponentItemRevision proc = null;
@ -938,7 +967,7 @@ public class CreateProcDYCCFolderController {
win.save();
win.refresh();
win.close();
} catch (TCException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -946,8 +975,8 @@ public class CreateProcDYCCFolderController {
TCComponentItemRevision newProc = null;
StringBuffer buff = new StringBuffer();
DefaultMutableTreeNode node;
String object_name = proc.getProperty("object_name");
// DefaultMutableTreeNode node;
// String object_name = proc.getProperty("object_name");
pb.setText("工艺路线创建......");
int len = beans.size();
DYCCProcBean dyccBean;
@ -972,7 +1001,7 @@ public class CreateProcDYCCFolderController {
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)) {
dyccBean = dialog.bomLink_maps.get(bomBean);
dyccBean.setGy(newProc);
@ -986,7 +1015,7 @@ public class CreateProcDYCCFolderController {
System.out.println("正在为" + bomBean.getRev() + "创建工艺路线");
pb.setText("正在为" + len + "/" + len + " " + 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)) {
dyccBean = dialog.bomLink_maps.get(bomBean);
@ -1076,7 +1105,7 @@ public class CreateProcDYCCFolderController {
String type = "";
List<TCComponentItemRevision> list;
int cout = 0;
// int cout = 0;
for (int i = 0, len = revs.size(); i < len; i++) {
rev = revs.get(i);
if (!KUtil.isHaveMeProcess(rev)) {
@ -1103,22 +1132,22 @@ public class CreateProcDYCCFolderController {
if ("DX1".equals(type)) {
if (maps_DX1.containsKey(zt2_MaterialNo)) {
maps_DX1.get(zt2_MaterialNo).add(rev);
cout++;
// cout++;
} else {
list = new ArrayList<TCComponentItemRevision>();
list.add(rev);
maps_DX1.put(zt2_MaterialNo, list);
cout++;
// cout++;
}
} else if ("DX3".equals("type")) {
if (maps_DX3.containsKey(zt2_MaterialNo)) {
maps_DX3.get(zt2_MaterialNo).add(rev);
cout++;
// cout++;
} else {
list = new ArrayList<TCComponentItemRevision>();
list.add(rev);
maps_DX3.put(zt2_MaterialNo, list);
cout++;
// cout++;
}
}
@ -1216,5 +1245,24 @@ 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.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.core.DataManagementService;
import sun.swing.table.DefaultTableCellHeaderRenderer;
/**
@ -165,15 +167,13 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
@Override
public void run() {
long startTime = System.currentTimeMillis();
try {
final InterfaceAIFComponent comp = app.getTargetComponent();
revs = new ArrayList<>(16);
revs = new ArrayList<>();
TCComponentItem item;
TCComponentItemRevision rev;
// String zt2_MaterialNo;
CreateProcBean bean = CreateProcController.getProcPres(session, "CHINT_ORG_TechnologyClassification",
groupID);
CreateProcBean bean = CreateProcController.getProcPres(session, "CHINT_ORG_TechnologyClassification", groupID);
if (bean == null) {
MessageBox.post("未找到[" + groupID + "]配置,请检查首选项<CHINT_ORG_TechnologyClassification>", "", 2);
return;
@ -182,72 +182,63 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
codeRemark_Technology = bean.getCodeRemark_Technology();
}
System.out.println("initUI:" + (System.currentTimeMillis() - startTime) / 1000);
// Command处已过滤掉Folder和TCComponentItemRevision外的其他对象
String object_name;
if (comp instanceof TCComponentFolder) {
folder = (TCComponentFolder) comp;
AIFComponentContext[] childs = folder.getChildren();
ArrayList<TCComponentItem> itemList = new ArrayList<>();
ArrayList<TCComponentItemRevision> revList = new ArrayList<>();
for (int i = 0, len = childs.length; i < len; i++) {
TCComponentItemRevision rev;
if (childs[i].getComponent() instanceof TCComponentItem) {
item = (TCComponentItem) childs[i].getComponent();
rev = item.getLatestItemRevision();
// revs.add(rev);
if (rev.getType().equals("Part Revision")) {
/*
* zt2_MaterialNo = rev.getProperty("zt2_MaterialNo");
* 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);
}
// rev = item.getLatestItemRevision();
if(!itemList.contains(item))
itemList.add(item);
} else if (childs[i].getComponent() instanceof TCComponentItemRevision) {
rev = (TCComponentItemRevision) childs[i].getComponent();
if (!revs.contains(rev)) {
if (rev.getType().equals("Part Revision")) {
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);
}
if(!revList.contains(rev))
revList.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);
for (TCComponentItemRevision rev : revList) {
if (rev.getType().equals("Part Revision")) {
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);
}
}
} else {
rev = (TCComponentItemRevision) comp;
TCComponentItemRevision rev = (TCComponentItemRevision) comp;
// zt2_MaterialNo = rev.getProperty("zt2_MaterialNo");
object_name = rev.getProperty("object_name");
if (object_name.contains("固定单元")) {
@ -282,6 +273,7 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
MessageBox.post(CreateProcDYCCFolderDialog.this, "未找到版本信息,请检查选择的文件夹对象", "", 2);
return;
}
System.out.println("initUI1:" + (System.currentTimeMillis() - startTime) / 1000);
initUI();
@ -292,6 +284,7 @@ public class CreateProcDYCCFolderDialog extends AbstractAIFDialog {
b_autoAssign.setEnabled(true);
}
}
System.out.println("initUI2:" + (System.currentTimeMillis() - startTime) / 1000);
new Thread(new Runnable() {
@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.BomBean;
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.KUtil;
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.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.core.DataManagementService;
import sun.swing.table.DefaultTableCellHeaderRenderer;
public class CreateProcGYKGDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private CreateProcGYKGDialogController controller;
private AbstractAIFApplication app;
@ -105,7 +110,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
// 工序
private List<TCComponent> by_lists;
// 工艺
private List<MEProcessBean> meprocs = new ArrayList(50);
private List<MEProcessBean> meprocs = new ArrayList<>();
protected TCComponentFolder folder_target = null; // 选中的文件夹
protected List<TCComponentItemRevision> revs = null;
@ -137,8 +142,8 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
groupID = actioninfo;
}
} catch (TCException e) {
// TODO Auto-generated catch block
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
@ -160,7 +165,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
codeRemark_Process = bean.getCodeRemark_Process();
codeRemark_Technology = bean.getCodeRemark_Technology();
}
revs = new ArrayList();
revs = new ArrayList<>();
TCComponentItem item;
TCComponentItemRevision rev;
if (target instanceof TCComponentItemRevision) {
@ -170,6 +175,17 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} else if (target instanceof TCComponentFolder) {
folder_target = (TCComponentFolder) target;
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++) {
if (childs[i].getComponent() instanceof TCComponentItem) {
item = (TCComponentItem) childs[i].getComponent();
@ -193,7 +209,6 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
initUI();
new Thread(new Runnable() {
@Override
public void run() {
ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this, new Dimension(250, 50));
@ -207,24 +222,30 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
if (current_bean != null) {
controller.readData(pb, rev_nodes.get(current_bean));
}
// current_bean = (BomBean) rev_nodes.get(current_bean).getUserObject();
} else {
controller.readData(pb, revs);
}
addListeners();
isAllowExpand = true;
pb.disposeDialog();
by_lists = KUtil.getClassObjects(codeRemark_Process, session);
} catch (Exception e) {
pb.disposeDialog();
MessageBox.post(CreateProcGYKGDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "",
MessageBox.ERROR);
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();
@ -263,6 +284,11 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int row, int column) {
if (column == 3 || column == 7) {
@ -307,6 +333,11 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
tree.putClientProperty("JTree.lineStyle", "Horizontal");// 使JTree的文件夹间具有水平分隔线。
this.treeCellRenderer = new DefaultTreeCellRenderer() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
@ -386,8 +417,8 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
}
}
System.out.println("版本个数:" + revs.size());
File[] tcFiles;
File fmsFile;
// File[] tcFiles;
// File fmsFile;
List<String> paths = new ArrayList<>();
// List<TCComponentDataset> datasets = new ArrayList<>();
try {
@ -410,7 +441,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
for (int j = 0; j < comps.length; j++) {
if (comps[j] instanceof TCComponentDataset && comps[j].getType().equals("PDF")) {
dataset = ((TCComponentDataset) comps[j]);
String d_type = dataset.getType();
// String d_type = dataset.getType();
String type = dataset.getProperty("ref_names");
String[] types = type.split(",");
for (int l = 0; l < types.length; l++) {
@ -433,7 +464,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
}
} catch (Exception e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
MessageBox.post("PDF打开异常:" + e1.getMessage(), "", 2);
}
@ -446,7 +477,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
// Auto-generated method stub
ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this, new Dimension(250, 50));
setCompEnabled(false);
try {
@ -519,7 +550,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
}
if (nodes.size() > 0) {
List<TCComponentItemRevision> revs = new ArrayList<>();
BomBean bomBean;
// BomBean bomBean;
TCComponentItemRevision rev;
for (int i = 0; i < nodes.size(); i++) {
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,
session);
} catch (Exception e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2);
}
@ -553,7 +584,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
new GYKGUpdateProcDialog(CreateProcGYKGDialog.this, revs, rev_Beans, value_strings,
session);
} catch (Exception e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2);
}
@ -562,7 +593,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
}
});
} catch (Exception e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
}
@ -572,9 +603,10 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
// 修改材料定额和自制外购
t_part.getModel().addTableModelListener(new TableModelListener() {
@SuppressWarnings("deprecation")
@Override
public void tableChanged(TableModelEvent e) {
// TODO Auto-generated method stub
// Auto-generated method stub
int col = e.getColumn();
int row = e.getFirstRow();
if (row < 0 || col < 0) {
@ -661,7 +693,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
}
} catch (Exception e1) {
KUtil.setByPass(false);
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
MessageBox.post(CreateProcGYKGDialog.this, "投料异常,ERROR:" + e1.getMessage(), "",
MessageBox.ERROR);
@ -695,10 +727,10 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
if (nodes.size() > 0) {
pb.startProgress();
pb.setText("开始校验对象工艺信息......");
List<DYCCProcBean> procBeans = new ArrayList<>();
// List<DYCCProcBean> procBeans = new ArrayList<>();
List<BomBean> bomBeans = new ArrayList<>();
BomBean bomBean;
DYCCProcBean procBean;
// DYCCProcBean procBean;
List<BomBean> allBeans = new ArrayList<>();
try {
for (int i = 0, len = nodes.size(); i < len; i++) {
@ -738,7 +770,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
return;
}
KUtil.setByPass(true);
TCComponentItemRevision meop;
// TCComponentItemRevision meop;
pb.startProgress();
pb.showDialog();
pb.setText("工艺模板准备中...");
@ -748,7 +780,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
} catch (Exception e) {
pb.disposeDialog();
// TODO: handle exception
// : handle exception
e.printStackTrace();
MessageBox.post(CreateProcGYKGDialog.this, "异常:" + e.getMessage(), "提示", 2);
}
@ -839,7 +871,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
@Override
public void run() {
// TODO Auto-generated method stub
// Auto-generated method stub
ProgressBar pb = new ProgressBar(CreateProcGYKGDialog.this,
new Dimension(250, 50));
setCompEnabled(false);
@ -862,7 +894,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
controller.refushTable(map_nodes.get(node));
current_bean = (BomBean) node.getUserObject();
} catch (Exception e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
MessageBox.post(CreateProcGYKGDialog.this, "获取对象信息时发生异常:" + e1.getMessage(), "",
MessageBox.ERROR);
e1.printStackTrace();
@ -874,7 +906,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
/*
* tree.clearSelection(); try {
* 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(); }
*/
}
@ -896,7 +928,7 @@ public class CreateProcGYKGDialog extends AbstractAIFDialog {
// controller.recurRemove(model,node,tm_part,bomLink_maps);
// controller.refushTable2();
} catch (Exception e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
}
}

@ -1,7 +1,8 @@
package com.connor.chint.sap2.proc_gykg;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
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.create_proc.CreateProcController;
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.BomBean;
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.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.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
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 {
@ -50,8 +55,8 @@ public class CreateProcGYKGDialogController {
this.session = (TCSession) app.getSession();
try {
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
} catch (TCException e) {
// TODO Auto-generated catch block
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
@ -107,6 +112,7 @@ public class CreateProcGYKGDialogController {
// 单独打开一个子项
public void readData(ProgressBar pb, DefaultMutableTreeNode topTreeNode) throws Exception {
long startTime = System.currentTimeMillis();
pb.startProgress();
pb.setText("加载数据...");
dialog.rev_Beans.clear();
@ -118,17 +124,46 @@ public class CreateProcGYKGDialogController {
win.setWindowTopLine(rev.getItem(), rev, null, null);
TCComponentBOMLine topLine = win.getTopBOMLine();
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);
// 20220418改
readTemplate(topLine, rev, topBean, procBeanList2);
getChilds(topTreeNode, topLine, pb, rev, topBean, procBeanList2);
win.refresh();
// 20220418改 TODO
String[] prefs = ChintPreferenceUtil.getPreferences("database_tc", session);
if (SqlUtil.getTCDataConnection(prefs) == null) {
MessageBox.post("数据库连接失败,请检查数据库连接配置!", "", 2);
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();
procBeanList.clear();
procBeanList.addAll(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--) {
topTreeNode.remove(i);
}
@ -139,56 +174,61 @@ public class CreateProcGYKGDialogController {
dialog.t_part.getColumnModel().getColumn(3).setCellEditor(procEditoe);
}
dialog.t_model.reload();
SqlUtil.freeAll();
System.out.println("readData5:" + (System.currentTimeMillis() - startTime) / 1000);
}
/*
* //读取数据 private void readBom(DefaultMutableTreeNode treeNode,
* TCComponentBOMLine topLine, ProgressBar pb,TCComponentItemRevision
* parentRev,BomBean parentBean ,List<BYProcBean> beanList) throws Exception {
* readTemplate(topLine,parentRev,parentBean,beanList); BomBean pBean =
* (BomBean) treeNode.getUserObject(); pb.setText("加载数据..."+pBean);
* AIFComponentContext[] cLines = topLine.getChildren(); TCComponentItemRevision
* parentRev2 = topLine.getItemRevision(); for (int i = 0; i < cLines.length;
* i++) { TCComponentBOMLine cLine = (TCComponentBOMLine)
* cLines[i].getComponent(); TCComponentItemRevision cRev =
* cLine.getItemRevision(); BomBean cBean = new
* BomBean(cRev,cLine,procBeanList.size()+1); pBean.getChildren().add(cBean);
* DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
* treeNode.add(cNode); System.out.println("添加:" + cBean); readBom(cNode, cLine,
* pb,parentRev2,cBean,beanList); } }
*
*
* //读取数据
* private void readBom(DefaultMutableTreeNode treeNode, TCComponentBOMLine topLine, ProgressBar pb,
* TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> beanList) throws Exception {
* readTemplate(topLine,parentRev,parentBean,beanList);
* BomBean pBean = (BomBean) treeNode.getUserObject();
* pb.setText("加载数据..."+pBean);
* AIFComponentContext[] cLines = topLine.getChildren();
* TCComponentItemRevision parentRev2 = topLine.getItemRevision();
* for (int i = 0; i < cLines.length; i++) {
* TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent();
* TCComponentItemRevision cRev = cLine.getItemRevision();
* BomBean cBean = new BomBean(cRev, cLine,procBeanList.size() + 1);
* pBean.getChildren().add(cBean);
* DefaultMutableTreeNode cNode = new DefaultMutableTreeNode(cBean);
* treeNode.add(cNode);
* System.out.println("添加:" + cBean);
* readBom(cNode, cLine, pb, parentRev2, cBean, beanList);
* }
* }
*/
public void getChilds(DefaultMutableTreeNode topNode, TCComponentBOMLine line, ProgressBar pb,
TCComponentItemRevision parentRev, BomBean parentBean, List<BYProcBean> beanList) throws Exception {
public void getChilds(DefaultMutableTreeNode topNode, TCComponentBOMLine line,
Map<String, ExpandPSData[]> bomLineTree, ProgressBar pb, TCComponentItemRevision parentRev,
BomBean parentBean, List<BYProcBean> beanList, List<String> codeList, List<String> idList) throws Exception {
// pb.setText("加载数据..."+pBean);
AIFComponentContext[] childs = line.getChildren();
// AIFComponentContext[] childs = line.getChildren();
TCComponentBOMLine childLine;
TCComponentItemRevision rev;
BomBean bean;
DefaultMutableTreeNode cNode;
TCComponentItemRevision parentRev2 = line.getItemRevision();
for (int i = 0, len = childs.length; i < len; i++) {
childLine = (TCComponentBOMLine) childs[i].getComponent();
rev = childLine.getItemRevision();
for (ExpandPSData data : bomLineTree.get(line.getUid())) {
childLine = data.bomLine;//(TCComponentBOMLine) childs[i].getComponent();
rev = data.itemRevOfBOMLine;
// 若为虚拟项,则过滤,并把虚拟项下面的子项往上提升
// 0714改 若为虚拟项,则过滤,并把虚拟项下面的子项都过滤
if ("是".equals(rev.getProperty("zt2_Diagram"))) {
// getChilds(topNode,childLine, pb,parentRev2,parentBean,beanList);
} else {
bean = new BomBean(rev, childLine, 1);
readTemplate(childLine, parentRev2, bean, beanList);
readTemplate(childLine, parentRev2, bean, beanList, codeList, idList);
cNode = new DefaultMutableTreeNode(bean);
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,
List<BYProcBean> beanList) throws Exception {
List<BYProcBean> beanList, List<String> codeList, List<String> idList) throws Exception {
TCComponentItemRevision comp = topLine.getItemRevision();
String bl_sequence_no = topLine.getProperty("bl_sequence_no");
String drawNo = "";
@ -205,7 +245,7 @@ public class CreateProcGYKGDialogController {
String zt2_MaterialMark = comp.getProperty("zt2_MaterialMark");
TCComponentItemRevision meop = null;
TCComponentItemRevision meopress = null;
AIFComponentContext[] refs = comp.whereReferencedByTypeRelation(null, null);
/*AIFComponentContext[] refs = comp.whereReferencedByTypeRelation(null, null);
System.out.println("查询产品工艺、投料工序:" + comp + ", 引用数量:" + refs.length);
for (int i = 0; i < refs.length; i++) {
InterfaceAIFComponent c = refs[i].getComponent();
@ -216,12 +256,16 @@ public class CreateProcGYKGDialogController {
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");
System.out.println("[ZT2_ClassificationNo=" + zt2_ClassificationCode + "]");
if (zt2_ClassificationCode.length() > 0) {
// System.out.println("[ZT2_ClassificationNo=" + zt2_ClassificationCode + "]");
/*if (zt2_ClassificationCode.length() > 0) {
Map<String, String> fields2 = new LinkedHashMap<>();
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) {
int len2 = res2.getListCount();
@ -232,7 +276,8 @@ public class CreateProcGYKGDialogController {
meopress = (TCComponentItemRevision) res2.get(0).getComponent();
}
}
}
}*/
idList.add(zt2_ClassificationCode);
BYProcBean bean = new BYProcBean(procBeanList.size() + 1, comp, parentRev, drawNo, object_name, zt2_Source,
meop, meopress, zt2_MaterialNorm, zt2_MaterialMark);
bean.setBl_sequence_no(bl_sequence_no);
@ -248,7 +293,7 @@ public class CreateProcGYKGDialogController {
return bean;
}
public void refushTable(List<BYProcBean> list) throws Exception {
protected void refushTable(List<BYProcBean> list) throws Exception {
dialog.tm_part.getDataVector().clear();
dialog.t_part.clearSelection();
dialog.t_part.revalidate();
@ -259,13 +304,100 @@ public class CreateProcGYKGDialogController {
}
}
public void refushTable2() throws Exception {
int cout = dialog.t_part.getRowCount();
BYProcBean bean;
for (int i = 0, len = cout; i < len; i++) {
bean = (BYProcBean) dialog.t_part.getValueAt(i, 0);
bean.setIndex(i + 1);
dialog.t_part.setValueAt(bean, i, 0);
private void refushTable2(List<BYProcBean> list) throws Exception {
for(int i = dialog.t_part.getRowCount() - 1; i >= 0; i--) {
dialog.tm_part.removeRow(i);
}
for (int i = 0, len = list.size(); i < len; i++) {
list.get(i).setIndex(i + 1);
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;
}
@SuppressWarnings("deprecation")
public void manualFeeding2(BYProcBean bean, String ZT2_ClassificationNo) throws Exception {
StringBuilder err = new StringBuilder();
TCComponentItemRevision rev = dialog.current_bean.getRev();
@ -295,7 +428,7 @@ public class CreateProcGYKGDialogController {
TCComponentBOMWindow win = bomWinType.create(null);
win.setWindowTopLine(rev.getItem(), rev, null, null);
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>();
fields.put("ZT2_ClassificationNo", ZT2_ClassificationNo);
serBomLine(topLine, bean, false, fields, 0, rev);
@ -324,7 +457,7 @@ public class CreateProcGYKGDialogController {
TCComponentBOMWindow win = bomWinType.create(null);
win.setWindowTopLine(bom_Rev.getItem(), bom_Rev, null, null);
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++) {
BYProcBean procBean = procBeanList.get(i);
@ -395,7 +528,7 @@ public class CreateProcGYKGDialogController {
TCComponentBOMWindow win = bomWinType.create(null);
win.setWindowTopLine(rev.getItem(), rev, null, null);
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");
for (int i = 0; i < sels.length; i++) {
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 {
TCComponentItemRevision template = bean.getMepRevision();
TCComponentItemRevision proc = null;
@ -471,17 +605,17 @@ public class CreateProcGYKGDialogController {
TCComponentItemRevision newProc = null;
StringBuffer buff = new StringBuffer();
DefaultMutableTreeNode node;
String object_name = proc.getProperty("object_name");
// DefaultMutableTreeNode node;
// String object_name = proc.getProperty("object_name");
pb.setText("工艺路线创建......");
int len = beans.size();
BYProcBean dyccBean;
BomBean bomBean;
List<BYProcBean> proList = new ArrayList<>();
// List<BYProcBean> proList = new ArrayList<>();
List<BYProcBean> procBeans;
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++) {
@ -498,13 +632,13 @@ public class CreateProcGYKGDialogController {
} else {
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)) {
dyccBean = dialog.bomLink_maps.get(bomBean);
dyccBean.setMeop(newProc);
procBeans = dialog.rev_Beans.get(bomBean.getRev());
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.setMeop(newProc);
if (dyccBean.isVisible)
@ -518,14 +652,14 @@ public class CreateProcGYKGDialogController {
System.out.println("正在为" + bomBean.getRev() + "创建工艺路线");
pb.setText("正在为" + len + "/" + len + " " + 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)) {
dyccBean = dialog.bomLink_maps.get(bomBean);
procBeans = dialog.rev_Beans.get(bomBean.getRev());
dyccBean.setMeop(newProc);
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.setMeop(proc);
if (dyccBean.isVisible)
@ -538,6 +672,7 @@ public class CreateProcGYKGDialogController {
}
// 创建工艺
@SuppressWarnings("deprecation")
public void createProcess(ProgressBar pb, MEProcessBean bean, TCSession session, List<TCComponentItemRevision> revs)
throws Exception {
if (revs.size() == 0)
@ -581,8 +716,8 @@ public class CreateProcGYKGDialogController {
TCComponentItemRevision rev;
TCComponentItemRevision newProc = null;
StringBuffer buff = new StringBuffer();
DefaultMutableTreeNode node;
String object_name = proc.getProperty("object_name");
// DefaultMutableTreeNode node;
// String object_name = proc.getProperty("object_name");
// pb.setText("工艺路线创建......");
int len = revs.size();
List<BYProcBean> cout_beans = new ArrayList<>();
@ -667,6 +802,7 @@ public class CreateProcGYKGDialogController {
int rowCount = tm_part.getRowCount();
int index = -1;
// BomBean bean = (BomBean) parent.getUserObject();
@SuppressWarnings("unlikely-arg-type")
BYProcBean procBean = bomLink_maps.get(parent);
if (procBean != null) {
for (int i = 0; i < rowCount; i++) {
@ -695,5 +831,14 @@ 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;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
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.ProcessChangeDialog;
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.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.kernel.AIFComponentContext;
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.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentMEOPRevisionType;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCException;
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 CreateProcXBController {
@ -74,6 +77,9 @@ public class CreateProcXBController {
// 展开的节点
protected Vector<TreePath> expandPaths = new Vector<>();
private String group;
private Map<String, ExpandPSData[]> bomLineTree;
public CreateProcXBController(CreateProcXBDialog dialog, AbstractAIFApplication app) {
this.app = app;
@ -89,6 +95,7 @@ public class CreateProcXBController {
// 读取对象的BOM 展开未读取节点
public void readData(ProgressBar pb, TCComponentItemRevision topRev) throws Exception {
isCanExpand = false;
group = session.getCurrentGroup().getUid();
pb.startProgress();
pb.setText("加载数据...");
win.setWindowTopLine(topRev.getItem(), topRev, null, null);
@ -96,32 +103,50 @@ public class CreateProcXBController {
XBBomBean bomBean = new XBBomBean(topRev);
DefaultMutableTreeNode topTreeNode = new DefaultMutableTreeNode(bomBean);
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);
int size = 1;
proBean.setIndex(size);
procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData());
// dialog.tm_part.addRow(proBean.getRowData());
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;
DefaultMutableTreeNode childNode, node;
XBBomBean childBomBean;
TCComponentItemRevision childRev;
List<TreePath> paths = new ArrayList<>();
TreePath path;
for (int i = 0, len = children.length; i < len; i++) {
childLine = (TCComponentBOMLine) children[i].getComponent();
childRev = childLine.getItemRevision();
for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
childLine = data.bomLine;
childRev = data.itemRevOfBOMLine;
// 读取最新零组件版本 20230630 by yudy
// childRev = childLine.getItem().getLatestItemRevision();
childBomBean = new XBBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean);
proBean = readTemplate(childLine, childBomBean, childRev);
proBean = readTemplate(childLine, childBomBean, childRev, noList, codeList);
proBean.setIndex(size);
procBeanList.add(proBean);
dialog.tm_part.addRow(proBean.getRowData());
size++;
if (childLine.hasChildren()) {
node_need_expands.add(childNode);
@ -136,6 +161,10 @@ public class CreateProcXBController {
maps_table_tree.put(proBean, childNode);
maps_tree_table.put(childBomBean, proBean);
}
getGY(procBeanList, noList, codeList);
for(XBProcBean bean : procBeanList) {
dialog.tm_part.addRow(bean.getRowData());
}
dialog.topNode.add(topTreeNode);
KUtil.expandTree(dialog.tree, new TreePath(dialog.topNode));
@ -149,13 +178,14 @@ public class CreateProcXBController {
@Override
public void run() {
// TODO Auto-generated method stub
// Auto-generated method stub
dialog.tree.updateUI();
TreeNode t_node = dialog.topNode.getChildAt(0);
System.out.println("t_node:" + t_node);
expandPaths.add(new TreePath(t_node));
}
});
SqlUtil.free();
pb.disposeDialog();
}
@ -214,19 +244,22 @@ public class CreateProcXBController {
TCComponentBOMLine topLine = maps_table_line_maps.get(procBean);
// procBeanList 这个是按index大小拍过序的
int index = procBeanList.indexOf(procBean);
AIFComponentContext[] children = topLine.getChildren();
// AIFComponentContext[] children = topLine.getChildren();
TCComponentBOMLine childLine;
XBBomBean childBomBean;
TCComponentItemRevision childRev;
DefaultMutableTreeNode childNode, node;
List<String> noList = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<TreePath> paths = new ArrayList<>();
TreePath path;
for (int i = 0, len = children.length; i < len; i++) {
childLine = (TCComponentBOMLine) children[i].getComponent();
childRev = childLine.getItemRevision();
int i = 0;
for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
childLine = data.bomLine;
childRev = data.itemRevOfBOMLine;
childBomBean = new XBBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean);
procBean = readTemplate(childLine, childBomBean, childRev);
procBean = readTemplate(childLine, childBomBean, childRev, noList, codeList);
procBean.setIndex(index + i + 2);
procBeanList.add(index + i + 1, procBean);
if (childLine.hasChildren()) {
@ -243,8 +276,9 @@ public class CreateProcXBController {
map_line_table_maps.put(childLine, procBean);
maps_tree_table.put(childBomBean, procBean);
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);
}
@ -253,7 +287,7 @@ public class CreateProcXBController {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
// Auto-generated method stub
dialog.tree.updateUI();
}
});
@ -270,20 +304,24 @@ public class CreateProcXBController {
int cout, index;
XBBomBean bomBean;
XBProcBean procBean;
List<String> noList = new ArrayList<>();
List<String> codeList = new ArrayList<>();
pb.startProgress();
pb.setText("正在展开......");
for (int i = 0, len = nodes.size(); i < len; i++) {
beans.clear();
noList.clear();
codeList.clear();
node = nodes.get(i);
cout = node.getChildCount();
bomBean = (XBBomBean) node.getUserObject();
pb.setText("正在展开子项" + 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);
for (int j = 0, len2 = beans.size(); j < len2; j++) {
beans.get(j).setIndex(index + j + 2);
}
procBeanList.addAll(index + 1, beans);
for (int j = cout - 1; j >= 0; j--) {
@ -293,7 +331,7 @@ public class CreateProcXBController {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
// Auto-generated method stub
dialog.tree.updateUI();
}
});
@ -305,9 +343,9 @@ public class CreateProcXBController {
// 展开
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);
AIFComponentContext[] children = topLine.getChildren();
// AIFComponentContext[] children = topLine.getChildren();
TCComponentItemRevision itemRevision = topLine.getItemRevision();
if(!isWgOrXn(itemRevision)) {
return;
@ -315,16 +353,16 @@ public class CreateProcXBController {
TCComponentBOMLine childLine;
XBBomBean childBomBean;
TCComponentItemRevision childRev;
DefaultMutableTreeNode childNode, node;
for (int i = 0, len = children.length; i < len; i++) {
childLine = (TCComponentBOMLine) children[i].getComponent();
childRev = childLine.getItemRevision();
DefaultMutableTreeNode childNode;
for (ExpandPSData data : bomLineTree.get(topLine.getUid())) {
childLine = data.bomLine;
childRev = data.itemRevOfBOMLine;
childBomBean = new XBBomBean(childRev);
childNode = new DefaultMutableTreeNode(childBomBean);
procBean = readTemplate(childLine, childBomBean, childRev);
procBean = readTemplate(childLine, childBomBean, childRev, noList, codeList);
beans.add(procBean);
if (childLine.hasChildren() && isWgOrXn(childRev)) {
expandAllNode(childNode, beans, childBomBean, procBean);
expandAllNode(childNode, beans, childBomBean, procBean, noList, codeList);
}
topNode.add(childNode);
bomBean.addChild(childBomBean);
@ -352,7 +390,7 @@ public class CreateProcXBController {
public void expandNode(DefaultMutableTreeNode topNode, TreePath path) throws Exception {
XBBomBean bomBean = (XBBomBean) topNode.getUserObject();
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大小拍过序的
int index = procBeanList.indexOf(procBean);
System.out.println("index:" + index);
@ -391,18 +429,18 @@ public class CreateProcXBController {
}
// ¶ÁÈ¡¾ßÌåÐÅÏ¢
private XBProcBean readTemplate(TCComponentBOMLine line, XBBomBean bean, TCComponentItemRevision rev)
throws Exception {
//TODO 读取具体信息
private XBProcBean readTemplate(TCComponentBOMLine line, XBBomBean bean, TCComponentItemRevision rev,
List<String> noList, List<String> codeList) throws Exception {
String type = rev.getType();// 类型
String drawNo; // 图样代号
TCComponentItemRevision rev_standard = null; // 标准图版本
TCComponentItemRevision tlgx_standard = null; // 标准图工序
TCComponentItemRevision cp_gx_rev = null, cp_gy_rev = null; // 产品工序、产品工
List<TCComponentItemRevision> list_standard = new ArrayList<>(4); // 标准图工艺
Map<String, String> fields = new LinkedHashMap<>();
// Map<String, String> fields = new LinkedHashMap<>();
String zt2_ClassificationCode; // 工序编码
TCComponentContextList res;
// TCComponentContextList res;
String drawingNo = "";
String zt2_Source = "";
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);
// 查询的是版本对象
res = KUtil.query(session, "chint_query_TYDH", fields);
@ -452,8 +491,7 @@ public class CreateProcXBController {
list_standard.add(meopRev);
}
}
}
}*/
} else if (type.equals("Part Revision")) {
drawNo = rev.getProperty("zt2_MaterialNo");
if (KUtil.isEmpty(drawNo)) {
@ -464,7 +502,8 @@ public class CreateProcXBController {
drawingNo = drawingNo.substring(0, ind);
}
// 查询标准图对象
fields.put("Áã×é¼þ ID", drawingNo);
noList.add(drawingNo);
/*fields.put("零组件 ID", drawingNo);
// 查询的是版本对象
res = KUtil.query(session, "零组件...", fields);
if (res != null) {
@ -493,15 +532,15 @@ public class CreateProcXBController {
list_standard.add(meopRev);
}
}
}
}*/
} else {
throw new Exception("BOM中存在非图纸/物料对象");
}
// 开始查找自身工艺以及工序
zt2_ClassificationCode = line.getProperty("ZT2_ClassificationNo");
if (!KUtil.isEmpty(zt2_ClassificationCode)) {
codeList.add(zt2_ClassificationCode);
/*if (!KUtil.isEmpty(zt2_ClassificationCode)) {
fields.clear();
fields.put("ID", zt2_ClassificationCode);
res = KUtil.query(session, "chint_query_item", fields);
@ -511,10 +550,10 @@ public class CreateProcXBController {
}
cp_gx_rev = (TCComponentItemRevision) res.get(0).getComponent();
}
}
}*/
AIFComponentContext[] refs = rev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" });
if (res != null && refs.length > 0) {
if (refs != null && refs.length > 0) {
cp_gy_rev = (TCComponentItemRevision) refs[0].getComponent();
}
@ -543,7 +582,7 @@ public class CreateProcXBController {
// 自动投料
public void autoFeeding(ProgressBar pb, TCComponent comp) throws Exception {
int cout = dialog.t_part.getRowCount();
// int cout = dialog.t_part.getRowCount();
XBProcBean procBean;
String item_id, object_name;
TCComponentBOMLine line;
@ -585,7 +624,7 @@ public class CreateProcXBController {
private void autoFeeding(TCSession session, TCComponentBOMLine line, TCComponentBOMLine parent, String feedNo,
Map<String, String> map_feed_maps, StringBuilder sbuild, StringBuilder sb) throws Exception {
XBProcBean procBean;
AIFComponentContext[] children = line.getChildren();
// AIFComponentContext[] children = line.getChildren();
TCComponentBOMLine child;
TCComponent proc;
TCComponentItemRevision rev;
@ -595,9 +634,9 @@ public class CreateProcXBController {
int index;
TCComponentContextList res;
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);
CreateProcessController.feeding(child, feedNo);
proc = null;
@ -649,6 +688,7 @@ public class CreateProcXBController {
}
// 手动投料 投料前过滤掉只选了BOM首行的
@SuppressWarnings("deprecation")
public void manualFeeding(int[] rows, TCComponent gx_comp) throws Exception {
String item_id = gx_comp.getProperty("item_id");
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 {
int[] sels = dialog.t_part.getSelectedRows();
if (sels != null && sels.length == 1) {
@ -796,6 +837,7 @@ public class CreateProcXBController {
MessageBox.post(dialog, "自动指派工艺成功!", "", 2);
}
@SuppressWarnings("deprecation")
private void match(String gyid, TCComponentItemRevision proc, Map<String, Map<String, Object>> gygxMap, double ndxs) {
try {
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
@ -803,9 +845,9 @@ public class CreateProcXBController {
win.lock();
win.setWindowTopLine(proc.getItem(), proc, null, null);
TCComponentBOMLine componentbomline = win.getTopBOMLine();
AIFComponentContext[] childs = componentbomline.getChildren();
for (AIFComponentContext child : childs) {
match(gyid, (TCComponentBOMLine) child.getComponent(), gygxMap, ndxs);
// AIFComponentContext[] childs = componentbomline.getChildren();
for (ExpandPSData data : bomLineTree.get(componentbomline.getUid())) {
match(gyid, data.bomLine, gygxMap, ndxs);
}
win.save();
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 {
// String type = line.getItemRevision().getType();
TCComponentType type = line.getItemRevision().getTypeComponent();
@ -845,9 +888,9 @@ public class CreateProcXBController {
LoggerUtils.debug("匹配为空。");
}
}
AIFComponentContext[] lineChilds = line.getChildren();
for (AIFComponentContext lineChild: lineChilds) {
match(gyid, (TCComponentBOMLine) lineChild.getComponent(), gygxMap, ndxs);
// AIFComponentContext[] lineChilds = line.getChildren();
for (ExpandPSData data : bomLineTree.get(line.getUid())) {
match(gyid, data.bomLine, gygxMap, ndxs);
}
}
@ -869,6 +912,7 @@ public class CreateProcXBController {
return nodes;
}
@SuppressWarnings("deprecation")
public void createProcess(ProgressBar pb, MEProcessBean bean, TCSession session, List<TCComponentItemRevision> revs)
throws Exception {
if (revs.size() == 0)
@ -898,8 +942,9 @@ public class CreateProcXBController {
win.setWindowTopLine(proc.getItem(), proc, null, null);
TCComponentBOMLine componentbomline = win.getTopBOMLine();
AIFComponentContext[] childs = componentbomline.getChildren();
for (int i = 0, len = childs.length; i < len; i++) {
CreateProcController.readClsss((TCComponentBOMLine) childs[i].getComponent(), gxs, nos);
for (AIFComponentContext data : childs) {
// for (ExpandPSData data : bomLineTree.get(componentbomline.getUid())) {
CreateProcController.readClsss((TCComponentBOMLine) data.getComponent(), gxs, nos);
}
win.save();
win.refresh();
@ -975,4 +1020,128 @@ public class CreateProcXBController {
System.out.println("list:" + list);
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.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
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.ProcessDialog;
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.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_gykg.CreateProcGYKGDialog;
import com.connor.chint.sap2.proc_gykg.GYKGUpdateProcDialog;
import com.connor.chint.sap2.util.ChintConfirmDialogUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.ProgressBar;
@ -78,6 +71,10 @@ import sun.swing.table.DefaultTableCellHeaderRenderer;
public class CreateProcXBDialog extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private CreateProcXBController controller;
private AbstractAIFApplication app;
private TCSession session;
@ -127,8 +124,8 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
if (groupID.equalsIgnoreCase("dba")) {
groupID = actionInfo;
}
} catch (TCException e) {
// TODO Auto-generated catch block
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
@ -149,7 +146,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
codeRemark_Technology = bean.getCodeRemark_Technology();
}
long time = new Date().getTime();
// long time = new Date().getTime();
this.bomRev = (TCComponentItemRevision) app.getTargetComponent();
try {
initUI();
@ -163,7 +160,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
value_strings = KUtil.getLOVDisplay_value(session, "zt2_ControlCode");
controller.readData(pb, bomRev);
addListener();
byq_gx_lists = KUtil.getClassObjects(codeRemark_Process, session);
// byq_gx_lists = KUtil.getClassObjects(codeRemark_Process, session);
} catch (Exception e) {
pb.disposeDialog();
MessageBox.post(CreateProcXBDialog.this, "获取对象信息时发生异常:" + e.getMessage(), "", MessageBox.ERROR);
@ -176,12 +173,12 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@Override
public void run() {
// TODO Auto-generated method stub
// Auto-generated method stub
try {
// KUtil.setByPass(true);
byq_gx_lists = KUtil.getClassObjects(codeRemark_Process, session);
meprocs = cpController.getMEProcs(session, codeRemark_Technology);
} catch (TCException e) {
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(CreateProcXBDialog.this, "获取工序时发生异常:" + e.getMessage(), "", MessageBox.ERROR);
} finally {
@ -191,7 +188,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
}).start();
showDialog();
} catch (Exception e) {
// TODO: handle exception
// : handle exception
e.printStackTrace();
MessageBox.post("初始化异常:" + e.getMessage(), "", 2);
}
@ -210,14 +207,14 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
// 界面关闭的时候关掉BOMWindow
@Override
protected void processWindowEvent(WindowEvent e) {
// TODO Auto-generated method stub
// Auto-generated method stub
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
if (controller.win != null) {
try {
controller.win.save();
controller.win.close();
} catch (TCException e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
}
}
@ -261,8 +258,8 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
}
}
System.out.println("版本个数:" + revs.size());
File[] tcFiles;
File fmsFile;
// File[] tcFiles;
// File fmsFile;
List<String> paths = new ArrayList<>();
try {
TCComponent[] comps;
@ -284,7 +281,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
for (int j = 0; j < comps.length; j++) {
if (comps[j] instanceof TCComponentDataset && comps[j].getType().equals("PDF")) {
dataset = ((TCComponentDataset) comps[j]);
String d_type = dataset.getType();
// String d_type = dataset.getType();
String type = dataset.getProperty("ref_names");
String[] types = type.split(",");
for (int l = 0; l < types.length; l++) {
@ -307,7 +304,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
}
} catch (Exception e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
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));
try {
KUtil.stopTableEditing(t_part);
List<DefaultMutableTreeNode> nodes = null;// controller.getSelectNodes();
// List<DefaultMutableTreeNode> nodes = null;// controller.getSelectNodes();
int[] rows = t_part.getSelectedRows();
if (rows.length == 0) {
MessageBox.post(CreateProcXBDialog.this, "请选择需要创建工艺的对象", "", 2);
@ -466,14 +463,14 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
new XBUpdateProcDialog(CreateProcXBDialog.this, revs, rev_Beans, value_strings,
session);
} catch (Exception e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
MessageBox.post("工艺修改异常:" + e.getMessage(), "", 2);
}
}
});
} catch (Exception e1) {
// TODO Auto-generated catch block
// Auto-generated catch block
e1.printStackTrace();
}
@ -577,10 +574,11 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@Override
public void treeExpanded(TreeExpansionEvent event) {
// TODO Auto-generated method stub
// Auto-generated method stub
final TreePath path = event.getPath();
if (path != null && path.getLastPathComponent() != null) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
@SuppressWarnings("unlikely-arg-type")
int index = controller.expandPaths.indexOf(node);
if (index == -1) {
controller.expandPaths.add(path);
@ -591,7 +589,7 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@Override
public void run() {
// TODO Auto-generated method stub
// Auto-generated method stub
try {
KUtil.stopTableEditing(t_part);
if (controller.node_need_expands.contains(node)) {
@ -613,10 +611,10 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
// TODO Auto-generated method stub
// Auto-generated method stub
final TreePath path = event.getPath();
if (path != null && path.getLastPathComponent() != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
// DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
int index = controller.expandPaths.indexOf(path);
KUtil.stopTableEditing(t_part);
if (controller.isCanExpand) {
@ -813,6 +811,11 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int row, int column) {
if (column == 3 || column == 4) {
@ -858,6 +861,11 @@ public class CreateProcXBDialog extends AbstractAIFDialog {
tree.putClientProperty("JTree.lineStyle", "Horizontal");// 使JTree的文件夹间具有水平分隔线。
this.treeCellRenderer = new DefaultTreeCellRenderer() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
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;
}
/**
*
*
* @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;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.rmi.RemoteException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.Comparator;
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_zy.FlowBean;
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.kernel.AIFComponentContext;
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 {
// String sql = SAPUtil.sqlRef.replace("\\?", "'" + uid + "'");
String sql = "select P.puid as supItemUID,V.puid as supRevUID,P.pitem_id as supItemID,ITRO.Pobject_Name as supItemName,"
+ "V.Pitem_Revision_Id as supRevID,cP.pitem_id as subItemID,cV.puid as subRevUID,RT.partifactname as °æ±¾Óë°æ±¾¹ØÏµ "
+ "from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g "
+ "where g.puid=V.puid and V.Puid = R.Rprimary_Objectu and r.rrelation_typeu = RT.puid and P.Puid = V.Ritems_Tagu and ITRO.Puid = V.Puid "
+ "and R.Rsecondary_Objectu = cV.Puid and cP.Puid = cV.Ritems_Tagu and cV.Puid = cITRO.Puid and ITRO.Pactive_Seq<>0 "
String sql = "select P.puid as supItemUID,V.puid as supRevUID,P.pitem_id as supItemID,"
+ "ITRO.Pobject_Name as supItemName,V.Pitem_Revision_Id as supRevID,cP.pitem_id as subItemID,"
+ "cV.puid as subRevUID,RT.partifactname as 版本与版本关系 "
+ "from PWORKSPACEOBJECT ITRO,PIMANRELATION R,PIMANTYPE RT,PITEMREVISION V,PITEM P,PITEMREVISION cV,"
+ "PITEM cP,PWORKSPACEOBJECT cITRO,PPOM_APPLICATION_OBJECT g "
+ "where g.puid=V.puid and V.Puid = R.Rprimary_Objectu and r.rrelation_typeu = RT.puid "
+ "and P.Puid = V.Ritems_Tagu and ITRO.Puid = V.Puid and R.Rsecondary_Objectu = cV.Puid "
+ "and cP.Puid = cV.Ritems_Tagu and cV.Puid = cITRO.Puid and ITRO.Pactive_Seq<>0 "
+ "and cITRO.Pactive_Seq<>0 and RT.partifactname='IMAN_METarget' and g.ROWNING_GROUPU='" + group + "' and cV.PUID = '" + uid + "'";
try {
ResultSet read = SqlUtil.read(sql);//SAPUtil.sqlRef, new Object[] { uid }
@ -6557,4 +6569,65 @@ public class SAPUtil {
}
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