refactor(scheduling): 重构堆垛机调度任务处理逻辑
- 移除API服务中废弃的入库作业创建和接收方法 - 将设备列表数据结构从DeviceSsj改为String类型并添加称重设备支持 - 添加出库任务计数查询功能和设备执行队列统计 - 优化入库取货队列创建逻辑,集成称重数据处理 - 更新WMS基础URL地址并调整相关接口调用 - 修复设备状态更新中的字段映射错误 - 添加线程安全的任务执行状态检查机制 - 实现出库队列任务优先级规则和防冲突机制
This commit is contained in:
@@ -1,40 +1,52 @@
|
||||
package com.ruoyi.schedule.util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Socket;
|
||||
|
||||
public class CheckWeight {
|
||||
|
||||
public String sendWeight(String ip, int por) {
|
||||
public static String sendWeight(String ip, int por) {
|
||||
|
||||
String zhi = "e9";
|
||||
String zhi = "0";
|
||||
try (
|
||||
Socket socket = new Socket(ip, por);
|
||||
InputStream is = socket.getInputStream();
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||
) {
|
||||
Thread.sleep(1000);
|
||||
char[] charArray = new char[8];
|
||||
Thread.sleep(300);
|
||||
byte[] bytes = new byte[8];
|
||||
int read = is.read(bytes);
|
||||
if (read!=-1){
|
||||
String weight = byteArrayToCharArray(bytes, "UTF-8");
|
||||
weight = weight.substring(1,8);
|
||||
weight = weight.replace("=","");
|
||||
|
||||
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;
|
||||
if (weight.length() == 7 && !weight.equals("0000000")) {
|
||||
zhi = weight;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return zhi;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte数组按指定编码转为char数组
|
||||
* @param byteArr 输入的byte数组
|
||||
* @param charset 字符编码(如UTF-8、GBK、ASCII)
|
||||
* @return 转换后的char数组
|
||||
* @throws UnsupportedEncodingException 编码不支持时抛出
|
||||
*/
|
||||
public static String byteArrayToCharArray(byte[] byteArr, String charset) throws UnsupportedEncodingException {
|
||||
if (byteArr == null) {
|
||||
return null;
|
||||
}
|
||||
// 核心:先将byte数组按指定编码转为String,再转为char数组
|
||||
return new String(byteArr, charset);
|
||||
}
|
||||
|
||||
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