|
|
@@ -5,10 +5,11 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
// 固定格式报文各参数获取方法
|
|
|
+// 协议 v2(2026-06-29 修订):oprno 字段从 6 字符扩到 8 字符,后续字段偏移整体 +2
|
|
|
public class ProtocolParam {
|
|
|
public static final Logger log = LoggerFactory.getLogger(ProtocolParam.class);
|
|
|
- // bbbbfffffARWAQDWGWOP100 GY100000ID151245P00000106200123062900001 RSOKDA2023-09-07ZT10:16:58
|
|
|
- public static Integer fixedLength = 96; // 固定长度
|
|
|
+ // bbbbfffffARWAQDWGWOP100 GY100000ID151245P00000106200123062900001 RSOKDA2023-09-07ZT10:16:58
|
|
|
+ public static Integer fixedLength = 98; // 固定长度(v1=96,v2 扩 oprno 后 +2)
|
|
|
|
|
|
// 获取消息类型 所有报文都可使用
|
|
|
public static String getMsgType(String msg){
|
|
|
@@ -19,59 +20,59 @@ public class ProtocolParam {
|
|
|
return msg.substring(12,16);
|
|
|
}
|
|
|
|
|
|
- // 获取工位号
|
|
|
+ // 获取工位号(8 字符)
|
|
|
public static String getOprno(String msg){
|
|
|
- if(msg.length() < 24){
|
|
|
+ if(msg.length() < 26){
|
|
|
return "";
|
|
|
}
|
|
|
- return msg.substring(18,24);
|
|
|
+ return msg.substring(18,26);
|
|
|
}
|
|
|
|
|
|
// 获取工艺号
|
|
|
public static String getCraft(String msg){
|
|
|
- if(msg.length() < 32){
|
|
|
+ if(msg.length() < 34){
|
|
|
return "";
|
|
|
}
|
|
|
- return msg.substring(26,32);
|
|
|
+ return msg.substring(28,34);
|
|
|
}
|
|
|
|
|
|
// 获取镭雕码或设备报警故障代码
|
|
|
public static String getSn(String msg){
|
|
|
- if(msg.length() < 70){
|
|
|
+ if(msg.length() < 72){
|
|
|
return "";
|
|
|
}
|
|
|
- return msg.substring(34,70);
|
|
|
+ return msg.substring(36,72);
|
|
|
}
|
|
|
|
|
|
public static String getLx(String msg){
|
|
|
- if(msg.length() < 72){
|
|
|
+ if(msg.length() < 74){
|
|
|
return "";
|
|
|
}
|
|
|
- return msg.substring(70,72);
|
|
|
+ return msg.substring(72,74);
|
|
|
}
|
|
|
|
|
|
// 获取结果
|
|
|
public static String getResult(String msg){
|
|
|
- if(msg.length() < 74){
|
|
|
+ if(msg.length() < 76){
|
|
|
return "";
|
|
|
}
|
|
|
- return msg.substring(72,74);
|
|
|
+ return msg.substring(74,76);
|
|
|
}
|
|
|
|
|
|
// 获取日期
|
|
|
public static String getDay(String msg){
|
|
|
- if(msg.length() < 86){
|
|
|
+ if(msg.length() < 88){
|
|
|
return "";
|
|
|
}
|
|
|
- return msg.substring(76,86);
|
|
|
+ return msg.substring(78,88);
|
|
|
}
|
|
|
|
|
|
// 获取时间
|
|
|
public static String getTime(String msg){
|
|
|
- if(msg.length() < 96){
|
|
|
+ if(msg.length() < 98){
|
|
|
return "";
|
|
|
}
|
|
|
- return msg.substring(88,96);
|
|
|
+ return msg.substring(90,98);
|
|
|
}
|
|
|
|
|
|
}
|