Forráskód Böngészése

支持 INSPXXX 质量校验结果显示

wangxichen 1 napja
szülő
commit
a20eea301b

+ 17 - 3
src/com/mes/netty/MesMsgUtils.java

@@ -7,10 +7,10 @@ public class MesMsgUtils {
     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 AQDW_LEN = 99;
     public static int MBDW_LEN = 98;
     public static int MJBW_LEN = 98;
-    public static int MQDW_LEN = 98;
+    public static int MQDW_LEN = 99;
     public static int MKSW_LEN = 96;
     public static int MSBW_LEN = 96;
     public static int MCSW_LEN = 96;
@@ -51,13 +51,27 @@ public class MesMsgUtils {
                     ret = 2;
                 }
                 break;
-            default:
+            case "AQDW":
                 if(len==AQDW_LEN) {
                     ret = 0;
                 }else {
                     ret = 2;
                 }
                 break;
+            case "MQDW":
+                if(len==MQDW_LEN) {
+                    ret = 0;
+                }else {
+                    ret = 2;
+                }
+                break;
+            default:
+                if(len==MCJW_LEN) {
+                    ret = 0;
+                }else {
+                    ret = 2;
+                }
+                break;
         }
         return ret;
     }

+ 9 - 9
src/com/mes/netty/ProtocolParam.java

@@ -5,7 +5,7 @@ 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 = 98; // 固定长度(响应报文,v1=96,v2 扩 oprno 后 +2)
+    public static Integer fixedLength = 99; // 固定长度(响应报文,v1=96,v2 扩 oprno 后 +2)
 
     // 获取消息类型  所有报文都可使用
     public static String getMsgType(String msg){
@@ -41,34 +41,34 @@ public class ProtocolParam {
     }
 
     public static String getLx(String msg){
-        if(msg.length() < 74){
+        if(msg.length() < 75){
             return "";
         }
-        return msg.substring(72,74);
+        return msg.substring(72,75).trim();
     }
 
     // 获取结果
     public static String getResult(String msg){
-        if(msg.length() < 76){
+        if(msg.length() < 77){
             return "";
         }
-        return msg.substring(74,76);
+        return msg.substring(75,77);
     }
 
     // 获取日期
     public static String getDay(String msg){
-        if(msg.length() < 88){
+        if(msg.length() < 89){
             return "";
         }
-        return msg.substring(78,88);
+        return msg.substring(79,89);
     }
 
     // 获取时间
     public static String getTime(String msg){
-        if(msg.length() < 98){
+        if(msg.length() < 99){
             return "";
         }
-        return msg.substring(90,98);
+        return msg.substring(91,99);
     }
 
 }

+ 13 - 5
src/com/mes/netty/XDecoder.java

@@ -135,18 +135,26 @@ public class XDecoder extends ByteToMessageDecoder {
                     tpsize = MesMsgUtils.ACLW_LEN;
                 }
                 break;
-            case "MCJW":
             case "AQDW":
+                if(str.length() >= MesMsgUtils.AQDW_LEN){
+                    tpsize = MesMsgUtils.AQDW_LEN;
+                }
+                break;
+            case "MQDW":
+                if(str.length() >= MesMsgUtils.MQDW_LEN){
+                    tpsize = MesMsgUtils.MQDW_LEN;
+                }
+                break;
+            case "MCJW":
             case "MBDW":
             case "MJBW":
-            case "MQDW":
             case "MKSW":
             case "MSBW":
             case "MCSW":
             case "AQRW":
-            default: // 默认新报文
-                if(str.length() >= ProtocolParam.fixedLength){ // 大于固定长度
-                    tpsize = ProtocolParam.fixedLength;
+            default: // default new packet
+                if(str.length() >= MesMsgUtils.MCJW_LEN){
+                    tpsize = MesMsgUtils.MCJW_LEN;
                 }
                 break;
         }

+ 17 - 2
src/com/mes/util/ErrorMsg.java

@@ -11,9 +11,9 @@ public class ErrorMsg {
             }else if(processMsgRet.equalsIgnoreCase("NN")) {
                 lmsg = "该工件跳过该工位";
             }else if(processMsgRet.equalsIgnoreCase("QN")) {
-                lmsg = "该工件OP"+ lx+"0加工NG";
+                lmsg = "该工件"+ getOprnoName(lx)+"加工NG";
             }else if(processMsgRet.equalsIgnoreCase("QD")) {
-                lmsg = "该工件OP"+ lx+"0未加工";
+                lmsg = "该工件"+ getOprnoName(lx)+"未加工";
             }else if(processMsgRet.equalsIgnoreCase("NF")) {
                 lmsg = "该工件已合格下线";
             }else if(processMsgRet.equalsIgnoreCase("NR")) {
@@ -46,4 +46,19 @@ public class ErrorMsg {
         }catch (Exception e){ }
         return lmsg;
     }
+    private static String getOprnoName(String lx) {
+        if (lx == null) {
+            return "OP";
+        }
+        lx = lx.trim();
+        if (lx.startsWith("I")) {
+            try {
+                int num = Integer.parseInt(lx.substring(1)) * 10;
+                return String.format("INSP%03d", num);
+            } catch (Exception e) {
+                return "INSP" + lx.substring(1);
+            }
+        }
+        return "OP" + lx + "0";
+    }
 }