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