没有BOM异步逻辑代码

no-bomasyn
陈翼晖 1 year ago
parent c695e780f5
commit 13d22cca14

@ -1,3 +1,2 @@
ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61
ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01
SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210

@ -26,10 +26,6 @@ import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
/**
* @author cyh
* ID
*/
public class AssignIdController {
private String groupID;
private TCSession session;

@ -84,12 +84,6 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
* @author cyh
*
* ´´½¨¸ü¸ÄECNÒ³Ãæ
*
*/
public class CreateEcnController extends KFXPanelController {
@FXML
private TextField ecnId;
@ -680,8 +674,6 @@ public class CreateEcnController extends KFXPanelController {
String result = read.getString("result");
if (result.equals("·ñ")) {
refTableBean.setShNo(true);
}else {
refTableBean.setShYes(true);
}
i = i + 1;
}

@ -82,8 +82,8 @@ public class RefTableBean {
return shYes;
}
public void setShYes(boolean shYes) {
this.shYes.setSelected(shYes);
public void setShYes(CheckBox shYes) {
this.shYes = shYes;
}
public CheckBox getShNo() {

@ -33,11 +33,6 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
* @author cyh
*
*
*/
public class RelateEcnController {
@FXML

@ -74,7 +74,7 @@ public class ExtractDiffComd extends KCommand {
return;
}
readChangeDesign(oldComponents, newComponents, tar);
MessageBox.post(resource.getString("SUCC_CHANGE"), "", 2);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -150,10 +150,9 @@ public class ExtractDiffComd extends KCommand {
ChangeDesignBean changeDesignBean = itemChangeMap.get(keyItem);
TCComponentItemRevision oldDesgin = changeDesignBean.getOldDesgin();
Map<String, PBomBean> materialOld = getMaterialByDesign(oldDesgin);
System.out.println("materialOld===>" + materialOld.toString());
TCComponentItemRevision newDesgin = changeDesignBean.getNewDesgin();
Map<String, PBomBean> materialNew = getMaterialByDesign(newDesgin);
System.out.println("materialOld===>" + materialOld.toString());
System.out.println("materialNew===>" + materialNew.toString());
// ±È½Ï±ä¸üǰºóÎïÁÏBOM
for (String materialNo : materialOld.keySet()) {
@ -317,8 +316,6 @@ public class ExtractDiffComd extends KCommand {
if (pbomMap.containsKey(materialNo)) {
PBomBean pBomBean = pbomMap.get(materialNo);
// ÊÇ·ñPBOM
System.out.println("matnrProps[1]===>" + matnrProps[1]);
System.out.println("matnrProps[2]===>" + matnrProps[2] + "pBomBean.getpRevision()"+pBomBean.getpRevision());
if (matnrProps[1].equals(Util.ZT_VAL_PBOM) && matnrProps[2].compareTo(pBomBean.getpRevision()) > 0) {
pBomBean.setpMaterial(represent);
pBomBean.setpRevision(matnrProps[2]);

@ -1,3 +1,2 @@
ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61
ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01
SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210

@ -1,7 +1,5 @@
package com.connor.chint.sap2.util;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -42,26 +40,8 @@ public class BomUtilWh {
public static final String WH_FACOTRY = "M060";
public static final String PARENTTCID = "PARENTTCID";
public static final String PARENTWLBM = "PARENTWLBM";
public static final String ZT2_WBSNO = "zt2_WBSNo";
public static final String ZT2_MATERIALNO = "zt2_MaterialNo";
public static final String SPLIT_MSG = "/";
public static final String UID = "UID";
public static final String detailsSql = "insert into CHINT_BOM_TO_SAP_SUM (code,factory,\"USER\",starttime,wbsno,projectno,taskstauts"
+ ",plmresult,transfer,keymsg,sapresult,PROJECTUID,SERVERHOST,USERID) values "
+ "(?,?,?,to_date(?,'yyyy-mm-ddhh24:mi:ss')" + ",?,?,'组织完成','未处理',?,?,'未返回',?,?,?)";
// 获取传递BOM中最大的序列
public static Integer getCode() throws SQLException {
String sql = "select Tab_SendBom_Sequence.nextval as sid from dual";
ResultSet rs = SqlUtil.read(sql);
Object objs[] = new Object[1];
int code = 0;
if (rs.next()) {
code = rs.getInt(1);
System.out.println("code:" + code);
}
SqlUtil.free();
return code;
}
/**
* BOMDETAILS
@ -71,21 +51,21 @@ public class BomUtilWh {
* @param productNos
* @function
*/
public static void logXmlMsg(Element interGrationList, String code, String productNos, String batchNo,
public static void logXmlMsg(Document interGrationList, String code, String productNos, String batchNo,
String wbsNo, TCSession session) {
String strs[] = session.getPreferenceService().getStringValues(DATABASE_TC);
SqlUtil.getTCDataConnection(strs);
try {
Element rootElement = interGrationList.getRootElement();
// 物料信息
Element element = interGrationList.element(WLLIST);
Element element = rootElement.element(WLLIST);
List<Element> elements = element.elements(WLCONTENTS);
for (Element content : elements) {
// 记录TCid UID 物料编码
Element bomContents = content.element("BOMCONTENTS");
String tcId = bomContents.elementText(PARENTTCID);
String tcId = content.elementText(PARENTTCID);
String[] split = tcId.split(SPLIT_MSG);
String parentMantrNo = bomContents.elementText(PARENTWLBM);
String uid = bomContents.elementText(UID);
String parentMantrNo = content.elementText(PARENTWLBM);
String uid = content.elementText(UID);
SqlUtil.write(logSql,
new String[] { code, batchNo, WH_FACOTRY, productNos, split[0], uid, parentMantrNo, wbsNo });
}
@ -1196,7 +1176,7 @@ public class BomUtilWh {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, List<TCComponentItem> cppRevision, String txtPath,
Map<String, TCComponentItemRevision> material_revs, String batchNum) {
Map<String, TCComponentItemRevision> material_revs) {
try {
String uid = pBomLine.getUid();
@ -1294,8 +1274,6 @@ public class BomUtilWh {
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
BOMCONTENTS.addElement("UID").setText(pRev.getUid());
BOMCONTENTS.addElement("BATCHNUMBER").setText(batchNum);
Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
String maxSeq = "10";
@ -1332,7 +1310,11 @@ public class BomUtilWh {
material_revs.put(properties2[2], rev2);
}
expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops,
INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum);
INTERGRATIONLIST, errMessage, txtPath, material_revs);
// if (!KUtil.isEmpty(zt2_materialNo)) {
// material_revs.put(zt2_materialNo, part2Rev);
// }
}
AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" });
@ -1548,7 +1530,7 @@ public class BomUtilWh {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, String txtPath,
Map<String, TCComponentItemRevision> material_revs, String batchNum) {
Map<String, TCComponentItemRevision> material_revs) {
try {
String uid = pBomLine.getUid();
@ -1639,10 +1621,6 @@ public class BomUtilWh {
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
//新增字段UID和批次号
BOMCONTENTS.addElement("UID").setText(pRev.getUid());
BOMCONTENTS.addElement("BATCHNUMBER").setText(batchNum);
Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
String maxSeq = "10";
@ -1687,7 +1665,7 @@ public class BomUtilWh {
material_revs.put(properties2[2], rev2);
}
expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops,
INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum);
INTERGRATIONLIST, errMessage, txtPath, material_revs);
}
AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },

@ -18,7 +18,6 @@ import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SAPMessageUtilFram;
import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.TXTUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
@ -48,7 +47,6 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
private String now;
private String groupName = "";
private TCComponentItemType ccomponentitemtype;
public BomSapWhBjOp(AbstractAIFApplication app) {
// TODO Auto-generated constructor stub
this.app = app;
@ -108,7 +106,6 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
return itemList;
}
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
@ -141,30 +138,21 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
return rev2;
}
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"
+ " <soapenv:Header/>\r\n" + " <soapenv:Body>\r\n" + " <urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n" + " </soapenv:Body>\r\n" + "</soapenv:Envelope>";
+ " <soapenv:Header/>\r\n"
+ " <soapenv:Body>\r\n"
+ " <urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </soapenv:Body>\r\n"
+ "</soapenv:Envelope>";
return soapXML;
}
@Override
public void executeOperation() throws Exception {
// TODO Auto-generated method stub
MyProgressBarCompent comp = null;
try {
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
String code = BomUtilWh.getCode().toString();
String batchNum = code + "-00001";
groupName = SAPUtil.getGroupID(session);
if (KUtil.isEmpty(groupName) || groupName.equalsIgnoreCase("dba")) {
MessageBox.post("当前登录组[" + groupName + "]不可使用该功能", "", MessageBox.INFORMATION);
@ -194,29 +182,6 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
List<TCComponentItem> cppRevision = getCPPPRevision(degignRev);
//获取产成品
System.out.println("cppRevision===>"+cppRevision.toString());
//记录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(TCComponentItem cppItem:cppRevision) {
TCComponentItemRevision latestItemRevision = cppItem.getLatestItemRevision();
String property = latestItemRevision.getProperty(BomUtilWh.ZT2_MATERIALNO);
productNosBuild.append(property).append(";");
productUidsBuild.append(latestItemRevision.getUid()).append(";");
}
String substring = productUidsBuild.toString().substring(0, productUidsBuild.length() - 1);
String serverHostname = session.getServerHostname();
String wbsNo = cppRevision.get(0).getLatestItemRevision().getProperty(BomUtilWh.ZT2_WBSNO);
SqlUtil.write(BomUtilWh.detailsSql, new String[] { code, "M060", userName, dataTime, wbsNo,
"", "部件传递", substring, "", serverHostname, userId });
SqlUtil.freeAll();
List<String> wbsList = new ArrayList<String>();
StringBuffer errMessage = new StringBuffer("");
@ -241,24 +206,16 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision, groupName, wbsList, session, now,
needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, cppRevision, txtPath, material_revs, batchNum);
BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision,
groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,cppRevision,txtPath,material_revs);
System.out.println("BOM全document===>"+document.asXML());
if(errMessage.length()>0) {
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
TXTUtil.writeTXT(txtPath, errMessage.toString());
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
// BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, pRevision.getProperty(BomUtilWh.ZT2_WBSNO), session);
new SAPMessageUtilFram("", "BOM传递SAP异常:\n" + errMessage.toString()).show();
win.close();
}else {
//记录产成品的物料编码
// StringBuilder productNosBuild = new StringBuilder("");
// for(TCComponentItem cppItem:cppRevision) {
// String property = cppItem.getLatestItemRevision().getProperty(BomUtilWh.ZT2_MATERIALNO);
// productNosBuild.append(property).append(";");
// }
BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, wbsNo, session);
new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
win.close();
}
@ -274,10 +231,8 @@ public class BomSapWhBjOp extends AbstractAIFOperation {
e.printStackTrace();
} finally {
KUtil.setByPass(false);
SqlUtil.freeAll();
}
}
public String getUserName(TCSession session) throws TCException {
TCComponentUser user = session.getUser();
session.getUserName();

@ -32,7 +32,6 @@ import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.TXTUtil;
import com.squareup.okhttp.Credentials;
import com.squareup.okhttp.MediaType;
@ -74,7 +73,6 @@ public class BomSendSapController {
public List<PartBean> partList = new ArrayList<>();
public BomSendSapWhFram dialog;
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) {
this.app = app;
this.session = (TCSession) app.getSession();
@ -143,16 +141,18 @@ public class BomSendSapController {
released_Yellow.save();
released_Yellow.unlock();
}
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
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"
+ " <soapenv:Header/>\r\n" + " <soapenv:Body>\r\n" + " <urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n" + " </soapenv:Body>\r\n" + "</soapenv:Envelope>";
+ " <soapenv:Header/>\r\n"
+ " <soapenv:Body>\r\n"
+ " <urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </soapenv:Body>\r\n"
+ "</soapenv:Envelope>";
return soapXML;
}
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
@ -176,48 +176,17 @@ public class BomSendSapController {
return rev2;
}
public String getUserName(TCSession session) throws TCException {
TCComponentUser user = session.getUser();
session.getUserName();
return user.getTCProperty("user_name").getDisplayValue();
}
public void sendSap() {
try {
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
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());
MyProgressBarCompent comp = null;
// try {
String txtName = format2.format(new Date()) + getUserName(session);
String txtPath = TXTUtil.createTxt(txtName);
comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
@ -225,10 +194,8 @@ public class BomSendSapController {
StringBuffer sendMessageAll = new StringBuffer("");
//2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
// project.getProperty("zt2_WBSNo");
project.getProperty("zt2_WBSNo");
//产成品BOM组织时除了产成品不同其他相同 BOM结构是一样的
// 记录产成品的物料编码
for(PartBean bean : selectedParts) {
Document document = DocumentHelper.parseText(getXML());
@ -255,9 +222,8 @@ public class BomSendSapController {
List<String> wbsList = new ArrayList<String>();
// 记录物料图纸关系的集合
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
// 2024 1 24 新加字段 UID 和 BATCHNUMBER
BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2, groupName, wbsList, session, now,
needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum);
BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2,
groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,txtPath,material_revs);
System.out.println("BOM全document===>"+document.asXML());
if(errMessage.length()>0) {
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
@ -269,10 +235,7 @@ public class BomSendSapController {
}else {
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
//记录XML信息到CHINT_BOM_TO_SAP_DETIALS
if (flag) {
flag = false;
BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, wbs, session);
}
sendMessageAll.append(SendToSap(txtPath,document.asXML()));
win.close();
}
@ -295,8 +258,6 @@ public class BomSendSapController {
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
SqlUtil.freeAll();
}
}
@ -328,7 +289,7 @@ public class BomSendSapController {
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
//推送SAP
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB");
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl");
String sapUrl = "";
String momUrl = "";
for(String stringValue:stringValues) {
@ -355,7 +316,6 @@ public class BomSendSapController {
// }
return errBuffer;
}
public StringBuffer sendSap(String url,String wsdlString,String txtPath) throws IOException {
StringBuffer errBuffer = new StringBuffer("");
@ -367,16 +327,20 @@ public class BomSendSapController {
client.setReadTimeout(100, TimeUnit.SECONDS);
// Authenticator authenticator = client.setAuthenticator(new Au);
String credential = "";//Credentials.basic("shpodev", "sap@2019");
if (url.contains("192.168.0.184") || url.contains("gfpot01")) {
credential = Credentials.basic("po_rfc", "1qaz!QAZ");
if(url.contains("192.168.0.184")) {
credential = Credentials.basic("shpodev", "sap@2019");
}else {
credential = Credentials.basic("shplm", "sap@2019");
}
MediaType mediaType = MediaType.parse("application/xml");
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
Request request = new Request.Builder().url(url).method("POST", body).header("Authorization", credential)
.addHeader("Content-Type", "application/xml").build();
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.header("Authorization", credential)
.addHeader("Content-Type", "application/xml")
.build();
Response response = client.newCall(request).execute();
Document document = null;
@ -386,26 +350,26 @@ public class BomSendSapController {
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
TXTUtil.writeTXT(txtPath, string);
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
// document = DocumentHelper.parseText(string);
// Element rootElement = document.getRootElement();
// Element bodys = rootElement.element("Body");
// Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
//// String attributeValue = elements.get(0).attributeValue("CODE");
// List<Element> ztable = elements.elements("ZTABLE_RETURN");
// for (Element zret : ztable) {
// String status = zret.elementText("TYPE");
// if (status.equals("E")) {
// String attributeValue = zret.elementText("MESSAGE");
// String MATNR = zret.elementText("MATNR");
// if (MATNR != null) {
// attributeValue = attributeValue + ",在" + MATNR + "BOM中";
// }
//// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
// System.out.println(attributeValue);
// errBuffer.append(attributeValue).append("\n");
// }
// }
} catch (Exception e) {
document = DocumentHelper.parseText(string);
Element rootElement = document.getRootElement();
Element bodys = rootElement.element("Body");
Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
// String attributeValue = elements.get(0).attributeValue("CODE");
List<Element> ztable = elements.elements("ZTABLE_RETURN");
for(Element zret:ztable) {
String status = zret.elementText("TYPE");
if(status.equals("E")) {
String attributeValue = zret.elementText("MESSAGE");
String MATNR = zret.elementText("MATNR");
if(MATNR!=null) {
attributeValue = attributeValue+",ÔÚ"+MATNR+"BOMÖÐ";
}
// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
System.out.println(attributeValue);
errBuffer.append(attributeValue).append("\n");
}
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -415,7 +379,6 @@ public class BomSendSapController {
// new SAPMessageUtil("", "BOM物料异常:\n" + errBuffer.toString());
// }
}
public String sendJsonHttpPost(String url, String xmlContent,String txtPath) {
CloseableHttpClient httpclient = HttpClients.createDefault();
@ -457,9 +420,9 @@ public class BomSendSapController {
}
return responseInfo;
}
public StringBuffer sendMom(String url,String wsdlString,String txtPath) throws IOException {
StringBuffer errBuffer = new StringBuffer("");
if(!url.contains("http")) {
return errBuffer;

@ -77,8 +77,8 @@ public class BomSendSapOp extends AbstractAIFOperation {
client.setReadTimeout(100, TimeUnit.SECONDS);
// Authenticator authenticator = client.setAuthenticator(new Au);
String credential = "";//Credentials.basic("shpodev", "sap@2019");
if(url.contains("192.168.0.184") || url.contains("gfpot01")) {
credential = Credentials.basic("po_rfc", "1qaz!QAZ");
if(url.contains("192.168.0.184")) {
credential = Credentials.basic("shpodev", "sap@2019");
}else {
credential = Credentials.basic("shplm", "sap@2019");
}
@ -100,25 +100,25 @@ public class BomSendSapOp extends AbstractAIFOperation {
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
TXTUtil.writeTXT(txtPath, string);
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
// document = DocumentHelper.parseText(string);
// Element rootElement = document.getRootElement();
// Element bodys = rootElement.element("Body");
// Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
//// String attributeValue = elements.get(0).attributeValue("CODE");
// List<Element> ztable = elements.elements("ZTABLE_RETURN");
// for(Element zret:ztable) {
// String status = zret.elementText("TYPE");
// if(status.equals("E")) {
// String attributeValue = zret.elementText("MESSAGE");
// String MATNR = zret.elementText("MATNR");
// if(MATNR!=null) {
// attributeValue = attributeValue+",ÔÚ"+MATNR+"BOMÖÐ";
// }
// System.out.println(attributeValue);
// errBuffer.append(attributeValue).append("\n");
// }
// }
} catch (Exception e) {
document = DocumentHelper.parseText(string);
Element rootElement = document.getRootElement();
Element bodys = rootElement.element("Body");
Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
// String attributeValue = elements.get(0).attributeValue("CODE");
List<Element> ztable = elements.elements("ZTABLE_RETURN");
for(Element zret:ztable) {
String status = zret.elementText("TYPE");
if(status.equals("E")) {
String attributeValue = zret.elementText("MESSAGE");
String MATNR = zret.elementText("MATNR");
if(MATNR!=null) {
attributeValue = attributeValue+",ÔÚ"+MATNR+"BOMÖÐ";
}
System.out.println(attributeValue);
errBuffer.append(attributeValue).append("\n");
}
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -191,7 +191,7 @@ public class BomSendSapOp extends AbstractAIFOperation {
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
//推送SAP
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB");
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl");
String sapUrl = "";
String momUrl = "";
for(String stringValue:stringValues) {

Loading…
Cancel
Save