From 19054a376b84d4aafa9d4f0a9460a9c547e48ec7 Mon Sep 17 00:00:00 2001
From: 18516761980 <56479841@qq.com>
Date: 星期四, 28 七月 2022 15:23:02 +0800
Subject: [PATCH] #

---
 src/main/java/com/slcf/filter/UpdateThread.java |  763 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 409 insertions(+), 354 deletions(-)

diff --git a/src/main/java/com/slcf/filter/UpdateThread.java b/src/main/java/com/slcf/filter/UpdateThread.java
index 0aa93d5..f3f04c8 100644
--- a/src/main/java/com/slcf/filter/UpdateThread.java
+++ b/src/main/java/com/slcf/filter/UpdateThread.java
@@ -1,16 +1,21 @@
 package com.slcf.filter;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.annotation.Resource;
 
+import com.alibaba.fastjson.JSON;
 import com.slcf.pojo.SapRequestLogBean;
 import com.slcf.service.SapRequestLogService;
+import com.slcf.util.HttpHandler;
 import net.sf.json.JSONString;
 import org.activiti.engine.impl.transformer.IntegerToString;
 import org.apache.log4j.Logger;
@@ -47,11 +52,11 @@
 //	private static WaitPakInServiceImpl waitPakInService;
 	@Autowired
 	SapRequestLogService sapRequestLogService;
-	
+
 	Logger logger=Logger.getLogger(UpdateThread.class);
-	
+
 	public static int count=0;
-	
+
 	private WaitPakInService waitPakInService;
 	public WaitPakInService getWaitPakInService() {
 		return waitPakInService;
@@ -67,23 +72,57 @@
 	public void setWaitPakOutService(WaitPakOutService waitPakOutService) {
 		this.waitPakOutService = waitPakOutService;
 	}
-	
+	public static boolean updateFlag = true;
+
 	public void run() {
 		waitPakInService = getWaitPakInService();
 		waitPakOutService = getWaitPakOutService();
 		while(true) {
 			try {
+				if(!updateFlag) return;
+				updateFlag = false;
+
 				updateWaitPakInData(); // 鍏ュ簱
 				sendPickPrintCmd(); // 鎵撳嵃
 				updateWaitPakOutData(); // 鍑哄簱
+				// 娓呯┖2澶╁墠鐨勬棩蹇�
+				sapRequestLogService.clearSapLog();
 //				updateWaitCheckData();
-				Thread.sleep(5000);
+				Thread.sleep(15000);
 			} catch (InterruptedException e) {
 				e.printStackTrace();
+			} finally {
+				updateFlag = true;
 			}
 		}
 	}
-	
+    public JSONObject requestSAP(JSONObject body, String url) {
+		logger.info(url);
+        JSONObject resp;
+
+            HashMap<String, Object> requestHeader = new HashMap<>();
+            requestHeader.put("Accept", "application/json");
+            requestHeader.put("Content-Type", "application/json");
+            requestHeader.put("X-Requested-With", "X");
+            requestHeader.put("Authorization","Basic TElRSTpzdGFydDEu");
+            requestHeader.put("sap-client","100");
+        String s = null;
+        try {
+            s = new HttpHandler.Builder()
+                    .setUri(url)
+                    .setJson(body.toString())
+					.setTimeout(10, TimeUnit.SECONDS)
+                    .setHeaders(requestHeader)
+                    .build()
+                    .doPost();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        resp = JSONObject.fromObject(s);
+		logger.info("杩斿洖浣擄細" + resp);
+        return resp;
+    }
+
 	/**
 	 * 澶勭悊鍏ュ簱閫氱煡妗f暟鎹�
 	 */
@@ -92,7 +131,7 @@
 //			logger.info("waitIn:" + count++);
 			WaitPakInBean waitPakInBean = waitPakInService.queryWaitPakInFnh();
 			if(waitPakInBean!=null) {
-				String httpUrl = Constants.SAP_URL + "/sap/opu/odata/SAP/Z_WM_H5_SRV/AsrsTrSet";
+				String httpUrl = Constants.SAP_URL + "/sap/opu/odata/SAP/Z_WM_H5_DW_SRV/AsrsTrSet";
 				int result = sendPakInStatus(httpUrl,waitPakInBean);
 			}
 		}catch(Exception e) {
@@ -100,7 +139,7 @@
 //			System.out.println(e.getMessage());
 		}
 	}
-	
+
 	/**
 	 * 鍏ュ簱瀹屾垚锛岃皟鐢╯ap鎺ュ彛涓婁紶瀹屾垚淇℃伅
 	 */
@@ -112,59 +151,59 @@
         String encodedPassword;
         String token="";
         String session_value="";
