张田野 2 тижнів тому
батько
коміт
71ee949dcb

+ 26 - 0
src/com/mes/ui/DataUtil.java

@@ -414,6 +414,32 @@ public class DataUtil {
         }
     }
 
+    /**
+     * HTTP绑定压铸件二维码到工艺号400002的materiel_sn(同步等待返回)
+     */
+    public static JSONObject bindYzjHttp(String sn, String materielSn, String user, String craft){
+        try{
+            String mes_server_ip = MesClient.mes_server_ip;
+            String oprno = MesClient.mes_gw == null ? "" : MesClient.mes_gw.trim();
+            String lineSn = MesClient.mes_line_sn == null ? "" : MesClient.mes_line_sn.trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductRecord/bindYzj";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&result=OK&ucode="+user
+                    + "&craft="+craft+"&wsn="+materielSn;
+            System.out.println("params="+params);
+            String result = doPost(url,params);
+            System.out.println("result="+result);
+
+            if(result == null || result.trim().isEmpty() || result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
+
     public static JSONObject unBindWarehouseData(String sn,String wsn,String userCode,String craft){
         try{
             String enconding = "UTF-8";

+ 339 - 57
src/com/mes/ui/MesClient.java

@@ -76,8 +76,18 @@ public class MesClient extends JFrame {
     public static Integer work_status2 = 0;
     public static Boolean check_quality_result2 = false;
 
-    public static Integer batch_status = 0; //A面 1=已绑定  0=未绑定
-    public static Integer batch_status2 = 0; //B面 1=已绑定  0=未绑定
+    public static Integer batch_status = 0; //A面 1=压铸件已绑定  0=未绑定
+    public static Integer batch_status2 = 0; //B面 1=压铸件已绑定  0=未绑定
+
+    public static final String YZJ_CRAFT = "400002";
+    public static final String[] YZJ_SN_OVERSEAS_PREFIXES = {
+            "500313660065119990", "500313660005119990", "501901660057119990"
+    };
+    public static final String[] YZJ_SN_DOMESTIC_PREFIXES = {
+            "501901660034119990", "501901660051119990"
+    };
+    public static final String YZJ_WSN_OVERSEAS_PREFIX = "02.02.000179";
+    public static final String YZJ_WSN_DOMESTIC_PREFIX = "02.02.000156";
 
     public static JButton heart_beat_menu;
     public static JButton status_menu;
@@ -89,8 +99,15 @@ public class MesClient extends JFrame {
     public static JButton finish_ng_bt;
     public static JButton finish_ng_bt2;
     public static JTextField product_sn;
+    public static JTextField product_yzj;
+    public static JTextField product_yzj2;
     public static JLabel pxstatus1;
     public static JLabel pxstatus2;
+    public static JLabel yzj_label_a;
+    public static JLabel yzj_label_b;
+
+    public static JButton rescan_yzj_a;
+    public static JButton rescan_yzj_b;
 
     public static JButton batch_scan_1;
     public static JButton batch_scan_2;
@@ -192,10 +209,6 @@ public class MesClient extends JFrame {
         cjTimerText.schedule(new TimerTask() {
             public void run() {
                 try{
-                    if(txtfa != null && mesClientFrame != null && mesClientFrame.isDisplayable()){
-                        txtfa.requestFocusInWindow();
-                    }
-
                     MesClient.curPage = PlcUtil.getCurAside(s7PLC);
                     final String pageLabel = MesClient.curPage.equals("A") ? "当前:A面" : "当前:B面";
                     final String modelText = PlcUtil.getModelTypeText(s7PLC);
@@ -205,6 +218,12 @@ public class MesClient extends JFrame {
                                 page_text.setText(pageLabel);
                             }
                             applyModelTypeText(modelText);
+                            refreshScanInputState();
+                            if(txtyzj != null && txtyzj.isEnabled()){
+                                txtyzj.requestFocusInWindow();
+                            }else if(txtfa != null && mesClientFrame != null && mesClientFrame.isDisplayable()){
+                                txtfa.requestFocusInWindow();
+                            }
                         }
                     });
                 }catch (Exception e){
@@ -422,7 +441,11 @@ public class MesClient extends JFrame {
         MesClient.finish_ok_bt.setEnabled(false);
         MesClient.mesQualityFlagA = false;
         product_sn.setText("");
+        if(product_yzj != null){
+            product_yzj.setText("");
+        }
         MesClient.pxstatus1.setText("A");
+        MesClient.batch_status = 0;
 
 //        PlcUtil.changeEnable(s7PLC,false);
 
@@ -442,11 +465,8 @@ public class MesClient extends JFrame {
         MesClient.tjFlaga = 0;
         MesClient.checkA = 0;
 
-//        MesClient.batch_status = 0;
-//        MesClient.textField.setText("");
-//        MesClient.batch_scan_1.setEnabled(false);
         MesClient.formatScanType(1);
-//        PlcUtil.changeEnable(MesClient.s7PLC,false);
+        MesClient.refreshScanInputState();
 
         finish_ok_bt.setEnabled(false);
         finish_ng_bt.setEnabled(false);
@@ -460,6 +480,8 @@ public class MesClient extends JFrame {
     public static JTextField textField;
     public static JTextField textField_1;
     public static JTextField txtfa;
+    public static JTextField txtyzj;
+    public static JLabel yzj_scan_label;
     public static JLabel model_type_text;
     public static JLabel scan_type_text;
     public static JLabel page_text;
@@ -487,6 +509,10 @@ public class MesClient extends JFrame {
         MesClient.finish_ng_bt.setEnabled(false);
         MesClient.mesQualityFlagB = false;
         product_sn2.setText("");
+        if(product_yzj2 != null){
+            product_yzj2.setText("");
+        }
+        MesClient.batch_status2 = 0;
 
 //        PlcUtil.changeEnable(s7PLC,false);
 
@@ -506,11 +532,8 @@ public class MesClient extends JFrame {
         MesClient.tjFlagb = 0;
         MesClient.checkB = 0;
 
-//        MesClient.batch_status2 = 0;
-//        MesClient.textField_1.setText("");
-//        MesClient.batch_scan_2.setEnabled(false);
         MesClient.formatScanType(1);
-//        PlcUtil.changeEnable(MesClient.s7PLC,false);
+        MesClient.refreshScanInputState();
         finish_ok_bt2.setEnabled(false);
         finish_ng_bt2.setEnabled(false);
 
@@ -761,11 +784,37 @@ public class MesClient extends JFrame {
         product_sn.setText("");
         product_sn.setHorizontalAlignment(SwingConstants.CENTER);
         product_sn.setEditable(false);
-        product_sn.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
-        product_sn.setBounds(26, 152, 446, 70);
+        product_sn.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
+        product_sn.setBounds(26, 140, 446, 48);
         indexPanelA.add(product_sn);
         product_sn.setColumns(10);
 
+        yzj_label_a = new JLabel("\u538b\u94f8\u4ef6\u4e8c\u7ef4\u7801");
+        yzj_label_a.setHorizontalAlignment(SwingConstants.CENTER);
+        yzj_label_a.setForeground(new Color(0, 128, 192));
+        yzj_label_a.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 14));
+        yzj_label_a.setBounds(26, 188, 446, 22);
+        indexPanelA.add(yzj_label_a);
+
+        product_yzj = new JTextField();
+        product_yzj.setText("");
+        product_yzj.setHorizontalAlignment(SwingConstants.CENTER);
+        product_yzj.setEditable(false);
+        product_yzj.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        product_yzj.setBounds(26, 208, 320, 40);
+        indexPanelA.add(product_yzj);
+        product_yzj.setColumns(10);
+
+        rescan_yzj_a = new JButton("\u91cd\u626b\u538b\u94f8\u4ef6-A");
+        rescan_yzj_a.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 14));
+        rescan_yzj_a.setBounds(352, 208, 120, 40);
+        rescan_yzj_a.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                rescanYzj("A");
+            }
+        });
+        indexPanelA.add(rescan_yzj_a);
+
 //        String[] hjtitles = new String[]{"閻掑﹥婧�1","閻掑﹥婧�2","閻掑﹥婧�3"};
 //        String[] hjvals = new String[]{"HJ001","HJ002","HJ003"};
 //        mesRadioHj = new MesRadio(hjtitles,hjvals);
@@ -922,14 +971,14 @@ public class MesClient extends JFrame {
         JLabel lblNewLabel = new JLabel("电压");
         lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel.setBounds(26, 340, 100, 40);
+        lblNewLabel.setBounds(26, 295, 100, 36);
         lblNewLabel.setVisible(true);
         indexPanelA.add(lblNewLabel);
 
         JLabel lblNewLabel_1 = new JLabel("电流");
         lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_1.setBounds(226, 340, 100, 40);
+        lblNewLabel_1.setBounds(226, 295, 100, 36);
         lblNewLabel_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1);
 
@@ -938,7 +987,7 @@ public class MesClient extends JFrame {
         param1.setEditable(false);
         param1.setHorizontalAlignment(SwingConstants.CENTER);
         param1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        param1.setBounds(136, 340, 70, 40);
+        param1.setBounds(136, 295, 70, 36);
         param1.setVisible(true);
         indexPanelA.add(param1);
         param1.setColumns(10);
@@ -949,14 +998,14 @@ public class MesClient extends JFrame {
         param2.setHorizontalAlignment(SwingConstants.CENTER);
         param2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param2.setColumns(10);
-        param2.setBounds(345, 340, 70, 40);
+        param2.setBounds(345, 295, 70, 36);
         param2.setVisible(true);
         indexPanelA.add(param2);
 
         JLabel lblNewLabel_2 = new JLabel("送丝速度");
         lblNewLabel_2.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_2.setBounds(26, 401, 100, 40);
+        lblNewLabel_2.setBounds(26, 345, 100, 36);
         lblNewLabel_2.setVisible(true);
         indexPanelA.add(lblNewLabel_2);
 
@@ -966,14 +1015,14 @@ public class MesClient extends JFrame {
         param3.setHorizontalAlignment(SwingConstants.CENTER);
         param3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param3.setColumns(10);
-        param3.setBounds(136, 401, 70, 40);
+        param3.setBounds(136, 345, 70, 36);
         param3.setVisible(true);
         indexPanelA.add(param3);
 
         JLabel lblNewLabel_1_1 = new JLabel("错误代码");
         lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_1_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_1_1.setBounds(213, 401, 122, 40);
+        lblNewLabel_1_1.setBounds(213, 345, 122, 36);
         lblNewLabel_1_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1);
 
@@ -983,7 +1032,7 @@ public class MesClient extends JFrame {
         param4.setHorizontalAlignment(SwingConstants.CENTER);
         param4.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param4.setColumns(10);
-        param4.setBounds(345, 401, 70, 40);
+        param4.setBounds(345, 345, 70, 36);
         param4.setVisible(true);
         indexPanelA.add(param4);
 
@@ -993,39 +1042,65 @@ public class MesClient extends JFrame {
         param5.setHorizontalAlignment(SwingConstants.CENTER);
         param5.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param5.setColumns(10);
-        param5.setBounds(226, 470, 70, 40);
+        param5.setBounds(226, 400, 70, 36);
         param5.setVisible(true);
         indexPanelA.add(param5);
 
         JLabel lblNewLabel_1_1_1 = new JLabel("JOB号");
         lblNewLabel_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_1_1_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_1_1_1.setBounds(106, 470, 122, 40);
+        lblNewLabel_1_1_1.setBounds(106, 400, 122, 36);
         lblNewLabel_1_1_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1_1);
 
         product_sn2 = new JTextField();
         product_sn2.setText("");
         product_sn2.setHorizontalAlignment(SwingConstants.CENTER);
-        product_sn2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
+        product_sn2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         product_sn2.setEditable(false);
         product_sn2.setColumns(10);
-        product_sn2.setBounds(517, 152, 446, 70);
+        product_sn2.setBounds(517, 140, 446, 48);
         indexPanelA.add(product_sn2);
 
+        yzj_label_b = new JLabel("\u538b\u94f8\u4ef6\u4e8c\u7ef4\u7801");
+        yzj_label_b.setHorizontalAlignment(SwingConstants.CENTER);
+        yzj_label_b.setForeground(new Color(0, 128, 192));
+        yzj_label_b.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 14));
+        yzj_label_b.setBounds(517, 188, 446, 22);
+        indexPanelA.add(yzj_label_b);
+
+        product_yzj2 = new JTextField();
+        product_yzj2.setText("");
+        product_yzj2.setHorizontalAlignment(SwingConstants.CENTER);
+        product_yzj2.setEditable(false);
+        product_yzj2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        product_yzj2.setColumns(10);
+        product_yzj2.setBounds(517, 208, 320, 40);
+        indexPanelA.add(product_yzj2);
+
+        rescan_yzj_b = new JButton("\u91cd\u626b\u538b\u94f8\u4ef6-B");
+        rescan_yzj_b.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 14));
+        rescan_yzj_b.setBounds(843, 208, 120, 40);
+        rescan_yzj_b.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                rescanYzj("B");
+            }
+        });
+        indexPanelA.add(rescan_yzj_b);
+
         JSeparator separator = new JSeparator();
         separator.setBounds(450, 247, 0, 120);
         indexPanelA.add(separator);
 
         JSeparator separator_1 = new JSeparator();
         separator_1.setOrientation(SwingConstants.VERTICAL);
-        separator_1.setBounds(495, 91, 23, 250);
+        separator_1.setBounds(495, 100, 2, 150);
         indexPanelA.add(separator_1);
 
         JLabel lblNewLabel_3 = new JLabel("电压");
         lblNewLabel_3.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_3.setBounds(528, 340, 100, 40);
+        lblNewLabel_3.setBounds(528, 295, 100, 36);
         lblNewLabel_3.setVisible(true);
         indexPanelA.add(lblNewLabel_3);
 
@@ -1035,14 +1110,14 @@ public class MesClient extends JFrame {
         param21.setHorizontalAlignment(SwingConstants.CENTER);
         param21.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param21.setColumns(10);
-        param21.setBounds(638, 340, 70, 40);
+        param21.setBounds(638, 295, 70, 36);
         param21.setVisible(true);
         indexPanelA.add(param21);
 
         JLabel lblNewLabel_1_2 = new JLabel("电流");
         lblNewLabel_1_2.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_1_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_1_2.setBounds(742, 340, 100, 40);
+        lblNewLabel_1_2.setBounds(742, 295, 100, 36);
         lblNewLabel_1_2.setVisible(true);
         indexPanelA.add(lblNewLabel_1_2);
 
@@ -1052,14 +1127,14 @@ public class MesClient extends JFrame {
         param22.setHorizontalAlignment(SwingConstants.CENTER);
         param22.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param22.setColumns(10);
-        param22.setBounds(852, 340, 70, 40);
+        param22.setBounds(852, 295, 70, 36);
         param22.setVisible(true);
         indexPanelA.add(param22);
 
         JLabel lblNewLabel_2_1 = new JLabel("送丝速度");
         lblNewLabel_2_1.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_2_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_2_1.setBounds(528, 401, 100, 40);
+        lblNewLabel_2_1.setBounds(528, 345, 100, 36);
         lblNewLabel_2_1.setVisible(true);
         indexPanelA.add(lblNewLabel_2_1);
 
@@ -1069,14 +1144,14 @@ public class MesClient extends JFrame {
         param23.setHorizontalAlignment(SwingConstants.CENTER);
         param23.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param23.setColumns(10);
-        param23.setBounds(638, 401, 70, 40);
+        param23.setBounds(638, 345, 70, 36);
         param23.setVisible(true);
         indexPanelA.add(param23);
 
         JLabel lblNewLabel_1_1_2 = new JLabel("错误代码");
         lblNewLabel_1_1_2.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_1_1_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_1_1_2.setBounds(718, 401, 122, 40);
+        lblNewLabel_1_1_2.setBounds(718, 345, 122, 36);
         lblNewLabel_1_1_2.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1_2);
 
@@ -1086,14 +1161,14 @@ public class MesClient extends JFrame {
         param24.setHorizontalAlignment(SwingConstants.CENTER);
         param24.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param24.setColumns(10);
-        param24.setBounds(852, 401, 70, 40);
+        param24.setBounds(852, 345, 70, 36);
         param24.setVisible(true);
         indexPanelA.add(param24);
 
         JLabel lblNewLabel_1_1_1_1 = new JLabel("JOB号");
         lblNewLabel_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel_1_1_1_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
-        lblNewLabel_1_1_1_1.setBounds(609, 470, 122, 40);
+        lblNewLabel_1_1_1_1.setBounds(609, 400, 122, 36);
         lblNewLabel_1_1_1_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1_1_1);
 
@@ -1103,22 +1178,22 @@ public class MesClient extends JFrame {
         param25.setHorizontalAlignment(SwingConstants.CENTER);
         param25.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param25.setColumns(10);
-        param25.setBounds(742, 470, 70, 40);
+        param25.setBounds(742, 400, 70, 36);
         param25.setVisible(true);
         indexPanelA.add(param25);
 
         pxstatus1 = new JLabel("A");
         pxstatus1.setForeground(new Color(255, 128, 64));
         pxstatus1.setHorizontalAlignment(SwingConstants.CENTER);
-        pxstatus1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
-        pxstatus1.setBounds(26, 98, 446, 44);
+        pxstatus1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
+        pxstatus1.setBounds(26, 100, 446, 36);
         indexPanelA.add(pxstatus1);
 
         pxstatus2 = new JLabel("B");
         pxstatus2.setForeground(new Color(255, 128, 64));
         pxstatus2.setHorizontalAlignment(SwingConstants.CENTER);
-        pxstatus2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
-        pxstatus2.setBounds(517, 98, 446, 44);
+        pxstatus2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
+        pxstatus2.setBounds(517, 100, 446, 36);
         indexPanelA.add(pxstatus2);
 
         JSeparator separator_2 = new JSeparator();
@@ -1127,21 +1202,21 @@ public class MesClient extends JFrame {
 
         JLabel lblNewLabel_4 = new JLabel("\u710A\u673A1");
         lblNewLabel_4.setHorizontalAlignment(SwingConstants.CENTER);
-        lblNewLabel_4.setFont(new Font("微软雅黑", Font.PLAIN, 24));
-        lblNewLabel_4.setBounds(170, 290, 156, 40);
+        lblNewLabel_4.setFont(new Font("微软雅黑", Font.PLAIN, 22));
+        lblNewLabel_4.setBounds(170, 255, 156, 32);
         lblNewLabel_4.setVisible(true);
         indexPanelA.add(lblNewLabel_4);
 
         JLabel lblNewLabel_4_1 = new JLabel("\u710A\u673A2");
         lblNewLabel_4_1.setHorizontalAlignment(SwingConstants.CENTER);
-        lblNewLabel_4_1.setFont(new Font("微软雅黑", Font.PLAIN, 24));
-        lblNewLabel_4_1.setBounds(670, 287, 156, 40);
+        lblNewLabel_4_1.setFont(new Font("微软雅黑", Font.PLAIN, 22));
+        lblNewLabel_4_1.setBounds(670, 255, 156, 32);
         lblNewLabel_4_1.setVisible(true);
         indexPanelA.add(lblNewLabel_4_1);
 
         JSeparator separator_1_1 = new JSeparator();
         separator_1_1.setOrientation(SwingConstants.VERTICAL);
-        separator_1_1.setBounds(495, 278, 23, 232);
+        separator_1_1.setBounds(495, 255, 2, 200);
         indexPanelA.add(separator_1_1);
 
         textField = new JTextField();
@@ -1249,9 +1324,9 @@ public class MesClient extends JFrame {
 
         txtfa = new JTextField();
         txtfa.setHorizontalAlignment(SwingConstants.LEFT);
-        txtfa.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
+        txtfa.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
         txtfa.setColumns(10);
-        txtfa.setBounds(239, 10, 503, 60);
+        txtfa.setBounds(239, 6, 503, 42);
         indexPanelA.add(txtfa);
         txtfa.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
@@ -1259,25 +1334,45 @@ public class MesClient extends JFrame {
             }
         });
 
+        yzj_scan_label = new JLabel("\u538b\u94f8\u4ef6\u4e8c\u7ef4\u7801");
+        yzj_scan_label.setForeground(new Color(0, 128, 192));
+        yzj_scan_label.setHorizontalAlignment(SwingConstants.RIGHT);
+        yzj_scan_label.setFont(new Font("微软雅黑", Font.PLAIN, 16));
+        yzj_scan_label.setBounds(97, 52, 132, 36);
+        indexPanelA.add(yzj_scan_label);
+
+        txtyzj = new JTextField();
+        txtyzj.setHorizontalAlignment(SwingConstants.LEFT);
+        txtyzj.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
+        txtyzj.setColumns(10);
+        txtyzj.setBounds(239, 52, 503, 36);
+        txtyzj.setEnabled(false);
+        indexPanelA.add(txtyzj);
+        txtyzj.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                scanYzjBarcode();
+            }
+        });
+
         page_text = new JLabel("当前:A面");
         page_text.setForeground(new Color(0, 255, 64));
-        page_text.setFont(new Font("微软雅黑", Font.PLAIN, 20));
+        page_text.setFont(new Font("微软雅黑", Font.PLAIN, 18));
         page_text.setHorizontalAlignment(SwingConstants.RIGHT);
-        page_text.setBounds(97, 10, 132, 60);
+        page_text.setBounds(97, 6, 132, 42);
         indexPanelA.add(page_text);
 
         scan_type_text = new JLabel("镭雕码");
         scan_type_text.setForeground(new Color(255, 128, 64));
         scan_type_text.setHorizontalAlignment(SwingConstants.LEFT);
-        scan_type_text.setFont(new Font("微软雅黑", Font.PLAIN, 20));
-        scan_type_text.setBounds(900, 10, 90, 60);
+        scan_type_text.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        scan_type_text.setBounds(900, 6, 90, 42);
         indexPanelA.add(scan_type_text);
 
         model_type_text = new JLabel("");
         model_type_text.setForeground(new Color(0, 128, 255));
         model_type_text.setHorizontalAlignment(SwingConstants.LEFT);
-        model_type_text.setFont(new Font("微软雅黑", Font.BOLD, 20));
-        model_type_text.setBounds(752, 10, 140, 60);
+        model_type_text.setFont(new Font("微软雅黑", Font.BOLD, 18));
+        model_type_text.setBounds(752, 6, 140, 42);
         indexPanelA.add(model_type_text);
 
         tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
@@ -1324,12 +1419,199 @@ public class MesClient extends JFrame {
         if(scan_type == 1){
             scan_type_text.setText("镭雕码");
         }else if(scan_type == 2){
-            scan_type_text.setText("后梁码");
+            scan_type_text.setText("\u538b\u94f8\u4ef6\u4e8c\u7ef4\u7801");
         }else{
             scan_type_text.setText("");
         }
     }
 
+    /** 质量通过后允许扫压铸件二维码 */
+    public static void enableYzjScan(){
+        formatScanType(2);
+        refreshScanInputState();
+        if(txtyzj != null){
+            txtyzj.requestFocusInWindow();
+        }
+    }
+
+    /** 根据当前面状态切换镭雕码/压铸件输入框可用状态 */
+    public static void refreshScanInputState(){
+        if(txtfa == null || txtyzj == null){
+            return;
+        }
+        boolean needYzj = false;
+        if("A".equals(curPage)){
+            needYzj = mesQualityFlagA && batch_status == 0 && product_sn != null
+                    && !product_sn.getText().trim().isEmpty();
+        }else if("B".equals(curPage)){
+            needYzj = mesQualityFlagB && batch_status2 == 0 && product_sn2 != null
+                    && !product_sn2.getText().trim().isEmpty();
+        }
+        if(needYzj){
+            formatScanType(2);
+            txtfa.setEnabled(false);
+            txtyzj.setEnabled(true);
+        }else{
+            formatScanType(1);
+            txtfa.setEnabled(true);
+            txtyzj.setEnabled(false);
+            txtyzj.setText("");
+        }
+    }
+
+    public static boolean checkYzjVersionLocal(String yzjSn, String sn){
+        if(yzjSn == null || sn == null){
+            return false;
+        }
+        if(sn.length() != 28 || yzjSn.length() != 28){
+            return false;
+        }
+        boolean snOverseas = false;
+        for(String p : YZJ_SN_OVERSEAS_PREFIXES){
+            if(sn.startsWith(p)){
+                snOverseas = true;
+                break;
+            }
+        }
+        boolean snDomestic = false;
+        for(String p : YZJ_SN_DOMESTIC_PREFIXES){
+            if(sn.startsWith(p)){
+                snDomestic = true;
+                break;
+            }
+        }
+        if(!snOverseas && !snDomestic){
+            return false;
+        }
+        if(snOverseas){
+            return yzjSn.startsWith(YZJ_WSN_OVERSEAS_PREFIX);
+        }
+        return yzjSn.startsWith(YZJ_WSN_DOMESTIC_PREFIX);
+    }
+
+    /** 重扫压铸件:仅刷新本地状态,重新扫码后绑定会覆盖MES数据 */
+    public static void rescanYzj(String side){
+        if("A".equals(side)){
+            if(MesClient.tjFlaga >= 2){
+                setMenuStatus("A面设备运行中或已结束,无法重扫压铸件",1);
+                return;
+            }
+            product_yzj.setText("");
+            batch_status = 0;
+            tjFlaga = 0;
+            if(mesQualityFlagA){
+                pxstatus1.setText("A:质量OK,请扫压铸件二维码");
+                setMenuStatus("A面请重新扫压铸件二维码",0);
+            }else{
+                pxstatus1.setText("A");
+                setMenuStatus("A面已刷新",0);
+            }
+        }else if("B".equals(side)){
+            if(MesClient.tjFlagb >= 2){
+                setMenuStatus("B面设备运行中或已结束,无法重扫压铸件",1);
+                return;
+            }
+            product_yzj2.setText("");
+            batch_status2 = 0;
+            tjFlagb = 0;
+            if(mesQualityFlagB){
+                pxstatus2.setText("B:质量OK,请扫压铸件二维码");
+                setMenuStatus("B面请重新扫压铸件二维码",0);
+            }else{
+                pxstatus2.setText("B");
+                setMenuStatus("B面已刷新",0);
+            }
+        }else{
+            return;
+        }
+        formatBatchSn();
+        refreshScanInputState();
+        if(side.equals(curPage) && txtyzj != null && txtyzj.isEnabled()){
+            txtyzj.requestFocusInWindow();
+        }
+        mesClientFrame.repaint();
+    }
+
+    /** 扫压铸件二维码并绑定到工艺号400002 */
+    public static void scanYzjBarcode(){
+        if(txtyzj == null || !txtyzj.isEnabled()){
+            setMenuStatus("请先扫镭雕码并通过质量校验",1);
+            return;
+        }
+        String yzjSn = txtyzj.getText().trim();
+        txtyzj.setText("");
+        if(yzjSn.isEmpty()){
+            setMenuStatus("\u538b\u94f8\u4ef6\u4e8c\u7ef4\u7801\u4e0d\u80fd\u4e3a\u7a7a",1);
+            return;
+        }
+        if(yzjSn.length() != 28){
+            setMenuStatus("\u538b\u94f8\u4ef6\u4e8c\u7ef4\u7801\u987b\u4e3a28\u4f4d",1);
+            return;
+        }
+
+        String sn;
+        if("A".equals(curPage)){
+            if(!mesQualityFlagA || product_sn.getText().trim().isEmpty()){
+                setMenuStatus("请先扫A面镭雕码",1);
+                return;
+            }
+            if(batch_status == 1){
+                setMenuStatus("A面压铸件已绑定,勿重复扫码",1);
+                return;
+            }
+            sn = product_sn.getText().trim();
+        }else{
+            if(!mesQualityFlagB || product_sn2.getText().trim().isEmpty()){
+                setMenuStatus("请先扫B面镭雕码",1);
+                return;
+            }
+            if(batch_status2 == 1){
+                setMenuStatus("B面压铸件已绑定,勿重复扫码",1);
+                return;
+            }
+            sn = product_sn2.getText().trim();
+        }
+
+        if(sn.length() != 28){
+            setMenuStatus("镭雕码须为28位",1);
+            return;
+        }
+        if(!checkYzjVersionLocal(yzjSn, sn)){
+            setMenuStatus("压铸件二维码与镭雕码版本不匹配(国内/海外)",1);
+            return;
+        }
+
+        getUser();
+        JSONObject retObj = DataUtil.bindYzjHttp(sn, yzjSn, user20, YZJ_CRAFT);
+        if(retObj == null){
+            setMenuStatus("请求失败,压铸件绑定失败,请重试",-1);
+            return;
+        }
+        if(retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")){
+            if("A".equals(curPage)){
+                product_yzj.setText(yzjSn);
+                batch_status = 1;
+                tjFlaga = 1;
+                pxstatus1.setText("A:可以加工,等待设备启动");
+            }else{
+                product_yzj2.setText(yzjSn);
+                batch_status2 = 1;
+                tjFlagb = 1;
+                pxstatus2.setText("B:可以加工,等待设备启动");
+            }
+            setMenuStatus("压铸件绑定成功,可启动设备",0);
+            refreshScanInputState();
+            formatBatchSn();
+            mesClientFrame.repaint();
+        }else{
+            if(retObj.get("result") == null){
+                setMenuStatus("请求失败,请重试",-1);
+            }else{
+                setMenuStatus(retObj.getString("message"),-1);
+            }
+        }
+    }
+
     public static void updateModelTypeText(){
         if(model_type_text == null){
             return;

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

@@ -38,16 +38,21 @@ public class MesRevice {
 
                 if(MesClient.curPage.equals("A")){
                     MesClient.mesQualityFlagA = true;
-                    MesClient.pxstatus1.setText("A:可以加工,等待设备启动");
+                    MesClient.pxstatus1.setText("A:质量OK,请扫压铸件二维码");
                     MesClient.curSna = MesClient.product_sn.getText();
-                    MesClient.tjFlaga = 1;
+                    // 扫完压铸件并绑定成功后才置 tjFlaga=1 并允许启动
+                    MesClient.tjFlaga = 0;
+                    MesClient.batch_status = 0;
                 }else{
                     MesClient.mesQualityFlagB = true;
-                    MesClient.pxstatus2.setText("B:可以加工,等待设备启动");
+                    MesClient.pxstatus2.setText("B:质量OK,请扫压铸件二维码");
                     MesClient.curSnb = MesClient.product_sn2.getText();
-                    MesClient.tjFlagb = 1;
+                    MesClient.tjFlagb = 0;
+                    MesClient.batch_status2 = 0;
                 }
-                PlcUtil.changeEnable(MesClient.s7PLC,true);
+                PlcUtil.changeEnable(MesClient.s7PLC,false);
+                MesClient.enableYzjScan();
+                MesClient.setMenuStatus("请扫压铸件二维码",0);
 
             }
         }catch (Exception e){

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

@@ -1,6 +1,6 @@
 mes.gw=OP080
-#mes.server_ip=127.0.0.1
-mes.server_ip=192.168.24.99
+mes.server_ip=127.0.0.1
+#mes.server_ip=192.168.24.99
 mes.tcp_port=3000
 mes.heart_beat_cycle=60
 mes.line_sn=XT