From aabdaf234ddfe22b0a7d320775d2faf42141aaa5 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期二, 20 五月 2025 08:19:09 +0800
Subject: [PATCH] Merge branch 'master' of http://159.223.171.199:10439/r/Haier_MES_II
---
/dev/null | 142 -----------------------------------
nglib/src/ng/devices/HexUtil.java | 42 +++++-----
nglib/.idea/encodings.xml | 4
nglib/src/builder/S7objectMachine.java | 1
nglib/src/ng/devices/MysqlService.java | 6
nglib/.classpath | 20 ++--
6 files changed, 39 insertions(+), 176 deletions(-)
diff --git a/nglib/.classpath b/nglib/.classpath
index 98f106f..c7eb922 100644
--- a/nglib/.classpath
+++ b/nglib/.classpath
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
- <classpathentry kind="lib" path="C:/Users/a'a'a/Desktop/Mes椤圭洰/repository/org/json/json/20080701/json-20080701.jar"/>
- <classpathentry kind="lib" path="D:/zyz/web_optima/GERP/WebContent/WEB-INF/lib/mysql-connector-java-8.0.20.jar"/>
+ <classpathentry kind="src" path="src" charset="UTF-8"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" charset="UTF-8"/>
+ <classpathentry kind="lib" path="C:/Users/a'a'a/Desktop/Mes椤圭洰/repository/org/json/json/20080701/json-20080701.jar" charset="UTF-8"/>
+ <classpathentry kind="lib" path="D:/zyz/web_optima/GERP/WebContent/WEB-INF/lib/mysql-connector-java-8.0.20.jar" charset="UTF-8"/>
<classpathentry kind="lib" path="D:/zyz/web_optima/GERP/WebContent/WEB-INF/lib/jacob.jar"/>
- <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/iot-communication-1.4.2.jar"/>
- <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/jul-to-slf4j-1.7.28.jar"/>
- <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/logback-classic-1.2.3.jar"/>
- <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/logback-core-1.2.3.jar"/>
- <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/slf4j-api-1.7.28.jar"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/iot-communication-1.4.2.jar" charset="UTF-8" />
+ <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/jul-to-slf4j-1.7.28.jar" charset="UTF-8"/>
+ <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/logback-classic-1.2.3.jar" charset="UTF-8"/>
+ <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/logback-core-1.2.3.jar"charset="UTF-8" />
+ <classpathentry kind="lib" path="E:/HuaweiMoveData/Users/SNG-010/Desktop/娴峰皵浜屾湡/slf4j-api-1.7.28.jar" charset="UTF-8" />
+ <classpathentry kind="output" path="bin" charset="UTF-8"/>
</classpath>
diff --git a/nglib/.idea/encodings.xml b/nglib/.idea/encodings.xml
index b858a91..b7072ea 100644
--- a/nglib/.idea/encodings.xml
+++ b/nglib/.idea/encodings.xml
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="Encoding">
+ <component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
+ <file url="file://$PROJECT_DIR$/src/builder/HttpApi.java" charset="GBK" />
+ <file url="file://$PROJECT_DIR$/src/builder/HttpApi2.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/src/builder/HttpHandlerDemo.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/src/builder/MachineManager.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/src/builder/Manager.java" charset="GBK" />
diff --git a/nglib/src/builder/S7objectMachine.java b/nglib/src/builder/S7objectMachine.java
index cb72023..730a2e1 100644
--- a/nglib/src/builder/S7objectMachine.java
+++ b/nglib/src/builder/S7objectMachine.java
@@ -46,6 +46,7 @@
logInfo+=key+":"+thisPlcParameterInfo.get(key).getValue()+",";
}
}
+
@Override
public void run() {
while (this != null) {
diff --git a/nglib/src/builder/httpApi.java b/nglib/src/builder/httpApi.java
deleted file mode 100644
index f0189bc..0000000
--- a/nglib/src/builder/httpApi.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package builder;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-public class httpApi {
-
- public static String Ip="localhost";
- public static void main(String[] args) {
-
-
- JSONObject jsonObject=new JSONObject();
- jsonObject.put("thickness", "5");
- jsonObject.put("width", "3660");
- jsonObject.put("height", "2440");
- jsonObject.put("sameCount", "2");
- jsonObject.put("glassType", "瓒呯櫧鐜�");
- sendShelfTask(jsonObject);
- JSONObject a=selectLoadRack();
- double width=Double.valueOf(a.get("width").toString());
- double height=Double.valueOf(a.get("height").toString());
- double thickness=Double.valueOf(a.get("thickness").toString());
- int sameCount=Integer.valueOf(a.get("sameCount").toString());
- System.out.println(width+","+height+","+thickness+","+sameCount);
-
- }
- //鍙戦�佷粨鍌ㄦ墍闇�鐜荤拑浠诲姟
- public static JSONObject sendShelfTask(JSONObject params){
- try {
- String requestURL="http://"+Ip+":5000/GlassInfo";
- String requestBody = params.toString();
- JSONObject resultJSON= httpApi(requestURL,"POST",requestBody);
- return resultJSON;
- } catch (Exception e) {
- // TODO: handle exception
- System.out.println("HTTP ERROR:http://39.105.110.179:5000/GlassInfo POST");
- }
- return null;
- }
- //MES鏄惁姝e父杩炴帴
- public static JSONObject sendShelfTask(){
- try {
- String requestURL="http://"+Ip+":5000/GlassInfo";
- JSONObject resultJSON= httpApi(requestURL,"GET",null);
- return resultJSON;
- } catch (Exception e) {
- // TODO: handle exception
- System.out.println("HTTP ERROR:http://39.105.110.179:5000/GlassInfo GET");
- }
- return null;
- }
- //鏌ヨ涓婄墖浣嶄俊鎭�
- public static JSONObject selectLoadRack(){
- try {
- String requestURL="http://"+Ip+":5000/GlassInfo/getReady";
- JSONObject resultJSON= httpApi(requestURL,"GET",null);
- JSONObject loadRack=resultJSON.getJSONObject("data").getJSONArray("stocklist").getJSONObject(0);
- return loadRack;
- } catch (Exception e) {
- // TODO: handle exception
- System.out.println("HTTP ERROR:http://"+Ip+":5000/GlassInfo GET");
- }
- return null;
- }
- //鍙嶉涓婄墖浣嶄俊鎭�-1
- public static JSONObject loadRackReduction(){
- try {
- String requestURL="http://"+Ip+":5000/GlassInfo/finishGet";
- JSONObject resultJSON= httpApi(requestURL,"GET",null);
- return resultJSON;
- } catch (Exception e) {
- // TODO: handle exception
- System.out.println("HTTP ERROR:http://"+Ip+":5000/GlassInfo/finishGet GET");
- }
- return null;
- }
- //鏌ヨ浠撳偍搴撳唴淇℃伅
- public static JSONObject storageRackInfo(){
- try {
- String requestURL="http://"+Ip+":5000/GlassInfo";
- JSONObject resultJSON= httpApi(requestURL,"GET",null);
- return resultJSON;
- } catch (Exception e) {
- // TODO: handle exception
- System.out.println("HTTP ERROR:http://39.105.110.179:5000/GlassInfo GET");
- }
- return null;
- }
- public static JSONObject httpApi(String requestURL,String requestMethod,String requestBody){
- JSONObject jsonObject = null;
- try {
- // 鍦板潃 URL
- URL url = new URL(requestURL);
- // 杩炴帴
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- // 璇锋眰鏂瑰紡
- connection.setRequestMethod(requestMethod);
- connection.setDoOutput(true);
- connection.setRequestProperty("Content-type", "application/json; charset=UTF-8");
- System.out.println(requestBody);
- // 鍙傛暟鍐欏叆
- if(requestBody!=null){
- try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
- outputStream.writeBytes(requestBody);
- outputStream.flush();
- }
- }
- // 鐘舵�佺爜
- int responseCode = connection.getResponseCode();
- // 璇诲彇杩斿洖鍐呭
- if (responseCode==200){
- BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- String line;
- StringBuilder response = new StringBuilder();
- while ((line = reader.readLine()) != null) {
- response.append(line);
- }
- reader.close();
- // 鍏抽棴
- connection.disconnect();
- String resultStr = response.toString();
- if (resultStr!=null&&resultStr.length()>0) {
- jsonObject =JSONObject.parseObject(resultStr);
- }
- //System.out.println(jsonObject);
- }else{
- System.out.println("Response Code: " + responseCode);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return jsonObject;
- }
-
-}
diff --git a/nglib/src/ng/devices/HexUtil.java b/nglib/src/ng/devices/HexUtil.java
index cf21d94..c2a8f1f 100644
--- a/nglib/src/ng/devices/HexUtil.java
+++ b/nglib/src/ng/devices/HexUtil.java
@@ -22,7 +22,7 @@
return result;
}
- //姝e父鐨勫瓧姣嶆暟瀛楀彉鎴愬瓧鑺傛暟鍙戦?佺粰鐩掑瓙
+ //姝e父鐨勫瓧姣嶆暟瀛楀彉鎴愬瓧鑺傛暟鍙戯拷?锟界粰鐩掑瓙
public static String asciiToHex(String str) {
char[] chars = str.toCharArray();
@@ -45,11 +45,11 @@
return result.toString();
}//12300 //00321
- //浜岃繘鍒惰浆鍗佽繘鍒?
+ //浜岃繘鍒惰浆鍗佽繘锟�?
public static int int2ToHex(String number) {
return Integer.parseInt(number, 2);
}
- //浜岃繘鍒惰浆16杩涘埗 4浣?
+ //浜岃繘鍒惰浆16杩涘埗 4锟�?
public static String intBinaryTo16(String number) {
int num=int2ToHex(number);
return intTo2ByteHex(num);
@@ -58,7 +58,7 @@
public static int int16ToHex(String number) {
return Integer.parseInt(number, 16);
}
- //鍗佽繘鍒惰浆浜岃繘鍒?
+ //鍗佽繘鍒惰浆浜岃繘锟�?
public static String intToBinary(int number) {
return Integer.toBinaryString(number);
}
@@ -82,7 +82,7 @@
}
/**
- * 灏嗘暣鏁拌浆鎹负2浣?16杩涘埗锛屽1杞崲涓?01锛?10杞崲涓?0a
+ * 灏嗘暣鏁拌浆鎹负2锟�?16杩涘埗锛屽1杞崲锟�?01锟�?10杞崲锟�?0a
*
* @param number
* @return
@@ -96,7 +96,7 @@
}
/**
- * 灏嗘暣鏁拌浆鎹负4浣?16杩涘埗锛屽1杞崲涓?0001锛?10杞崲涓?000a
+ * 灏嗘暣鏁拌浆鎹负4锟�?16杩涘埗锛屽1杞崲锟�?0001锟�?10杞崲锟�?000a
*
* @param number
* @return
@@ -108,9 +108,9 @@
return numberHex;
}
-
+
/**
- * 灏嗘暣鏁拌浆鎹负8浣?16杩涘埗锛屽1杞崲涓?00000001锛?10杞崲涓?0000000a
+ * 灏嗘暣鏁拌浆鎹负8锟�?16杩涘埗锛屽1杞崲锟�?00000001锟�?10杞崲锟�?0000000a
*
* @param number
* @return
@@ -122,7 +122,7 @@
}
/**
- * 灏嗘椂闂磋浆鎹负16杩涘埗鏍煎紡锛屽勾锛?2瀛楄妭锛? + 鏈堬紙1瀛楄妭锛? + 鏃ワ紙1瀛楄妭锛? + 鏃讹紙1瀛楄妭锛? + 鍒嗭紙1瀛楄妭锛? + 绉掞紙1瀛楄妭锛?
+ * 灏嗘椂闂磋浆鎹负16杩涘埗鏍煎紡锛屽勾锟�?2瀛楄妭锟�? + 鏈堬紙1瀛楄妭锟�? + 鏃ワ紙1瀛楄妭锟�? + 鏃讹紙1瀛楄妭锟�? + 鍒嗭紙1瀛楄妭锟�? + 绉掞紙1瀛楄妭锟�?
*
* @param time
* @return
@@ -142,7 +142,7 @@
}
/**
- * 灏?16杩涘埗鐨勬椂闂磋浆鎹负yyyy-MM-dd HH:mm:ss鐨勬牸寮?
+ * 锟�?16杩涘埗鐨勬椂闂磋浆鎹负yyyy-MM-dd HH:mm:ss鐨勬牸锟�?
*
* @param hexTime
* @return
@@ -157,7 +157,7 @@
return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
}
- //鍗佸叚杩涘埗杞?10杩涘埗
+ //鍗佸叚杩涘埗锟�?10杩涘埗
public static int hexToInt(String hex) {
return Integer.parseInt(hex, 16);
}
@@ -181,7 +181,7 @@
}
/**
- * 灏嗗瓧鑺傝浆鎹负涓や綅鍗佸叚杩涘埗瀛楃涓诧紝涓嶅浣嶅墠鍔?0
+ * 灏嗗瓧鑺傝浆鎹负涓や綅鍗佸叚杩涘埗瀛楃涓诧紝涓嶅浣嶅墠锟�?0
*
* @param b
* @return
@@ -197,7 +197,7 @@
}
/**
- * 灏嗗崄鍏繘鍒跺瓧绗︼紝杞崲鎴愪簩杩涘埗鐨勫瓧绗?
+ * 灏嗗崄鍏繘鍒跺瓧绗︼紝杞崲鎴愪簩杩涘埗鐨勫瓧锟�?
*
* @param b
* @return
@@ -213,7 +213,7 @@
}
/**
- * 灏嗗崄鍏繘鍒跺瓧绗︼紝杞崲鎴愪簩杩涘埗鐨勫瓧绗?
+ * 灏嗗崄鍏繘鍒跺瓧绗︼紝杞崲鎴愪簩杩涘埗鐨勫瓧锟�?
*
* @param b
* @return
@@ -231,7 +231,7 @@
/**
- * 鍗佽繘鍒跺瓧鑺傛暟缁勮浆鍗佸叚杩涘埗瀛楃涓?
+ * 鍗佽繘鍒跺瓧鑺傛暟缁勮浆鍗佸叚杩涘埗瀛楃锟�?
* @param bufSize
* @param msg
* @return
@@ -270,16 +270,18 @@
// System.out.println(HexUtil.hexToInt("00d2"));
//
// System.out.println(HexUtil.formatHex("3c5354413e"));
+
+
String message = "Hello World!|This is the first signal from device!";
- int length = message.length() * 2 + 10; // 闀垮害鍖呮嫭缁撳熬鐨?<EOF>锛屼竴涓瓧绗﹀湪淇″彿涓敱涓や釜瀛楄妭琛ㄧず銆?
+ int length = message.length() * 2 + 10; // 闀垮害鍖呮嫭缁撳熬锟�?<EOF>锛屼竴涓瓧绗﹀湪淇″彿涓敱涓や釜瀛楄妭琛ㄧず锟�?
- String command = HexUtil.asciiToHex("<STA>"); // 娣诲姞寮?濮嬫爣璇?
+ String command = HexUtil.asciiToHex("<STA>"); // 娣诲姞锟�?濮嬫爣锟�?
command += (String.format("%4s", HexUtil.intToHex(length)).replace(' ', '0')); // 娣诲姞闀垮害鏍囪瘑
- command += "01"; // 娣诲姞璁惧绫诲瀷 0x01琛ㄧず鍒囧壊鏈猴紝0x02琛ㄧず閽㈠寲鐐?
- command += "0001"; // 娣诲姞璁惧鍨嬪彿锛?0x0001琛ㄧず鍩烘湰娆撅紝0x0002琛ㄧず涓骇娆?
+ command += "01"; // 娣诲姞璁惧绫诲瀷 0x01琛ㄧず鍒囧壊鏈猴紝0x02琛ㄧず閽㈠寲锟�?
+ command += "0001"; // 娣诲姞璁惧鍨嬪彿锟�?0x0001琛ㄧず鍩烘湰娆撅紝0x0002琛ㄧず涓骇锟�?
command += "0000"; // 鍔熻兘鍙凤紝0x0000鏄笅浣嶆満涓诲姩鍙戠粰涓婁綅鏈猴紱0x0001鏄笂浣嶆満淇敼涓嬩綅鏈篟TC
- command += "00"; // 鍔犲瘑鏂瑰紡锛?0x00琛ㄧず涓嶅姞瀵?
+ command += "00"; // 鍔犲瘑鏂瑰紡锟�?0x00琛ㄧず涓嶅姞锟�?
Calendar c = Calendar.getInstance();
diff --git a/nglib/src/ng/devices/MysqlService.java b/nglib/src/ng/devices/MysqlService.java
index 3290efa..f94cb08 100644
--- a/nglib/src/ng/devices/MysqlService.java
+++ b/nglib/src/ng/devices/MysqlService.java
@@ -5,7 +5,7 @@
import builder.Manager;
import builder.S7control;
-import builder.httpApi;
+import builder.HttpApi;
import com.alibaba.fastjson.JSONObject;
import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
import ng.db.DBHelper;
@@ -114,7 +114,7 @@
//上片
if(id==2){
try{
- JSONObject jSONObject=httpApi.selectLoadRack();
+ JSONObject jSONObject=HttpApi.selectLoadRack();
// JSONObject jSONObject=new JSONObject();
// jSONObject.put("thickness", "4");
// jSONObject.put("width", "3660");
@@ -141,7 +141,7 @@
flag= sql.getString(8);//1 表示任务完成数量减一
if ("1".equals(flag) ){
for (int i=0;i<1;){
- JSONObject loadRackReductionJson=httpApi.loadRackReduction();
+ JSONObject loadRackReductionJson=HttpApi.loadRackReduction();
if ("true".equals(loadRackReductionJson.get("success").toString())){
//调用成功
i++;
--
Gitblit v1.8.0