Ver código fonte

修复绑定液冷板无校验问题

张田野 2 semanas atrás
pai
commit
9455f8586c

+ 15 - 3
src/com/mes/ui/DataUtil.java

@@ -94,11 +94,14 @@ public class DataUtil {
         }
     }
 
+    /** 液冷板绑定/解绑固定写到 OP220(工艺 400006);本机开工/交结果仍用 config 的 mes.gw(OP230) */
+    public static final String COLD_PLATE_BIND_GW = "OP220A";
+
     public static Boolean bindWarehouse(NettyClient nettyClient,String sn,String wsn,String user,String craft){
         try{
             String msgType = "MBDW";
             String param = rightPad(wsn, 36);
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param);
+            Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param, COLD_PLATE_BIND_GW);
             return aqdw_str;
         }catch (Exception e){
             return false;
@@ -109,7 +112,7 @@ public class DataUtil {
         try{
             String msgType = "MJBW";
             String param = rightPad(wsn, 36);
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param);
+            Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param, COLD_PLATE_BIND_GW);
             return aqdw_str;
         }catch (Exception e){
             return false;
@@ -149,13 +152,22 @@ public class DataUtil {
     }
 
     public static Boolean sendMessage(NettyClient nettyClient,String msgType,String craft,String lx,String sn,String result,String user,String paramNums,String params){
+        return sendMessage(nettyClient, msgType, craft, lx, sn, result, user, paramNums, params, null);
+    }
+
+    /**
+     * @param gwOverride 非空时用该工位号组报文(如液冷板绑定固定 OP220A);空则用 config 的 mes.gw
+     */
+    public static Boolean sendMessage(NettyClient nettyClient,String msgType,String craft,String lx,String sn,String result,String user,String paramNums,String params,String gwOverride){
         try{
             String enconding = "UTF-8";
             InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
             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 gwCode = (gwOverride != null && !gwOverride.trim().isEmpty())
+                    ? gwOverride.trim() : pro.getProperty("mes.gw");
+            String gw = "GW"+rightPad(gwCode, 6);
             String start = "aaaabbbbbABW";
             String gy = "GY" + rightPad(craft, 6);
             String reslx = "LX" + rightPad(lx, 2);

+ 4 - 26
src/com/mes/ui/MesClient.java

@@ -479,37 +479,15 @@ public class MesClient extends JFrame {
             mesClientFrame.repaint();
 
             if(work_status == 1){
-                // 校验工件码与冷板码版本匹配
-                String snText = product_sn.getText();
-                String lbText = scanBarcode;
-                String snPrefix = snText.length() >= 13 ? snText.substring(0, 13) : snText;
-                String lbPrefix = lbText.length() >= 13 ? lbText.substring(0, 13) : lbText;
-                // 国内版前13位
-                final String SN_DOMESTIC = "5019016600451";
-                final String SN_OVERSEAS  = "5019016600361";
-                final String LB_DOMESTIC = "5099006618051";
-                final String LB_OVERSEAS  = "5099006617551";
-                boolean snIsDomestic = SN_DOMESTIC.equals(snPrefix);
-                boolean snIsOverseas = SN_OVERSEAS.equals(snPrefix);
-                boolean lbIsDomestic = LB_DOMESTIC.equals(lbPrefix);
-                boolean lbIsOverseas = LB_OVERSEAS.equals(lbPrefix);
-                boolean match = (snIsDomestic && lbIsDomestic) || (snIsOverseas && lbIsOverseas);
-                if(!match) {
-                    product_sn_lb.setText("");
-                    mesClientFrame.repaint();
-                    status_menu.setText("冷板码不匹配!");
-                    status_menu.setForeground(Color.RED);
-//
-                    return;
-                }
-
+                // 流程工位是 OP230;液冷板绑定报文固定写 OP220/400006,版本校验在服务端
                 String warehouseSn = getBarcode(product_sn_lb.getText());
                 String sn = getBarcode(product_sn.getText());
                 Boolean ret = DataUtil.bindWarehouse(nettyClient, sn, warehouseSn, user20, "400006");
                 if(ret != null && ret) {
-                    MesClient.setMenuStatus("绑定成功",0);
+                    MesClient.setMenuStatus("冷板绑定中,请稍候...",0);
                 } else {
-                    MesClient.setMenuStatus("请求失败,请重试",-1);
+                    product_sn_lb.setText("");
+                    MesClient.setMenuStatus("绑定请求发送失败,请重试",-1);
                 }
             }else{
                 setMenuStatus("请先扫工件码",1);

+ 17 - 3
src/com/mes/ui/MesRevice.java

@@ -87,9 +87,23 @@ public class MesRevice {
     public static void bindRevice(String processMsgRet,String mes_msg){
         try{
             if(processMsgRet.equalsIgnoreCase("OK")) {
-
-            }else{
-
+                MesClient.setMenuStatus("冷板绑定成功", 0);
+            } else if(processMsgRet.equalsIgnoreCase("LN")) {
+                MesClient.product_sn_lb.setText("");
+                MesClient.setMenuStatus("国内工件只能绑定国内冷板", -1);
+            } else if(processMsgRet.equalsIgnoreCase("LW")) {
+                MesClient.product_sn_lb.setText("");
+                MesClient.setMenuStatus("国外工件只能绑定国外冷板", -1);
+            } else if(processMsgRet.equalsIgnoreCase("LP")) {
+                MesClient.product_sn_lb.setText("");
+                MesClient.setMenuStatus("冷板码不在国内/国外前缀配置范围内", -1);
+            } else {
+                MesClient.product_sn_lb.setText("");
+                String lmsg = ErrorMsg.getErrorMsg(processMsgRet, mes_msg);
+                if(lmsg == null || lmsg.equals("该工件本工位不可加工")){
+                    lmsg = "冷板绑定失败";
+                }
+                MesClient.setMenuStatus(lmsg, -1);
             }
         }catch (Exception e){
             e.printStackTrace();

+ 6 - 0
src/com/mes/util/ErrorMsg.java

@@ -56,6 +56,12 @@ public class ErrorMsg {
                 lmsg = "涂胶静置时间超过规定时长";
             }else if(processMsgRet.equalsIgnoreCase("TT")) {
                 lmsg = "套筒涂胶静置时间未达到规定时长";
+            }else if(processMsgRet.equalsIgnoreCase("LN")) {
+                lmsg = "国内工件只能绑定国内冷板";
+            }else if(processMsgRet.equalsIgnoreCase("LW")) {
+                lmsg = "国外工件只能绑定国外冷板";
+            }else if(processMsgRet.equalsIgnoreCase("LP")) {
+                lmsg = "冷板码不在国内/国外前缀配置范围内";
             }
         }catch (Exception e){ }
         return lmsg;

+ 8 - 8
src/resources/config/config.properties

@@ -1,11 +1,11 @@
-# ???
-mes.gw=OP220A
-# ???IP
-mes.server_ip=127.0.0.1
-#mes.server_ip=192.168.21.99
-# TCP????
+# 本机流程工位(查质量/开工/交结果)
+mes.gw=OP230A
+# 服务器IP
+#mes.server_ip=127.0.0.1
+mes.server_ip=192.168.21.99
+# TCP端口
 mes.tcp_port=3000
-# TCP????
+# 心跳周期
 mes.heart_beat_cycle=60
-# ????
+# 产线
 mes.line_sn=XT