|
|
package com.connor.dfl.plm.dfl020;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
//import org.jacorb.idl.runtime.int_token;
|
|
|
|
|
|
import com.connor.dfl.plm.util.AutoSign;
|
|
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
|
|
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
|
|
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
|
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.TCComponentBOMWindow;
|
|
|
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
|
|
import com.teamcenter.rac.kernel.TCComponentGroup;
|
|
|
import com.teamcenter.rac.kernel.TCComponentICO;
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
import com.teamcenter.rac.kernel.TCComponentListOfValues;
|
|
|
import com.teamcenter.rac.kernel.TCComponentProject;
|
|
|
import com.teamcenter.rac.kernel.TCComponentTask;
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
import com.teamcenter.rac.kernel.TCProperty;
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
import com.teamcenter.rac.kernel.TCTypeService;
|
|
|
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.schemas.core._2012_09.projectlevelsecurity.ProjectTeamsResponse;
|
|
|
import com.teamcenter.soaictstubs.stringSeq_tHolder;
|
|
|
|
|
|
import oracle.sql.BLOB;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class Dfl020Operation extends AbstractAIFOperation{
|
|
|
private AbstractAIFApplication app;
|
|
|
private TCSession session;
|
|
|
private List<String> attrList;
|
|
|
|
|
|
private String url ;
|
|
|
|
|
|
private String user;
|
|
|
|
|
|
private String password ;
|
|
|
private Connection conn = null;//
|
|
|
|
|
|
private PreparedStatement pre = null;//
|
|
|
|
|
|
private ResultSet result = null;//
|
|
|
private String outPutInfo= "";
|
|
|
private String tops;
|
|
|
private String ns ;
|
|
|
|
|
|
//private String weiyi_id;
|
|
|
String accountSet;
|
|
|
private String zhangtao;
|
|
|
private AutoSign as = null;
|
|
|
private List<FatherBomLineBean> list = new ArrayList<FatherBomLineBean>();
|
|
|
String zong;
|
|
|
private boolean isEquipment = false;
|
|
|
|
|
|
String z_peizhi = "";
|
|
|
|
|
|
String outString = "";
|
|
|
|
|
|
private String txt_pinhao;
|
|
|
|
|
|
|
|
|
public Dfl020Operation(AbstractAIFApplication app, TCSession session ,String accountSet,String zhangtao) {
|
|
|
this.app = app;
|
|
|
this.session = session;
|
|
|
this.accountSet = accountSet;
|
|
|
this.as=new AutoSign();
|
|
|
this.zhangtao = zhangtao;
|
|
|
}
|
|
|
public Dfl020Operation(AbstractAIFApplication app, TCSession session) {
|
|
|
this.app = app;
|
|
|
this.session = session;
|
|
|
this.as=new AutoSign();
|
|
|
String[] stringArrays = session.getPreferenceService().getStringValues("DFL_zhangtao");
|
|
|
String[] BOMZT = session.getPreferenceService().getStringValues("DFL_ERPBom_zhangtao");
|
|
|
if (BOMZT == null || BOMZT.length <= 0 ) {
|
|
|
MessageBox.post("<22><>ѡ<EFBFBD><D1A1>DFL_ERPBom_zhangtaoδ<6F><CEB4><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>Ա!!",
|
|
|
"<22><><EFBFBD><EFBFBD>", MessageBox.ERROR);
|
|
|
return;
|
|
|
}
|
|
|
Map<String, String> account_set = new HashMap<String, String>();
|
|
|
if (stringArrays == null || stringArrays.length <= 0 ) {
|
|
|
MessageBox.post("<22><>ѡ<EFBFBD><D1A1>DFL_zhangtaoδ<6F><CEB4><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>Ա!!",
|
|
|
"<22><><EFBFBD><EFBFBD>", MessageBox.ERROR);
|
|
|
return;
|
|
|
}else {
|
|
|
for(int i = 0 ;i<stringArrays.length;i++) {
|
|
|
|
|
|
|
|
|
String s1 = stringArrays[i].split("=")[0];
|
|
|
String s0 = stringArrays[i].split("=")[1];
|
|
|
account_set.put(s1, s0);
|
|
|
}
|
|
|
}
|
|
|
TCComponentGroup group = session.getCurrentGroup();
|
|
|
try {
|
|
|
String group_name = group.getStringProperty("display_name");
|
|
|
System.out.println("group_name=============="+group_name);
|
|
|
if(group_name.contains(".")) {
|
|
|
String[] names = group_name.split("\\.");
|
|
|
System.out.println("names=============="+names.length);
|
|
|
if(names != null && names.length >=2) {
|
|
|
for (int i = 0; i < BOMZT.length; i++) {
|
|
|
System.out.println("BOMZT[i]====="+BOMZT[i]);
|
|
|
if(BOMZT[i].contains("=")) {
|
|
|
String[] zts = BOMZT[i].split("=");
|
|
|
System.out.println("names[names.length-2]====="+names[names.length-2]);
|
|
|
if(names[names.length-2].equals(zts[0])) {
|
|
|
this.zhangtao = zts[1];
|
|
|
this.accountSet = account_set.get(zhangtao);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (TCException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void executeOperation(){
|
|
|
new Runnable() {
|
|
|
public void run() {
|
|
|
sendBOMTOERP();
|
|
|
}
|
|
|
}.run();
|
|
|
}
|
|
|
|
|
|
public void sendBOMTOERP() {
|
|
|
InterfaceAIFComponent[] comp = app.getTargetComponents();
|
|
|
String uid ="";
|
|
|
|
|
|
|
|
|
String[] stringArray = ((TCSession) app.getSession()).getPreferenceService().getStringValues("DFL2_SQL_Connect");
|
|
|
|
|
|
url = "jdbc:oracle:thin:@//"+stringArray[0];//
|
|
|
|
|
|
user = stringArray[1];//
|
|
|
|
|
|
password = stringArray[2];//
|
|
|
|
|
|
conn = null;//
|
|
|
|
|
|
pre = null;//
|
|
|
|
|
|
result = null;//
|
|
|
|
|
|
|
|
|
|
|
|
TCComponentItemRevision rev = null;
|
|
|
|
|
|
try {
|
|
|
if(comp[0] instanceof TCComponentItemRevision || comp[0] instanceof TCComponentBOMLine ) {
|
|
|
|
|
|
if(comp[0] instanceof TCComponentItemRevision ) {
|
|
|
rev = (TCComponentItemRevision) comp[0];
|
|
|
String rve_id = rev.getStringProperty("current_revision_id");
|
|
|
System.out.println("11.17rve_id======"+rve_id);
|
|
|
}
|
|
|
if(comp[0] instanceof TCComponentBOMLine ) {
|
|
|
TCComponentBOMLine get_bom_line = (TCComponentBOMLine) comp[0];
|
|
|
rev = get_bom_line.getItemRevision();
|
|
|
}
|
|
|
TCProperty tcProperty1 = rev.getTCProperty("release_status_list");
|
|
|
TCComponent[] targets1 = tcProperty1.getReferenceValueArray();
|
|
|
String item_type = rev.getType();
|
|
|
|
|
|
if("T2_EquipmentRevision".equals(item_type)) {
|
|
|
isEquipment = true;
|
|
|
}
|
|
|
//<2F><><EFBFBD><EFBFBD>û<EFBFBD>з<EFBFBD><D0B7><EFBFBD>״̬<D7B4><CCAC><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>bom<6F><6D><EFBFBD><EFBFBD>erp<72><70><EFBFBD><EFBFBD>
|
|
|
if("T2_VirtualRevision".equals(item_type) || "T2_EquipmentRevision".equals(item_type)) {
|
|
|
if(targets1 == null || targets1.length <= 0) {
|
|
|
MessageBox.post("<22><>ѡ<EFBFBD>еİ汾<C4B0><E6B1BE><EFBFBD><EFBFBD>û<EFBFBD>з<EFBFBD><D0B7><EFBFBD>״̬","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B9BA><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>bom<6F><6D><EFBFBD><EFBFBD>erp<72><70><EFBFBD><EFBFBD>
|
|
|
if("T2_OutBuyPartRevision".equals(item_type)) {
|
|
|
MessageBox.post("<22><>ѡ<EFBFBD>еİ汾<C4B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B9BA><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD>bom<6F><6D><EFBFBD><EFBFBD>erp","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
return;
|
|
|
}
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>bom<6F><6D><EFBFBD><EFBFBD>erp<72><70><EFBFBD><EFBFBD>
|
|
|
if ("T2_outsourceRevision".equals(item_type)) {
|
|
|
MessageBox.post("<22><>ѡ<EFBFBD>еİ汾<C4B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD>bom<6F><6D><EFBFBD><EFBFBD>erp","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
return;
|
|
|
}
|
|
|
//<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>bom<6F><6D><EFBFBD><EFBFBD>erp<72><70><EFBFBD><EFBFBD>
|
|
|
if ("T2_SystemSchemeRevision".equals(item_type)) {
|
|
|
MessageBox.post("<22><>ѡ<EFBFBD>еİ汾<C4B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD>bom<6F><6D><EFBFBD><EFBFBD>erp","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
return;
|
|
|
}
|
|
|
//TCProperty tcProperty = rev.getTCProperty("fnd0MyWorkflowTasks");
|
|
|
TCProperty tcProperty = rev.getTCProperty("fnd0MyWorkflowTasks");
|
|
|
TCComponent[] targets = tcProperty.getReferenceValueArray();
|
|
|
// if(targets != null && targets.length>0) {
|
|
|
// MessageBox.post("<22><>ѡ<EFBFBD>еİ汾<C4B0><E6B1BE><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
// return;
|
|
|
// for(int i = 0;i<targets.length;i++) {
|
|
|
// String ss =targets[i].getStringProperty("current_name");
|
|
|
// System.out.println("ss======"+ss);
|
|
|
// if("<22><><EFBFBD><EFBFBD>ERP".equals(ss)) {
|
|
|
// uid = targets[i].getUid();
|
|
|
// }else {
|
|
|
// MessageBox.post("<22><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD>ִ<EFBFBD>д<EFBFBD><D0B4><EFBFBD>ERP","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
// return;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
}else if(comp[0] instanceof TCComponentTask){
|
|
|
TCComponentTask task = (TCComponentTask) comp[0];
|
|
|
String ss = task.getStringProperty("object_name");
|
|
|
System.out.println("ss==========="+ss);
|
|
|
// if("<22><><EFBFBD><EFBFBD>ERP".equals(ss)) {
|
|
|
// uid = comp[0].getUid();
|
|
|
// TCComponent[] targets = task.getReferenceListProperty("root_target_attachments");
|
|
|
// for (int i = 0; i < targets.length; i++) {
|
|
|
// if(targets[i] instanceof TCComponentItemRevision) {
|
|
|
// rev = (TCComponentItemRevision) targets[i];
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// }else {
|
|
|
// MessageBox.post("<22><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD>ִ<EFBFBD>д<EFBFBD><D0B4><EFBFBD>ERP","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
// return;
|
|
|
// }
|
|
|
}else {
|
|
|
MessageBox.post("<22><>ѡ<EFBFBD>еIJ<D0B5><C4B2>ǰ汾<C7B0><E6B1BE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>BOM<4F><4D>","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
return;
|
|
|
}
|
|
|
TCComponentItem item =rev.getItem();
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
System.out.print(item.getProperty("object_string"));
|
|
|
|
|
|
TCTypeService service = session.getTypeService();
|
|
|
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
|
|
|
TCComponentBOMWindow view = winType.create(null);
|
|
|
TCComponentBOMLine line = view.setWindowTopLine(item,rev, null, null);
|
|
|
AIFComponentContext[] childs = line.getChildren();
|
|
|
if(childs != null && childs.length > 0) {
|
|
|
createXMLFile(line,zhangtao);
|
|
|
}else {
|
|
|
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD><CFBD><EFBFBD>BOM<4F><4D><EFBFBD><EFBFBD>ERP","<22><>ʾ",MessageBox.INFORMATION);
|
|
|
return;
|
|
|
}
|
|
|
view.close();
|
|
|
if(!("".equals(uid))&& !(" ".equals(uid))) {
|
|
|
as.AutoSignServer(uid,session);
|
|
|
}
|
|
|
MessageBox.post("BOM<4F><4D><EFBFBD>ݴ洢<DDB4>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ERP<52><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
"<22><>ʾ", MessageBox.WARNING);
|
|
|
} catch (Exception e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
MessageBox.post("BOM<4F><4D><EFBFBD>ݴ洢ʧ<E6B4A2>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
"<22><>ʾ", MessageBox.WARNING);
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD>
|
|
|
|
|
|
protected void createXMLFile(TCComponentBOMLine line ,String zhangtao) throws TCException, IOException {
|
|
|
String weiyi_id = "";
|
|
|
// List<FatherBomLineBean> list = new ArrayList<FatherBomLineBean>();
|
|
|
try {
|
|
|
getBOMValue(line,list,1);
|
|
|
if(list.size() <=0) {
|
|
|
MessageBox.post("BOM <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOM<4F><4D><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʾ",
|
|
|
MessageBox.INFORMATION);
|
|
|
return;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
// TODO: handle exception
|
|
|
MessageBox.post("BOM <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOM<4F><4D><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!" ,"<22><>ʾ",MessageBox.INFORMATION);
|
|
|
e.printStackTrace();
|
|
|
return;
|
|
|
}
|
|
|
//<2F><>ȡ<EFBFBD><C8A1> <20><><EFBFBD><EFBFBD>
|
|
|
String userName = session.getUser().getUserName();
|
|
|
List<String> toFus = new ArrayList<String>();
|
|
|
for(int f_index = 0;f_index< list.size();f_index++) {
|
|
|
String fuUID = list.get(f_index).getItem_uid();
|
|
|
if(!toFus.contains(fuUID)) {
|
|
|
toFus.add(fuUID);
|
|
|
}else {
|
|
|
continue;
|
|
|
}
|
|
|
StringBuilder sb2 = new StringBuilder();
|
|
|
StringBuilder uidSB = new StringBuilder();
|
|
|
Date date = new Date();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
String plmls = df.format(date);
|
|
|
String s1 ="<Request><Access><Authentication user=\"tiptop\" password=\"tiptop\"/><Connection application=\"NEWPLM\" source=\"192.168.1.153\"/>";
|
|
|
String s3 = "<Organization name=\""+zhangtao+"\"/><Locale language=\"zh_cn\"/></Access><RequestContent><Parameter><Record><Field name=\"status\" value=\"Y\"/>";
|
|
|
String s4 = "<Field name=\"bmx10\" value=\""+userName+"\"/><Field name=\"smyslip\" value=\"4101\"/><Field name=\"ws_name\" value=\"CreatePLMBOMData\"/>";
|
|
|
String s5 = "<Field name=\"datakey\" value=\""+plmls+"\"/><Field name=\"tot_cnt\" value=\"1\"/><Field name=\"sub_cnt\" value=\"1\"/>";
|
|
|
String s6 = "</Record></Parameter><Document>";
|
|
|
|
|
|
sb2.append(s1);
|
|
|
sb2.append(s3);
|
|
|
sb2.append(s4);
|
|
|
sb2.append(s5);
|
|
|
sb2.append(s6);
|
|
|
uidSB.append(list.get(f_index).getItem_uid());
|
|
|
if(f_index< list.size()-1) {
|
|
|
uidSB.append(";");
|
|
|
}
|
|
|
|
|
|
|
|
|
// int iii = f_index+1;
|
|
|
// System.out.println("==== <20><>"+ iii+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
System.out.println("******Ʒ<><C6B7>"+list.get(f_index).getPinhao()+"*****");
|
|
|
|
|
|
String peizhi1 ="<RecordSet id=\""+1+"\">";
|
|
|
// String peizhi1 ="<RecordSet id=\""+iii+"\">";
|
|
|
//String peizhi2 = "<22><>"+iii +"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ";
|
|
|
String peizhi3 = "<Master name=\"bma_file\"><Record><Field name=\"acttype\" value=\"\"/><Field name=\"bma01\" ";
|
|
|
String peizhi4 = "value=\""+list.get(f_index).getPinhao()+"\"/></Record></Master><Detail name=\"bmb_file\">";
|
|
|
|
|
|
sb2.append(peizhi1);
|
|
|
sb2.append(peizhi3);
|
|
|
sb2.append(peizhi4);
|
|
|
//z_peizhi+=peizhi;
|
|
|
List<ChirldBomBean> l = (List<ChirldBomBean>) list.get(f_index).getList();
|
|
|
for(int z = 0 ;z<l.size();z++) {
|
|
|
ChirldBomBean bean = (ChirldBomBean) l.get(z);
|
|
|
int i = z+1;
|
|
|
// System.out.println("<22><><EFBFBD><EFBFBD> "+bean.getNumber());
|
|
|
// System.out.println("Ԫ<><D4AA>"+bean.getPinhao());
|
|
|
// System.out.println("<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>"+bean.getDate());
|
|
|
// System.out.println("<22><><EFBFBD><EFBFBD>"+ bean.getYonglian());
|
|
|
// System.out.println("<22><>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>"+bean.getWork_id());
|
|
|
// System.out.println("<22><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>"+ bean.getChajian_id());
|
|
|
// System.out.println("PLMKey"+bean.getPlmkey());
|
|
|
|
|
|
String yongliang = null;
|
|
|
String work_id =null;
|
|
|
String cha_jian =null;
|
|
|
String beizhu = null;
|
|
|
if( bean.getYonglian()==null) {
|
|
|
yongliang = "";
|
|
|
}else {
|
|
|
yongliang = bean.getYonglian();
|
|
|
}
|
|
|
|
|
|
if( bean.getWork_id()==null) {
|
|
|
work_id = "";
|
|
|
}else {
|
|
|
work_id = bean.getWork_id();
|
|
|
}
|
|
|
|
|
|
if( bean.getChajian_id()==null) {
|
|
|
cha_jian = "";
|
|
|
}else {
|
|
|
cha_jian = bean.getChajian_id();
|
|
|
}
|
|
|
|
|
|
if (bean.getBeizhu()==null) {
|
|
|
beizhu = "";
|
|
|
} else {
|
|
|
beizhu = bean.getBeizhu();
|
|
|
if(beizhu.contains("&")) {
|
|
|
beizhu = beizhu.replace("&", "&");
|
|
|
}
|
|
|
if(beizhu.contains("<")) {
|
|
|
beizhu = beizhu.replace("<", "<");
|
|
|
}
|
|
|
if(beizhu.contains(">")) {
|
|
|
beizhu = beizhu.replace(">", ">");
|
|
|
}
|
|
|
if(beizhu.contains("\"")) {
|
|
|
beizhu = beizhu.replace("\"", """);
|
|
|
}
|
|
|
}
|
|
|
String xh = "<Record><Field name=\"bmb02\" value=\""+i+"\"/>";
|
|
|
String yj = "<Field name=\"bmb03\" value=\""+bean.getPinhao()+"\"/>";
|
|
|
String sxrq = "<Field name=\"bmb04\" value=\""+bean.getDate()+"\"/>";
|
|
|
String yl = "<Field name=\"bmb06\" value=\""+yongliang+"\"/>";
|
|
|
String zybh = "<Field name=\"bmb09\" value=\""+work_id+"\"/>";
|
|
|
String xjwz = "<Field name=\"bmb13\" value=\""+cha_jian+"\"/>";
|
|
|
String bz = "<Field name=\"bmbud01\" value=\""+beizhu+"\"/>";
|
|
|
String plmkey ="<Field name=\"bmb37\" value=\""+bean.getPlmkey()+"\"/></Record>";
|
|
|
sb2.append(xh);//<2F><><EFBFBD><EFBFBD>
|
|
|
sb2.append(yj);//id
|
|
|
sb2.append(sxrq);//<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
|
sb2.append(yl);//
|
|
|
sb2.append(zybh);//<2F><>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>
|
|
|
sb2.append(xjwz);//
|
|
|
sb2.append(bz);
|
|
|
sb2.append(plmkey);
|
|
|
|
|
|
}
|
|
|
sb2.append("</Detail></RecordSet>");
|
|
|
|
|
|
|
|
|
String bottomS ="</Document></RequestContent></Request>";
|
|
|
sb2.append(bottomS);
|
|
|
outPutInfo = sb2.toString();
|
|
|
System.out.println("================"+outPutInfo);
|
|
|
|
|
|
String fileName ="BOM-"+ list.get(f_index).getPinhao()+"-"+plmls;
|
|
|
String tempPath = System.getProperty("java.io.tmpdir");
|
|
|
String uid_fileName ="BOM-UID-"+list.get(f_index).getPinhao()+"-"+ plmls;
|
|
|
System.out.println("10.20temp·<EFBFBD><EFBFBD>======="+tempPath);
|
|
|
//String path = "D:\\SENDTOERPLOG\\" + fileName + ".txt";
|
|
|
String path = tempPath + fileName + ".txt";
|
|
|
String path1 = tempPath + uid_fileName + ".txt";
|
|
|
File file = new File(path);
|
|
|
File file1 = new File(path1);
|
|
|
if (!file.exists()) {
|
|
|
//file.getParentFile().mkdirs();
|
|
|
file.createNewFile();
|
|
|
}
|
|
|
if (!file1.exists()) {
|
|
|
//file.getParentFile().mkdirs();
|
|
|
file1.createNewFile();
|
|
|
}
|
|
|
try {
|
|
|
FileOutputStream fos = new FileOutputStream(file);
|
|
|
fos.write(outPutInfo.getBytes());
|
|
|
fos.flush();
|
|
|
fos.close();
|
|
|
} catch (Exception e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
//
|
|
|
// InputStream in = new FileInputStream("c:/fugang.jpg");
|
|
|
//
|
|
|
// byte[] fileContent = new byte[in.available()];
|
|
|
//
|
|
|
// in.read(fileContent);
|
|
|
//
|
|
|
// in.close();
|
|
|
// //
|
|
|
|
|
|
//<2F><>txt<78>ļ<EFBFBD> <20><><EFBFBD>浽<EFBFBD><E6B5BD><EFBFBD>ݿ<EFBFBD>
|
|
|
|
|
|
weiyi_id = getId();
|
|
|
|
|
|
System.out.println("=======================Ψһʶ<D2BB><CAB6><EFBFBD><EFBFBD>" +weiyi_id);
|
|
|
|
|
|
//if(f_index > 0 && f_index%60 == 0) {
|
|
|
String uidString = uidSB.toString();
|
|
|
try {
|
|
|
FileOutputStream fos2 = new FileOutputStream(file1);
|
|
|
fos2.write(uidString.getBytes());
|
|
|
fos2.flush();
|
|
|
fos2.close();
|
|
|
} catch (Exception e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
as.insertNewTxtFile(path,fileName, weiyi_id,session.getUser().getUid() , url, user, password,"CreatePLMBOMDataRequest",list.get(f_index).getPinhao(),zhangtao,session.getUser().getUserId(),path1,uid_fileName,session);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
private void getBOMValue(TCComponentBOMLine line, List<FatherBomLineBean> list,int pQty)
|
|
|
{
|
|
|
FatherBomLineBean fatherBean = new FatherBomLineBean();
|
|
|
try
|
|
|
{
|
|
|
TCComponentItemRevision rev = line.getItemRevision();
|
|
|
AIFComponentContext[] childrens = line.getChildren();
|
|
|
if (childrens.length > 0) {
|
|
|
rev.getStringProperty("t2_ERPBomStatus");
|
|
|
} else {
|
|
|
return;
|
|
|
}
|
|
|
List<ChirldBomBean> z_list = new ArrayList<ChirldBomBean>();
|
|
|
String fuID = rev.getStringProperty("item_id");
|
|
|
String idlast =fuID.substring(fuID.length()-2, fuID.length());
|
|
|
if(idlast.endsWith("-Y")) {
|
|
|
fuID = fuID.substring(0,fuID.length()-2);
|
|
|
}
|
|
|
// fuID = fuID.replace("-Y", "");
|
|
|
String fuType = rev.getStringProperty("object_type");
|
|
|
if ("T2_outsourceRevision".equals(fuType))
|
|
|
{
|
|
|
String revId = rev.getStringProperty("item_revision_id");
|
|
|
//fuID = fuID + revId;
|
|
|
}
|
|
|
fatherBean.setPinhao(fuID);
|
|
|
fatherBean.setItem_uid(rev.getUid());
|
|
|
int childLineNum = 0;
|
|
|
boolean ispack = false;
|
|
|
for (int i = 0; i < childrens.length; i++)
|
|
|
{
|
|
|
InterfaceAIFComponent childComp = childrens[i].getComponent();
|
|
|
if ((childComp instanceof TCComponentBOMLine))
|
|
|
{
|
|
|
TCComponentBOMLine childLine = (TCComponentBOMLine)childComp;
|
|
|
String occType = childLine.getStringProperty("TCAI_OCC_TYPE");
|
|
|
String num = childLine.getStringProperty( "T2_ActualConsumption");//ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(num==null||"".equals(num.trim())) {
|
|
|
num = childLine.getStringProperty( "T2_DesignQuantity");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(num==null||"".equals(num.trim())) {
|
|
|
num = childLine.getStringProperty( "bl_quantity");//<2F><><EFBFBD><EFBFBD>
|
|
|
if(num==null||"".equals(num.trim())) {
|
|
|
num = "1";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
System.out.println("num=============="+num);
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>͡<EFBFBD><CDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(childLine.isPacked() || "<22>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>".equals(num) || "<22>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>".equals(occType))
|
|
|
{
|
|
|
childLine.unpack();
|
|
|
ispack = true;
|
|
|
childLine.refresh();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (ispack) {
|
|
|
line.refresh();
|
|
|
}
|
|
|
childrens = line.getChildren();
|
|
|
List<String> idList = new ArrayList<String>();
|
|
|
for (int i = 0; i < childrens.length; i++)
|
|
|
{
|
|
|
InterfaceAIFComponent childComp = childrens[i].getComponent();
|
|
|
if ((childComp instanceof TCComponentBOMLine))
|
|
|
{
|
|
|
TCComponentBOMLine childLine = (TCComponentBOMLine)childComp;
|
|
|
String occType = childLine.getStringProperty("TCAI_OCC_TYPE");
|
|
|
if (!"Reference".equals(occType))
|
|
|
{
|
|
|
getChildValue(childLine, z_list, childLineNum,idList,pQty);
|
|
|
childLineNum++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
fatherBean.setList(z_list);
|
|
|
list.add(fatherBean);
|
|
|
for (int i = 0; i < childrens.length; i++)
|
|
|
{
|
|
|
|
|
|
TCComponentBOMLine z_line = (TCComponentBOMLine)childrens[i].getComponent();
|
|
|
TCComponentItem item = z_line.getItem();
|
|
|
// String idString = item.getStringProperty("item_id");
|
|
|
// System.out.println("11.17id======"+idString);
|
|
|
System.out.println("11.17z_line======="+z_line);
|
|
|
System.out.println("11.17list======="+list);
|
|
|
String type = item.getType();
|
|
|
System.out.println("type=============" + type);
|
|
|
if (!("T2_OutBuyPart".equals(type)) && !("T2_outsource".equals(type)))
|
|
|
{
|
|
|
String occType = z_line.getStringProperty("TCAI_OCC_TYPE");
|
|
|
if (!"Reference".equals(occType))
|
|
|
{
|
|
|
AIFComponentContext[] childrenAifs = z_line.getChildren();
|
|
|
if (childrenAifs.length > 0) {
|
|
|
String childType = z_line.getItemRevision().getType();
|
|
|
if(childType.equals("T2_VirtualRevision") && isEquipment) {
|
|
|
TCProperty tcProperty1 = z_line.getItemRevision().getTCProperty("release_status_list");
|
|
|
TCComponent[] targets1 = tcProperty1.getReferenceValueArray();
|
|
|
if(targets1==null || targets1.length<=0) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
String num = z_line.getStringProperty( "T2_ActualConsumption");//ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(num==null||"".equals(num.trim())) {
|
|
|
num = z_line.getStringProperty( "T2_DesignQuantity");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(num==null||"".equals(num.trim())) {
|
|
|
num = z_line.getStringProperty( "bl_quantity");//<2F><><EFBFBD><EFBFBD>
|
|
|
if(num==null||"".equals(num.trim())) {
|
|
|
num = "1";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// z_line.getStringProperty("bl_")
|
|
|
getBOMValue(z_line, list,Integer.valueOf(num)*pQty);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (TCException e)
|
|
|
{
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
private String toString(int num1) {
|
|
|
// TODO Auto-generated method stub
|
|
|
return null;
|
|
|
}
|
|
|
public void getChildValue(TCComponentBOMLine childLine, List<ChirldBomBean> z_list,int childLineNum,List<String> idList,int pQty) {
|
|
|
try {
|
|
|
String occType = childLine.getStringProperty("TCAI_OCC_TYPE");
|
|
|
if("Reference".equals(occType)) {
|
|
|
return;
|
|
|
}
|
|
|
String childID = childLine.getItem().getStringProperty("item_id");
|
|
|
String childtypeString = childLine.getItem().getStringProperty("object_type");
|
|
|
String childRevstring = childLine.getItemRevision().getStringProperty("item_revision_id");
|
|
|
if("T2_outsource".equals(childtypeString)) {
|
|
|
StringBuilder sb = new StringBuilder(childID);
|
|
|
//2022/8/23 ȡ<><C8A1>ƴ<EFBFBD>Ӱ汾
|
|
|
//sb.append(childRevstring);
|
|
|
childID = sb.toString();
|
|
|
}
|
|
|
System.out.println("childID2============"+childID);
|
|
|
String Quantity = childLine.getStringProperty( "T2_ActualConsumption");//ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(Quantity==null||"".equals(Quantity.trim())) {
|
|
|
Quantity = childLine.getStringProperty( "T2_DesignQuantity");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(Quantity==null||"".equals(Quantity.trim())) {
|
|
|
Quantity = childLine.getStringProperty( "bl_quantity");//<2F><><EFBFBD><EFBFBD>
|
|
|
if(Quantity==null||"".equals(Quantity.trim())) {
|
|
|
Quantity =1+"";//Ĭ<><C4AC>Ϊ1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// int num = Integer.valueOf(Quantity)*pQty;
|
|
|
// Quantity = String.valueOf(num);
|
|
|
System.out.println("Quantity=============="+Quantity);
|
|
|
if(idList.contains(childID)) {
|
|
|
int index = idList.indexOf(childID);
|
|
|
ChirldBomBean child = z_list.get(index);
|
|
|
String yl = child.getYonglian();
|
|
|
double d1 = Double.parseDouble(yl);
|
|
|
double d2 = 0;
|
|
|
if(Quantity != null && !("".equals(Quantity.trim()))) {
|
|
|
try {
|
|
|
d2 = Double.parseDouble(Quantity);
|
|
|
} catch (Exception e) {
|
|
|
// TODO: handle exception
|
|
|
d2 = 1;
|
|
|
}
|
|
|
}else {
|
|
|
d2 = 1;
|
|
|
}
|
|
|
double d3 = d1 + d2;
|
|
|
System.out.println("d3=============="+d3);
|
|
|
child.setYonglian(d3+"");
|
|
|
return;
|
|
|
}else {
|
|
|
idList.add(childID);
|
|
|
}
|
|
|
ChirldBomBean childBean = new ChirldBomBean();
|
|
|
//<2F><>ȡϵͳ<CFB5><CDB3>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
SimpleDateFormat sdf =new SimpleDateFormat("YYYYMMdd");
|
|
|
String daatatext = sdf.format(new Date());
|
|
|
int j = 0;
|
|
|
childBean.setNumber(childLineNum+1);//<2F><><EFBFBD><EFBFBD>
|
|
|
childBean.setYonglian(Quantity);
|
|
|
String childRev = childLine.getItemRevision().getStringProperty("item_revision_id");
|
|
|
String childType = childLine.getItem().getStringProperty("object_type");
|
|
|
// childID = childID.replace("-Y", "");
|
|
|
String idlast =childID.substring(childID.length()-2, childID.length());
|
|
|
System.out.println("id<69>ĺ<EFBFBD><C4BA><EFBFBD>λ<EFBFBD><CEBB>"+idlast);
|
|
|
// if(idlast.contains("-Y")) {
|
|
|
// return;
|
|
|
// }
|
|
|
if(childID.endsWith("-Y")) {
|
|
|
childID = childID.replace("-Y", "");
|
|
|
}
|
|
|
System.out.println("childID============"+childID);
|
|
|
System.out.println("childRev============"+childRev);
|
|
|
System.out.println("childType============"+childType);
|
|
|
// if("T2_outsource".equals(childType)) {
|
|
|
// StringBuilder sb = new StringBuilder(childID);
|
|
|
// sb.append(childRev);
|
|
|
// childID = sb.toString();
|
|
|
// }
|
|
|
|
|
|
childBean.setPinhao(childID);//Ԫ<><D4AA><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>
|
|
|
//<2F><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>date<74><65><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>ΪString<6E><67><EFBFBD><EFBFBD>
|
|
|
java.text.SimpleDateFormat formatter = new SimpleDateFormat( "yyyy/MM/dd");
|
|
|
|
|
|
Date released_time = childLine.getItemRevision().getDateProperty("last_mod_date");
|
|
|
String date = formatter.format(released_time);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
|
childBean.setDate(date);//<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
|
//<2F> <20><>Э Ҫ<>ж<EFBFBD><D0B6>Ƿ<C7B7>
|
|
|
|
|
|
|
|
|
|
|
|
childBean.setWork_id(childLine.getStringProperty("T2_JobNumber"));//<2F><>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>
|
|
|
childBean.setBeizhu(childLine.getStringProperty("T2_remark"));//<2F><>ע
|
|
|
childBean.setChajian_id(childLine.getStringProperty("T2_weihao"));//<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
|
|
|
|
// T2_DesignQuantity <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
// T2_JobNumber <20><>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>
|
|
|
// T2_remark <20><>ע
|
|
|
// T2_weihao λ<><CEBB>
|
|
|
|
|
|
childBean.setPlmkey(childID+"-"+childLine.getItemRevision().getStringProperty("item_revision_id") );//PLMkey
|
|
|
z_list.add(childBean);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
// TODO: handle exception
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static String getId(){
|
|
|
String id=UUID.randomUUID().toString();//<2F><><EFBFBD>ɵ<EFBFBD>id942cd30b-16c8-449e-8dc5-028f38495bb5<62>м京<D0BC>к<EFBFBD><D0BA>ܣ<EFBFBD><span style="color: rgb(75, 75, 75); font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 20.7999992370605px;"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id<69>Ǻ<EFBFBD>ʵ<EFBFBD>õġ<C3B5></span>
|
|
|
id=id.replace("-", "");//<2F>滻<EFBFBD><E6BBBB><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD>Ǹ<EFBFBD>б<EFBFBD><D0B1>
|
|
|
return id;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|