@ -1,5 +1,12 @@
package com.connor.dfl.plm.dfl019 ;
import java.awt.BorderLayout ;
import java.awt.Container ;
import java.awt.Font ;
import java.awt.GraphicsEnvironment ;
import java.awt.Rectangle ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
import java.io.BufferedInputStream ;
import java.io.File ;
import java.io.FileInputStream ;
@ -19,6 +26,13 @@ import java.util.List;
import java.util.Map ;
import java.util.UUID ;
import javax.swing.DefaultComboBoxModel ;
import javax.swing.JButton ;
import javax.swing.JComboBox ;
import javax.swing.JFrame ;
import javax.swing.JLabel ;
import javax.swing.JPanel ;
import com.connor.dfl.plm.util.AutoSign ;
import com.connor.dfl.plm.util.ClassValueBean ;
import com.connor.dfl.plm.util.ClassValueUtil ;
@ -30,6 +44,7 @@ import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCClassificationService ;
import com.teamcenter.rac.kernel.TCComponent ;
import com.teamcenter.rac.kernel.TCComponentBOMLine ;
import com.teamcenter.rac.kernel.TCComponentGroup ;
import com.teamcenter.rac.kernel.TCComponentICO ;
import com.teamcenter.rac.kernel.TCComponentItemRevision ;
import com.teamcenter.rac.kernel.TCComponentListOfValues ;
@ -43,6 +58,7 @@ import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute ;
import com.teamcenter.rac.kernel.ics.ICSProperty ;
import com.teamcenter.rac.util.MessageBox ;
import com.teamcenter.soaictstubs.booleanSeq_tHolder ;
import oracle.sql.BLOB ;
@ -68,6 +84,12 @@ public class Dfl019Operation extends AbstractAIFOperation{
private AutoSign as = null ;
private ProgressBarThread wait ;
private JLabel exportTypeLabel ;
private JComboBox < String > exportTypeBox ;
private DefaultComboBoxModel < String > exportTypeModel ;
private Map < String , String > account_set ;
private JFrame frame = null ;
private boolean flag = false ;
public Dfl019Operation ( AbstractAIFApplication app , TCSession session , String accountSet , String zhangtao ) {
this . app = app ;
this . session = session ;
@ -80,7 +102,7 @@ public class Dfl019Operation extends AbstractAIFOperation{
this . session = session ;
this . as = new AutoSign ( ) ;
String [ ] stringArrays = session . getPreferenceService ( ) . getStringValues ( "DFL_zhangtao" ) ;
Map< String , String > account_set = new HashMap < String , String > ( ) ;
account_set = new HashMap < String , String > ( ) ;
if ( stringArrays = = null | | stringArrays . length < = 0 ) {
MessageBox . post ( "首选项DFL_zhangtao未配置,请联系管理员!!" ,
"错误" , MessageBox . ERROR ) ;
@ -95,10 +117,101 @@ public class Dfl019Operation extends AbstractAIFOperation{
}
}
this . zhangtao = "DFL" ;
this . accountSet = account_set . get ( zhangtao ) ;
String [ ] BOMZT = session . getPreferenceService ( ) . getStringValues ( "DFL_ERPBom_zhangtao" ) ;
if ( BOMZT = = null | | BOMZT . length < = 0 ) {
MessageBox . post ( "首选项DFL_ERPBom_zhangtao未配置,请联系管理员!!" ,
"错误" , MessageBox . ERROR ) ;
return ;
}
String temp = null ;
try {
TCComponentGroup group = session . getCurrentGroup ( ) ;
String group_name = group . getStringProperty ( "display_name" ) ;
System . out . println ( "group_name==============" + group_name ) ;
if ( group_name . contains ( "." ) ) {
String [ ] names = group_name . split ( "\\." ) ;
if ( names ! = null & & names . length > = 2 ) {
for ( int i = 0 ; i < BOMZT . length ; i + + ) {
if ( BOMZT [ i ] . contains ( "=" ) ) {
String [ ] zts = BOMZT [ i ] . split ( "=" ) ;
System . out . println ( "names[names.length-2]==============" + names [ names . length - 2 ] ) ;
System . out . println ( "zts[0]==============" + zts [ 0 ] ) ;
if ( names [ names . length - 2 ] . equals ( zts [ 0 ] ) ) {
if ( names [ names . length - 2 ] . contains ( "医用包材" ) ) {
frame = new JFrame ( ) ;
frame . setTitle ( "请选择传递的账套" ) ;
frame . setDefaultCloseOperation ( JFrame . DISPOSE_ON_CLOSE ) ;
GraphicsEnvironment ge = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ;
Rectangle rect = ge . getMaximumWindowBounds ( ) ;
int sw = rect . width ;
int sh = rect . height ;
frame . setBounds ( ( sw - 350 ) / 2 , ( sh - 300 ) / 2 , 350 , 300 ) ; // 设置位置即大小
JPanel myJPanel = new JPanel ( ) ;
myJPanel . setLayout ( null ) ;
JButton okbutton ;
exportTypeLabel = new JLabel ( "导出类型" ) ;
exportTypeLabel . setFont ( new Font ( "微软雅黑" , Font . BOLD , 20 ) ) ;
exportTypeLabel . setSize ( 100 , 30 ) ;
exportTypeModel = new DefaultComboBoxModel < String > ( ) ;
exportTypeBox = new JComboBox < String > ( exportTypeModel ) ;
exportTypeBox . setBounds ( 200 , 190 , 170 , 30 ) ;
exportTypeBox . setFont ( new Font ( "微软雅黑" , Font . BOLD , 20 ) ) ;
exportTypeModel . addElement ( "上海包材" ) ;
exportTypeModel . addElement ( "上河南包材" ) ;
exportTypeLabel . setBounds ( 30 , 50 , 100 , 30 ) ;
exportTypeBox . setBounds ( 150 , 50 , 150 , 30 ) ;
okbutton = new JButton ( "确定" ) ;
okbutton . setFont ( new Font ( "微软雅黑" , Font . BOLD , 20 ) ) ;
okbutton . setBounds ( 100 , 180 , 120 , 30 ) ;
okbutton . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
// TODO Auto-generated method stub
final String element = exportTypeModel . getElementAt ( exportTypeBox . getSelectedIndex ( ) ) ;
System . out . println ( element ) ;
if ( "上海包材" . equals ( element ) ) {
zhangtao = "DYC" ;
accountSet = account_set . get ( zhangtao ) ;
} else {
zhangtao = "HNC" ;
accountSet = account_set . get ( zhangtao ) ;
}
frame . setVisible ( false ) ;
startWork ( ) ;
return ;
}
} ) ;
myJPanel . add ( exportTypeLabel ) ;
myJPanel . add ( exportTypeBox ) ;
myJPanel . add ( okbutton ) ;
Container contentPane = frame . getContentPane ( ) ;
contentPane . add ( myJPanel , BorderLayout . CENTER ) ;
frame . setVisible ( true ) ;
break ;
}
this . zhangtao = "DFL" ;
this . accountSet = account_set . get ( zhangtao ) ;
startWork ( ) ;
}
}
}
}
}
} catch ( TCException e ) {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
} finally {
}
}
private void startWork ( ) {
// TODO Auto-generated method stub
session . queueOperation ( this ) ;
}
@Override
public void executeOperation ( ) throws Exception {
InterfaceAIFComponent [ ] comp = app . getTargetComponents ( ) ;
@ -135,16 +248,16 @@ public class Dfl019Operation extends AbstractAIFOperation{
if ( targets . length > 0 ) {
// MessageBox.post("您选中的版本对象没有在流程中","提示",MessageBox.INFORMATION);
// return;
for ( int i = 0 ; i < targets . length ; i + + ) {
String ss = targets [ i ] . getStringProperty ( "current_name" ) ;
System . out . println ( "ss======" + ss ) ;
if ( "传递ERP" . equals ( ss ) ) {
uid = targets [ i ] . getUid ( ) ;
} else {
MessageBox . post ( "您当前所在的流程不能执行传递ERP" , "提示" , MessageBox . INFORMATION ) ;
return ;
}
}
// for(int i = 0;i<targets.length;i++) {
// String ss =targets[i].getStringProperty("current_name");
// System.out.println("ss======"+ss);
// if("传递ERP".equals(ss)) {
// uid = targets[i].getUid();
// }else {
// MessageBox.post("您当前所在的流程不能执行传递ERP","提示",MessageBox.INFORMATION);
// return;
// }
// }
}
// String uid = targets[0].getUid();
@ -306,6 +419,7 @@ public class Dfl019Operation extends AbstractAIFOperation{
}
return beanList ;
}
public boolean setvalues ( List < ItemBean > beanList , TCComponent comp , List < String > errList ) throws TCException {
// TODO Auto-generated method stub
boolean flag2 = false ;
@ -324,6 +438,7 @@ public class Dfl019Operation extends AbstractAIFOperation{
TCComponentBOMLine get_bom_line = ( TCComponentBOMLine ) comp ;
rev = get_bom_line . getItemRevision ( ) ;
}
rev . refresh ( ) ;
String statu = rev . getStringProperty ( "t2_ERPStatus" ) ;
// if("已传".equals(statu)) {
// return flag2;
@ -331,28 +446,33 @@ public class Dfl019Operation extends AbstractAIFOperation{
try {
String type = rev . getStringProperty ( "object_type" ) ;
id = rev . getStringProperty ( "item_id" ) ;
if ( id . contains ( "-Y" ) ) {
id = id . replace ( "-Y" , "" ) ;
String idlast = id . substring ( id . length ( ) - 2 , id . length ( ) ) ;
System . out . println ( "4.2:" + id ) ;
System . out . println ( "id的后两位: " + idlast ) ;
if ( idlast . contains ( "-Y" ) ) {
System . out . println ( "物料带-Y不传递" ) ;
return false ;
//id = id.replace("-Y", "");
//判断这个版本是否为虚拟件版本
if ( "T2_VirtualRevision" . equals ( type ) ) {
String [ ] keys = new String [ ] { "零组件 ID" } ;
String [ ] values = new String [ ] { id } ;
//查询零组件版本的item_id为id的
List < TCComponent > compList = queryObject ( "零组件版本..." , keys , values ) ;
//判断是否为不为空的
if ( compList ! = null ) {
for ( int i = 0 ; i < compList . size ( ) ; i + + ) {
TCComponentItemRevision rev1 = null ;
rev1 = ( TCComponentItemRevision ) compList . get ( i ) ;
String type1 = rev1 . getStringProperty ( "object_type" ) ;
System . out . println ( "9.10===type===" + type1 ) ;
//如果查询出来的版本为设备版本, 则不传递erp
if ( "T2_EquipmentRevision" . equals ( type1 ) ) {
return true ;
}
}
}
}
// if("T2_VirtualRevision".equals(type)){
// String[] keys = new String[]{"零组件 ID"};
// String[] values = new String[]{id};
// //查询零组件版本的item_id为id的
// List<TCComponent> compList = queryObject("零组件版本...", keys, values);
// //判断是否为不为空的
// if(compList!=null) {
// for(int i = 0; i < compList.size(); i++){
// TCComponentItemRevision rev1 = null;
// rev1 = (TCComponentItemRevision) compList.get(i);
// String type1 = rev1.getStringProperty("object_type");
// System.out.println("9.10===type==="+type1);
// //如果查询出来的版本为设备版本, 则不传递erp
// if("T2_EquipmentRevision".equals(type1)) {
// return true;
// }
// }
// }
// }
}
String groupCode = rev . getStringProperty ( "t2_groupCode" ) ;
System . out . println ( "t2_groupCode============" + groupCode ) ;
@ -361,20 +481,34 @@ public class Dfl019Operation extends AbstractAIFOperation{
if ( "T2_outsourceRevision" . equals ( type ) | | "T2_OutBuyPartRevision" . equals ( type )
| | "T2_VirtualRevision" . equals ( type ) | | "T2_EquipmentRevision" . equals ( type )
| | "T2_SystemSchemeRevision" . equals ( type ) ) {
//判断是否有状态
// if("T2_VirtualRevision".equals(type)) {
// return false;
// }
//判断是否有状态
if ( "T2_outsourceRevision" . equals ( type ) | | "T2_OutBuyPartRevision" . equals ( type )
// ||"T2_VirtualRevision".equals(type)
) {
TCProperty tcProperty = rev . getTCProperty ( "release_status_list" ) ;
TCComponent [ ] targets = tcProperty . getReferenceValueArray ( ) ;
String groupcode1 = rev . getStringProperty ( "t2_groupCode" ) ;
String sourceCode1 = rev . getStringProperty ( "t2_sourceCode" ) ;
// String status = rev.getStringProperty("release_status_list");
// String status = rev.getStringProperty("release_status_list");
// System.out.println("发布状态:"+status);
if ( targets = = null | | targets . length < = 0 ) {
MessageBox . post ( rev . getStringProperty ( "item_id" ) + "该物料没有发布状态!!" ,
"提示" , MessageBox . WARNING ) ;
return true ;
}
// if(status.equals("")||status.equals(" ")) {
// MessageBox.post(rev.getStringProperty("item_id")+"该物料没有发布状态!!",
// "提示", MessageBox.WARNING);
// return true;
// }
if ( "T2_outsourceRevision" . equals ( type ) | | "T2_OutBuyPartRevision" . equals ( type )
) {
if ( groupcode1 . equals ( "" ) ) {
@ -398,7 +532,8 @@ public class Dfl019Operation extends AbstractAIFOperation{
boolean flag = false ;
if ( "T2_outsourceRevision" . equals ( type ) ) {
StringBuilder sb = new StringBuilder ( id ) ;
sb . append ( rev . getStringProperty ( "item_revision_id" ) ) ;
//2022/8/23 修改取消拼接版本
//sb.append(rev.getStringProperty("item_revision_id"));
id = sb . toString ( ) ;
String classID = id . substring ( 0 , 2 ) ;
System . out . println ( "classID===============" + classID ) ;
@ -799,9 +934,10 @@ public class Dfl019Operation extends AbstractAIFOperation{
protected void createXMLFile ( List < ItemBean > beanList , String zhangtao ) throws TCException , IOException {
String weiyi_id = "" ;
Date date = new Date ( ) ;
SimpleDateFormat df = new SimpleDateFormat ( "yyyyMMddHHmm ") ;
SimpleDateFormat df = new SimpleDateFormat ( "yyyyMMddHHmm ss ") ;
StringBuilder uidSB = new StringBuilder ( ) ;
String fileName = session . getUser ( ) . getUserName ( ) + "-" + df . format ( date ) ;
String fileName = "WL-" + beanList . get ( 0 ) . getItem_id ( ) + "-" + df . format ( date ) ;
String uid_fileName = "WL-UID-" + beanList . get ( 0 ) . getItem_id ( ) + "-" + df . format ( date ) ;
// String s1 = "<?xml version=\"1.0\"?><Request><Access><Authentication user=\"tiptop\" password=\"tiptop\" /><Connection source=\"192.168.1.8\" application=\"PLM\"/>";
// String s2 ="<Organization name=\""+AccountSet+"\"/><Locale language=\"zh_cn\"/></Access><RequestContent><Parameter><Record>";
@ -810,13 +946,13 @@ public class Dfl019Operation extends AbstractAIFOperation{
String sss1 = "<Request><Access><Authentication user=\"tiptop\" password=\"tiptop\"/><Connection application=\"NEWPLM\" source=\"192.168.1.1 37 \"/><Organization name=\""+ zhangtao + "\"/>" ;
String sss1 = "<Request><Access><Authentication user=\"tiptop\" password=\"tiptop\"/><Connection application=\"NEWPLM\" source=\"192.168.1.1 5 3\"/><Organization name=\""+ zhangtao + "\"/>" ;
String sss2 = "<Locale language=\"zh_cn\"/></Access><RequestContent><Parameter><Record><Field name=\"status\" value=\"Y\"/><Field name=\"ws_name\" value=\"CreateItemMasterData\"/><Field name=\"datakey\" value=\"" ;
String sss3 = "\"/><Field name=\"tot_cnt\" value=\"\"/><Field name=\"sub_cnt\" value=\"1\"/></Record></Parameter><Document>" ;
tops = sss1 + sss2 ;
String bottom = "</Document></RequestContent></Request>" ;
int j = 1 ;
int o = 1 ;
StringBuilder sss3SB = new StringBuilder ( ) ;
StringBuilder xmlSB = new StringBuilder ( ) ;
for ( int i = 0 ; i < beanList . size ( ) ; i + + ) {
@ -828,53 +964,12 @@ public class Dfl019Operation extends AbstractAIFOperation{
String n = n1 + n2 + n3 ;
xmlSB . append ( n ) ;
j + + ;
if ( i > 0 & & i % 60 = = 0 ) {
sss3SB . append ( fileName ) ;
sss3SB . append ( "-" + o + + ) ;
sss3SB . append ( sss3 ) ;
sss3SB . append ( xmlSB . toString ( ) ) ;
String zong = tops + sss3SB . toString ( ) + bottom ;
System . out . println ( zong ) ;
String tempPath = System . getProperty ( "java.io.tmpdir" ) ;
System . out . println ( "10.20temp路径=======" + tempPath ) ;
//String path = "D:\\SENDTOERPLOG\\" + fileName + ".txt";
String path = tempPath + fileName + ".txt" ;
File file = new File ( path ) ;
if ( ! file . exists ( ) ) {
//file.getParentFile().mkdirs();
file . createNewFile ( ) ;
}
try {
FileOutputStream fos = new FileOutputStream ( file ) ;
fos . write ( zong . getBytes ( ) ) ;
fos . flush ( ) ;
fos . close ( ) ;
weiyi_id = getId ( ) ;
System . out . println ( "=======================唯一识别码" + weiyi_id ) ;
as . insertNewTxtFile ( fileName , file , weiyi_id , session . getUser ( ) . getUid ( ) , url , user , password , "CreateItemMasterDataRequest" , beanList . get ( 0 ) . getItem_id ( ) , zhangtao , session . getUser ( ) . getUserId ( ) , uidSB . toString ( ) ) ;
file . delete ( ) ;
weiyi_id = "" ;
} catch ( Exception e1 ) {
// TODO Auto-generated catch block
e1 . printStackTrace ( ) ;
}
j = 1 ;
uidSB = new StringBuilder ( ) ;
xmlSB = new StringBuilder ( ) ;
sss3SB = new StringBuilder ( ) ;
continue ;
}
if ( i < beanList . size ( ) - 1 ) {
uidSB . append ( ";" ) ;
}
}
if ( ! ( "" . equals ( uidSB . toString ( ) ) ) ) {
sss3SB . append ( fileName ) ;
sss3SB . append ( "-" + o + + ) ;
sss3SB . append ( sss3 ) ;
sss3SB . append ( xmlSB . toString ( ) ) ;
String zong = tops + sss3SB . toString ( ) + bottom ;
@ -883,11 +978,26 @@ public class Dfl019Operation extends AbstractAIFOperation{
System . out . println ( "10.20temp路径=======" + tempPath ) ;
//String path = "D:\\SENDTOERPLOG\\" + fileName + ".txt";
String path = tempPath + fileName + ".txt" ;
String path1 = tempPath + uid_fileName + ".txt" ;
File file = new File ( path ) ;
if ( ! file . exists ( ) ) {
//file.getParentFile().mkdirs();
file . createNewFile ( ) ;
}
File file1 = new File ( path1 ) ;
if ( ! file1 . exists ( ) ) {
//file.getParentFile().mkdirs();
file1 . createNewFile ( ) ;
}
try {
FileOutputStream fos2 = new FileOutputStream ( file1 ) ;
fos2 . write ( uidSB . toString ( ) . getBytes ( ) ) ;
fos2 . flush ( ) ;
fos2 . close ( ) ;
} catch ( Exception e ) {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
}
try {
FileOutputStream fos = new FileOutputStream ( file ) ;
fos . write ( zong . getBytes ( ) ) ;
@ -898,8 +1008,7 @@ public class Dfl019Operation extends AbstractAIFOperation{
System . out . println ( "=======================唯一识别码" + weiyi_id ) ;
as . insertNewTxtFile ( fileName , file , weiyi_id , session . getUser ( ) . getUid ( ) , url , user , password , "CreateItemMasterDataRequest" , beanList . get ( 0 ) . getItem_id ( ) , zhangtao , session . getUser ( ) . getUserId ( ) , uidSB . toString ( ) ) ;
file . delete ( ) ;
as . insertNewTxtFile ( path , fileName , weiyi_id , session . getUser ( ) . getUid ( ) , url , user , password , "CreateItemMasterDataRequest" , beanList . get ( 0 ) . getItem_id ( ) , zhangtao , session . getUser ( ) . getUserId ( ) , path1 , uid_fileName , session ) ;
} catch ( Exception e1 ) {
// TODO Auto-generated catch block
e1 . printStackTrace ( ) ;