Browse Source

绑定前梁和左边梁

hfy 1 tuần trước cách đây
mục cha
commit
dcb4d9af70

+ 28 - 1
src/com/mes/ui/DataUtil.java

@@ -102,7 +102,34 @@ public class DataUtil {
             return false;
         }
     }
-
+    public static JSONObject bindWarehouse(String sn, String wsn, String user, String craft) {
+        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 mes_server_ip = pro.getProperty("mes.server_ip");
+            String oprno = pro.getProperty("mes.gw").trim();
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/bindWarehouse";
+            String sidParam = "";
+            if (MesClient.sessionid != null && !MesClient.sessionid.trim().isEmpty()) {
+                sidParam = "&__sid=" + MesClient.sessionid.trim();
+            }
+            String params = "__ajax=json&oprno=" + oprno + "&lineSn=" + lineSn + "&sn=" + sn + "&wsn=" + wsn + "&craft=" + craft + "&ucode=" + user + sidParam;
+            log.info("params=" + params);
+            String result = doPost(url, params);
+            log.info("result=" + result);
+            if (result == null || result.equalsIgnoreCase("false")) {
+                return null;
+            }
+            return JSONObject.parseObject(result);
+        } catch (Exception e) {
+            log.info("e=" + e.getMessage());
+            return null;
+        }
+    }
     public static Boolean unBindWarehouse(NettyClient nettyClient,String sn,String wsn,String user,String craft){
         try{
             String msgType = "MJBW";

+ 2 - 2
src/com/mes/ui/LoginFarme.java

@@ -187,14 +187,14 @@ public class LoginFarme extends JFrame {
                     MesClient.mesClientFrame.setVisible(true);
 
                     if(MesClient.jfxPanel == null){
-                        String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProductRecord/work?__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
+                        String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProductRecord/work?__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"B"+"&lineSn="+MesClient.mes_line_sn;
                         MesClient.jfxPanel = new MesWebView(url);
                         MesClient.jfxPanel.setSize(990, 550);
                         MesClient.indexPanelB.add(MesClient.jfxPanel);
                     }
 
                     if(MesClient.jfxPanel2 == null){
-                        String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProcessCheckRecord/ulist?__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
+                        String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProcessCheckRecord/ulist?__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"B"+"&lineSn="+MesClient.mes_line_sn;
                         MesClient.jfxPanel2 = new MesWebView(url);
                         MesClient.jfxPanel2.setSize(990, 550);
                         MesClient.indexPanelC.add(MesClient.jfxPanel2);

+ 260 - 146
src/com/mes/ui/MesClient.java

@@ -142,6 +142,23 @@ public class MesClient extends JFrame {
     public static JTable table;
     public static Object[] columnNames = { "物料名称", "绑定批次", "剩余次数", "操作" };
     public static Object[][] rowData = null;
+
+    public static int userLoginHours;//用户登录所处小时
+    public static JTextField textField;
+    public static JTextField textField_2;
+    public static JTextField textField_1;
+    public static JTextField textField_3;
+    public static JButton btnBindA;
+    public static JButton btnBindC;
+    public static JButton btnBindB;
+    public static JButton btnBindD;
+    public static String tempWsnA = "";
+    public static String tempWsnB = "";
+    public static String tempWsnC = "";
+    public static String tempWsnD = "";
+    public static JTextField txtfa;
+    public static JLabel scan_type_text;
+    public static JLabel page_text;
 //    public static Object[][] rowData = {
 //    };
 
@@ -407,49 +424,45 @@ public class MesClient extends JFrame {
     public static void resetScanA() {
         work_status = 0;
         check_quality_result = false;
-        MesClient.finish_ok_bt.setEnabled(false);
+        if (MesClient.finish_ok_bt != null) MesClient.finish_ok_bt.setEnabled(false);
         MesClient.mesQualityFlagA = false;
-        product_sn.setText("");
-        MesClient.pxstatus1.setText("A");
+        if (product_sn != null) product_sn.setText("");
+        if (MesClient.pxstatus1 != null) MesClient.pxstatus1.setText("A");
 
 //        PlcUtil.changeEnable(s7PLC,false);
 
-        MesClient.param1.setText("");
-        MesClient.param2.setText("");
-        MesClient.param3.setText("");
-        MesClient.param4.setText("");
-        MesClient.param5.setText("");
-
-        MesClient.param21.setText("");
-        MesClient.param22.setText("");
-        MesClient.param23.setText("");
-        MesClient.param24.setText("");
-        MesClient.param25.setText("");
+        if (MesClient.param1 != null) MesClient.param1.setText("");
+        if (MesClient.param2 != null) MesClient.param2.setText("");
+        if (MesClient.param3 != null) MesClient.param3.setText("");
+        if (MesClient.param4 != null) MesClient.param4.setText("");
+        if (MesClient.param5 != null) MesClient.param5.setText("");
 
         MesClient.curSna = "";
         MesClient.tjFlaga = 0;
         MesClient.checkA = 0;
 
-//        MesClient.batch_status = 0;
-//        MesClient.textField.setText("");
-//        MesClient.batch_scan_1.setEnabled(false);
+        MesClient.tempWsnA = "";
+        if (MesClient.btnBindA != null) MesClient.btnBindA.setEnabled(false);
+        if (textField != null) MesClient.textField.setText("");
+
+        MesClient.tempWsnC = "";
+        if (MesClient.btnBindC != null) MesClient.btnBindC.setEnabled(false);
+        if (textField_2 != null) MesClient.textField_2.setText("");
+
+        if (MesClient.batch_scan_1 != null) MesClient.batch_scan_1.setEnabled(false);
         MesClient.formatScanType(1);
 //        PlcUtil.changeEnable(MesClient.s7PLC,false);
 
-        finish_ok_bt.setEnabled(false);
-        finish_ng_bt.setEnabled(false);
+        if (finish_ok_bt != null) finish_ok_bt.setEnabled(false);
+        if (finish_ng_bt != null) finish_ng_bt.setEnabled(false);
+        setMenuStatus("请扫镭雕码", 0);
 
         updateMaterailData(); // 更新物料
 
         shiftUserCheck();
     }
 
-    public static int userLoginHours;//用户登录所处小时
-    public static JTextField textField;
-    public static JTextField textField_1;
-    public static JTextField txtfa;
-    public static JLabel scan_type_text;
-    public static JLabel page_text;
+
     //换班用户信息检查
     private static  void  shiftUserCheck() {
         LocalDateTime now = LocalDateTime.now();
@@ -471,36 +484,36 @@ public class MesClient extends JFrame {
     public static void resetScanB() {
         work_status2 = 0;
         check_quality_result2 = false;
-        MesClient.finish_ng_bt.setEnabled(false);
+        if (MesClient.finish_ng_bt != null) MesClient.finish_ng_bt.setEnabled(false);
         MesClient.mesQualityFlagB = false;
-        product_sn2.setText("");
+        if (product_sn2 != null) product_sn2.setText("");
 
 //        PlcUtil.changeEnable(s7PLC,false);
 
-        MesClient.pxstatus2.setText("B");
-        MesClient.param1.setText("");
-        MesClient.param2.setText("");
-        MesClient.param3.setText("");
-        MesClient.param4.setText("");
-        MesClient.param5.setText("");
-
-        MesClient.param21.setText("");
-        MesClient.param22.setText("");
-        MesClient.param23.setText("");
-        MesClient.param24.setText("");
-        MesClient.param25.setText("");
+        if (MesClient.pxstatus2 != null) MesClient.pxstatus2.setText("B");
+        if (MesClient.param21 != null) MesClient.param21.setText("");
+        if (MesClient.param22 != null) MesClient.param22.setText("");
+        if (MesClient.param23 != null) MesClient.param23.setText("");
+        if (MesClient.param24 != null) MesClient.param24.setText("");
+        if (MesClient.param25 != null) MesClient.param25.setText("");
         MesClient.curSnb = "";
         MesClient.tjFlagb = 0;
         MesClient.checkB = 0;
 
-//        MesClient.batch_status2 = 0;
-//        MesClient.textField_1.setText("");
-//        MesClient.batch_scan_2.setEnabled(false);
+        MesClient.tempWsnB = "";
+        if (MesClient.btnBindB != null) MesClient.btnBindB.setEnabled(false);
+        if (MesClient.textField_1 != null) MesClient.textField_1.setText("");
+
+        MesClient.tempWsnD = "";
+        if (MesClient.btnBindD != null) MesClient.btnBindD.setEnabled(false);
+        if (MesClient.textField_3 != null) MesClient.textField_3.setText("");
+        setMenuStatus("请扫镭雕码", 0);
+
+        if (MesClient.batch_scan_2 != null) MesClient.batch_scan_2.setEnabled(false);
         MesClient.formatScanType(1);
 //        PlcUtil.changeEnable(MesClient.s7PLC,false);
-        finish_ok_bt2.setEnabled(false);
-        finish_ng_bt2.setEnabled(false);
-
+        if (finish_ok_bt2 != null) finish_ok_bt2.setEnabled(false);
+        if (finish_ng_bt2 != null) finish_ng_bt2.setEnabled(false);
 
         updateMaterailData(); // 更新物料
 
@@ -597,28 +610,36 @@ public class MesClient extends JFrame {
         });
         settingMenu.add(resetTcpMenu);
 
-        JMenuItem resetTcpMenu_1 = new JMenuItem("\u91CD\u65B0\u626B\u7801-A");
+        JMenuItem resetTcpMenu_1 = new JMenuItem("重新扫码-A");
         resetTcpMenu_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
         resetTcpMenu_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
-        resetTcpMenu_1.addMouseListener(new MouseAdapter() {
+        resetTcpMenu_1.addActionListener(new ActionListener() {
             @Override
-            public void mousePressed(MouseEvent e) {
-                super.mouseClicked(e);
+            public void actionPerformed(ActionEvent e) {
                 resetScanA();
-                PlcUtil.changeEnable(s7PLC,false);
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        PlcUtil.changeEnable(s7PLC,false);
+                    }
+                }).start();
             }
         });
         settingMenu.add(resetTcpMenu_1);
 
-        JMenuItem resetTcpMenu_1_1 = new JMenuItem("\u91CD\u65B0\u626B\u7801-B");
+        JMenuItem resetTcpMenu_1_1 = new JMenuItem("重新扫码-B");
         resetTcpMenu_1_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
         resetTcpMenu_1_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
-        resetTcpMenu_1_1.addMouseListener(new MouseAdapter() {
+        resetTcpMenu_1_1.addActionListener(new ActionListener() {
             @Override
-            public void mousePressed(MouseEvent e) {
-                super.mouseClicked(e);
+            public void actionPerformed(ActionEvent e) {
                 resetScanB();
-                PlcUtil.changeEnable(s7PLC,false);
+                new Thread(new Runnable() {
+                    @Override
+                    public void run() {
+                        PlcUtil.changeEnable(s7PLC,false);
+                    }
+                }).start();
             }
         });
         settingMenu.add(resetTcpMenu_1_1);
@@ -1109,24 +1130,6 @@ public class MesClient extends JFrame {
         pxstatus2.setBounds(517, 98, 446, 44);
         indexPanelA.add(pxstatus2);
 
-        JSeparator separator_2 = new JSeparator();
-        separator_2.setBounds(10, 264, 973, 13);
-//        indexPanelA.add(separator_2);
-
-        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.setVisible(false);
-//        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.setVisible(false);
-//        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);
@@ -1138,45 +1141,42 @@ public class MesClient extends JFrame {
         textField.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
         textField.setEditable(false);
         textField.setColumns(10);
-        textField.setBounds(26, 333, 446, 70);
-//        indexPanelA.add(textField);
-
-        batch_scan_1 = new JButton("解绑");
-        batch_scan_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/delete.png")));
-        batch_scan_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 32));
-        batch_scan_1.setEnabled(false);
-        batch_scan_1.setVisible(false);
-        batch_scan_1.setBounds(136, 430, 230, 80);
-        batch_scan_1.addActionListener(new ActionListener() {
+        textField.setBounds(26, 260, 300, 70);
+        indexPanelA.add(textField);
+
+        btnBindA = new JButton("绑定前梁");
+        //btnBindA.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
+        btnBindA.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        btnBindA.setEnabled(false);
+        btnBindA.setBounds(350, 260, 140, 70);
+        btnBindA.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
-                if(MesClient.curPage.equals("B")){
-                    MesClient.setMenuStatus("该状态后梁无法解绑",-1);
-                }else{
-                    String sn = MesClient.product_sn.getText().trim();
-                    String wsn = MesClient.textField.getText().trim();
-                    JSONObject retObj = DataUtil.unBindWarehouseData(sn,wsn,user_menu.getText().trim(),"400007");
-                    if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
-                        MesClient.setMenuStatus("后梁码解绑成功",0);
-                        MesClient.formatScanType(2);
-
-                        textField.setText("");
-                        batch_scan_1.setEnabled(false);
-                        PlcUtil.changeEnable(s7PLC,false);
-                    }else{
-                        MesClient.formatScanType(2);
-                        batch_scan_1.setEnabled(true);
-                        if(retObj.get("result")==null){
-                            MesClient.setMenuStatus("请求失败,后梁码解绑失败,请重试",-1);
-                        }else{
-                            if(retObj.get("result").toString().equalsIgnoreCase("false")){
-                                MesClient.setMenuStatus(retObj.getString("message"),-1);
-                            }
-                        }
-                    }
-                }
+                scanFrontBeam("A");
+            }
+        });
+        indexPanelA.add(btnBindA);
+
+        textField_2 = new JTextField();
+        textField_2.setText("");
+        textField_2.setHorizontalAlignment(SwingConstants.CENTER);
+        textField_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
+        textField_2.setEditable(false);
+        textField_2.setColumns(10);
+        textField_2.setBounds(26, 350, 300, 70);
+        indexPanelA.add(textField_2);
+
+        btnBindC = new JButton("绑定左边梁");
+        //btnBindA.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
+        btnBindC.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        btnBindC.setEnabled(false);
+        btnBindC.setBounds(350, 350, 140, 70);
+        btnBindC.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                scanFrontZuoBeam("A");
             }
         });
-        indexPanelA.add(batch_scan_1);
+        indexPanelA.add(btnBindC);
+
 
         textField_1 = new JTextField();
         textField_1.setText("");
@@ -1184,42 +1184,42 @@ public class MesClient extends JFrame {
         textField_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
         textField_1.setEditable(false);
         textField_1.setColumns(10);
-        textField_1.setBounds(517, 333, 446, 70);
-//        indexPanelA.add(textField_1);
-
-        batch_scan_2 = new JButton("解绑");
-        batch_scan_2.setIcon(new ImageIcon(MesClient.class.getResource("/bg/delete.png")));
-        batch_scan_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 32));
-        batch_scan_2.setEnabled(false);
-        batch_scan_2.setVisible(false);
-        batch_scan_2.setBounds(633, 430, 230, 80);
-        batch_scan_2.addActionListener(new ActionListener() {
+        textField_1.setBounds(517, 260, 300, 70);
+        indexPanelA.add(textField_1);
+
+        btnBindB = new JButton("绑定前梁");
+       // btnBindB.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
+        btnBindB.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        btnBindB.setEnabled(false);
+        btnBindB.setBounds(840, 260, 140, 70);
+        btnBindB.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
-                if(MesClient.curPage.equals("A")){
-                    MesClient.setMenuStatus("该状态后梁无法解绑",-1);
-                }else{
-                    String sn = MesClient.product_sn2.getText().trim();
-                    String wsn = MesClient.textField_1.getText().trim();
-                    JSONObject retObj = DataUtil.unBindWarehouseData(sn,wsn,user_menu.getText().trim(),"400007");
-                    if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
-                        MesClient.setMenuStatus("后梁码解绑成功",0);
-                        MesClient.formatScanType(2);
-                        textField_1.setText("");
-                        batch_scan_2.setEnabled(false);
-                        PlcUtil.changeEnable(s7PLC,false);
-                    }else{
-                        if(retObj.get("result")==null){
-                            MesClient.setMenuStatus("请求失败,前梁码解绑失败,请重试",-1);
-                        }else{
-                            if(retObj.get("result").toString().equalsIgnoreCase("false")){
-                                MesClient.setMenuStatus(retObj.getString("message"),-1);
-                            }
-                        }
-                    }
-                }
+                scanFrontBeam("B");
+            }
+        });
+        indexPanelA.add(btnBindB);
+
+        textField_3 = new JTextField();
+        textField_3.setText("");
+        textField_3.setHorizontalAlignment(SwingConstants.CENTER);
+        textField_3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
+        textField_3.setEditable(false);
+        textField_3.setColumns(10);
+        textField_3.setBounds(517, 350, 300, 70);
+        indexPanelA.add(textField_3);
+
+        btnBindD = new JButton("绑定左边梁");
+        //btnBindA.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
+        btnBindD.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
+        btnBindD.setEnabled(false);
+        btnBindD.setBounds(840, 350, 140, 70);
+        btnBindD.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                scanFrontZuoBeam("B");
             }
         });
