package com.mes.netty; public class MesMsgUtils { public static int SYNR_LEN = 46; public static int AXTW_LEN = 46; public static int ACLW_LEN = 46; public static int MCJW_LEN = 96; public static int AQDW_LEN = 96; public static int MBDW_LEN = 96; public static int MJBW_LEN = 96; public static int MQDW_LEN = 96; public static int MKSW_LEN = 96; public static int MSBW_LEN = 96; public static int MCSW_LEN = 96; public static int AQRW_LEN = 96; public static String MSG_TYPE[] = { "SYNR", "AXTW", "ACLW", "MCJW", "AQDW", "MBDW", "MJBW", "MQDW", "MKSW", "MSBW", "MCSW", "AQRW", }; public static int isMsgContentOK(String msg, String msg_type) { //ret=0OK,1 空内容,2 长度不符 int ret = 0; if(msg==null||msg.equalsIgnoreCase("")) { ret = 1; return ret; } int len = msg.length(); //System.out.println("len="+len); switch(msg_type) { case "SYNR": case "AXTW": case "ACLW": if(len==SYNR_LEN) { ret = 0; }else { ret = 2; } break; default: if(len==AQDW_LEN) { ret = 0; }else { ret = 2; } break; } return ret; } // 判断报文类型是否在清单里 public static boolean isMsgTypeOk(String msg_type) { for (String str : MSG_TYPE) { if (str.equals(msg_type)) { return true; } } return false; } // 处理报文数据 public static String processMsg(String msg, String msg_type) { String processMsgRet = ""; if(msg_type.equalsIgnoreCase("SYNR")) { }else if(msg_type.equalsIgnoreCase("AXTW")) { }else if(msg_type.equalsIgnoreCase("ACLW")) { }else{ processMsgRet = ProtocolParam.getResult(msg); } return processMsgRet; } }