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