-        indexPanelA.add(batch_scan_2);
+        indexPanelA.add(btnBindD);
+
 
         JLabel pxstatus1_1 = new JLabel("A后梁");
         pxstatus1_1.setHorizontalAlignment(SwingConstants.CENTER);
@@ -1302,10 +1302,11 @@ public class MesClient extends JFrame {
 
     public static void formatScanType(int st){
         scan_type = st;
+        if (scan_type_text == null) return;
         if(scan_type == 1){
             scan_type_text.setText("镭雕码");
         }else if(scan_type == 2){
-            scan_type_text.setText("梁码");
+            scan_type_text.setText("梁码");
         }else{
             scan_type_text.setText("");
         }
@@ -1318,8 +1319,7 @@ public class MesClient extends JFrame {
         //刷新界面
         mesClientFrame.repaint();
         System.out.println("456");
-        System.out.println("156"+scan_type);
-        if(MesClient.scan_type == 1){ // 镭雕码
+        System.out.println("156"+scan_type);// 镭雕码
             System.out.println("type1");
             if(scanBarcodeSn.isEmpty()){
                 System.out.println("type2");
@@ -1352,10 +1352,124 @@ public class MesClient extends JFrame {
             if(!sendret){
                 MesClient.setMenuStatus("消息发送失败,请重试",1);
             }
+
+    }
+
+    public static void scanFrontBeam(String op) {
+        String scanBarcodeTitle = "请扫前梁二维码(" + op + "面)";
+        String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
+        if (scanBarcode != null && !scanBarcode.trim().isEmpty()) {
+            String sn = op.equals("A") ? product_sn.getText().trim() : product_sn2.getText().trim();
+            if (sn.isEmpty()) {
+                setMenuStatus(op + "面请先扫描镭雕码", 1);
+                return;
+            }
+            // 绑定前梁码
+            if (op.equals("A")) {
+                tempWsnA=scanBarcode.trim() ;
+                JSONObject retObj = DataUtil.bindWarehouse(sn,tempWsnA,user20,"400008");
+                if (retObj != null && retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
+                    MesClient.textField.setText(tempWsnA);
+                    setMenuStatus("前梁码绑定成功", 0);
+                    btnBindA.setEnabled(false);
+                    //如果A面左边梁为空,setMenuStatus设置状态,A面左边梁不为空则启动设备
+                    if (textField_2 != null && textField_2.getText().trim().length() > 0){
+                        PlcUtil.changeEnable(MesClient.s7PLC,true);
+                        MesClient.pxstatus1.setText("A:可以加工,等待设备启动");
+                    }else {
+                        setMenuStatus("左边梁为空,请绑定左边梁", 0);
+                    }
+
+                } else {
+                    if (retObj == null || retObj.get("result") == null) {
+                        setMenuStatus("请求失败,请重试", -1);
+                    } else {
+                        setMenuStatus(retObj.getString("message"), -1);
+                    }
+                }
+            }
+            else {
+                tempWsnB=scanBarcode.trim();
+                JSONObject retObj = DataUtil.bindWarehouse(sn,tempWsnB,user20,"400008");
+                if (retObj != null && retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
+                    MesClient.textField_1.setText(tempWsnB);
+                    btnBindB.setEnabled(false);
+                    setMenuStatus("前梁码绑定成功", 0);
+                    if (textField_3 != null && textField_3.getText().trim().length() > 0){
+                        PlcUtil.changeEnable(MesClient.s7PLC,true);
+                        MesClient.pxstatus2.setText("B:可以加工,等待设备启动");
+                    }else {
+                        setMenuStatus("左边梁为空,请绑定左边梁", 0);
+                    }
+                } else {
+                    if (retObj == null || retObj.get("result") == null) {
+                        setMenuStatus("请求失败,请重试", -1);
+                    } else {
+                        setMenuStatus(retObj.getString("message"), -1);
+                    }
+                }
+            }
+        }
+    }
+    //绑定左边梁
+    public static void scanFrontZuoBeam(String op) {
+        String scanBarcodeTitle = "请扫左边梁二维码(" + op + "面)";
+        String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
+        if (scanBarcode != null && !scanBarcode.trim().isEmpty()) {
+            String sn = op.equals("A") ? product_sn.getText().trim() : product_sn2.getText().trim();
+            if (sn.isEmpty()) {
+                setMenuStatus(op + "面请先扫描镭雕码", 1);
+                return;
+            }
+            // 绑定左边梁
+            if (op.equals("A")) {
+                tempWsnC=scanBarcode.trim() ;
+                JSONObject retObj = DataUtil.bindWarehouse(sn,tempWsnC,user20,"400009");
+                if (retObj != null && retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
+                    MesClient.textField_2.setText(tempWsnC);
+                    btnBindC.setEnabled(false);
+                    setMenuStatus("左边梁绑定成功", 0);
+                    if (textField != null && textField.getText().trim().length() > 0){
+                        PlcUtil.changeEnable(MesClient.s7PLC,true);
+                        MesClient.pxstatus1.setText("A:可以加工,等待设备启动");
+                    }else {
+                        setMenuStatus("前边梁为空,请绑定前边梁", 0);
+                    }
+
+                } else {
+                    if (retObj == null || retObj.get("result") == null) {
+                        setMenuStatus("请求失败,请重试", -1);
+                    } else {
+                        setMenuStatus(retObj.getString("message"), -1);
+                    }
+                }
+            }
+            else {
+                tempWsnD=scanBarcode.trim();
+                JSONObject retObj = DataUtil.bindWarehouse(sn,tempWsnD,user20,"400009");
+                if (retObj != null && retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
+                    MesClient.textField_3.setText(tempWsnD);
+                    btnBindD.setEnabled(false);
+                    setMenuStatus("左边梁绑定成功", 0);
+                    if (textField_1 != null && textField_1.getText().trim().length() > 0){
+                        PlcUtil.changeEnable(MesClient.s7PLC,true);
+                        MesClient.pxstatus2.setText("B:可以加工,等待设备启动");
+                    }else {
+                        setMenuStatus("前边梁为空,请绑定前边梁", 0);
+                    }
+                } else {
+                    if (retObj == null || retObj.get("result") == null) {
+                        setMenuStatus("请求失败,请重试", -1);
+                    } else {
+                        setMenuStatus(retObj.getString("message"), -1);
+                    }
+                }
+            }
         }
     }
 
     public static void setMenuStatus(String msg,int error){
+        if (MesClient.status_menu == null) return;
         if(error == 0){
             MesClient.status_menu.setForeground(Color.GREEN);
         }else{
@@ -1401,7 +1515,7 @@ public class MesClient extends JFrame {
                 i++;
             }
 
-            MesClient.table.repaint();
+            if (MesClient.table != null) MesClient.table.repaint();
         }
     }
 

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

@@ -22,18 +22,26 @@ public class MesRevice {
                     String barcode36 = MesClient.getBarcode(sn);//处理36为码
                     MesClient.getUser();
                     DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"A");
+                    MesClient.btnBindA.setEnabled(true);
+                    MesClient.btnBindC.setEnabled(true);
                 }else if(oprno.equals("OP110B")){
                     String barcode36 = MesClient.getBarcode(sn);//处理36为码
                     MesClient.getUser();
                     DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"B");
+                    MesClient.btnBindB.setEnabled(true);
+                    MesClient.btnBindD.setEnabled(true);
                 }else if(oprno.equals("OP110C")){
                     String barcode36 = MesClient.getBarcode(sn);//处理36为码
                     MesClient.getUser();
                     DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"A");
+                    MesClient.btnBindA.setEnabled(true);
+                    MesClient.btnBindC.setEnabled(true);
                 }else if(oprno.equals("OP110D")){
                     String barcode36 = MesClient.getBarcode(sn);//处理36为码
                     MesClient.getUser();
                     DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"B");
+                    MesClient.btnBindB.setEnabled(true);
+                    MesClient.btnBindD.setEnabled(true);
                 }
 
             }else {
@@ -44,6 +52,7 @@ public class MesRevice {
                 }
 
                 String lmsg = ErrorMsg.getErrorMsg(processMsgRet, mes_msg);
+                System.out.println("baocddddddd"+lmsg);
                 MesClient.setMenuStatus(lmsg,-1);
                 PlcUtil.changeEnable(MesClient.s7PLC,false);
             }
