From 9906e6b188bf2c36dddc0d5adadbf02e69ea3e4b Mon Sep 17 00:00:00 2001
From: wujian <14790700720@163.com>
Date: 星期五, 25 十月 2024 09:17:29 +0800
Subject: [PATCH] add -sap

---
 jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java |   55 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 37 insertions(+), 18 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 e286019..abd05b1 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
@@ -25,16 +25,19 @@
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.io.IOUtils;
 import com.jcdm.main.om.productionOrde.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.swing.border.Border;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 public class ReceivingServices {
+
+    private static final Logger logger = LoggerFactory.getLogger("sys-user");
     @Autowired
 //    private static IOmProductionOrdeInfoService omProductionOrdeInfoService;
     private static IOmProductionOrdeInfoService omProductionOrdeInfoService = BeanUtils.getBean(IOmProductionOrdeInfoService.class);
@@ -110,18 +113,25 @@
     
     public static void insertWebserviceData(String factory,String str) {
         String result = getInterfaceInformationXml(ProductionPlanInformationUrl, getProductionPlanInformationXml(factory,str));
+        logger.info("messageLocation1,"+result);
         String jsonStr = xmlToJSON2(result);
+        logger.info("messageLocation5,"+jsonStr);
         if (StrUtil.isNotBlank(jsonStr)){
             if (!jsonStr.contains("[") && !jsonStr.contains("]")){
                 StringBuilder stringBuilder = new StringBuilder(jsonStr);
                 stringBuilder.insert(8,"[");
                 stringBuilder.insert(jsonStr.length(),"]");
                 jsonStr = stringBuilder.toString();
+                logger.info("messageLocation6,"+jsonStr);
             }
             Gson gson = new Gson();
             // 灏唈son瀛楃涓茶浆鎹㈡垚瀵硅薄
             ItemList itemList = gson.fromJson(jsonStr, ItemList.class);
+            if (ObjectUtil.isNotNull(itemList)){
+                logger.info("messageLocation7,"+ itemList);
+            }
             for (Item item : itemList.getItem()) {
+                logger.info("messageLocation8,"+item);
                 OmProductionOrdeInfo ordeInfo = new OmProductionOrdeInfo();
                 ordeInfo.setWorkshopCode(item.getWERKS());
                 ordeInfo.setProductCode(item.getPLNBEZ());
@@ -165,28 +175,26 @@
         }
 
         // 璁剧疆璇锋眰澶撮儴锛屽惁鍒欏彲鑳戒細鎶� 鈥渘o SOAPAction header鈥� 鐨勯敊璇�
-        postMethod.setRequestHeader("SOAPAction", "");
+        postMethod.setRequestHeader("SOAPAction", "application/x-www-form-urlencoded; charset=UTF-8");
         // 璁剧疆璇锋眰浣�
         postMethod.setRequestEntity(requestEntity);
         int status = 0;
         try {
             status = client.executeMethod(postMethod);
         } catch (IOException e) {
+            logger.info("errorLocation1,"+e);
             throw new RuntimeException(e);
         }
         if (status == 200) {// 鎴愬姛
             InputStream is = null;
-            try {
-                is = postMethod.getResponseBodyAsStream();
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            }
             // 鑾峰彇璇锋眰缁撴灉瀛楃涓�
             String result = null;
             try {
-                result = IOUtils.toString(is);
+                result = postMethod.getResponseBodyAsString();
+                logger.info("浜屾杈撳嚭娴�333333,{}",result);
                 return result;
             } catch (IOException e) {
+                logger.info("errorLocation2,"+e);
                 throw new RuntimeException(e);
             }
         }
@@ -224,15 +232,26 @@
                 .getAsJsonObject("SOAP:Body")
                 .getAsJsonObject("n0:ZPP_CF_MES_005.Response");
         if (ObjectUtil.isNotNull(result)){
+            logger.info("messageLocation2,"+result);
             String string = result.get("EV_MESSAGE").toString();
-            if (string.contains("鏌ヨ鎴愬姛")){
-                JsonObject etData = jsonObject2
-                        .getAsJsonObject("SOAP:Envelope")
-                        .getAsJsonObject("SOAP:Body")
-                        .getAsJsonObject("n0:ZPP_CF_MES_005.Response")
-                        .getAsJsonObject("ET_DATA");
-                data = etData.toString();
-            }
+//            if (string.contains("鏌ヨ鎴愬姛")){
+//                logger.info("messageLocation3,"+string);
+//                JsonObject etData = jsonObject2
+//                        .getAsJsonObject("SOAP:Envelope")
+//                        .getAsJsonObject("SOAP:Body")
+//                        .getAsJsonObject("n0:ZPP_CF_MES_005.Response")
+//                        .getAsJsonObject("ET_DATA");
+//                data = etData.toString();
+//                logger.info("messageLocation4,"+data);
+//            }
+            logger.info("messageLocation3,"+string);
+            JsonObject etData = jsonObject2
+                    .getAsJsonObject("SOAP:Envelope")
+                    .getAsJsonObject("SOAP:Body")
+                    .getAsJsonObject("n0:ZPP_CF_MES_005.Response")
+                    .getAsJsonObject("ET_DATA");
+            data = etData.toString();
+            logger.info("messageLocation4,"+data);
         }
 
         return data;

--
Gitblit v1.9.3