From 01cb633562174ae7390d12b85690a45997f34be7 Mon Sep 17 00:00:00 2001 From: yyt <306727702@qq.com> Date: 星期三, 24 一月 2024 11:17:20 +0800 Subject: [PATCH] 更新OPCUA --- jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java | 69 ++++++++++++++++++++++++++++------ 1 files changed, 57 insertions(+), 12 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java b/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java index d5c02be..7bcd85e 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java +++ b/jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java @@ -2,6 +2,9 @@ import cn.hutool.json.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; @@ -40,16 +43,28 @@ // test1(); // String serviceUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_MES_005_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; -// +// String serviceUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_BC_001_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; +//// String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + +//// " <soapenv:Header/>\n" + +//// " <soapenv:Body>\n" + +//// " <urn:ZPP_CF_MES_005>\n" + +//// " <!--Optional:-->\n" + +//// " <IV_WERKS>1000</IV_WERKS>\n" + +//// " <!--Optional:-->\n" + +//// " <IV_ZSCTZD>A0055577</IV_ZSCTZD>\n" + +//// " </urn:ZPP_CF_MES_005>\n" + +//// " </soapenv:Body>\n" + +//// "</soapenv:Envelope>"; // String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + // " <soapenv:Header/>\n" + // " <soapenv:Body>\n" + -// " <urn:ZPP_CF_MES_005>\n" + -// " <!--Optional:-->\n" + -// " <IV_WERKS>1000</IV_WERKS>\n" + -// " <!--Optional:-->\n" + -// " <IV_ZSCTZD>A0055577</IV_ZSCTZD>\n" + -// " </urn:ZPP_CF_MES_005>\n" + +// " <urn:ZPP_BC_001>\n" + +// " <IV_AUFNR>000010569212</IV_AUFNR>\n" + +// " <IV_VORNR>0010</IV_VORNR>\n" + +// " <IV_LMNGA>1</IV_LMNGA>\n" + +// " <IV_XMNGA>0</IV_XMNGA> \n" + +// " <IV_STATU>1</IV_STATU> \n" + +// " </urn:ZPP_BC_001>\n" + // " </soapenv:Body>\n" + // "</soapenv:Envelope>"; // // HttpClient鍙戦�丼OAP璇锋眰 @@ -79,10 +94,10 @@ // InputStream is = postMethod.getResponseBodyAsStream(); // // 鑾峰彇璇锋眰缁撴灉瀛楃涓� // String result = IOUtils.toString(is); -// String jsonStr = xmlToJSON2(result); -// Gson gson = new Gson(); -// // 灏唈son瀛楃涓茶浆鎹㈡垚瀵硅薄 -// ItemList itemList = gson.fromJson(jsonStr, ItemList.class); +//// String jsonStr = xmlToJSON2(result); +//// Gson gson = new Gson(); +//// // 灏唈son瀛楃涓茶浆鎹㈡垚瀵硅薄 +//// ItemList itemList = gson.fromJson(jsonStr, ItemList.class); // System.out.println("杩斿洖缁撴灉:" + result); // } else { // System.out.println("閿欒浠g爜锛�" + status + ":" + postMethod.getResponseBodyAsString()); @@ -97,11 +112,12 @@ ItemList itemList = gson.fromJson(jsonStr, ItemList.class); for (Item item : itemList.getItem()) { OmProductionOrdeInfo ordeInfo = new OmProductionOrdeInfo(); + ordeInfo.setProductCode(item.getPLNBEZ()); ordeInfo.setProductName(item.getMAKTX()); ordeInfo.setLineCode(item.getFEVOR()); ordeInfo.setWorkOrderNo(item.getAUFNR()); ordeInfo.setPlanQty((long) Double.parseDouble(item.getPSMNG())); - ordeInfo.setProductionNotice(item.getZSTAT()); + ordeInfo.setProductionNotice(item.getZSCTZD()); ordeInfo.setTypeZ(item.getFERTH()); ordeInfo.setCreateUser(item.getZUSER()); ordeInfo.setCreateTime(item.getZDATE()); @@ -194,4 +210,33 @@ return etData.toString(); } + /** + * 鏂瑰紡--璐� + * 浣跨敤hutool宸ュ叿鍖呬腑鐨勫伐鍏疯浆鍖� + * @param xmlStr + * @return + */ + public static String xmlToJSON3(String xmlStr){ + String status = ""; + if(xmlStr.contains("EV_STATUS")){ + JSONObject jsonObject1 = cn.hutool.json.XML.toJSONObject(xmlStr, true); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode rootNode = null; + try { + rootNode = objectMapper.readTree(String.valueOf(jsonObject1)); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + String evStatus = rootNode + .path("SOAP:Envelope") + .path("SOAP:Body") + .path("n0:ZPP_BC_001.Response") + .path("EV_STATUS") + .asText(); + status = evStatus; + } + return status; + } + } -- Gitblit v1.9.3