MesMsgUtils.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.mes.netty;
  2. public class MesMsgUtils {
  3. public static int SYNR_LEN = 46;
  4. public static int AXTW_LEN = 46;
  5. public static int ACLW_LEN = 46;
  6. public static int MCJW_LEN = 96;
  7. public static int AQDW_LEN = 96;
  8. public static int MBDW_LEN = 96;
  9. public static int MJBW_LEN = 96;
  10. public static int MQDW_LEN = 96;
  11. public static int MKSW_LEN = 96;
  12. public static int MSBW_LEN = 96;
  13. public static int MCSW_LEN = 96;
  14. public static int AQRW_LEN = 96;
  15. public static String MSG_TYPE[] = {
  16. "SYNR",
  17. "AXTW",
  18. "ACLW",
  19. "MCJW",
  20. "AQDW",
  21. "MBDW",
  22. "MJBW",
  23. "MQDW",
  24. "MKSW",
  25. "MSBW",
  26. "MCSW",
  27. "AQRW",
  28. };
  29. public static int isMsgContentOK(String msg, String msg_type) {
  30. //ret=0OK,1 空内容,2 长度不符
  31. int ret = 0;
  32. if(msg==null||msg.equalsIgnoreCase("")) {
  33. ret = 1;
  34. return ret;
  35. }
  36. int len = msg.length();
  37. //System.out.println("len="+len);
  38. switch(msg_type) {
  39. case "SYNR":
  40. case "AXTW":
  41. case "ACLW":
  42. if(len==SYNR_LEN) {
  43. ret = 0;
  44. }else {
  45. ret = 2;
  46. }
  47. break;
  48. default:
  49. if(len==AQDW_LEN) {
  50. ret = 0;
  51. }else {
  52. ret = 2;
  53. }
  54. break;
  55. }
  56. return ret;
  57. }
  58. // 判断报文类型是否在清单里
  59. public static boolean isMsgTypeOk(String msg_type) {
  60. for (String str : MSG_TYPE) {
  61. if (str.equals(msg_type)) {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. // 处理报文数据
  68. public static String processMsg(String msg, String msg_type) {
  69. String processMsgRet = "";
  70. if(msg_type.equalsIgnoreCase("SYNR")) {
  71. }else if(msg_type.equalsIgnoreCase("AXTW")) {
  72. }else if(msg_type.equalsIgnoreCase("ACLW")) {
  73. }else{
  74. processMsgRet = ProtocolParam.getResult(msg);
  75. }
  76. return processMsgRet;
  77. }
  78. }