wangxichen vor 2 Wochen
Ursprung
Commit
c9ae3f13f8

+ 9 - 8
src/com/mes/netty/MesMsgUtils.java

@@ -2,14 +2,15 @@ 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;
+    // 协议 v2(2026-06-29):oprno 字段从 6 字符扩到 8 字符,所有长度 +2
+    public static int SYNR_LEN = 48;
+    public static int AXTW_LEN = 48;
+    public static int ACLW_LEN = 48;
+    public static int MCJW_LEN = 98;
+    public static int AQDW_LEN = 98;
+    public static int MBDW_LEN = 98;
+    public static int MJBW_LEN = 98;
+    public static int MQDW_LEN = 98;
     public static int MKSW_LEN = 96;
     public static int MSBW_LEN = 96;
     public static int MCSW_LEN = 96;

+ 18 - 17
src/com/mes/netty/ProtocolParam.java

@@ -2,9 +2,10 @@ package com.mes.netty;
 
 
 // 固定格式报文各参数获取方法
+// 协议 v2(2026-06-29 修订):oprno 字段从 6 字符扩到 8 字符,后续字段偏移整体 +2
 public class ProtocolParam {
-    // bbbbfffffARWAQDWGWOP100 GY100000ID151245P00000106200123062900001      RSOKDA2023-09-07ZT10:16:58
-    public static Integer fixedLength = 96; // 固定长度
+    // bbbbfffffARWAQDWGWOP100   GY100000ID151245P00000106200123062900001      RSOKDA2023-09-07ZT10:16:58
+    public static Integer fixedLength = 98; // 固定长度(响应报文,v1=96,v2 扩 oprno 后 +2)
 
     // 获取消息类型  所有报文都可使用
     public static String getMsgType(String msg){
@@ -15,59 +16,59 @@ public class ProtocolParam {
         return msg.substring(12,16);
     }
 
-    // 获取工位号
+    // 获取工位号(8 字符)
     public static String getOprno(String msg){
-        if(msg.length() < 24){
+        if(msg.length() < 26){
             return "";
         }
-        return msg.substring(18,24);
+        return msg.substring(18,26);
     }
 
     // 获取工艺号
     public static String getCraft(String msg){
-        if(msg.length() < 32){
+        if(msg.length() < 34){
             return "";
         }
-        return msg.substring(26,32);
+        return msg.substring(28,34);
     }
 
     // 获取镭雕码或设备报警故障代码
     public static String getSn(String msg){
-        if(msg.length() < 70){
+        if(msg.length() < 72){
             return "";
         }
-        return msg.substring(34,70);
+        return msg.substring(36,72);
     }
 
     public static String getLx(String msg){
-        if(msg.length() < 72){
+        if(msg.length() < 74){
             return "";
         }
-        return msg.substring(70,72);
+        return msg.substring(72,74);
     }
 
     // 获取结果
     public static String getResult(String msg){
-        if(msg.length() < 74){
+        if(msg.length() < 76){
             return "";
         }
-        return msg.substring(72,74);
+        return msg.substring(74,76);
     }
 
     // 获取日期
     public static String getDay(String msg){
-        if(msg.length() < 86){
+        if(msg.length() < 88){
             return "";
         }
-        return msg.substring(76,86);
+        return msg.substring(78,88);
     }
 
     // 获取时间
     public static String getTime(String msg){
-        if(msg.length() < 96){
+        if(msg.length() < 98){
             return "";
         }
-        return msg.substring(88,96);
+        return msg.substring(90,98);
     }
 
 }

+ 4 - 4
src/com/mes/ui/DataUtil.java

@@ -18,7 +18,7 @@ public class DataUtil {
             //TCP连接后,直接先发同步报文
             String start = "aaaabbbbbABW";
             String msgType = "SYNR";
-            String gw = "GW"+DataUtil.rightPad(mes_gw, 6);
+            String gw = "GW"+DataUtil.rightPad(mes_gw, 8);
             String da = "DA" + DateLocalUtils.getCurrentDate();
             String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
             String synr_str = start + msgType + gw + da + zt;
@@ -40,7 +40,7 @@ public class DataUtil {
             //TCP连接后,直接先发同步报文
             String start = "aaaabbbbbABW";
             String msgType = "AXTW";
-            String gw = "GW"+DataUtil.rightPad(mes_gw, 6);
+            String gw = "GW"+DataUtil.rightPad(mes_gw, 8);
             String da = "DA" + DateLocalUtils.getCurrentDate();
             String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
             String axtw_str = start + msgType + gw + da + zt;
@@ -134,7 +134,7 @@ public class DataUtil {
             Properties pro = new Properties();
             BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
             pro.load(br);
-            String gw = "GW"+rightPad(pro.getProperty("mes.gw"), 6);
+            String gw = "GW"+rightPad(pro.getProperty("mes.gw"), 8);
             String start = "aaaabbbbbABW";
             String gy = "GY" + rightPad(craft, 6);
             String reslx = "LX" + rightPad("", 2);
@@ -159,7 +159,7 @@ public class DataUtil {
             Properties pro = new Properties();
             BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
             pro.load(br);
-            String gw = "GW"+rightPad(pro.getProperty("mes.gw"), 6);
+            String gw = "GW"+rightPad(pro.getProperty("mes.gw"), 8);
             String start = "aaaabbbbbABW";
             String gy = "GY" + rightPad(craft, 6);
             String reslx = "LX" + rightPad(lx, 2);