-        
-        HttpURLConnection connection1 = null;
+
+//        HttpURLConnection connection1 = null;
+//		try {
+//			encodedPassword = base.encode(input.getBytes("UTF-8"));
+//			URL url1 = new URL(httpUrl);
+//	        connection1 = (HttpURLConnection) url1.openConnection();
+//	        connection1.setDoOutput(true);
+//	        connection1.setDoInput(true);
+//	        connection1.setConnectTimeout(30000);
+//	        connection1.setReadTimeout(30000);
+//	        connection1.setRequestMethod("GET");
+//	        connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
+//	        connection1.setRequestProperty("x-csrf-token","Fetch");
+//
+//
+//	        String sessionCookie = connection1.getHeaderField("Set-Cookie");
+//	        if(sessionCookie==null || sessionCookie.length()<1)
+//	        {
+//	        	logger.error("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
+//				// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
+//				SapRequestLogBean logInfo = new SapRequestLogBean();
+//				logInfo.setMatnr(waitPakIn.getMatnr());
+//				logInfo.setRequest("鑾峰彇cookie澶辫触,cookie鍊�:" + sessionCookie);
+//				logInfo.setResponse("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
+//				logInfo.setCreate_time(new Date());
+//				logInfo.setType(2);
+////				sapRequestLogService.addSapLog(logInfo);
+//	        	return result;
+//	        }
+//	        String[] sessionId = sessionCookie.split(";");
+//	        session_value = sessionId[0];
+//	        token = connection1.getHeaderField("x-csrf-token");
+////	        Map<String, List<String>> map = connection1.getHeaderFields();
+////	        token = map.get("x-csrf-token").toString();
+//		} catch (Exception e1) {
+//			logger.error("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛1锛実et璇锋眰鑾峰彇cookie澶辫触銆�" + e1.getMessage());
+//			// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
+//			SapRequestLogBean logInfo = new SapRequestLogBean();
+//			logInfo.setMatnr(waitPakIn.getMatnr());
+//			logInfo.setRequest("鑾峰彇cookie澶辫触");
+//			logInfo.setResponse("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛1锛実et璇锋眰鑾峰彇cookie澶辫触銆�" + e1.getMessage());
+//			logInfo.setCreate_time(new Date());
+//			logInfo.setType(2);
+////			sapRequestLogService.addSapLog(logInfo);
+////			e1.printStackTrace();
+//		}finally {
+//			if(connection1!=null){
+//				connection1.disconnect();
+//			}
+//		}
+
+		JSONObject jsObj = new JSONObject();
 		try {
-			encodedPassword = base.encode(input.getBytes("UTF-8"));
-			URL url1 = new URL(httpUrl);
-	        connection1 = (HttpURLConnection) url1.openConnection();
-	        connection1.setDoOutput(true);
-	        connection1.setDoInput(true);
-	        connection1.setConnectTimeout(30000);
-	        connection1.setReadTimeout(30000);
-	        connection1.setRequestMethod("GET");
-	        connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
-	        connection1.setRequestProperty("x-csrf-token","Fetch");
-	       
-	        
-	        String sessionCookie = connection1.getHeaderField("Set-Cookie");
-	        if(sessionCookie==null || sessionCookie.length()<1)
-	        {
-	        	logger.error("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
-				// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
-				SapRequestLogBean logInfo = new SapRequestLogBean();
-				logInfo.setMatnr(waitPakIn.getMatnr());
-				logInfo.setRequest("鑾峰彇cookie澶辫触,cookie鍊�:" + sessionCookie);
-				logInfo.setResponse("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
-				logInfo.setCreate_time(new Date());
-				logInfo.setType(2);
-				sapRequestLogService.addSapLog(logInfo);
-	        	return result;
-	        }
-	        String[] sessionId = sessionCookie.split(";");
-	        session_value = sessionId[0];
-	        token = connection1.getHeaderField("x-csrf-token");
-//	        Map<String, List<String>> map = connection1.getHeaderFields();
-//	        token = map.get("x-csrf-token").toString();
-		} catch (Exception e1) {
-			logger.error("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛1锛実et璇锋眰鑾峰彇cookie澶辫触銆�" + e1.getMessage());
-			// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
-			SapRequestLogBean logInfo = new SapRequestLogBean();
-			logInfo.setMatnr(waitPakIn.getMatnr());
-			logInfo.setRequest("鑾峰彇cookie澶辫触");
-			logInfo.setResponse("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛1锛実et璇锋眰鑾峰彇cookie澶辫触銆�" + e1.getMessage());
-			logInfo.setCreate_time(new Date());
-			logInfo.setType(2);
-			sapRequestLogService.addSapLog(logInfo);
-//			e1.printStackTrace();
-		}finally {
-			if(connection1!=null){
-				connection1.disconnect();
-			}
-		}
-        
-		try {
-			JSONObject jsObj = new JSONObject();
 			JSONArray arr = new JSONArray();
 			for(int i=0;i<1;i++) {
 				JSONObject json = new JSONObject();
@@ -172,7 +211,7 @@
 				json.put("tbnum",Long.toString(waitPakIn.getTbnum()));
 				json.put("tbpos",Integer.toString(waitPakIn.getTbpos()));
 				json.put("zmatid",waitPakIn.getZmatid());
-				
+
 				json.put("anfme",Double.toString(waitPakIn.getAnfme()));
 				json.put("altme",waitPakIn.getAltme());
 				json.put("nltyp","A01");
@@ -183,55 +222,57 @@
 			jsObj.put("item", arr);
 			byte[] buff = jsObj.toString().getBytes();
 			int buffLen = buff.length;
-			//鍒涘缓杩炴帴
-			HttpURLConnection connection = null;
-	        try {
-//	        	String input = "ZHANGX:654321";
-//	            BASE64Encoder base = new BASE64Encoder();
-//	            String encodedPassword = base.encode(input.getBytes("UTF-8"));
-	            
-	        	URL url = new URL(httpUrl);
-		        connection = (HttpURLConnection) url.openConnection();
-		        connection.setDoOutput(true);
-		        connection.setDoInput(true);
-		        connection.setRequestMethod("POST");
-		        connection.setConnectTimeout(30000);
-		        connection.setReadTimeout(30000);
-//        		connection.setUseCaches(false);            
-//        		connection.setInstanceFollowRedirects(true);
-//		        connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
-		        connection.setRequestProperty("Cookie", session_value);
-		        connection.setRequestProperty("Content-Type","application/json");
-		        connection.setRequestProperty("Accept","application/json");
-		        connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8");
-		        connection.setRequestProperty("Content-Length","" + buffLen);
-//		        connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
-		        connection.setRequestProperty("x-csrf-token",token);
-		        
-		        //POST璇锋眰
-		        OutputStream out = connection.getOutputStream();
-		        out.write(buff);
-				out.close();
-				
-		        //璇诲彇鍝嶅簲
-		        BufferedReader reader = new BufferedReader(new InputStreamReader(
-		                connection.getInputStream()));
-		        String lines;
-		        StringBuffer sb = new StringBuffer("");
-		        while ((lines = reader.readLine()) != null) {
-		            lines = new String(lines.getBytes(), "utf-8");
-		            sb.append(lines);
-		        }
+            JSONObject json = requestSAP(jsObj, httpUrl);
+
+            //鍒涘缓杩炴帴
+//			HttpURLConnection connection = null;
+//	        try {
+////	        	String input = "ZHANGX:654321";
+////	            BASE64Encoder base = new BASE64Encoder();
+////	            String encodedPassword = base.encode(input.getBytes("UTF-8"));
+//
+//	        	URL url = new URL(httpUrl);
+//		        connection = (HttpURLConnection) url.openConnection();
+//		        connection.setDoOutput(true);
+//		        connection.setDoInput(true);
+//		        connection.setRequestMethod("POST");
+//		        connection.setConnectTimeout(30000);
+//		        connection.setReadTimeout(30000);
+////        		connection.setUseCaches(false);
+////        		connection.setInstanceFollowRedirects(true);
+////		        connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
+//		        connection.setRequestProperty("Cookie", session_value);
+//		        connection.setRequestProperty("Content-Type","application/json");
+//		        connection.setRequestProperty("Accept","application/json");
+//		        connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8");
+//		        connection.setRequestProperty("Content-Length","" + buffLen);
+////		        connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
+//		        connection.setRequestProperty("x-csrf-token",token);
+//
+//		        //POST璇锋眰
+//		        OutputStream out = connection.getOutputStream();
+//		        out.write(buff);
+//				out.close();
+//
+//		        //璇诲彇鍝嶅簲
+//		        BufferedReader reader = new BufferedReader(new InputStreamReader(
+//		                connection.getInputStream()));
+//		        String lines;
+//		        StringBuffer sb = new StringBuffer("");
+//		        while ((lines = reader.readLine()) != null) {
+//		            lines = new String(lines.getBytes(), "utf-8");
+//		            sb.append(lines);
+//		        }
 //		        logger.error("SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛岃繑鍥濲SON鏁版嵁锛�" + sb.toString());
 //		        System.out.println(sb.toString());
-		        JSONObject json = JSONObject.fromObject(sb.toString());
+//		        JSONObject json = JSONObject.fromObject(sb.toString());
 				String d = json.get("d").toString();
 				JSONObject jsonD = JSONObject.fromObject(d);
 				String Item = jsonD.get("item").toString();
 				JSONObject jsonItem = JSONObject.fromObject(Item);
 				String results = jsonItem.get("results").toString();
 				JSONArray array = JSONArray.fromObject(results);
-				
+
 				if(array.size()>0) {
 					for(int i=0;i<array.size();i++){
 						JSONObject job = array.getJSONObject(i);
@@ -248,11 +289,11 @@
 							SapRequestLogBean logInfo = new SapRequestLogBean();
 							logInfo.setMatnr(waitPakIn.getMatnr());
 							logInfo.setRequest(jsObj.toString());
-							logInfo.setResponse(sb.toString());
+							logInfo.setResponse(json.toString());
 							logInfo.setCreate_time(new Date());
 							logInfo.setRemark("涓婃灦瀹屾垚鎺ュ彛:" + message);
 							logInfo.setType(1);
-							sapRequestLogService.addSapLog(logInfo);
+//							sapRequestLogService.addSapLog(logInfo);
 //						if(zstatus.equals("s")) {
 							waitPakIn.setIo_status("Y");
 							waitPakInService.upWaitPakIn(waitPakIn);
@@ -262,11 +303,11 @@
 							SapRequestLogBean logInfo = new SapRequestLogBean();
 							logInfo.setMatnr(waitPakIn.getMatnr());
 							logInfo.setRequest(jsObj.toString());
-							logInfo.setResponse(sb.toString());
+							logInfo.setResponse(json.toString());
 							logInfo.setCreate_time(new Date());
 							logInfo.setRemark("涓婃灦瀹屾垚鎺ュ彛:" + message);
 							logInfo.setType(2);
-							sapRequestLogService.addSapLog(logInfo);
+//							sapRequestLogService.addSapLog(logInfo);
 							waitPakIn.setIo_status("X");
 							waitPakIn.setMemo(message);
 							waitPakInService.upWaitPakIn(waitPakIn);
@@ -281,22 +322,35 @@
 				waitPakIn.setMemo(e.getMessage());
 				waitPakInService.upWaitPakIn(waitPakIn);
 	        	logger.error("SAP Error sendPakInStatus--"+waitPakIn.getMatnr()+"---" + e.getMessage());
+				logger.error("1鍏ュ簱瀹屾垚鍥炴姤寮傚父鏃禔SRS璇锋眰JSON锛�" + jsObj.toString());
 //				System.out.println(e.getMessage());
-			}finally {
-				if(connection!=null){
-					connection.disconnect();
-				}
 			}
-		}catch (Exception e) {
-			waitPakIn.setIo_status("X");
-			waitPakIn.setMemo(e.getMessage());
-			waitPakInService.upWaitPakIn(waitPakIn);
-			logger.error("SAP Error sendPakInStatus--"+waitPakIn.getMatnr()+"---" + e.getMessage());
-//			System.out.println(e.getMessage());
-		}
+//		}catch (Exception e) {
+//			waitPakIn.setIo_status("X");
+//			waitPakIn.setMemo(e.getMessage());
+//			waitPakInService.upWaitPakIn(waitPakIn);
+//			logger.error("SAP Error sendPakInStatus--"+waitPakIn.getMatnr()+"---" + e.getMessage());
+//			logger.error("2鍏ュ簱瀹屾垚鍥炴姤寮傚父鏃禔SRS璇锋眰JSON锛�" + jsObj.toString());
+////			System.out.println(e.getMessage());
+//		}
 		return result;
 	}
-	
+
+	/**
+	 * 澶勭悊鍑哄簱閫氱煡妗f暟鎹�
+	 */
+	private void updateWaitPakOutData1() {
+		try {
+//			logger.info("waitOut:" + count++);
+			WaitPakOutBean waitPakOutBean = waitPakOutService.queryWaitPakOutFnh();
+			if(waitPakOutBean!=null) {
+
+			}
+		}catch(Exception e) {
+			logger.error("SAP Error updateWaitPakOutData---" + e.getMessage());
+		}
+	}
+
 	/**
 	 * 澶勭悊鍑哄簱閫氱煡妗f暟鎹�
 	 */
@@ -305,14 +359,14 @@
 //			logger.info("waitOut:" + count++);
 			WaitPakOutBean waitPakOutBean = waitPakOutService.queryWaitPakOutFnh();
 			if(waitPakOutBean!=null) {
-				String httpUrl = Constants.SAP_URL + "/sap/opu/odata/SAP/Z_WM_H5_SRV/ToConHeadSet";
+				String httpUrl = Constants.SAP_URL + "/sap/opu/odata/SAP/Z_WM_H5_DW_SRV/ToConHeadSet";
 				int result = sendPakOutStatus(httpUrl,waitPakOutBean);
 			}
 		}catch(Exception e) {
 			logger.error("SAP Error updateWaitPakOutData---" + e.getMessage());
 		}
 	}
-	
+
 	/**
 	 * 鍑哄簱瀹屾垚锛岃皟鐢╯ap鎺ュ彛涓婁紶瀹屾垚淇℃伅
 	 */
@@ -324,68 +378,70 @@
         String encodedPassword;
         String token="";
         String session_value="";
-        
-        HttpURLConnection connection1 = null;
+
+//        HttpURLConnection connection1 = null;
+//		try {
+//			encodedPassword = base.encode(input.getBytes("UTF-8"));
+//			URL url1 = new URL(httpUrl);
+//	        connection1 = (HttpURLConnection) url1.openConnection();
+//	        connection1.setDoOutput(true);
+//	        connection1.setDoInput(true);
+//	        connection1.setConnectTimeout(30000);
+//	        connection1.setReadTimeout(30000);
+//	        connection1.setRequestMethod("GET");
+//	        connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
+//	        connection1.setRequestProperty("x-csrf-token","Fetch");
+//	        String sessionCookie = connection1.getHeaderField("Set-Cookie");
+//	        if(sessionCookie==null || sessionCookie.length()<1)
+//	        {
+//	        	logger.error("璋冪敤涓嬫灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
+//				// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
+//				SapRequestLogBean logInfo = new SapRequestLogBean();
+//				logInfo.setMatnr(waitPakOut.getMatnr());
+//				logInfo.setRequest("鑾峰彇cookie鍊煎け璐�,cookie锛�" + sessionCookie);
+//				logInfo.setResponse("璋冪敤鍑哄簱瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
+//				logInfo.setCreate_time(new Date());
+//				logInfo.setType(2);
+////				sapRequestLogService.addSapLog(logInfo);
+//	        	return result;
+//	        }
+//	        String[] sessionId = sessionCookie.split(";");
+//	        session_value = sessionId[0];
+//	        token = connection1.getHeaderField("x-csrf-token");
+//
+////	        Map<String, List<String>> map = connection1.getHeaderFields();
+////	        token = map.get("x-csrf-token").toString();
+//		} catch (Exception e1) {
+//			logger.error("璋冪敤涓嬫灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触" + e1.getMessage());
+//			// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
+//			SapRequestLogBean logInfo = new SapRequestLogBean();
+//			logInfo.setMatnr(waitPakOut.getMatnr());
+//			logInfo.setRequest("鑾峰彇cookie澶辫触");
+//			logInfo.setResponse("璋冪敤鍑哄簱瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
+//			logInfo.setCreate_time(new Date());
+//			logInfo.setType(2);
+////			sapRequestLogService.addSapLog(logInfo);
+////			e1.printStackTrace();
+//		}finally{
+//			if(connection1!=null){
+//				connection1.disconnect();
+//			}
+//		}
+
+		logger.info("TEST===>>4");
+
+		JSONObject jsObj = new JSONObject();
 		try {
-			encodedPassword = base.encode(input.getBytes("UTF-8"));
-			URL url1 = new URL(httpUrl);
-	        connection1 = (HttpURLConnection) url1.openConnection();
-	        connection1.setDoOutput(true);
-	        connection1.setDoInput(true);
-	        connection1.setConnectTimeout(30000);
-	        connection1.setReadTimeout(30000);
-	        connection1.setRequestMethod("GET");
-	        connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
-	        connection1.setRequestProperty("x-csrf-token","Fetch");
-	        String sessionCookie = connection1.getHeaderField("Set-Cookie");
-	        if(sessionCookie==null || sessionCookie.length()<1)
-	        {
-	        	logger.error("璋冪敤涓嬫灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
-				// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
-				SapRequestLogBean logInfo = new SapRequestLogBean();
-				logInfo.setMatnr(waitPakOut.getMatnr());
-				logInfo.setRequest("鑾峰彇cookie鍊煎け璐�,cookie锛�" + sessionCookie);
-				logInfo.setResponse("璋冪敤鍑哄簱瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
-				logInfo.setCreate_time(new Date());
-				logInfo.setType(2);
-				sapRequestLogService.addSapLog(logInfo);
-	        	return result;
-	        }
-	        String[] sessionId = sessionCookie.split(";");
-	        session_value = sessionId[0];
-	        token = connection1.getHeaderField("x-csrf-token");
-	        
-//	        Map<String, List<String>> map = connection1.getHeaderFields();
-//	        token = map.get("x-csrf-token").toString();
-		} catch (Exception e1) {
-			logger.error("璋冪敤涓嬫灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触" + e1.getMessage());
-			// SAP INFO-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛屾棩蹇楄褰�
-			SapRequestLogBean logInfo = new SapRequestLogBean();
-			logInfo.setMatnr(waitPakOut.getMatnr());
-			logInfo.setRequest("鑾峰彇cookie澶辫触");
-			logInfo.setResponse("璋冪敤鍑哄簱瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
-			logInfo.setCreate_time(new Date());
-			logInfo.setType(2);
-			sapRequestLogService.addSapLog(logInfo);
-//			e1.printStackTrace();
-		}finally{
-			if(connection1!=null){
-				connection1.disconnect();
-			}
-		}
-        
-		try {
-			JSONObject jsObj = new JSONObject();
 			JSONArray arr = new JSONArray();
 			for(int i=0;i<1;i++) {
 				JSONObject json = new JSONObject();
 				json.put("lgnum",waitPakOut.getLgnum());
 				json.put("tanum",Long.toString(waitPakOut.getTanum()));
 				json.put("tapos",Integer.toString(waitPakOut.getTapos()));
-				
+
 				double nista =  waitPakOut.getNista();
-//				if(nista>0) 				
-				if(nista>=-1 && (int)nista!=0) 
+//				if(nista>0)
+				if(nista>=-1 && (int)nista!=0)
 				{
 					double vsolm = waitPakOut.getVsolm();
 					if( (int)nista == -1 ) {
@@ -410,53 +466,55 @@
 			byte[] buff = jsObj.toString().getBytes();
 			int buffLen = buff.length;
 			//鍒涘缓杩炴帴
-			HttpURLConnection connection = null;
-	        try {
-//	        	String input = "ZHANGX:654321";
-//	            BASE64Encoder base = new BASE64Encoder();
-//	            String encodedPassword = base.encode(input.getBytes("UTF-8"));
-	            
-	        	URL url = new URL(httpUrl);
-		        connection = (HttpURLConnection) url.openConnection();
-		        connection.setDoOutput(true);
-		        connection.setDoInput(true);
-		        connection.setConnectTimeout(30000);
-		        connection.setReadTimeout(30000);
-		        connection.setRequestMethod("POST");
-		//        connection.setUseCaches(false);            
-		//        connection.setInstanceFollowRedirects(true);
-//		        connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
-		        connection.setRequestProperty("Cookie", session_value);
-		        connection.setRequestProperty("Content-Type","application/json");
-		        connection.setRequestProperty("Accept","application/json");
-		        connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8");
-		        connection.setRequestProperty("Content-Length","" + buffLen);
-//		        connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
-		        connection.setRequestProperty("x-csrf-token",token);
-		        
-		        //POST璇锋眰
-		        OutputStream out = connection.getOutputStream();
-		        out.write(buff);
-				out.close();
-				
-		        //璇诲彇鍝嶅簲
-		        BufferedReader reader = new BufferedReader(new InputStreamReader(
-		                connection.getInputStream()));
-		        String lines;
-		        StringBuffer sb = new StringBuffer("");
-		        while ((lines = reader.readLine()) != null) {
-		            lines = new String(lines.getBytes(), "utf-8");
-		            sb.append(lines);
-		        }
+//			HttpURLConnection connection = null;
+//	        try {
+////	        	String input = "ZHANGX:654321";
+////	            BASE64Encoder base = new BASE64Encoder();
+////	            String encodedPassword = base.encode(input.getBytes("UTF-8"));
+//
+//	        	URL url = new URL(httpUrl);
+//		        connection = (HttpURLConnection) url.openConnection();
+//		        connection.setDoOutput(true);
+//		        connection.setDoInput(true);
+//		        connection.setConnectTimeout(30000);
+//		        connection.setReadTimeout(30000);
+//		        connection.setRequestMethod("POST");
+//		//        connection.setUseCaches(false);
+//		//        connection.setInstanceFollowRedirects(true);
+////		        connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
+//		        connection.setRequestProperty("Cookie", session_value);
+//		        connection.setRequestProperty("Content-Type","application/json");
+//		        connection.setRequestProperty("Accept","application/json");
+//		        connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8");
+//		        connection.setRequestProperty("Content-Length","" + buffLen);
+////		        connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
+//		        connection.setRequestProperty("x-csrf-token",token);
+//
+//		        //POST璇锋眰
+//		        OutputStream out = connection.getOutputStream();
+//		        out.write(buff);
+//				out.close();
+//
+//		        //璇诲彇鍝嶅簲
+//		        BufferedReader reader = new BufferedReader(new InputStreamReader(
+//		                connection.getInputStream()));
+//		        String lines;
+//		        StringBuffer sb = new StringBuffer("");
+//		        while ((lines = reader.readLine()) != null) {
+//		            lines = new String(lines.getBytes(), "utf-8");
+//		            sb.append(lines);
+//		        }
 //		        System.out.println(sb.toString());
-		        JSONObject json = JSONObject.fromObject(sb.toString());
+                JSONObject json = requestSAP(jsObj, httpUrl);
+//		        JSONObject json = JSONObject.fromObject(sb.toString());
 				String d = json.get("d").toString();
 				JSONObject jsonD = JSONObject.fromObject(d);
 				String Item = jsonD.get("item").toString();
 				JSONObject jsonItem = JSONObject.fromObject(Item);
 				String results = jsonItem.get("results").toString();
 				JSONArray array = JSONArray.fromObject(results);
-				
+
+				logger.info("鍑哄簱閫氱煡妗AP杩斿洖鏁版嵁闆嗗ぇ灏� ===>> " + array.size());
 				if(array.size()>0) {
 					for(int i=0;i<array.size();i++){
 						JSONObject job = array.getJSONObject(i);
@@ -472,11 +530,11 @@
 							SapRequestLogBean logInfo = new SapRequestLogBean();
 							logInfo.setMatnr(waitPakOut.getMatnr());
 							logInfo.setRequest(jsObj.toString());
-							logInfo.setResponse(sb.toString());
+							logInfo.setResponse(json.toString());
 							logInfo.setCreate_time(new Date());
 							logInfo.setType(1);
 							logInfo.setRemark("鍑哄簱瀹屾垚鎺ュ彛:" + message);
-							sapRequestLogService.addSapLog(logInfo);
+//							sapRequestLogService.addSapLog(logInfo);
 //						if(zstatus.equals("s")) {//涓婃姤SAP鎴愬姛,杞巻鍙叉。
 							waitPakOut.setIo_status("Y");
 							waitPakOutService.upWaitPakOut(waitPakOut,0);
@@ -486,11 +544,11 @@
 							SapRequestLogBean logInfo = new SapRequestLogBean();
 							logInfo.setMatnr(waitPakOut.getMatnr());
 							logInfo.setRequest(jsObj.toString());
-							logInfo.setResponse(sb.toString());
+							logInfo.setResponse(json.toString());
 							logInfo.setCreate_time(new Date());
 							logInfo.setType(2);
 							logInfo.setRemark("鍑哄簱瀹屾垚鎺ュ彛:" + message);
-							sapRequestLogService.addSapLog(logInfo);
+//							sapRequestLogService.addSapLog(logInfo);
 							waitPakOut.setIo_status("X");
 							waitPakOut.setMemo(message);
 							waitPakOutService.upWaitPakOut(waitPakOut,0);
@@ -505,23 +563,21 @@
 	        	waitPakOut.setIo_status("X");
 				waitPakOut.setMemo(e.getMessage());
 				waitPakOutService.upWaitPakOut(waitPakOut,0);
-	        	logger.error("鍑哄簱閫氱煡妗e洖鎶ュ紓甯�--"+waitPakOut.getMatnr() + "---" + e.getMessage());
+	        	logger.error("鍑哄簱閫氱煡妗e洖鎶ュ紓甯�1--"+waitPakOut.getMatnr() + "---" + e.getMessage());
+	        	logger.error("1鍑哄簱瀹屾垚鍥炴姤寮傚父鏃禔SRS璇锋眰JSON锛�" + jsObj.toString());
 //				System.out.println(e.getMessage());
-			}finally{
-				if(connection!=null){
-					connection.disconnect();
-				}
 			}
-		}catch (Exception e) {
-			waitPakOut.setIo_status("X");
-			waitPakOut.setMemo(e.getMessage());
-			waitPakOutService.upWaitPakOut(waitPakOut,0);
-			logger.error("鍑哄簱閫氱煡妗e洖鎶ュ紓甯�--"+waitPakOut.getMatnr() + "---" + e.getMessage());
-//			System.out.println(e.getMessage());
-		}
+//		}catch (Exception e) {
+//			waitPakOut.setIo_status("X");
+//			waitPakOut.setMemo(e.getMessage());
+//			waitPakOutService.upWaitPakOut(waitPakOut,0);
+//			logger.error("鍑哄簱閫氱煡妗e洖鎶ュ紓甯�2--"+waitPakOut.getMatnr() + "---" + e.getMessage());
+//			logger.error("2鍑哄簱瀹屾垚鍥炴姤寮傚父鏃禔SRS璇锋眰JSON锛�" + jsObj.toString());
+////			System.out.println(e.getMessage());
+//		}
 		return result;
 	}
-	
+
 	/**
 	 * 澶勭悊鎵撳嵃鏍囩闇�姹�
 	 */
@@ -529,14 +585,14 @@
 		try {
 			WaitPakOutBean waitPakOutBean = waitPakOutService.getWaitPakOutPrint();
 			if(waitPakOutBean!=null) {
-				String httpUrl = Constants.SAP_URL + "/sap/opu/odata/SAP/Z_WM_H5_SRV/ToConHeadSet";
+				String httpUrl = Constants.SAP_URL + "/sap/opu/odata/SAP/Z_WM_H5_DW_SRV/ToConHeadSet";
 				int result = sendPrinCommand(httpUrl,waitPakOutBean);
 			}
 		}catch(Exception e) {
 			logger.error("SAP Error updateWaitPakOutData---" + e.getMessage());
 		}
 	}
-	
+
 	/**
 	 * 鎷f枡绔欙紝璋冪敤SAP鎵撳嵃鏍囩鎺ュ彛,action=2
 	 */
@@ -548,58 +604,58 @@
         String encodedPassword;
         String token="";
         String session_value="";
-        
-        HttpURLConnection connection1 = null;
+//
+//        HttpURLConnection connection1 = null;
+//		try {
+////			logger.error("sendPrinCommand-----璋冪敤鎵撳嵃鎺ュ彛" + waitPakOut.getMaktx());
+//			encodedPassword = base.encode(input.getBytes("UTF-8"));
+//			URL url1 = new URL(httpUrl);
+//	        connection1 = (HttpURLConnection) url1.openConnection();
+//	        connection1.setDoOutput(true);
+//	        connection1.setDoInput(true);
+//	        connection1.setConnectTimeout(30000);
+//	        connection1.setReadTimeout(30000);
+//	        connection1.setRequestMethod("GET");
+//	        connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
+//	        connection1.setRequestProperty("x-csrf-token","Fetch");
+//	        String sessionCookie = connection1.getHeaderField("Set-Cookie");
+//	        if(sessionCookie==null || sessionCookie.length()<1)
+//	        {
+//	        	logger.error("璋冪敤鎵撳嵃鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
+//	        	// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
+//				SapRequestLogBean logInfo = new SapRequestLogBean();
+//				logInfo.setMatnr(waitPakOut.getMatnr());
+//				logInfo.setRequest("璋冪敤鎵撳嵃鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
+//				logInfo.setResponse(sessionCookie);
+//				logInfo.setCreate_time(new Date());
+//				logInfo.setType(2);
+//				sapRequestLogService.addSapLog(logInfo);
+//	        	return result;
+//	        }
+//	        String[] sessionId = sessionCookie.split(";");
+//	        session_value = sessionId[0];
+//	        token = connection1.getHeaderField("x-csrf-token");
+////	        Map<String, List<String>> map = connection1.getHeaderFields();
+////	        token = map.get("x-csrf-token").toString();
+//		} catch (Exception e1) {
+//			logger.error("sendPrinCommand1-----璋冪敤鎵撳嵃鎺ュ彛璇锋眰cookie澶辫触" + waitPakOut.getMaktx() + e1.getMessage());
+//			// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
+//			SapRequestLogBean logInfo = new SapRequestLogBean();
+//			logInfo.setMatnr(waitPakOut.getMatnr());
+//			logInfo.setRequest("sendPrinCommand1-----璋冪敤鎵撳嵃鎺ュ彛璇锋眰cookie澶辫触"  + waitPakOut.getMaktx());
+//			logInfo.setResponse(e1.getMessage());
+//			logInfo.setCreate_time(new Date());
+//			logInfo.setType(2);
+//			sapRequestLogService.addSapLog(logInfo);
+//			e1.printStackTrace();
+//		}finally{
+//			if(connection1!=null){
+//				connection1.disconnect();
+//			}
+//		}
+
 		try {
-//			logger.error("sendPrinCommand-----璋冪敤鎵撳嵃鎺ュ彛" + waitPakOut.getMaktx());
-			encodedPassword = base.encode(input.getBytes("UTF-8"));
-			URL url1 = new URL(httpUrl);
-	        connection1 = (HttpURLConnection) url1.openConnection();
-	        connection1.setDoOutput(true);
-	        connection1.setDoInput(true);
-	        connection1.setConnectTimeout(30000);
-	        connection1.setReadTimeout(30000);
-	        connection1.setRequestMethod("GET");
-	        connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
-	        connection1.setRequestProperty("x-csrf-token","Fetch");
-	        String sessionCookie = connection1.getHeaderField("Set-Cookie");
-	        if(sessionCookie==null || sessionCookie.length()<1)
-	        {
-	        	logger.error("璋冪敤鎵撳嵃鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
-	        	// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
-				SapRequestLogBean logInfo = new SapRequestLogBean();
-				logInfo.setMatnr(waitPakOut.getMatnr());
-				logInfo.setRequest("璋冪敤鎵撳嵃鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
-				logInfo.setResponse(sessionCookie);
-				logInfo.setCreate_time(new Date());
-				logInfo.setType(2);
-				sapRequestLogService.addSapLog(logInfo);
-	        	return result;
-	        }
-	        String[] sessionId = sessionCookie.split(";");
-	        session_value = sessionId[0];
-	        token = connection1.getHeaderField("x-csrf-token");
-//	        Map<String, List<String>> map = connection1.getHeaderFields();
-//	        token = map.get("x-csrf-token").toString();
-		} catch (Exception e1) {
-			logger.error("sendPrinCommand1-----璋冪敤鎵撳嵃鎺ュ彛璇锋眰cookie澶辫触" + waitPakOut.getMaktx() + e1.getMessage());
-			// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
-			SapRequestLogBean logInfo = new SapRequestLogBean();
-			logInfo.setMatnr(waitPakOut.getMatnr());
-			logInfo.setRequest("sendPrinCommand1-----璋冪敤鎵撳嵃鎺ュ彛璇锋眰cookie澶辫触"  + waitPakOut.getMaktx());
-			logInfo.setResponse(e1.getMessage());
-			logInfo.setCreate_time(new Date());
-			logInfo.setType(2);
-			sapRequestLogService.addSapLog(logInfo);
-			e1.printStackTrace();
-		}finally{
-			if(connection1!=null){
-				connection1.disconnect();
-			}
-		}
-        
-		try {
-//			logger.error("sendPrinCommand2-----寮�濮嬭皟鐢ㄦ墦鍗版帴鍙�" + waitPakOut.getMaktx());
+			logger.error("sendPrinCommand2-----寮�濮嬭皟鐢ㄦ墦鍗版帴鍙�" + waitPakOut.getMatnr() + "--" + waitPakOut.getMaktx());
 			JSONObject jsObj = new JSONObject();
 			JSONArray arr = new JSONArray();
 			for(int i=0;i<1;i++) {
@@ -607,9 +663,9 @@
 				json.put("lgnum",waitPakOut.getLgnum());
 				json.put("tanum",Long.toString(waitPakOut.getTanum()));
 				json.put("tapos",Integer.toString(waitPakOut.getTapos()));
-				
+
 				double nista =  waitPakOut.getNista();
-				if(nista>0) 
+				if(nista>0)
 				{
 					double vsolm = waitPakOut.getVsolm();
 					double ndifa = vsolm - nista;
@@ -627,53 +683,56 @@
 			byte[] buff = jsObj.toString().getBytes();
 			int buffLen = buff.length;
 			//鍒涘缓杩炴帴
-			HttpURLConnection connection = null;
-	        try {
-//	        	String input = "ZHANGX:654321";
-//	            BASE64Encoder base = new BASE64Encoder();
-//	            String encodedPassword = base.encode(input.getBytes("UTF-8"));
-	            
-	        	URL url = new URL(httpUrl);
-		        connection = (HttpURLConnection) url.openConnection();
-		        connection.setDoOutput(true);
-		        connection.setDoInput(true);
-		        connection.setConnectTimeout(30000);
-		        connection.setReadTimeout(30000);
-		        connection.setRequestMethod("POST");
-		//        connection.setUseCaches(false);            
-		//        connection.setInstanceFollowRedirects(true);
-//		        connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
-		        connection.setRequestProperty("Cookie", session_value);
-		        connection.setRequestProperty("Content-Type","application/json");
-		        connection.setRequestProperty("Accept","application/json");
-		        connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8");
-		        connection.setRequestProperty("Content-Length","" + buffLen);
-//		        connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
-		        connection.setRequestProperty("x-csrf-token",token);
-		        
-		        //POST璇锋眰
-		        OutputStream out = connection.getOutputStream();
-		        out.write(buff);
-				out.close();
-//				logger.error("sendPrinCommand3-----璋冪敤鎵撳嵃鎺ュ彛" + waitPakOut.getMaktx());
-		        //璇诲彇鍝嶅簲
-		        BufferedReader reader = new BufferedReader(new InputStreamReader(
-		                connection.getInputStream()));
-		        String lines;
-		        StringBuffer sb = new StringBuffer("");
-		        while ((lines = reader.readLine()) != null) {
-		            lines = new String(lines.getBytes(), "utf-8");
-		            sb.append(lines);
-		        }
-//		        System.out.println(sb.toString());
-		        JSONObject json = JSONObject.fromObject(sb.toString());
+//			HttpURLConnection connection = null;
+//	        try {
+////	        	String input = "ZHANGX:654321";
+////	            BASE64Encoder base = new BASE64Encoder();
+////	            String encodedPassword = base.encode(input.getBytes("UTF-8"));
+//
+//	        	URL url = new URL(httpUrl);
+//		        connection = (HttpURLConnection) url.openConnection();
+//		        connection.setDoOutput(true);
+//		        connection.setDoInput(true);
+//		        connection.setConnectTimeout(30000);
+//		        connection.setReadTimeout(30000);
+//		        connection.setRequestMethod("POST");
+//		//        connection.setUseCaches(false);
+//		//        connection.setInstanceFollowRedirects(true);
+////		        connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
+//		        connection.setRequestProperty("Cookie", session_value);
+//		        connection.setRequestProperty("Content-Type","application/json");
+//		        connection.setRequestProperty("Accept","application/json");
+//		        connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8");
+//		        connection.setRequestProperty("Content-Length","" + buffLen);
+////		        connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
+//		        connection.setRequestProperty("x-csrf-token",token);
+//
+//		        //POST璇锋眰
+//		        OutputStream out = connection.getOutputStream();
+//		        out.write(buff);
+//				out.close();
+////				logger.error("sendPrinCommand3-----璋冪敤鎵撳嵃鎺ュ彛" + waitPakOut.getMaktx());
+//		        //璇诲彇鍝嶅簲
+//		        BufferedReader reader = new BufferedReader(new InputStreamReader(
+//		                connection.getInputStream()));
+//		        String lines;
+//		        StringBuffer sb = new StringBuffer("");
+//		        while ((lines = reader.readLine()) != null) {
+//		            lines = new String(lines.getBytes(), "utf-8");
+//		            sb.append(lines);
+//		        }
+////		        System.out.println(sb.toString());
+//		        JSONObject json = JSONObject.fromObject(sb.toString());
+				logger.error("sendPrinCommand4-----璋冪敤鎵撳嵃鎺ュ彛" + waitPakOut.getTanum() + "==" + waitPakOut.getMatnr() + "==" + waitPakOut.getMaktx());
+                JSONObject json = requestSAP(jsObj, httpUrl);
+
 				String d = json.get("d").toString();
 				JSONObject jsonD = JSONObject.fromObject(d);
 				String Item = jsonD.get("item").toString();
 				JSONObject jsonItem = JSONObject.fromObject(Item);
 				String results = jsonItem.get("results").toString();
 				JSONArray array = JSONArray.fromObject(results);
-				logger.error("sendPrinCommand4-----璋冪敤鎵撳嵃鎺ュ彛" + waitPakOut.getMaktx());
+
 				if(array.size()>0) {
 					for(int i=0;i<array.size();i++){
 						JSONObject job = array.getJSONObject(i);
@@ -690,12 +749,12 @@
 							waitPakOut.setPrnstatus(2);  //鎵撳嵃瀹屾垚
 							waitPakOutService.upWaitPakOut(waitPakOut,0);
 							logger.error("sendPrinCommand5---璋冪敤鎵撳嵃鎺ュ彛鎴愬姛锛岃姹俲son鏁版嵁--" + jsObj.toString());
-							logger.info("sendPrinCommand5---璋冪敤鎵撳嵃鎺ュ彛鎴愬姛锛岃繑鍥瀓son鏁版嵁--" + sb.toString());
+							logger.info("sendPrinCommand5---璋冪敤鎵撳嵃鎺ュ彛鎴愬姛锛岃繑鍥瀓son鏁版嵁--" + json.toString());
 							// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
 							SapRequestLogBean logInfo = new SapRequestLogBean();
 							logInfo.setMatnr(waitPakOut.getMatnr());
 							logInfo.setRequest(jsObj.toString());
-							logInfo.setResponse(sb.toString());
+							logInfo.setResponse(json.toString());
 							logInfo.setCreate_time(new Date());
 							logInfo.setRemark(message);
 							logInfo.setType(1);
@@ -709,7 +768,7 @@
 							SapRequestLogBean logInfo = new SapRequestLogBean();
 							logInfo.setMatnr(waitPakOut.getMatnr());
 							logInfo.setRequest(jsObj.toString());
-							logInfo.setResponse(sb.toString());
+							logInfo.setResponse(json.toString());
 							logInfo.setCreate_time(new Date());
 							logInfo.setRemark(message);
 							logInfo.setType(2);
@@ -726,37 +785,33 @@
 				// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
 				SapRequestLogBean logInfo = new SapRequestLogBean();
 				logInfo.setMatnr(waitPakOut.getMatnr());
-				logInfo.setRequest(jsObj.toString());
+//				logInfo.setRequest(jsObj.toString());
 				logInfo.setResponse("sendPrinCommand7---璋冪敤鎵撳嵃鎺ュ彛鍥炴姤寮傚父--"+waitPakOut.getMatnr() + "---");
 				logInfo.setCreate_time(new Date());
 				logInfo.setRemark(e.getMessage());
 				logInfo.setType(2);
 				sapRequestLogService.addSapLog(logInfo);
 //				System.out.println(e.getMessage());
-			}finally{
-				if(connection!=null){
-					connection.disconnect();
-				}
 			}
-		}catch (Exception e) {
-			waitPakOut.setPrnstatus(3); 	//鎵撳嵃澶辫触
-			waitPakOut.setMemo(e.getMessage());
-			waitPakOutService.upWaitPakOut(waitPakOut,0);
-			logger.error("sendPrinCommand8---璋冪敤鎵撳嵃鎺ュ彛鍥炴姤寮傚父--"+waitPakOut.getMatnr() + "---" + e.getMessage());
-			// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
-			SapRequestLogBean logInfo = new SapRequestLogBean();
-			logInfo.setMatnr(waitPakOut.getMatnr());
-			logInfo.setRequest("鎵撳嵃璇锋眰澶辫触");
-			logInfo.setResponse("sendPrinCommand8---璋冪敤鎵撳嵃鎺ュ彛鍥炴姤寮傚父--"+waitPakOut.getMatnr() + "---");
-			logInfo.setCreate_time(new Date());
-			logInfo.setRemark(e.getMessage());
-			logInfo.setType(2);
-			sapRequestLogService.addSapLog(logInfo);
-//			System.out.println(e.getMessage());
-		}
+//		}catch (Exception e) {
+//			waitPakOut.setPrnstatus(3); 	//鎵撳嵃澶辫触
+//			waitPakOut.setMemo(e.getMessage());
+//			waitPakOutService.upWaitPakOut(waitPakOut,0);
+//			logger.error("sendPrinCommand8---璋冪敤鎵撳嵃鎺ュ彛鍥炴姤寮傚父--"+waitPakOut.getMatnr() + "---" + e.getMessage());
+//			// 璋冪敤sap鎵撳嵃鎺ュ彛,璁板綍鏃ュ織
+//			SapRequestLogBean logInfo = new SapRequestLogBean();
+//			logInfo.setMatnr(waitPakOut.getMatnr());
+//			logInfo.setRequest("鎵撳嵃璇锋眰澶辫触");
+//			logInfo.setResponse("sendPrinCommand8---璋冪敤鎵撳嵃鎺ュ彛鍥炴姤寮傚父--"+waitPakOut.getMatnr() + "---");
+//			logInfo.setCreate_time(new Date());
+//			logInfo.setRemark(e.getMessage());
+//			logInfo.setType(2);
+//			sapRequestLogService.addSapLog(logInfo);
+////			System.out.println(e.getMessage());
+//		}
 		return result;
 	}
-	
+
 	/**
 	 * 澶勭悊鐩樼偣閫氱煡妗f暟鎹�
 	 */
@@ -764,10 +819,10 @@
 		try {
 //			logger.info("waitCheck:" + count++);
 		}catch(Exception e) {
-			
+
 		}
 	}
-	
+
 	public static void main(String[] args) {
 		UpdateThread Thread1=new UpdateThread();
 		Thread mThread1=new Thread(Thread1,"绾跨▼1");

--
Gitblit v1.9.1