ProtocolParam.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.mes.netty;
  2. // 固定格式报文各参数获取方法
  3. public class ProtocolParam {
  4. // bbbbfffffARWAQDWGWOP100 GY100000ID151245P00000106200123062900001 RSOKDA2023-09-07ZT10:16:58
  5. public static Integer fixedLength = 96; // 固定长度
  6. // 获取消息类型 所有报文都可使用
  7. public static String getMsgType(String msg){
  8. System.out.print(msg);
  9. if(msg.length() < 16){
  10. return "";
  11. }
  12. return msg.substring(12,16);
  13. }
  14. // 获取工位号
  15. public static String getOprno(String msg){
  16. if(msg.length() < 24){
  17. return "";
  18. }
  19. return msg.substring(18,24);
  20. }
  21. // 获取工艺号
  22. public static String getCraft(String msg){
  23. if(msg.length() < 32){
  24. return "";
  25. }
  26. return msg.substring(26,32);
  27. }
  28. // 获取镭雕码或设备报警故障代码
  29. public static String getSn(String msg){
  30. if(msg.length() < 70){
  31. return "";
  32. }
  33. return msg.substring(34,70);
  34. }
  35. public static String getLx(String msg){
  36. if(msg.length() < 72){
  37. return "";
  38. }
  39. return msg.substring(70,72);
  40. }
  41. // 获取结果
  42. public static String getResult(String msg){
  43. if(msg.length() < 74){
  44. return "";
  45. }
  46. return msg.substring(72,74);
  47. }
  48. // 获取日期
  49. public static String getDay(String msg){
  50. if(msg.length() < 86){
  51. return "";
  52. }
  53. return msg.substring(76,86);
  54. }
  55. // 获取时间
  56. public static String getTime(String msg){
  57. if(msg.length() < 96){
  58. return "";
  59. }
  60. return msg.substring(88,96);
  61. }
  62. }