@@ -62,19 +71,31 @@ public class MesRevice {
 
                 if(oprno.equals(MesClient.mes_gw+"A") || oprno.equals(MesClient.mes_gw+"C")){
                     MesClient.mesQualityFlagA = true;
-                    MesClient.pxstatus1.setText("A:可以加工,等待设备启动");
+                    MesClient.pxstatus1.setText("A:绑定前梁码和左边梁码后设备启动");
                     MesClient.curSna = MesClient.product_sn.getText();
                     MesClient.tjFlaga = 1;
+                    MesClient.btnBindA.setEnabled(true);
+                    MesClient.btnBindC.setEnabled(true);
+                    MesClient.textField.setText("");
+                    MesClient.textField_2.setText("");
+                    MesClient.tempWsnC = "";
+                    MesClient.tempWsnA = "";
                 }else{
                     MesClient.mesQualityFlagB = true;
-                    MesClient.pxstatus2.setText("B:可以加工,等待设备启动");
+                    MesClient.pxstatus2.setText("B:绑定前梁码和左边梁码后设备启动");
                     MesClient.curSnb = MesClient.product_sn2.getText();
                     MesClient.tjFlagb = 1;
+                    MesClient.btnBindB.setEnabled(true);
+                    MesClient.btnBindD.setEnabled(true);
+                    MesClient.textField_1.setText("");
+                    MesClient.textField_3.setText("");
+                    MesClient.tempWsnD = "";
+                    MesClient.tempWsnB = "";
                 }
 //                System.out.println("scan_type1:"+MesClient.scan_type);
 //                MesClient.formatScanType(2);// 1=镭雕码 2=后梁码
 //                System.out.println("scan_type2:"+MesClient.scan_type);
-                PlcUtil.changeEnable(MesClient.s7PLC,true);
+             //   PlcUtil.changeEnable(MesClient.s7PLC,true);
 
             }
         }catch (Exception e){

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

@@ -169,7 +169,13 @@ public class PlcUtil {
     }
 
     public static void getStatusA(S7PLC s7PLC){
-        if(MesClient.tjFlaga == 1){ // 已扫码,设备未运行
+        if(MesClient.tjFlaga == 1&&MesClient.textField != null && !MesClient.textField.getText().trim().isEmpty()&&MesClient.textField_2 != null && !MesClient.textField_2.getText().trim().isEmpty()){ // 已扫码,设备未运行
+            if (MesClient.textField.getText().trim().isEmpty()){
+                MesClient.setMenuStatus("A:前梁码为空",-1);
+            }
+            if (MesClient.textField_2.getText().trim().isEmpty()){
+                MesClient.setMenuStatus("A:左边梁为空",-1);
+            }
             Boolean starta = getAStart(s7PLC); //A启动中
             if(starta){
                 MesClient.curFlag = "A";
@@ -197,7 +203,13 @@ public class PlcUtil {
     }
 
     public static void getStatusB(S7PLC s7PLC){
-        if(MesClient.tjFlagb == 1){ // 已扫码,设备未运行
+        if(MesClient.tjFlagb == 1&&MesClient.textField_1 != null && !MesClient.textField_1.getText().trim().isEmpty()&&MesClient.textField_3 != null && !MesClient.textField_3.getText().trim().isEmpty()){ // 已扫码,设备未运行
+            if (MesClient.textField_1.getText().trim().isEmpty()){
+                MesClient.setMenuStatus("B:前梁码为空",-1);
+            }
+            if (MesClient.textField_3.getText().trim().isEmpty()){
+                MesClient.setMenuStatus("B:左边梁为空",-1);
+            }
             Boolean startb = getBStart(s7PLC); //B启动中
             if(startb){
                 MesClient.curFlag = "B";
@@ -273,7 +285,7 @@ public class PlcUtil {
     public static Boolean changeEnable(S7PLC s7PLC,Boolean result){
         try{
             //DB9.21.7 A//DB9.26.4 B
-            s7PLC.writeBoolean("DB9.26.4",result);
+            s7PLC.writeBoolean("DB9.23.7",result);
 //            s7PLC.writeBoolean("DB9.21.7",result);
             return true;
         }catch (Exception e){

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

@@ -4,4 +4,4 @@ mes.server_ip=192.168.22.99
 mes.tcp_port=3000
 mes.heart_beat_cycle=60
 mes.line_sn=XT
-mes.gwflag=A
+mes.gwflag=B