|
|
@ -32,6 +32,7 @@ import com.connor.chint.sap2.util.KUtil;
|
|
|
|
import com.connor.chint.sap2.util.MyProgressBarCompent;
|
|
|
|
import com.connor.chint.sap2.util.MyProgressBarCompent;
|
|
|
|
import com.connor.chint.sap2.util.SAPMessageUtil;
|
|
|
|
import com.connor.chint.sap2.util.SAPMessageUtil;
|
|
|
|
import com.connor.chint.sap2.util.SAPUtil;
|
|
|
|
import com.connor.chint.sap2.util.SAPUtil;
|
|
|
|
|
|
|
|
import com.connor.chint.sap2.util.SqlUtil;
|
|
|
|
import com.connor.chint.sap2.util.TXTUtil;
|
|
|
|
import com.connor.chint.sap2.util.TXTUtil;
|
|
|
|
import com.squareup.okhttp.Credentials;
|
|
|
|
import com.squareup.okhttp.Credentials;
|
|
|
|
import com.squareup.okhttp.MediaType;
|
|
|
|
import com.squareup.okhttp.MediaType;
|
|
|
@ -64,7 +65,7 @@ import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData
|
|
|
|
public class BomSendSapController {
|
|
|
|
public class BomSendSapController {
|
|
|
|
|
|
|
|
|
|
|
|
public static final String TYPE_REV_PART = "Part Revision";
|
|
|
|
public static final String TYPE_REV_PART = "Part Revision";
|
|
|
|
public TCComponent project; //项目信息
|
|
|
|
public TCComponent project; // 项目信息
|
|
|
|
public String groupName;
|
|
|
|
public String groupName;
|
|
|
|
public String zt2_ProjectNo;
|
|
|
|
public String zt2_ProjectNo;
|
|
|
|
public String wbs;
|
|
|
|
public String wbs;
|
|
|
@ -73,6 +74,7 @@ public class BomSendSapController {
|
|
|
|
public List<PartBean> partList = new ArrayList<>();
|
|
|
|
public List<PartBean> partList = new ArrayList<>();
|
|
|
|
public BomSendSapWhFram dialog;
|
|
|
|
public BomSendSapWhFram dialog;
|
|
|
|
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
|
|
|
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) {
|
|
|
|
public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) {
|
|
|
|
this.app = app;
|
|
|
|
this.app = app;
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
@ -91,11 +93,11 @@ public class BomSendSapController {
|
|
|
|
System.out.println("检查对象:" + target);
|
|
|
|
System.out.println("检查对象:" + target);
|
|
|
|
List<TCComponentItemRevision> partRevList = KUtil.getCCPFromProject(project);
|
|
|
|
List<TCComponentItemRevision> partRevList = KUtil.getCCPFromProject(project);
|
|
|
|
|
|
|
|
|
|
|
|
for(TCComponentItemRevision rev:partRevList) {
|
|
|
|
for (TCComponentItemRevision rev : partRevList) {
|
|
|
|
String cType = rev.getType();
|
|
|
|
String cType = rev.getType();
|
|
|
|
// System.out.println(">> 找到子对象:" + cName + "|" + cType);
|
|
|
|
// System.out.println(">> 找到子对象:" + cName + "|" + cType);
|
|
|
|
if (TYPE_REV_PART.equals(cType)) {
|
|
|
|
if (TYPE_REV_PART.equals(cType)) {
|
|
|
|
PartBean bean = new PartBean(rev, partList.size() + 1,"");
|
|
|
|
PartBean bean = new PartBean(rev, partList.size() + 1, "");
|
|
|
|
SAPPushBOMBean.readUser(bean, rev, groupName, session);
|
|
|
|
SAPPushBOMBean.readUser(bean, rev, groupName, session);
|
|
|
|
bean.setPSPID(project.getProperty("zt2_ProjectNo"));
|
|
|
|
bean.setPSPID(project.getProperty("zt2_ProjectNo"));
|
|
|
|
partList.add(bean);
|
|
|
|
partList.add(bean);
|
|
|
@ -141,33 +143,31 @@ public class BomSendSapController {
|
|
|
|
released_Yellow.save();
|
|
|
|
released_Yellow.save();
|
|
|
|
released_Yellow.unlock();
|
|
|
|
released_Yellow.unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
|
|
public static String getXML(){
|
|
|
|
public static String getXML() {
|
|
|
|
String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n"
|
|
|
|
String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n"
|
|
|
|
+ " <soapenv:Header/>\r\n"
|
|
|
|
+ " <soapenv:Header/>\r\n" + " <soapenv:Body>\r\n" + " <urn:MT_MATERIAL_BOP_REQ>\r\n"
|
|
|
|
+ " <soapenv:Body>\r\n"
|
|
|
|
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n" + " </soapenv:Body>\r\n" + "</soapenv:Envelope>";
|
|
|
|
+ " <urn:MT_MATERIAL_BOP_REQ>\r\n"
|
|
|
|
|
|
|
|
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n"
|
|
|
|
|
|
|
|
+ " </soapenv:Body>\r\n"
|
|
|
|
|
|
|
|
+ "</soapenv:Envelope>";
|
|
|
|
|
|
|
|
return soapXML;
|
|
|
|
return soapXML;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
|
|
|
|
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
|
|
|
|
|
|
|
|
|
|
|
|
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
|
|
|
|
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
|
|
|
|
if(rev2.getType().equals("Part Revision")) {
|
|
|
|
if (rev2.getType().equals("Part Revision")) {
|
|
|
|
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
|
|
|
|
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
|
|
|
|
if(zt2_ifpbom.equals("P")) {
|
|
|
|
if (zt2_ifpbom.equals("P")) {
|
|
|
|
return rev2;
|
|
|
|
return rev2;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
|
|
|
|
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
|
|
|
|
if(designRev!=null) {
|
|
|
|
if (designRev != null) {
|
|
|
|
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
|
|
|
|
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
|
|
|
|
for(TCComponent matnr:matnrs) {
|
|
|
|
for (TCComponent matnr : matnrs) {
|
|
|
|
String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"});
|
|
|
|
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" });
|
|
|
|
if(properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) {
|
|
|
|
if (properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) {
|
|
|
|
return (TCComponentItemRevision)matnr;
|
|
|
|
return (TCComponentItemRevision) matnr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -176,27 +176,60 @@ public class BomSendSapController {
|
|
|
|
return rev2;
|
|
|
|
return rev2;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getUserName(TCSession session) throws TCException {
|
|
|
|
public String getUserName(TCSession session) throws TCException {
|
|
|
|
TCComponentUser user = session.getUser();
|
|
|
|
TCComponentUser user = session.getUser();
|
|
|
|
session.getUserName();
|
|
|
|
session.getUserName();
|
|
|
|
return user.getTCProperty("user_name").getDisplayValue();
|
|
|
|
return user.getTCProperty("user_name").getDisplayValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void sendSap() {
|
|
|
|
public void sendSap() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String strs[] = session.getPreferenceService().getStringValues("database_tc");
|
|
|
|
|
|
|
|
if (SqlUtil.getTCDataConnection(strs) == null) {
|
|
|
|
|
|
|
|
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
List<PartBean> selectedParts = getSelectedParts();
|
|
|
|
List<PartBean> selectedParts = getSelectedParts();
|
|
|
|
|
|
|
|
// 记录SUM表信息
|
|
|
|
|
|
|
|
String userName = session.getUser().getProperty("user_name");
|
|
|
|
|
|
|
|
String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
|
|
|
|
|
String zt2_WBSNo = project.getStringProperty("zt2_WBSNo");
|
|
|
|
|
|
|
|
String object_name = project.getStringProperty("object_name");
|
|
|
|
|
|
|
|
String userId = session.getUser().getUserId();
|
|
|
|
|
|
|
|
String code = BomUtilWh.getCode().toString();
|
|
|
|
|
|
|
|
StringBuilder productNosBuild = new StringBuilder("");
|
|
|
|
|
|
|
|
StringBuilder productUidsBuild = new StringBuilder("");
|
|
|
|
|
|
|
|
for (PartBean cppItem : selectedParts) {
|
|
|
|
|
|
|
|
String property = cppItem.part.getProperty(BomUtilWh.ZT2_MATERIALNO);
|
|
|
|
|
|
|
|
productNosBuild.append(property).append(";");
|
|
|
|
|
|
|
|
productUidsBuild.append(cppItem.part.getUid()).append(";");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String substring = productUidsBuild.toString().substring(0, productUidsBuild.length() - 1);
|
|
|
|
|
|
|
|
String serverHostname = session.getServerHostname();
|
|
|
|
|
|
|
|
SqlUtil.write(BomUtilWh.detailsSql, new String[] { code, "M060", userName, dataTime, zt2_WBSNo, object_name,
|
|
|
|
|
|
|
|
"产成品传递", substring, project.getUid(), serverHostname, userId });
|
|
|
|
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
|
|
|
|
// 存在多个产成品时 下面的PBOM是一样的,只需要记录一次日志新的
|
|
|
|
|
|
|
|
boolean flag = true;
|
|
|
|
|
|
|
|
String batchNum = code + "-00001";
|
|
|
|
|
|
|
|
|
|
|
|
String now = format.format(new Date());
|
|
|
|
String now = format.format(new Date());
|
|
|
|
MyProgressBarCompent comp = null;
|
|
|
|
MyProgressBarCompent comp = null;
|
|
|
|
// try {
|
|
|
|
|
|
|
|
String txtName = format2.format(new Date()) + getUserName(session);
|
|
|
|
String txtName = format2.format(new Date()) + getUserName(session);
|
|
|
|
String txtPath = TXTUtil.createTxt(txtName);
|
|
|
|
String txtPath = TXTUtil.createTxt(txtName);
|
|
|
|
comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
|
|
|
|
comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
|
|
|
|
StringBuffer errMessageAll = new StringBuffer("");
|
|
|
|
StringBuffer errMessageAll = new StringBuffer("");
|
|
|
|
StringBuffer sendMessageAll = new StringBuffer("");
|
|
|
|
StringBuffer sendMessageAll = new StringBuffer("");
|
|
|
|
|
|
|
|
|
|
|
|
//2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
|
|
|
|
// 2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
|
|
|
|
project.getProperty("zt2_WBSNo");
|
|
|
|
// project.getProperty("zt2_WBSNo");
|
|
|
|
//产成品BOM组织时除了产成品不同,其他相同 BOM结构是一样的
|
|
|
|
// 产成品BOM组织时除了产成品不同,其他相同 BOM结构是一样的
|
|
|
|
for(PartBean bean : selectedParts) {
|
|
|
|
// 记录产成品的物料编码
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (PartBean bean : selectedParts) {
|
|
|
|
|
|
|
|
|
|
|
|
Document document = DocumentHelper.parseText(getXML());
|
|
|
|
Document document = DocumentHelper.parseText(getXML());
|
|
|
|
Element rootElement = document.getRootElement();
|
|
|
|
Element rootElement = document.getRootElement();
|
|
|
@ -213,30 +246,34 @@ public class BomSendSapController {
|
|
|
|
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
|
|
|
TCComponentBOMWindow win = bomWinType.create(null);
|
|
|
|
TCComponentBOMWindow win = bomWinType.create(null);
|
|
|
|
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null);
|
|
|
|
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null);
|
|
|
|
//优化项:BOM全展开
|
|
|
|
// 优化项:BOM全展开
|
|
|
|
System.out.println("BOM全展开");
|
|
|
|
System.out.println("BOM全展开");
|
|
|
|
Map<String, TCComponent> gy_meops = new HashMap<>(32);
|
|
|
|
Map<String, TCComponent> gy_meops = new HashMap<>(32);
|
|
|
|
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
|
|
|
|
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
|
|
|
|
//三种情况有PBOM传PDBOM,没PBOM传EBOM,没EBOM传图纸BOM
|
|
|
|
// 三种情况有PBOM传PDBOM,没PBOM传EBOM,没EBOM传图纸BOM
|
|
|
|
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
|
|
|
|
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
|
|
|
|
List<String> wbsList = new ArrayList<String>();
|
|
|
|
List<String> wbsList = new ArrayList<String>();
|
|
|
|
// 记录物料图纸关系的集合
|
|
|
|
// 记录物料图纸关系的集合
|
|
|
|
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
|
|
|
|
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
|
|
|
|
BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2,
|
|
|
|
// 2024 1 24 新加字段 UID 和 BATCHNUMBER
|
|
|
|
groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,txtPath,material_revs);
|
|
|
|
BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2, groupName, wbsList, session, now,
|
|
|
|
System.out.println("BOM全document===>"+document.asXML());
|
|
|
|
needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum);
|
|
|
|
if(errMessage.length()>0) {
|
|
|
|
System.out.println("BOM全document===>" + document.asXML());
|
|
|
|
|
|
|
|
if (errMessage.length() > 0) {
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, errMessage.toString());
|
|
|
|
TXTUtil.writeTXT(txtPath, errMessage.toString());
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
|
|
|
|
errMessageAll.append(errMessage);
|
|
|
|
errMessageAll.append(errMessage);
|
|
|
|
// new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessage.toString());
|
|
|
|
// new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessage.toString());
|
|
|
|
win.close();
|
|
|
|
win.close();
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
//记录XML信息到CHINT_BOM_TO_SAP_DETIALS
|
|
|
|
// 记录XML信息到CHINT_BOM_TO_SAP_DETIALS
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
sendMessageAll.append(SendToSap(txtPath,document.asXML()));
|
|
|
|
flag = false;
|
|
|
|
|
|
|
|
BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, wbs, session);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sendMessageAll.append(SendToSap(txtPath, document.asXML()));
|
|
|
|
win.close();
|
|
|
|
win.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
|
|
|
|
TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
|
|
|
@ -245,19 +282,21 @@ public class BomSendSapController {
|
|
|
|
TXTUtil.addTxttoTarget(rev2, dataset);
|
|
|
|
TXTUtil.addTxttoTarget(rev2, dataset);
|
|
|
|
KUtil.setByPass(false);
|
|
|
|
KUtil.setByPass(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(comp!=null) {
|
|
|
|
if (comp != null) {
|
|
|
|
comp.setVisible(false);
|
|
|
|
comp.setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(errMessageAll.length()>0) {
|
|
|
|
if (errMessageAll.length() > 0) {
|
|
|
|
new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessageAll.toString());
|
|
|
|
new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessageAll.toString());
|
|
|
|
}else if(sendMessageAll.length()>0) {
|
|
|
|
} else if (sendMessageAll.length() > 0) {
|
|
|
|
new SAPMessageUtil("", "BOM推送异常:\n" + sendMessageAll.toString());
|
|
|
|
new SAPMessageUtil("", "BOM推送异常:\n" + sendMessageAll.toString());
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
MessageBox.post("BOM数据推送完成..","提示",2);
|
|
|
|
MessageBox.post("BOM数据推送完成..", "提示", 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
SqlUtil.freeAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -282,32 +321,32 @@ public class BomSendSapController {
|
|
|
|
return selectedParts;
|
|
|
|
return selectedParts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public StringBuffer SendToSap(String txtPath,String wsdlString) throws IOException {
|
|
|
|
public StringBuffer SendToSap(String txtPath, String wsdlString) throws IOException {
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递数据--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递数据--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, wsdlString);
|
|
|
|
TXTUtil.writeTXT(txtPath, wsdlString);
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
|
|
|
|
|
|
|
|
|
|
|
|
//推送SAP
|
|
|
|
// 推送SAP
|
|
|
|
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl");
|
|
|
|
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB");
|
|
|
|
String sapUrl = "";
|
|
|
|
String sapUrl = "";
|
|
|
|
String momUrl = "";
|
|
|
|
String momUrl = "";
|
|
|
|
for(String stringValue:stringValues) {
|
|
|
|
for (String stringValue : stringValues) {
|
|
|
|
if(stringValue.startsWith("SAP:1=")) {
|
|
|
|
if (stringValue.startsWith("SAP:1=")) {
|
|
|
|
sapUrl = stringValue.replaceAll("SAP:1=", "");
|
|
|
|
sapUrl = stringValue.replaceAll("SAP:1=", "");
|
|
|
|
}else if(stringValue.startsWith("MOM:1=")) {
|
|
|
|
} else if (stringValue.startsWith("MOM:1=")) {
|
|
|
|
momUrl = stringValue.replaceAll("MOM:1=", "");
|
|
|
|
momUrl = stringValue.replaceAll("MOM:1=", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StringBuffer sendSap = sendSap(sapUrl,wsdlString,txtPath);
|
|
|
|
StringBuffer sendSap = sendSap(sapUrl, wsdlString, txtPath);
|
|
|
|
StringBuffer sendMom = sendMom(momUrl,wsdlString,txtPath);
|
|
|
|
StringBuffer sendMom = sendMom(momUrl, wsdlString, txtPath);
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
if(sendSap.length()>0) {
|
|
|
|
if (sendSap.length() > 0) {
|
|
|
|
errBuffer.append("推送SAP异常:").append("\n");
|
|
|
|
errBuffer.append("推送SAP异常:").append("\n");
|
|
|
|
errBuffer.append(sendSap);
|
|
|
|
errBuffer.append(sendSap);
|
|
|
|
//new SAPMessageUtil("", "s:\n" + errBuffer.toString());
|
|
|
|
// new SAPMessageUtil("", "s:\n" + errBuffer.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(sendMom.length()>0) {
|
|
|
|
if (sendMom.length() > 0) {
|
|
|
|
errBuffer.append("推送MOM异常:").append("\n");
|
|
|
|
errBuffer.append("推送MOM异常:").append("\n");
|
|
|
|
errBuffer.append(sendMom);
|
|
|
|
errBuffer.append(sendMom);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -316,31 +355,28 @@ public class BomSendSapController {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public StringBuffer sendSap(String url,String wsdlString,String txtPath) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
public StringBuffer sendSap(String url, String wsdlString, String txtPath) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
if(!url.contains("http")) {
|
|
|
|
if (!url.contains("http")) {
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
|
client.setConnectTimeout(100, TimeUnit.SECONDS);
|
|
|
|
client.setConnectTimeout(100, TimeUnit.SECONDS);
|
|
|
|
client.setReadTimeout(100, TimeUnit.SECONDS);
|
|
|
|
client.setReadTimeout(100, TimeUnit.SECONDS);
|
|
|
|
// Authenticator authenticator = client.setAuthenticator(new Au);
|
|
|
|
// Authenticator authenticator = client.setAuthenticator(new Au);
|
|
|
|
String credential = "";//Credentials.basic("shpodev", "sap@2019");
|
|
|
|
String credential = "";// Credentials.basic("shpodev", "sap@2019");
|
|
|
|
if(url.contains("192.168.0.184")) {
|
|
|
|
if (url.contains("192.168.0.184") || url.contains("gfpot01")) {
|
|
|
|
credential = Credentials.basic("shpodev", "sap@2019");
|
|
|
|
credential = Credentials.basic("po_rfc", "1qaz!QAZ");
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
credential = Credentials.basic("shplm", "sap@2019");
|
|
|
|
credential = Credentials.basic("shplm", "sap@2019");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MediaType mediaType = MediaType.parse("application/xml");
|
|
|
|
MediaType mediaType = MediaType.parse("application/xml");
|
|
|
|
RequestBody body = RequestBody.create(mediaType,wsdlString);
|
|
|
|
RequestBody body = RequestBody.create(mediaType, wsdlString);
|
|
|
|
//http://192.168.0.184:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_CHINT_ELECTRIC&receiverParty=&receiverService=&interface=SIO_MATERIAL_BOP_PLM_SYN&interfaceNamespace=urn:chintelectric.com:xi:plm
|
|
|
|
// http://192.168.0.184:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_CHINT_ELECTRIC&receiverParty=&receiverService=&interface=SIO_MATERIAL_BOP_PLM_SYN&interfaceNamespace=urn:chintelectric.com:xi:plm
|
|
|
|
Request request = new Request.Builder()
|
|
|
|
Request request = new Request.Builder().url(url).method("POST", body).header("Authorization", credential)
|
|
|
|
.url(url)
|
|
|
|
.addHeader("Content-Type", "application/xml").build();
|
|
|
|
.method("POST", body)
|
|
|
|
|
|
|
|
.header("Authorization", credential)
|
|
|
|
|
|
|
|
.addHeader("Content-Type", "application/xml")
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Response response = client.newCall(request).execute();
|
|
|
|
Response response = client.newCall(request).execute();
|
|
|
|
Document document = null;
|
|
|
|
Document document = null;
|
|
|
|
|
|
|
|
|
|
|
@ -350,26 +386,26 @@ public class BomSendSapController {
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
|
|
|
|
TXTUtil.writeTXT(txtPath, string);
|
|
|
|
TXTUtil.writeTXT(txtPath, string);
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
|
|
|
|
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
|
|
|
|
document = DocumentHelper.parseText(string);
|
|
|
|
// document = DocumentHelper.parseText(string);
|
|
|
|
Element rootElement = document.getRootElement();
|
|
|
|
// Element rootElement = document.getRootElement();
|
|
|
|
Element bodys = rootElement.element("Body");
|
|
|
|
// Element bodys = rootElement.element("Body");
|
|
|
|
Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
|
|
|
|
// Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
|
|
|
|
// String attributeValue = elements.get(0).attributeValue("CODE");
|
|
|
|
//// String attributeValue = elements.get(0).attributeValue("CODE");
|
|
|
|
List<Element> ztable = elements.elements("ZTABLE_RETURN");
|
|
|
|
// List<Element> ztable = elements.elements("ZTABLE_RETURN");
|
|
|
|
for(Element zret:ztable) {
|
|
|
|
// for (Element zret : ztable) {
|
|
|
|
String status = zret.elementText("TYPE");
|
|
|
|
// String status = zret.elementText("TYPE");
|
|
|
|
if(status.equals("E")) {
|
|
|
|
// if (status.equals("E")) {
|
|
|
|
String attributeValue = zret.elementText("MESSAGE");
|
|
|
|
// String attributeValue = zret.elementText("MESSAGE");
|
|
|
|
String MATNR = zret.elementText("MATNR");
|
|
|
|
// String MATNR = zret.elementText("MATNR");
|
|
|
|
if(MATNR!=null) {
|
|
|
|
// if (MATNR != null) {
|
|
|
|
attributeValue = attributeValue+",在"+MATNR+"BOM中";
|
|
|
|
// attributeValue = attributeValue + ",在" + MATNR + "BOM中";
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
|
|
|
|
//// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
|
|
|
|
System.out.println(attributeValue);
|
|
|
|
// System.out.println(attributeValue);
|
|
|
|
errBuffer.append(attributeValue).append("\n");
|
|
|
|
// errBuffer.append(attributeValue).append("\n");
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
} catch (DocumentException e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -379,7 +415,8 @@ public class BomSendSapController {
|
|
|
|
// new SAPMessageUtil("", "BOM物料异常:\n" + errBuffer.toString());
|
|
|
|
// new SAPMessageUtil("", "BOM物料异常:\n" + errBuffer.toString());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public String sendJsonHttpPost(String url, String xmlContent,String txtPath) {
|
|
|
|
|
|
|
|
|
|
|
|
public String sendJsonHttpPost(String url, String xmlContent, String txtPath) {
|
|
|
|
|
|
|
|
|
|
|
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|
|
|
|
CloseableHttpClient httpclient = HttpClients.createDefault();
|
|
|
|
String responseInfo = null;
|
|
|
|
String responseInfo = null;
|
|
|
@ -391,10 +428,10 @@ public class BomSendSapController {
|
|
|
|
// 设置请求体
|
|
|
|
// 设置请求体
|
|
|
|
StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8);
|
|
|
|
StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
|
|
|
|
if(url.contains("10.128.11.12")) {
|
|
|
|
if (url.contains("10.128.11.12")) {
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg=");
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg=");
|
|
|
|
// http://10.128.11.12:7788/gateway/chint/bop-sync
|
|
|
|
// http://10.128.11.12:7788/gateway/chint/bop-sync
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg=");
|
|
|
|
httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg=");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -420,14 +457,14 @@ public class BomSendSapController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return responseInfo;
|
|
|
|
return responseInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public StringBuffer sendMom(String url,String wsdlString,String txtPath) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StringBuffer sendMom(String url, String wsdlString, String txtPath) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
StringBuffer errBuffer = new StringBuffer("");
|
|
|
|
if(!url.contains("http")) {
|
|
|
|
if (!url.contains("http")) {
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String string = sendJsonHttpPost(url,wsdlString,txtPath); //"http://10.128.11.12:7788/gateway/chint/bop-sync"
|
|
|
|
String string = sendJsonHttpPost(url, wsdlString, txtPath); // "http://10.128.11.12:7788/gateway/chint/bop-sync"
|
|
|
|
|
|
|
|
|
|
|
|
return errBuffer;
|
|
|
|
return errBuffer;
|
|
|
|
|
|
|
|
|
|
|
|