现场调试修改 入库 出库 放货目标有货
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.schedule.util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Socket;
|
||||
|
||||
public class CheckWeight {
|
||||
|
||||
public String sendWeight(String ip, int por) {
|
||||
|
||||
String zhi = "e9";
|
||||
try (
|
||||
Socket socket = new Socket(ip, por);
|
||||
InputStream is = socket.getInputStream();
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||
) {
|
||||
Thread.sleep(1000);
|
||||
char[] charArray = new char[8];
|
||||
|
||||
System.out.println("开始读取");
|
||||
int readLength = inputStreamReader.read(charArray);
|
||||
System.out.println("readLength:" + readLength);
|
||||
if (readLength != -1) {
|
||||
String newString = new String(charArray, 0, readLength);
|
||||
newString = newString.replaceAll("\r|\n", "");
|
||||
if (newString.length() == 8 && !newString.equals("=0000000")) {
|
||||
newString = newString.substring(1, 8);
|
||||
newString = newString.replaceAll("^(0+)", "");
|
||||
zhi = newString;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return zhi;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CheckWeight checkWeight = new CheckWeight();
|
||||
System.out.println(checkWeight.sendWeight("192.168.56.101", 4001));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user