MesMsgUtils.java 2.6 KB

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