From f25c800bca726b67ea74e6ed576b038b1b9561a7 Mon Sep 17 00:00:00 2001
From: 18516761980 <4761516tqsxp>
Date: 星期一, 16 八月 2021 08:22:57 +0800
Subject: [PATCH] #
---
src/main/java/com/slcf/filter/UpdateThread.java | 101 ++++++++++++++++++++++++++------------------------
1 files changed, 52 insertions(+), 49 deletions(-)
diff --git a/src/main/java/com/slcf/filter/UpdateThread.java b/src/main/java/com/slcf/filter/UpdateThread.java
index 0aa93d5..dc86fc9 100644
--- a/src/main/java/com/slcf/filter/UpdateThread.java
+++ b/src/main/java/com/slcf/filter/UpdateThread.java
@@ -47,11 +47,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,7 +67,7 @@
public void setWaitPakOutService(WaitPakOutService waitPakOutService) {
this.waitPakOutService = waitPakOutService;
}
-
+
public void run() {
waitPakInService = getWaitPakInService();
waitPakOutService = getWaitPakOutService();
@@ -76,6 +76,8 @@
updateWaitPakInData(); // 鍏ュ簱
sendPickPrintCmd(); // 鎵撳嵃
updateWaitPakOutData(); // 鍑哄簱
+ // 娓呯┖2澶╁墠鐨勬棩蹇�
+ sapRequestLogService.clearSapLog();
// updateWaitCheckData();
Thread.sleep(5000);
} catch (InterruptedException e) {
@@ -83,7 +85,7 @@
}
}
}
-
+
/**
* 澶勭悊鍏ュ簱閫氱煡妗f暟鎹�
*/
@@ -100,7 +102,7 @@
// System.out.println(e.getMessage());
}
}
-
+
/**
* 鍏ュ簱瀹屾垚锛岃皟鐢╯ap鎺ュ彛涓婁紶瀹屾垚淇℃伅
*/
@@ -112,7 +114,7 @@
String encodedPassword;
String token="";
String session_value="";
-
+
HttpURLConnection connection1 = null;
try {
encodedPassword = base.encode(input.getBytes("UTF-8"));
@@ -125,8 +127,8 @@
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)
{
@@ -138,7 +140,7 @@
logInfo.setResponse("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
logInfo.setCreate_time(new Date());
logInfo.setType(2);
- sapRequestLogService.addSapLog(logInfo);
+// sapRequestLogService.addSapLog(logInfo);
return result;
}
String[] sessionId = sessionCookie.split(";");
@@ -155,14 +157,14 @@
logInfo.setResponse("SAP ERROR-----璋冪敤涓婃灦瀹屾垚鎺ュ彛1锛実et璇锋眰鑾峰彇cookie澶辫触銆�" + e1.getMessage());
logInfo.setCreate_time(new Date());
logInfo.setType(2);
- sapRequestLogService.addSapLog(logInfo);
+// sapRequestLogService.addSapLog(logInfo);
// e1.printStackTrace();
}finally {
if(connection1!=null){
connection1.disconnect();
}
}
-
+
try {
JSONObject jsObj = new JSONObject();
JSONArray arr = new JSONArray();
@@ -172,7 +174,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");
@@ -189,7 +191,7 @@
// 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);
@@ -197,7 +199,7 @@
connection.setRequestMethod("POST");
connection.setConnectTimeout(30000);
connection.setReadTimeout(30000);
-// connection.setUseCaches(false);
+// connection.setUseCaches(false);
// connection.setInstanceFollowRedirects(true);
// connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
connection.setRequestProperty("Cookie", session_value);
@@ -207,12 +209,12 @@
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()));
@@ -231,7 +233,7 @@
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);
@@ -252,7 +254,7 @@
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);
@@ -266,7 +268,7 @@
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);
@@ -296,7 +298,7 @@
}
return result;
}
-
+
/**
* 澶勭悊鍑哄簱閫氱煡妗f暟鎹�
*/
@@ -312,7 +314,7 @@
logger.error("SAP Error updateWaitPakOutData---" + e.getMessage());
}
}
-
+
/**
* 鍑哄簱瀹屾垚锛岃皟鐢╯ap鎺ュ彛涓婁紶瀹屾垚淇℃伅
*/
@@ -324,7 +326,7 @@
String encodedPassword;
String token="";
String session_value="";
-
+
HttpURLConnection connection1 = null;
try {
encodedPassword = base.encode(input.getBytes("UTF-8"));
@@ -348,13 +350,13 @@
logInfo.setResponse("璋冪敤鍑哄簱瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
logInfo.setCreate_time(new Date());
logInfo.setType(2);
- sapRequestLogService.addSapLog(logInfo);
+// 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) {
@@ -366,14 +368,14 @@
logInfo.setResponse("璋冪敤鍑哄簱瀹屾垚鎺ュ彛锛実et璇锋眰鑾峰彇cookie澶辫触");
logInfo.setCreate_time(new Date());
logInfo.setType(2);
- sapRequestLogService.addSapLog(logInfo);
+// sapRequestLogService.addSapLog(logInfo);
// e1.printStackTrace();
}finally{
if(connection1!=null){
connection1.disconnect();
}
}
-
+
try {
JSONObject jsObj = new JSONObject();
JSONArray arr = new JSONArray();
@@ -382,10 +384,10 @@
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 ) {
@@ -415,7 +417,7 @@
// 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);
@@ -423,7 +425,7 @@
connection.setConnectTimeout(30000);
connection.setReadTimeout(30000);
connection.setRequestMethod("POST");
- // connection.setUseCaches(false);
+ // connection.setUseCaches(false);
// connection.setInstanceFollowRedirects(true);
// connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
connection.setRequestProperty("Cookie", session_value);
@@ -433,12 +435,12 @@
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()));
@@ -456,7 +458,8 @@
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);
@@ -476,7 +479,7 @@
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);
@@ -490,7 +493,7 @@
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);
@@ -521,7 +524,7 @@
}
return result;
}
-
+
/**
* 澶勭悊鎵撳嵃鏍囩闇�姹�
*/
@@ -536,7 +539,7 @@
logger.error("SAP Error updateWaitPakOutData---" + e.getMessage());
}
}
-
+
/**
* 鎷f枡绔欙紝璋冪敤SAP鎵撳嵃鏍囩鎺ュ彛,action=2
*/
@@ -548,7 +551,7 @@
String encodedPassword;
String token="";
String session_value="";
-
+
HttpURLConnection connection1 = null;
try {
// logger.error("sendPrinCommand-----璋冪敤鎵撳嵃鎺ュ彛" + waitPakOut.getMaktx());
@@ -597,7 +600,7 @@
connection1.disconnect();
}
}
-
+
try {
// logger.error("sendPrinCommand2-----寮�濮嬭皟鐢ㄦ墦鍗版帴鍙�" + waitPakOut.getMaktx());
JSONObject jsObj = new JSONObject();
@@ -607,9 +610,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;
@@ -632,7 +635,7 @@
// 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);
@@ -640,7 +643,7 @@
connection.setConnectTimeout(30000);
connection.setReadTimeout(30000);
connection.setRequestMethod("POST");
- // connection.setUseCaches(false);
+ // connection.setUseCaches(false);
// connection.setInstanceFollowRedirects(true);
// connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
connection.setRequestProperty("Cookie", session_value);
@@ -650,7 +653,7 @@
connection.setRequestProperty("Content-Length","" + buffLen);
// connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
connection.setRequestProperty("x-csrf-token",token);
-
+
//POST璇锋眰
OutputStream out = connection.getOutputStream();
out.write(buff);
@@ -756,7 +759,7 @@
}
return result;
}
-
+
/**
* 澶勭悊鐩樼偣閫氱煡妗f暟鎹�
*/
@@ -764,10 +767,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