hou 4 일 전
부모
커밋
5838f8122e

+ 148 - 41
src/com/mes/ui/MesClient.java

@@ -65,6 +65,9 @@ public class MesClient extends JFrame {
     public static int mes_heart_icon_cycle = 1;
     public static String mes_line_sn = "";
     public static String mes_gwflag = ""; // 工位标识
+    public static String mes_sn_prefix = ""; // 工件码开头格式(共用回退),多个用逗号分隔
+    public static String mes_sn_prefix_a = ""; // 第1码(OP030)开头格式
+    public static String mes_sn_prefix_b = ""; // 第2码(OP031)开头格式
 
     public static NettyClient nettyClient;
     public static boolean tcp_connect_flag = false;
@@ -522,15 +525,52 @@ public class MesClient extends JFrame {
         }
     }
 
-    private static void checkQualityForScan(String scanBarcodeSn, String displayName, String face){
+    /** 铸件走 OP030,后边框走 OP031(后者才会进 validateDbjEntry) */
+    private static void checkQualityForScan(String scanBarcodeSn, String displayName, String oprno){
         setMenuStatus(displayName + " 扫码成功,质量查询中", 0);
         getUser();
-        Boolean sendret = DataUtil.checkQuality(nettyClient, scanBarcodeSn, user20, getQualityOprnoByFace(face));
+        Boolean sendret = DataUtil.checkQuality(nettyClient, scanBarcodeSn, user20, oprno);
         if(!sendret){
             setMenuStatus("消息发送失败,请重试", 1);
         }
     }
 
+    /**
+     * 校验扫码内容是否以配置的工件码开头格式匹配。
+     * 未配置前缀时不做校验;多个前缀用逗号分隔,命中任一即可。
+     */
+    public static boolean matchSnPrefix(String sn, String prefixConfig) {
+        if (prefixConfig == null || prefixConfig.trim().isEmpty()) {
+            return true;
+        }
+        if (sn == null) {
+            return false;
+        }
+        String[] prefixes = prefixConfig.split(",");
+        for (String prefix : prefixes) {
+            String p = prefix == null ? "" : prefix.trim();
+            if (!p.isEmpty() && sn.startsWith(p)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /** @deprecated 使用 matchSnPrefix(sn, prefixConfig) */
+    public static boolean matchSnPrefix(String sn) {
+        return matchSnPrefix(sn, mes_sn_prefix);
+    }
+
+    private static boolean checkSnPrefixBeforeQuality(String scanBarcodeSn, String prefixConfig, String codeLabel){
+        if (matchSnPrefix(scanBarcodeSn, prefixConfig)) {
+            return true;
+        }
+        String tip = codeLabel + "工件码错误";
+        setMenuStatus(tip, 1);
+//        JOptionPane.showMessageDialog(mesClientFrame, tip, "提示窗口", JOptionPane.INFORMATION_MESSAGE);
+        return false;
+    }
+
     private static void scanCurrentFace(String scanBarcodeSn){
         if(isFaceCodesComplete(curPage)){
             setMenuStatus(("A".equals(curPage) ? "A" : "B") + "面两个码已扫完", 1);
@@ -542,11 +582,17 @@ public class MesClient extends JFrame {
                     setMenuStatus(getDisplayOprno030A() + "已存在,勿重复扫码", 1);
                     return;
                 }
+                if(!checkSnPrefixBeforeQuality(scanBarcodeSn, mes_sn_prefix_a, "第1码")){
+                    return;
+                }
                 product_sn.setText(scanBarcodeSn);
-                checkQualityForScan(scanBarcodeSn, getDisplayOprno030A(), "A");
+                checkQualityForScan(scanBarcodeSn, getDisplayOprno030A(), getOprno030A());
             }else{
+                if(!checkSnPrefixBeforeQuality(scanBarcodeSn, mes_sn_prefix_b, "第2码")){
+                    return;
+                }
                 textField.setText(scanBarcodeSn);
-                checkQualityForScan(scanBarcodeSn, getDisplayOprno031A(), "A");
+                checkQualityForScan(scanBarcodeSn, getDisplayOprno031A(), getOprno031A());
                 tryStartBothWorks();
             }
         }else{
@@ -555,11 +601,17 @@ public class MesClient extends JFrame {
                     setMenuStatus(getDisplayOprno030B() + "已存在,勿重复扫码", 1);
                     return;
                 }
+                if(!checkSnPrefixBeforeQuality(scanBarcodeSn, mes_sn_prefix_a, "第1码")){
+                    return;
+                }
                 product_sn2.setText(scanBarcodeSn);
-                checkQualityForScan(scanBarcodeSn, getDisplayOprno030B(), "B");
+                checkQualityForScan(scanBarcodeSn, getDisplayOprno030B(), getOprno030B());
             }else{
+                if(!checkSnPrefixBeforeQuality(scanBarcodeSn, mes_sn_prefix_b, "第2码")){
+                    return;
+                }
                 textField_1.setText(scanBarcodeSn);
-                checkQualityForScan(scanBarcodeSn, getDisplayOprno031B(), "B");
+                checkQualityForScan(scanBarcodeSn, getDisplayOprno031B(), getOprno031B());
                 tryStartBothWorks();
             }
         }
@@ -650,6 +702,18 @@ public class MesClient extends JFrame {
         mes_tcp_port = Integer.parseInt(pro.getProperty("mes.tcp_port"));
         mes_heart_beat_cycle = Integer.parseInt(pro.getProperty("mes.heart_beat_cycle"));
         mes_line_sn = pro.getProperty("mes.line_sn");
+        mes_sn_prefix = pro.getProperty("mes.sn_prefix");
+        if (mes_sn_prefix == null) {
+            mes_sn_prefix = "";
+        }
+        mes_sn_prefix_a = pro.getProperty("mes.sn_prefix.a");
+        if (mes_sn_prefix_a == null || mes_sn_prefix_a.trim().isEmpty()) {
+            mes_sn_prefix_a = mes_sn_prefix;
+        }
+        mes_sn_prefix_b = pro.getProperty("mes.sn_prefix.b");
+        if (mes_sn_prefix_b == null || mes_sn_prefix_b.trim().isEmpty()) {
+            mes_sn_prefix_b = mes_sn_prefix;
+        }
 
         mes_gw_des = OprnoUtil.getGwDes(mes_line_sn,mes_gw);
         if(!mes_gw_b.equals(mes_gw)){
@@ -700,10 +764,12 @@ public class MesClient extends JFrame {
     public static JTextField param1;
     public static JTextField param2;
     public static JTextField param3;
+    public static JTextField param4;
     public static JTextField product_sn2;
     public static JTextField param21;
     public static JTextField param22;
     public static JTextField param23;
+    public static JTextField param24;
     public static void startHeartBeatTimer() {
         if(heartBeatTimer!=null) {
             heartBeatTimer.cancel();
@@ -796,10 +862,12 @@ public class MesClient extends JFrame {
         MesClient.param1.setText("");
         MesClient.param2.setText("");
         MesClient.param3.setText("");
+        MesClient.param4.setText("");
 
         MesClient.param21.setText("");
         MesClient.param22.setText("");
         MesClient.param23.setText("");
+        MesClient.param24.setText("");
 
         MesClient.curSna = "";
         MesClient.tjFlaga = 0;
@@ -852,10 +920,12 @@ public class MesClient extends JFrame {
         MesClient.param1.setText("");
         MesClient.param2.setText("");
         MesClient.param3.setText("");
+        MesClient.param4.setText("");
 
         MesClient.param21.setText("");
         MesClient.param22.setText("");
         MesClient.param23.setText("");
+        MesClient.param24.setText("");
         MesClient.curSnb = "";
         MesClient.tjFlagb = 0;
         MesClient.checkB = 0;
@@ -1218,9 +1288,11 @@ public class MesClient extends JFrame {
 
         //妫f牠銆�
         JPanel indexPanelA = new JPanel();
-        indexScrollPaneA = new JScrollPane(indexPanelA);
         indexPanelA.setLayout(null);
-        indexPanelA.setPreferredSize(new Dimension(1010, 520));
+        indexScrollPaneA = new JScrollPane(indexPanelA);
+        indexScrollPaneA.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+        indexScrollPaneA.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+        indexPanelA.setPreferredSize(new Dimension(1010, 450));
 
         // ---- 顶部扫码输入区 y=8~64 ----
         page_text = new JLabel("当前:A面 请扫主码");
@@ -1326,7 +1398,7 @@ public class MesClient extends JFrame {
         // ---- 焊机参数区 y=272~510 ----
         JSeparator separator_1_1 = new JSeparator();
         separator_1_1.setOrientation(SwingConstants.VERTICAL);
-        separator_1_1.setBounds(495, 272, 2, 230);
+        separator_1_1.setBounds(495, 272, 2, 180);
         indexPanelA.add(separator_1_1);
 
         JLabel lblNewLabel_4 = new JLabel("A面");
@@ -1418,98 +1490,133 @@ public class MesClient extends JFrame {
 //        mesRadioHj.setBounds(190,170,500,50);
 //        indexPanelA.add(mesRadioHj);
 
-        // 焊机1参数 - 纵向排列(标签在上,数值在下)
+        // 焊机参数:第一行 电压/电流/送丝速度,第二行 程序名(整行)
+        int welder1X = 26;
+        int welder1W = 446;
+        int welder2X = 517;
+        int welder2W = 446;
+        int metricColW = 140;
+        int metricLabelY = 318;
+        int metricFieldY = 338;
+        int metricFieldH = 28;
+        int progLabelY = 376;
+        int progFieldY = 396;
+        int progFieldH = 28;
+
         JLabel lblDyA = new JLabel("电压");
         lblDyA.setHorizontalAlignment(SwingConstants.CENTER);
-        lblDyA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblDyA.setBounds(169, 318, 158, 22);
+        lblDyA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblDyA.setBounds(welder1X, metricLabelY, metricColW, 20);
         indexPanelA.add(lblDyA);
 
         param1 = new JTextField();
         param1.setEnabled(false);
         param1.setEditable(false);
         param1.setHorizontalAlignment(SwingConstants.CENTER);
-        param1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        param1.setBounds(169, 342, 158, 30);
-        param1.setColumns(10);
+        param1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param1.setBounds(welder1X, metricFieldY, metricColW, metricFieldH);
         indexPanelA.add(param1);
 
         JLabel lblDlA = new JLabel("电流");
         lblDlA.setHorizontalAlignment(SwingConstants.CENTER);
-        lblDlA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblDlA.setBounds(169, 378, 158, 22);
+        lblDlA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblDlA.setBounds(welder1X + metricColW + 8, metricLabelY, metricColW, 20);
         indexPanelA.add(lblDlA);
 
         param2 = new JTextField();
         param2.setEnabled(false);
         param2.setEditable(false);
         param2.setHorizontalAlignment(SwingConstants.CENTER);
-        param2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        param2.setBounds(169, 402, 158, 30);
-        param2.setColumns(10);
+        param2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param2.setBounds(welder1X + metricColW + 8, metricFieldY, metricColW, metricFieldH);
         indexPanelA.add(param2);
 
         JLabel lblSsA = new JLabel("送丝速度");
         lblSsA.setHorizontalAlignment(SwingConstants.CENTER);
-        lblSsA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblSsA.setBounds(169, 438, 158, 22);
+        lblSsA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblSsA.setBounds(welder1X + (metricColW + 8) * 2, metricLabelY, metricColW, 20);
         indexPanelA.add(lblSsA);
 
         param3 = new JTextField();
         param3.setEnabled(false);
         param3.setEditable(false);
         param3.setHorizontalAlignment(SwingConstants.CENTER);
-        param3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        param3.setBounds(169, 462, 158, 30);
-        param3.setColumns(10);
+        param3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param3.setBounds(welder1X + (metricColW + 8) * 2, metricFieldY, metricColW, metricFieldH);
         indexPanelA.add(param3);
 
-        // 焊机2参数 - 纵向排列(标签在上,数值在下)
+        JLabel lblProgA = new JLabel("程序名");
+        lblProgA.setHorizontalAlignment(SwingConstants.CENTER);
+        lblProgA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblProgA.setBounds(welder1X, progLabelY, welder1W, 20);
+        indexPanelA.add(lblProgA);
+
+        param4 = new JTextField();
+        param4.setEnabled(false);
+        param4.setEditable(false);
+        param4.setHorizontalAlignment(SwingConstants.CENTER);
+        param4.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param4.setBounds(welder1X, progFieldY, welder1W, progFieldH);
+        indexPanelA.add(param4);
+
         JLabel lblDyB = new JLabel("电压");
         lblDyB.setHorizontalAlignment(SwingConstants.CENTER);
-        lblDyB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblDyB.setBounds(669, 318, 158, 22);
+        lblDyB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblDyB.setBounds(welder2X, metricLabelY, metricColW, 20);
         indexPanelA.add(lblDyB);
 
         param21 = new JTextField();
         param21.setEnabled(false);
         param21.setEditable(false);
         param21.setHorizontalAlignment(SwingConstants.CENTER);
-        param21.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        param21.setBounds(669, 342, 158, 30);
-        param21.setColumns(10);
+        param21.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param21.setBounds(welder2X, metricFieldY, metricColW, metricFieldH);
         indexPanelA.add(param21);
 
         JLabel lblDlB = new JLabel("电流");
         lblDlB.setHorizontalAlignment(SwingConstants.CENTER);
-        lblDlB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblDlB.setBounds(669, 378, 158, 22);
+        lblDlB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblDlB.setBounds(welder2X + metricColW + 8, metricLabelY, metricColW, 20);
         indexPanelA.add(lblDlB);
 
         param22 = new JTextField();
         param22.setEnabled(false);
         param22.setEditable(false);
         param22.setHorizontalAlignment(SwingConstants.CENTER);
-        param22.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        param22.setBounds(669, 402, 158, 30);
-        param22.setColumns(10);
+        param22.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param22.setBounds(welder2X + metricColW + 8, metricFieldY, metricColW, metricFieldH);
         indexPanelA.add(param22);
 
         JLabel lblSsB = new JLabel("送丝速度");
         lblSsB.setHorizontalAlignment(SwingConstants.CENTER);
-        lblSsB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblSsB.setBounds(669, 438, 158, 22);
+        lblSsB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblSsB.setBounds(welder2X + (metricColW + 8) * 2, metricLabelY, metricColW, 20);
         indexPanelA.add(lblSsB);
 
         param23 = new JTextField();
         param23.setEnabled(false);
         param23.setEditable(false);
         param23.setHorizontalAlignment(SwingConstants.CENTER);
-        param23.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        param23.setBounds(669, 462, 158, 30);
-        param23.setColumns(10);
+        param23.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param23.setBounds(welder2X + (metricColW + 8) * 2, metricFieldY, metricColW, metricFieldH);
         indexPanelA.add(param23);
 
+        JLabel lblProgB = new JLabel("程序名");
+        lblProgB.setHorizontalAlignment(SwingConstants.CENTER);
+        lblProgB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        lblProgB.setBounds(welder2X, progLabelY, welder2W, 20);
+        indexPanelA.add(lblProgB);
+
+        param24 = new JTextField();
+        param24.setEnabled(false);
+        param24.setEditable(false);
+        param24.setHorizontalAlignment(SwingConstants.CENTER);
+        param24.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        param24.setBounds(welder2X, progFieldY, welder2W, progFieldH);
+        indexPanelA.add(param24);
+
+        indexPanelA.revalidate();
+
         tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
         tabbedPane.setEnabledAt(0, true);
 

+ 12 - 10
src/com/mes/ui/MesRevice.java

@@ -20,7 +20,7 @@ public class MesRevice {
 
 
 
-    // 质量查询(A面 OP030A,B面 OP030B)
+    // 质量查询(A面 OP030A/OP031A,B面 OP030B/OP031B)
 
     public static void checkQualityRevice(String processMsgRet,String mes_msg){
 
@@ -34,13 +34,13 @@ public class MesRevice {
 
                 String oprno = ProtocolParam.getOprno(mes_msg).trim();
 
-                if(oprno.equals(MesClient.getOprno030A())){
+                if(oprno.equals(MesClient.getOprno030A()) || oprno.equals(MesClient.getOprno031A())){
 
                     MesClient.qualityOkA = true;
 
                     MesClient.tryStartBothWorks();
 
-                }else if(oprno.equals(MesClient.getOprno030B())){
+                }else if(oprno.equals(MesClient.getOprno030B()) || oprno.equals(MesClient.getOprno031B())){
 
                     MesClient.qualityOkB = true;
 
@@ -54,7 +54,7 @@ public class MesRevice {
 
                 String oprno = ProtocolParam.getOprno(mes_msg).trim();
 
-                if(oprno.equals(MesClient.getOprno030A()) || MesClient.curPage.equals("A")){
+                if(oprno.equals(MesClient.getOprno030A()) || oprno.equals(MesClient.getOprno031A()) || MesClient.curPage.equals("A")){
 
                     MesClient.check_quality_result = false;
 
@@ -62,7 +62,7 @@ public class MesRevice {
 
                 }
 
-                if(oprno.equals(MesClient.getOprno030B()) || MesClient.curPage.equals("B")){
+                if(oprno.equals(MesClient.getOprno030B()) || oprno.equals(MesClient.getOprno031B()) || MesClient.curPage.equals("B")){
 
                     MesClient.check_quality_result2 = false;
 
@@ -76,13 +76,13 @@ public class MesRevice {
 
                 MesClient.setMenuStatus(lmsg,-1);
 
-                if(oprno.equals(MesClient.getOprno030A()) || MesClient.curPage.equals("A")){
+                if(oprno.equals(MesClient.getOprno030A()) || oprno.equals(MesClient.getOprno031A()) || MesClient.curPage.equals("A")){
 
                     PlcUtil.changeEnableA(MesClient.s7PLC,false);
 
                 }
 
-                if(oprno.equals(MesClient.getOprno030B()) || MesClient.curPage.equals("B")){
+                if(oprno.equals(MesClient.getOprno030B()) || oprno.equals(MesClient.getOprno031B()) || MesClient.curPage.equals("B")){
 
                     PlcUtil.changeEnableB(MesClient.s7PLC,false);
 
@@ -238,17 +238,19 @@ public class MesRevice {
 
             }else{
 
-                MesClient.status_menu.setText(oprno + " 提交失败");
+                String lmsg = ErrorMsg.getErrorMsg(processMsgRet, mes_msg);
+                String failMsg = oprno + " 提交失败:" + lmsg;
+                MesClient.status_menu.setText(failMsg);
 
                 if(oprno.equals(MesClient.getOprno030A()) || oprno.equals(MesClient.getOprno031A())){
 
-                    MesClient.pxstatus1.setText(oprno + ":提交失败");
+                    MesClient.pxstatus1.setText(failMsg);
 
                     MesClient.tjStatusa = 1;
 
                 }else if(oprno.equals(MesClient.getOprno030B()) || oprno.equals(MesClient.getOprno031B())){
 
-                    MesClient.pxstatus2.setText(oprno + ":提交失败");
+                    MesClient.pxstatus2.setText(failMsg);
 
                     MesClient.tjStatusb = 1;
 

+ 13 - 1
src/com/mes/util/ErrorMsg.java

@@ -21,7 +21,15 @@ public class ErrorMsg {
             }else if(processMsgRet.equalsIgnoreCase("QN")) {
                 lmsg = "该工件OP"+ lx+"加工NG";
             }else if(processMsgRet.equalsIgnoreCase("QD")) {
-                lmsg = "该工件OP"+ lx+"未加工";
+                // OP031(第2码)依赖 OP023:服务端返回 RSQD 时 lx 会误解析成 RSD
+                String oprno = ProtocolParam.getOprno(mes_msg).trim();
+                if (oprno.startsWith("OP031")) {
+                    lmsg = "该工件OP023未加工";
+                } else if ("RSD".equalsIgnoreCase(lx) || "RS".equalsIgnoreCase(lxpre)) {
+                    lmsg = "该工件前工位未加工";
+                } else {
+                    lmsg = "该工件OP"+ lx+"未加工";
+                }
             }else if(processMsgRet.equalsIgnoreCase("NF")) {
                 lmsg = "该工件已合格下线";
             }else if(processMsgRet.equalsIgnoreCase("NR")) {
@@ -58,6 +66,10 @@ public class ErrorMsg {
                 lmsg = "涂胶静置时间超过规定时长";
             }else if(processMsgRet.equalsIgnoreCase("TT")) {
                 lmsg = "套筒涂胶静置时间未达到规定时长";
+            }else if(processMsgRet.equalsIgnoreCase("GH")) {
+                lmsg = "上一工位完成后冷却时间未到";
+            }else if(processMsgRet.equalsIgnoreCase("RP")) {
+                lmsg = "该精追码已在本工位加工完成,不可重复";
             }
         }catch (Exception e){ }
         return lmsg;

+ 14 - 7
src/com/mes/util/IweldCloudUtil.java

@@ -33,14 +33,15 @@ public class IweldCloudUtil {
         public String voltage = "";
         public String current = "";
         public String wireSpeed = "";
+        public String programName = "";
 
         public boolean hasData() {
-            return !voltage.isEmpty() || !current.isEmpty() || !wireSpeed.isEmpty();
+            return !voltage.isEmpty() || !current.isEmpty() || !wireSpeed.isEmpty() || !programName.isEmpty();
         }
 
         @Override
         public String toString() {
-            return "电压=" + voltage + ", 电流=" + current + ", 送丝速度=" + wireSpeed;
+            return "电压=" + voltage + ", 电流=" + current + ", 送丝速度=" + wireSpeed + ", 程序名=" + programName;
         }
     }
 
@@ -259,16 +260,14 @@ public class IweldCloudUtil {
         MesClient.param1.setText(welders[0].voltage);
         MesClient.param2.setText(welders[0].current);
         MesClient.param3.setText(welders[0].wireSpeed);
+        MesClient.param4.setText(welders[0].programName);
         MesClient.param21.setText(welders[1].voltage);
         MesClient.param22.setText(welders[1].current);
         MesClient.param23.setText(welders[1].wireSpeed);
+        MesClient.param24.setText(welders[1].programName);
 
         String recordTime = DateLocalUtils.getCurrentTime();
-        MesClient.hjparams.add(
-                welders[0].voltage + "|" + welders[0].current + "|" + welders[0].wireSpeed + "|" + "" + "|" + "" + "|"
-                        + welders[1].voltage + "|" + welders[1].current + "|" + welders[1].wireSpeed + "|" + "" + "|" + "" + "|"
-                        + recordTime
-        );
+        MesClient.hjparams.add(buildHjParamRecord(welders[0], welders[1], recordTime));
 
         if (MesClient.hjparams.size() == 60) {
             persistHjParams(MesClient.curFlag);
@@ -362,9 +361,17 @@ public class IweldCloudUtil {
                 "weldingAi", "D07", "WeldA", "weldingCurrent", "current", "actualCurrent", "actualCur");
         params.wireSpeed = readField(item,
                 "silkRate", "D18", "SilkRate", "wireFeedSpeed", "wireSpeed", "feedingSpeed", "feedSpeed");
+        params.programName = readField(item, "programName", "ProgramName", "weldProgram", "jobName");
         return params;
     }
 
+    /** 格式与 MES 后台一致:错误码位留空,JOB 位存 programName */
+    private static String buildHjParamRecord(WelderParams welder1, WelderParams welder2, String recordTime) {
+        return welder1.voltage + "|" + welder1.current + "|" + welder1.wireSpeed + "|" + "" + "|" + welder1.programName + "|"
+                + welder2.voltage + "|" + welder2.current + "|" + welder2.wireSpeed + "|" + "" + "|" + welder2.programName + "|"
+                + recordTime;
+    }
+
     private static String readField(JSONObject item, String... keys) {
         for (String key : keys) {
             if (item.containsKey(key) && item.get(key) != null) {

+ 3 - 0
src/com/mes/util/IweldCloudUtilTest.java

@@ -225,6 +225,9 @@ public class IweldCloudUtilTest {
             return;
         }
         System.out.println(label + ": " + params);
+        if (!params.programName.isEmpty()) {
+            System.out.println(label + " 程序名: " + params.programName);
+        }
     }
 
     private static void sleepBetweenRequests() {

+ 15 - 9
src/resources/config/config.properties

@@ -1,6 +1,6 @@
-mes.gw=OP040
-mes.gw.a=OP040
-mes.gw.b=OP041
+mes.gw=OP030
+mes.gw.a=OP030
+mes.gw.b=OP031
 # 界面显示名(留空则使用默认工位号;MES通信用 mes.gw.a/b 及 A/B 后缀,不受此项影响)
 mes.display.op030a=199-0Y7A-插件面板-铸件
 mes.display.op031a=199-0Y7A-后边框-型材机加件
@@ -8,12 +8,18 @@ mes.display.op030b=199-0Y7A-插件面板-铸件
 mes.display.op031b=199-0Y7A-后边框-型材机加件
 mes.display.material.op030=199-0Y7A-插件面板-铸件
 mes.display.material.op031=199-0Y7A-后边框-型材机加件
-#mes.server_ip=127.0.0.1
-mes.server_ip=192.168.16.99
+mes.server_ip=127.0.0.1
+#mes.server_ip=192.168.16.99
 mes.tcp_port=3000
 mes.heart_beat_cycle=60
 mes.line_sn=XT
 mes.gwflag=A
+#工件码开头格式,扫码后质量查询前校验;多个用逗号分隔
+# mes.sn_prefix.a=第1码(OP030/mes.gw.a),mes.sn_prefix.b=第2码(OP031/mes.gw.b)
+# 若 a/b 未配置,则回退使用 mes.sn_prefix
+mes.sn_prefix=
+mes.sn_prefix.a=30100201530
+mes.sn_prefix.b=30100201543
 
 # IweldCloud Login
 iweld.accessKey=19353:BN15MTY2NA==08X
@@ -21,14 +27,14 @@ iweld.login.url=https://api.iweldcloud.com/ApiServer/Login
 # 实时数据接口类型:robot=机器人(getRobotRunInfo),welder=焊机(getWeldRunInfo)
 iweld.device.type=robot
 # 1号机产品编码
-#iweld.prodCode=2026S0085
+iweld.prodCode=2026S0085
 # 2号机产品编码
-iweld.prodCode=2026S0083
+#iweld.prodCode=2026S0083
 # 焊机2产品编码,留空则仅使用 dataList 第2条或焊机2显示为空
 # 1号机产品编码
-#iweld.prodCode2=2026T0425
+iweld.prodCode2=2026T0425
 # 2号机产品编码
-iweld.prodCode2=2026T0498
+#iweld.prodCode2=2026T0498
 # 实时数据接口地址(留空则按 iweld.device.type 自动选择)
 #iweld.run.info.url=
 iweld.robot.run.info.url=https://api.iweldcloud.com/ApiServer/rest/WeldWebService/getRobotRunInfo