package com.mes.netty; // 固定格式报文各参数获取方法 public class ProtocolParam { // bbbbfffffARWAQDWGWOP100 GY100000ID151245P00000106200123062900001 RSOKDA2023-09-07ZT10:16:58 public static Integer fixedLength = 96; // 固定长度 // 获取消息类型 所有报文都可使用 public static String getMsgType(String msg){ System.out.print(msg); if(msg.length() < 16){ return ""; } return msg.substring(12,16); } // 获取工位号 public static String getOprno(String msg){ if(msg.length() < 24){ return ""; } return msg.substring(18,24); } // 获取工艺号 public static String getCraft(String msg){ if(msg.length() < 32){ return ""; } return msg.substring(26,32); } // 获取镭雕码或设备报警故障代码 public static String getSn(String msg){ if(msg.length() < 70){ return ""; } return msg.substring(34,70); } public static String getLx(String msg){ if(msg.length() < 72){ return ""; } return msg.substring(70,72); } // 获取结果 public static String getResult(String msg){ if(msg.length() < 74){ return ""; } return msg.substring(72,74); } // 获取日期 public static String getDay(String msg){ if(msg.length() < 86){ return ""; } return msg.substring(76,86); } // 获取时间 public static String getTime(String msg){ if(msg.length() < 96){ return ""; } return msg.substring(88,96); } }