Kaynağa Gözat

拉铆ng复盘+绑定液冷板

张田野 4 gün önce
ebeveyn
işleme
7eca722a9e

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

@@ -101,6 +101,32 @@ public class DataUtil {
         }
     }
 
+    /**
+     * HTTP 绑定液冷板(同步等待返回,成功后才能开启拉铆)
+     */
+    public static JSONObject bindWarehouseHttp(String sn,String materielSn,String user,String craft ){
+        String ret = "OK";
+        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/bindWarehouse";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&result="+ret+"&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 Boolean unBindWarehouse(NettyClient nettyClient,String sn,String wsn,String user,String craft){
         try{
             String msgType = "MJBW";

+ 145 - 30
src/com/mes/ui/MesClient.java

@@ -69,7 +69,14 @@ public class MesClient extends JFrame {
     public static JButton finish_ok_bt;
     public static JButton finish_ng_bt;
     public static JTextField product_sn;
+    public static JTextField product_sn_lb;
     public static JButton f_scan_data_bt_1;
+    public static JButton f_scan_data_bt_2;
+
+    /** 液冷板绑定工艺号(与工艺模板配置一致) */
+    public static final String COLD_PLATE_CRAFT = "400006";
+    /** 液冷板是否已绑定成功(绑定成功后才允许开启拉铆) */
+    public static Boolean cold_plate_bound = false;
 
     public static String user20 = "";
 
@@ -86,10 +93,15 @@ public class MesClient extends JFrame {
     public static JTextField param3;
     public static JTextField param4;
 
-//    public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.7");
-//    public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.8");
-    public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.27");
-    public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.28");
+
+
+//    tw -210b
+//    public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.7");//81
+//    public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.8");//1
+
+//    tw-op130b
+    public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.7");//29
+    public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.8");//26
 
     public static Timer cjTimer;
 
@@ -97,14 +109,15 @@ public class MesClient extends JFrame {
 
     public static Timer cjTimer3;
 
-    public static Short aSetNum = 19;
-//    public static Short aSetNum = 49;
+    public static Short aSetNum = 29;
+//public static Short aSetNum = 81;
+
     public static Short sortA = 0;
     public static Short aMax = 0;
     public static Short aFinish = 0;
     public static List<Map> alist = new ArrayList<>();
-    public static Short bSetNum = 50;
-//    public static Short bSetNum = 27;
+    public static Short bSetNum = 26;
+//public static Short bSetNum = 1;
     public static Short sortB = 0;
     public static Short bMax = 0;
     public static Short bFinish = 0;
@@ -184,7 +197,7 @@ public class MesClient extends JFrame {
         cjTimer4.schedule(new TimerTask() {
             public void run() {
                 try{
-                    if(work_status == 1){
+                    if(work_status == 1 && cold_plate_bound){
                         List<Boolean> yxstatus = plcA.readCoil(3128,1);
                         if(yxstatus.size() >= 1 && !yxstatus.get(0)){
                             if(!MesClient.curSn.isEmpty() && MesClient.aMax > 0 && MesClient.aMax == MesClient.sortA){
@@ -425,10 +438,17 @@ public class MesClient extends JFrame {
     public static void resetScanA() {
         work_status = 0;
         check_quality_result = false;
+        cold_plate_bound = false;
         MesClient.finish_ok_bt.setEnabled(false);
         MesClient.finish_ng_bt.setEnabled(false);
         product_sn.setText("");
         curSn = "";
+        if (product_sn_lb != null) {
+            product_sn_lb.setText("");
+        }
+        if (f_scan_data_bt_2 != null) {
+            f_scan_data_bt_2.setEnabled(false);
+        }
 
         MesClient.f_scan_data_bt_1.setEnabled(true);
         MesClient.setMenuStatus("请扫工件码",0);
@@ -726,6 +746,38 @@ public class MesClient extends JFrame {
         f_scan_data_bt_1.setBounds(693, 70, 198, 70);
         indexPanelA.add(f_scan_data_bt_1);
 
+        JLabel lbLabel = new JLabel("液冷板:");
+        lbLabel.setFont(new Font("微软雅黑", Font.PLAIN, 24));
+        lbLabel.setBounds(10, 155, 90, 50);
+        indexPanelA.add(lbLabel);
+        product_sn_lb = new JTextField();
+        product_sn_lb.setHorizontalAlignment(SwingConstants.CENTER);
+        product_sn_lb.setEditable(false);
+        product_sn_lb.setFont(new Font("微软雅黑", Font.PLAIN, 28));
+        product_sn_lb.setBounds(100, 150, 580, 60);
+        indexPanelA.add(product_sn_lb);
+        product_sn_lb.setColumns(10);
+
+        f_scan_data_bt_2 = new JButton("扫码");
+        f_scan_data_bt_2.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if (product_sn.getText().isEmpty()){
+                    setMenuStatus("请在扫完工件码后扫液冷板码!",1);
+                    return;
+                }
+                if (work_status == 1 && check_quality_result){
+                    scanBarcodeLb();
+                }else{
+                    setMenuStatus("请在工件质量检测合格后扫液冷板码!",1);
+                }
+            }
+        });
+        f_scan_data_bt_2.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
+        f_scan_data_bt_2.setFont(new Font("微软雅黑", Font.PLAIN, 30));
+        f_scan_data_bt_2.setBounds(693, 150, 198, 60);
+        f_scan_data_bt_2.setEnabled(false);
+        indexPanelA.add(f_scan_data_bt_2);
+
 //        String[] hjtitles = new String[]{"焊机1","焊机2","焊机3"};
 //        String[] hjvals = new String[]{"HJ001","HJ002","HJ003"};
 //        mesRadioHj = new MesRadio(hjtitles,hjvals);
@@ -738,6 +790,10 @@ public class MesClient extends JFrame {
         finish_ok_bt.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 if(work_status == 1 && check_quality_result){
+                    if (!cold_plate_bound){
+                        JOptionPane.showMessageDialog(MesClient.mesClientFrame,"请绑定液冷板码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
+                        return;
+                    }
 
                     String sn = getBarcode(product_sn.getText());
                     getUser();
@@ -754,7 +810,7 @@ public class MesClient extends JFrame {
         });
         finish_ok_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ok_bg.png")));
         finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
-        finish_ok_bt.setBounds(185, 395, 240, 80);
+        finish_ok_bt.setBounds(185, 470, 240, 80);
         finish_ok_bt.setEnabled(false);
         indexPanelA.add(finish_ok_bt);
 
@@ -777,19 +833,19 @@ public class MesClient extends JFrame {
         });
         finish_ng_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ng_bg.png")));
         finish_ng_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
-        finish_ng_bt.setBounds(508, 395, 240, 80);
+        finish_ng_bt.setBounds(508, 470, 240, 80);
         finish_ng_bt.setEnabled(false);
         indexPanelA.add(finish_ng_bt);
 
         JLabel lblNewLabel = new JLabel("A\u67AA");
         lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
         lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
-        lblNewLabel.setBounds(204, 186, 166, 28);
+        lblNewLabel.setBounds(204, 230, 166, 28);
         indexPanelA.add(lblNewLabel);
 
         JLabel lblNewLabel_1 = new JLabel("\u9884\u8BBE\u6570\u91CF");
         lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1.setBounds(204, 241, 83, 34);
+        lblNewLabel_1.setBounds(204, 275, 83, 34);
         indexPanelA.add(lblNewLabel_1);
 
         param1 = new JTextField();
@@ -797,13 +853,13 @@ public class MesClient extends JFrame {
         param1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
         param1.setText("0");
         param1.setEditable(false);
-        param1.setBounds(288, 241, 83, 34);
+        param1.setBounds(288, 275, 83, 34);
         indexPanelA.add(param1);
         param1.setColumns(10);
 
         JLabel lblNewLabel_1_1 = new JLabel("\u5B8C\u6210\u6570\u91CF");
         lblNewLabel_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1_1.setBounds(204, 285, 83, 34);
+        lblNewLabel_1_1.setBounds(204, 319, 83, 34);
         indexPanelA.add(lblNewLabel_1_1);
 
         param2 = new JTextField();
@@ -812,18 +868,18 @@ public class MesClient extends JFrame {
         param2.setText("0");
         param2.setEditable(false);
         param2.setColumns(10);
-        param2.setBounds(288, 285, 83, 34);
+        param2.setBounds(288, 319, 83, 34);
         indexPanelA.add(param2);
 
         JLabel lblB = new JLabel("B\u67AA");
         lblB.setHorizontalAlignment(SwingConstants.CENTER);
         lblB.setFont(new Font("微软雅黑", Font.PLAIN, 20));
-        lblB.setBounds(525, 186, 166, 28);
+        lblB.setBounds(525, 230, 166, 28);
         indexPanelA.add(lblB);
 
         JLabel lblNewLabel_1_2 = new JLabel("\u9884\u8BBE\u6570\u91CF");
         lblNewLabel_1_2.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1_2.setBounds(525, 241, 83, 34);
+        lblNewLabel_1_2.setBounds(525, 275, 83, 34);
         indexPanelA.add(lblNewLabel_1_2);
 
         param3 = new JTextField();
@@ -832,12 +888,12 @@ public class MesClient extends JFrame {
         param3.setFont(new Font("微软雅黑", Font.PLAIN, 18));
         param3.setEditable(false);
         param3.setColumns(10);
-        param3.setBounds(608, 241, 83, 34);
+        param3.setBounds(608, 275, 83, 34);
         indexPanelA.add(param3);
 
         JLabel lblNewLabel_1_1_1 = new JLabel("\u5B8C\u6210\u6570\u91CF");
         lblNewLabel_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
-        lblNewLabel_1_1_1.setBounds(525, 285, 83, 34);
+        lblNewLabel_1_1_1.setBounds(525, 319, 83, 34);
         indexPanelA.add(lblNewLabel_1_1_1);
 
         param4 = new JTextField();
@@ -846,17 +902,17 @@ public class MesClient extends JFrame {
         param4.setFont(new Font("微软雅黑", Font.PLAIN, 18));
         param4.setEditable(false);
         param4.setColumns(10);
-        param4.setBounds(608, 285, 83, 34);
+        param4.setBounds(608, 319, 83, 34);
         indexPanelA.add(param4);
 
         JLabel lblNgJudgeA = new JLabel("NG\u590d\u5224");
         lblNgJudgeA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        lblNgJudgeA.setBounds(204, 322, 167, 22);
+        lblNgJudgeA.setBounds(204, 358, 167, 22);
         indexPanelA.add(lblNgJudgeA);
 
         JLabel lblNgJudgeB = new JLabel("NG\u590d\u5224");
         lblNgJudgeB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        lblNgJudgeB.setBounds(525, 322, 167, 22);
+        lblNgJudgeB.setBounds(525, 358, 167, 22);
         indexPanelA.add(lblNgJudgeB);
 
         resetResultA = new JButton("重拉");
@@ -879,7 +935,9 @@ public class MesClient extends JFrame {
                         smaxA = "";
                         sminA = "";
                         curA = "";
-                        ModbusUtil.setPowerOn(plcA);
+                        if(cold_plate_bound){
+                            ModbusUtil.setPowerOn(plcA);
+                        }
                     }else{
                         setMenuStatus("NG中断未审核",-1);
                     }
@@ -888,7 +946,7 @@ public class MesClient extends JFrame {
         });
         resetResultA.setEnabled(false);
         resetResultA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        resetResultA.setBounds(204, 348, 70, 36);
+        resetResultA.setBounds(204, 384, 70, 36);
         indexPanelA.add(resetResultA);
 
         okResultA = new JButton("OK");
@@ -923,7 +981,7 @@ public class MesClient extends JFrame {
         okResultA.setEnabled(false);
         okResultA.setForeground(new Color(0, 128, 0));
         okResultA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        okResultA.setBounds(281, 348, 70, 36);
+        okResultA.setBounds(281, 384, 70, 36);
         indexPanelA.add(okResultA);
 
         ngResultA = new JButton("NG");
@@ -957,7 +1015,7 @@ public class MesClient extends JFrame {
         ngResultA.setEnabled(false);
         ngResultA.setForeground(new Color(255, 0, 0));
         ngResultA.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        ngResultA.setBounds(358, 348, 70, 36);
+        ngResultA.setBounds(358, 384, 70, 36);
         indexPanelA.add(ngResultA);
 
         resetResultB = new JButton("重拉");
@@ -989,7 +1047,7 @@ public class MesClient extends JFrame {
         });
         resetResultB.setEnabled(false);
         resetResultB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        resetResultB.setBounds(525, 348, 70, 36);
+        resetResultB.setBounds(525, 384, 70, 36);
         indexPanelA.add(resetResultB);
 
         okResultB = new JButton("OK");
@@ -1024,7 +1082,7 @@ public class MesClient extends JFrame {
         okResultB.setEnabled(false);
         okResultB.setForeground(new Color(0, 128, 0));
         okResultB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        okResultB.setBounds(602, 348, 70, 36);
+        okResultB.setBounds(602, 384, 70, 36);
         indexPanelA.add(okResultB);
 
         ngResultB = new JButton("NG");
@@ -1058,7 +1116,7 @@ public class MesClient extends JFrame {
         ngResultB.setEnabled(false);
         ngResultB.setForeground(new Color(255, 0, 0));
         ngResultB.setFont(new Font("微软雅黑", Font.PLAIN, 14));
-        ngResultB.setBounds(679, 348, 70, 36);
+        ngResultB.setBounds(679, 384, 70, 36);
         indexPanelA.add(ngResultB);
 
         tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
@@ -1199,4 +1257,61 @@ public class MesClient extends JFrame {
         tabbedPane.addTab("绑定物料", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), indexScrollPaneB, null);
     }
 
+    /**
+     * 扫液冷板码并调用 bindWarehouse 绑定,成功后开启拉铆
+     */
+    public static void scanBarcodeLb() {
+        product_sn_lb.setText("");
+        cold_plate_bound = false;
+        String scanBarcode = JOptionPane.showInputDialog(null, "请扫液冷板码");
+        if(scanBarcode == null || scanBarcode.trim().isEmpty()) {
+            setMenuStatus("液冷板码为空,请重新扫码",1);
+            return;
+        }
+        scanBarcode = scanBarcode.trim();
+
+        getUser();
+        String warehouseSn = getBarcode(scanBarcode);
+        product_sn_lb.setText(scanBarcode);
+        mesClientFrame.repaint();
+
+        if(work_status != 1) {
+            product_sn_lb.setText("");
+            setMenuStatus("请先扫工件码",1);
+            return;
+        }
+
+        String sn = getBarcode(product_sn.getText());
+        getUser();
+        JSONObject retObj = DataUtil.bindWarehouseHttp(sn, warehouseSn, user20, COLD_PLATE_CRAFT);
+
+        if(retObj == null){
+            product_sn_lb.setText("");
+            cold_plate_bound = false;
+            MesClient.setMenuStatus("请求失败,请重试",-1);
+            return;
+        }
+        if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
+            cold_plate_bound = true;
+            MesClient.setMenuStatus("液冷板绑定成功,可开始拉铆",0);
+            enableRiveting();
+        }else{
+            product_sn_lb.setText("");
+            cold_plate_bound = false;
+            if(retObj.get("result")==null){
+                MesClient.setMenuStatus("请求失败,请重试",-1);
+            }else if(retObj.get("result").toString().equalsIgnoreCase("false")){
+                MesClient.setMenuStatus(retObj.getString("message"),-1);
+            }
+        }
+    }
+
+    /** 液冷板绑定成功后开启拉铆枪 */
+    public static void enableRiveting() {
+        ModbusUtil.setPowerOn(MesClient.plcA);
+        ModbusUtil.setPowerOn(MesClient.plcB);
+        ModbusUtil.setTask(MesClient.plcA,MesClient.aSetNum);
+        ModbusUtil.setTask(MesClient.plcB,MesClient.bSetNum);
+    }
+
 }

+ 11 - 11
src/com/mes/ui/MesRevice.java

@@ -44,18 +44,18 @@ public class MesRevice {
                 MesClient.work_status = 1;
                 MesClient.f_scan_data_bt_1.setEnabled(false);
                 MesClient.tjStatus = 0;
+                MesClient.cold_plate_bound = false;
+                if (MesClient.product_sn_lb != null) {
+                    MesClient.product_sn_lb.setText("");
+                }
+                // 工件开工成功后,先扫液冷板绑定,绑定成功才开启拉铆
+                if (MesClient.f_scan_data_bt_2 != null) {
+                    MesClient.f_scan_data_bt_2.setEnabled(true);
+                }
+                MesClient.setMenuStatus("请扫液冷板码",0);
 
-//                MesClient.deviceControl = ModbusUtil.getControlModel(MesClient.plcA);
-//                if(MesClient.deviceControl == 1){
-//
-//                }
-
-//                MesClient.plcA.writeCoil(3128,false);
-//                MesClient.plcB.writeCoil(3128,false);
-
-                ModbusUtil.setPowerOn(MesClient.plcA); // 远程开机
-                ModbusUtil.setPowerOn(MesClient.plcB); // 远程开机
-
+                ModbusUtil.setPowerOff(MesClient.plcA); // 远程关机,等待液冷板绑定
+                ModbusUtil.setPowerOff(MesClient.plcB);
                 ModbusUtil.setTask(MesClient.plcA,MesClient.aSetNum);
                 ModbusUtil.setTask(MesClient.plcB,MesClient.bSetNum);
             }

+ 26 - 10
src/com/mes/ui/ModbusUtil.java

@@ -45,9 +45,17 @@ public class ModbusUtil {
             MesClient.param2.setText(cur+"");
             System.out.println("cur:"+cur);
 
-//            if(MesClient.sortA == 4){
-//                    plc.writeInt16(1070,(short) 2000);
-//                    plc.writeInt16(1071,(short) 5000);
+
+//            op130
+            if(MesClient.sortA == 23){
+                plc.writeInt16(1070,(short) 4000);
+                plc.writeInt16(1071,(short) 5000);
+            }
+
+            //210
+//            if(MesClient.sortA == 75){
+//                plc.writeInt16(1070,(short) 2500);
+//                plc.writeInt16(1071,(short) 3500);
 //            }
 
             if(!MesClient.product_sn.getText().isEmpty()){
@@ -275,16 +283,24 @@ public class ModbusUtil {
             plc.writeInt16(1136,(short) 0);
             plc.writeInt16(1138,(short) 0);
 
-//            if(setNum == 22){
-//                plc.writeInt16(1070,(short) 2500);
-//                plc.writeInt16(1071,(short) 4500);
-//            }
-//
-//            if (setNum == 40){
-//                plc.writeInt16(1070,(short) 2000);
+//            if(setNum == 81){
+//                plc.writeInt16(1070,(short) 3000);
 //                plc.writeInt16(1071,(short) 4000);
 //            }
 
+
+//            op130
+            if(setNum == 29){
+                plc.writeInt16(1070,(short) 3200);
+                plc.writeInt16(1071,(short) 4200);
+            }
+
+//            op130
+            if(setNum == 26){
+                plc.writeInt16(1070,(short) 3200);
+                plc.writeInt16(1071,(short) 4200);
+            }
+
         }catch (Exception e){
             e.printStackTrace();
         }

+ 4 - 2
src/com/mes/ui/OprnoUtil.java

@@ -5,11 +5,13 @@ import java.util.List;
 import java.util.Map;
 
 public class OprnoUtil {
+
     public static String[] xtoprnos = new String[]{
-            "OP310"
+
+            "OP210","OP130"
     };
     public static String[] xtoprnodes = new String[]{
-            "反面装配"
+            "总成反面装配1","液冷板拉铆"
     };
     public static String[] lboprnos = new String[]{
             "OP040","OP050","OP060","OP070","OP080","OP090","OP100","OP110",

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

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