产线入库流程修改

This commit is contained in:
liuhanqing
2025-09-28 14:56:02 +08:00
parent fd9b720fe6
commit 3273fae260
12 changed files with 109 additions and 62 deletions

View File

@@ -11,8 +11,10 @@ import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.common.domain.HslRead;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.schedule.plcRead.util.ParseUtil;
import com.ruoyi.schedule.plcRead.util.Tools;
import lombok.extern.slf4j.Slf4j;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
@@ -125,8 +127,10 @@ public class PlcSsjRead implements Runnable {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setException(ParseUtil.optInt(8, ddsx1));
ssjDevice.setException(ParseUtil.optInt(4, ddsx1));
ssjDevice.setAllowPut(ParseUtil.optInt(6, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
}
}
@@ -136,16 +140,23 @@ public class PlcSsjRead implements Runnable {
* @param ssjDevice
*/
private void readPlcLineSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("220"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
ssjDevice.setTraySize(ParseUtil.optInt(14, ddsx1));
ssjDevice.setTraySize(ParseUtil.optInt(6, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
OperateResultExOne<byte[]> trayCodeRead = readWriteNet.Read("DB502.0", Short.parseShort("220"));
if (trayCodeRead.IsSuccess){
byte[] content = trayCodeRead.Content;
//去除bytes中
ssjDevice.setTrayCode(ParseUtil.filterAndConvert(trayCodeRead.Content));
}
}
}
@@ -196,4 +207,7 @@ public class PlcSsjRead implements Runnable {
setIsConnect(false);
}
}

View File

@@ -51,6 +51,29 @@ public class ParseUtil {
}
/**
* 过滤ASCII数组中的无效字符,只保留可打印字符(32-126)
* @param asciiArray 原始ASCII码数组
* @return 转换后的字符串
*/
public static String filterAndConvert(byte[] asciiArray) {
if (asciiArray == null) {
return "";
}
StringBuilder sb = new StringBuilder();
for (int code : asciiArray) {
// 只保留可打印ASCII字符(32-空格到126-~)
if (code >= 32 && code <= 126) {
sb.append((char) code);
}
}
return sb.toString();
}