jingbo před 5 dny
rodič
revize
dd62eb4ec9

+ 112 - 7
src/com/mes/ui/DataUtil.java

@@ -165,15 +165,15 @@ public class DataUtil {
             BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
             pro.load(br);
 
-            if(MesClient.mes_gwflag.equals("B")){
-                if(op.equals("A")){
-                    op = "C";
-                }else{
-                    op = "D";
-                }
+            String gw;
+            if("A".equals(op)){
+                gw = "GW" + rightPad(MesClient.mes_gw1, 6);
+            }else if("B".equals(op)){
+                gw = "GW" + rightPad(MesClient.mes_gw2, 6);
+            }else{
+                gw = "GW" + rightPad(pro.getProperty("mes.gw") + op, 6);
             }
 
-            String gw = "GW"+rightPad(pro.getProperty("mes.gw")+op, 6);
             String start = "aaaabbbbbABW";
             String gy = "GY" + rightPad(craft, 6);
             String reslx = "LX" + rightPad(lx, 2);
@@ -419,4 +419,109 @@ public class DataUtil {
             return null;
         }
     }
+
+
+    /*
+    *删除工位当前工件
+    * @param
+    * @return
+     */
+    public static JSONObject delCurSn(String oprno,String serverIp,String lineSn){
+        try {
+            String url = "http://"+serverIp+":8980/js/a/mes/mesProductRecord/cancelCurSn";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&__sid="+MesClient.sessionid;
+            JSONObject result = JSONObject.parseObject(doPost(url, params));
+//            log.info("请求参数:"+params);
+            return result;
+        } catch (Exception e) {
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * 获取当前SN
+     * @param oprno
+     * @param serverIp
+     * @param lineSn
+     * @return
+     */
+    public static JSONObject getCurSn(String oprno,String serverIp,String lineSn){
+        try {
+            String url = "http://"+serverIp+":8980/js/a/mes/mesProductRecord/getCurSn";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&__sid="+MesClient.sessionid;
+            JSONObject result = JSONObject.parseObject(doPost(url, params));
+//            log.info("请求参数:"+params);
+            return result;
+        } catch (Exception e) {
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+
+    /**
+     * 检查质量
+     * @param sn
+     * @param user
+     * @param oprno
+     * @param lineSn
+     * @param serverIp
+     * @return
+     */
+    public static JSONObject checkQuality(String sn, String user, String oprno, String lineSn, String serverIp){
+        try{
+            String url = "http://"+serverIp+":8980/js/a/mes/mesProductRecord/pccheck";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&ucode="+user+"&__sid="+MesClient.sessionid;
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "AQDW", sn);
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+
+    /**
+     * 加工结果发送
+     * @param sn
+     * @param ret
+     * @param user
+     * @param oprno
+     * @param lineSn
+     * @param serverIp
+     * @return
+     */
+    public static JSONObject sendQualityPc(String sn, String ret, String user, String oprno, String lineSn, String serverIp){
+        try{
+            String url = "http://"+serverIp+":8980/js/a/mes/mesProductRecord/pcresult";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&result="+ret+"&ucode="+user+"&__sid="+MesClient.sessionid;
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+            System.out.println("请求参数"+params);
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "MQDW", sn);
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+
+
+
+
+
 }

+ 85 - 34
src/com/mes/ui/MesClient.java

@@ -47,6 +47,8 @@ public class MesClient extends JFrame {
 
     public static int mes_auth = 0;
     public static String mes_gw = "";
+    public static String mes_gw1 = ""; // A面对应工位
+    public static String mes_gw2 = ""; // B面对应工位
     public static String mes_gw_des = "";
     public static String mes_server_ip = "";
     public static int mes_tcp_port = 3000;
@@ -117,6 +119,7 @@ public class MesClient extends JFrame {
 
     public static Boolean mesQualityFlagB = false; // true=可工作
 
+    public static String scanOprno = "";
 
     public static String user20 = "";
 
@@ -157,6 +160,8 @@ public class MesClient extends JFrame {
 
                     //获取当前面
                     textFocus();
+                    // 扫码
+                    startScanTimer();
 
                     // 获取PLC 加工状态参数
                     getPlcParam();
@@ -186,8 +191,10 @@ public class MesClient extends JFrame {
                 MesClient.curPage = PlcUtil.getCurAside(s7PLC);
                 if(MesClient.curPage .equals("A")){
                     page_text.setText("当前:A面");
+                    scanOprno = mes_gw1;
                 }else{
                     page_text.setText("当前:B面");
+                    scanOprno = mes_gw2;
                 }
             }
         }, 1000,1000);
@@ -265,6 +272,50 @@ public class MesClient extends JFrame {
         }, 1000,500);
     }
 
+    // 扫码定时任务
+    public static Timer ScanTimer;
+    public static void startScanTimer() {
+        if(ScanTimer!=null) {
+            ScanTimer.cancel();
+        }
+        ScanTimer = new Timer();
+        ScanTimer.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                JSONObject result = DataUtil.getCurSn(scanOprno, MesClient.mes_server_ip, MesClient.mes_line_sn);
+                if (result != null || result.getString("result").equalsIgnoreCase("true")){
+                    // 看是否成功
+                    if (result.get("result") != null && result.get("result").toString().equalsIgnoreCase("true")) {
+                        String sn = result.getString("data");
+                        MesClient.curSna = sn;
+                        if (sn != null && !sn.equals("")) {
+                            // 质量检查
+                            JSONObject result2 = DataUtil.checkQuality(sn,MesClient.user20,scanOprno,MesClient.mes_line_sn,MesClient.mes_server_ip);
+                            if (result2 != null){
+                                if (result2.get("result") != null && result2.get("result").toString().equalsIgnoreCase("true")) {
+                                    // 允许做件
+                                    if (scanOprno != null && !scanOprno.equals(MesClient.mes_gw1)){
+                                        MesClient.mesQualityFlagA = true;
+                                        MesClient.tjFlaga = 1;
+                                        MesClient.setMenuStatus("A:可以加工,等待设备启动",0);
+                                    }else if (scanOprno != null && scanOprno.equals(MesClient.mes_gw2)){
+                                        MesClient.mesQualityFlagB = true;
+                                        MesClient.tjFlagb = 1;
+                                        MesClient.setMenuStatus("B:可以加工,等待设备启动",0);
+                                    }
+
+                                }else {
+                                    // 不允许做件
+                                    MesClient.setMenuStatus(result2.getString("message"),-1);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }, 1000,500);
+    }
+
 
     private static void readProperty() throws IOException{
         String enconding = "UTF-8";
@@ -273,6 +324,8 @@ public class MesClient extends JFrame {
         BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
         pro.load(br);
         mes_gw =  pro.getProperty("mes.gw");
+        mes_gw1 = pro.getProperty("mes.gw1");
+        mes_gw2 = pro.getProperty("mes.gw2");
 
 //        mes_gw_des = pro.getProperty("mes.gw_des");
         mes_server_ip = pro.getProperty("mes.server_ip");
@@ -285,6 +338,7 @@ public class MesClient extends JFrame {
         mes_gwflag = pro.getProperty("mes.gwflag");
 
         System.out.println(mes_gw + ";" + mes_gw_des + ";" + mes_server_ip + ";" + mes_tcp_port + ";" + mes_heart_beat_cycle);
+        System.out.println("mes_gw1=" + mes_gw1 + ", mes_gw2=" + mes_gw2);
     }
 
 
@@ -608,8 +662,7 @@ public class MesClient extends JFrame {
             @Override
             public void mousePressed(MouseEvent e) {
                 super.mouseClicked(e);
-                finish_ok_bt.setEnabled(true);
-                finish_ng_bt.setEnabled(true);
+
 
             }
         });
@@ -622,8 +675,7 @@ public class MesClient extends JFrame {
             @Override
             public void mousePressed(MouseEvent e) {
                 super.mouseClicked(e);
-                finish_ok_bt2.setEnabled(true);
-                finish_ng_bt2.setEnabled(true);
+
 
             }
         });
@@ -764,19 +816,19 @@ public class MesClient extends JFrame {
         finish_ng_bt.setEnabled(false);
         finish_ng_bt.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
-                String sn = getBarcode(product_sn2.getText());
+                String sn = getBarcode(product_sn.getText());
                 getUser();
 
                 if(!sn.isEmpty()){
-                    String qret = "OK";
-                    Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20,"B");
+                    String qret = "NG";
+                    Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20,"A");
                     if(!sendret){
-                        MesClient.pxstatus2.setText("B:结果上传MES失败");
-                        MesClient.tjStatusb = 1;
+                        MesClient.pxstatus1.setText("A:结果上传MES失败");
+                        MesClient.tjStatusa = 1;
                     }else{
-                        MesClient.pxstatus2.setText("B:提交成功");
-                        MesClient.status_menu.setText("B件提交成功");
-                        MesClient.resetScanB();
+                        MesClient.pxstatus1.setText("A:提交成功");
+                        MesClient.status_menu.setText("A件提交成功");
+                        MesClient.resetScanA();
                     }
                 }
             }
@@ -797,7 +849,7 @@ public class MesClient extends JFrame {
 //
 //
 //                }
-                String sn = getBarcode(product_sn.getText());
+                String sn = getBarcode(product_sn2.getText());
                 getUser();
 
                 if(!sn.isEmpty()){
@@ -854,14 +906,14 @@ public class MesClient extends JFrame {
         lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
         lblNewLabel.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         lblNewLabel.setBounds(26, 340, 100, 40);
-        lblNewLabel.setVisible(false);
+        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.setVisible(false);
+        lblNewLabel_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1);
 
         param1 = new JTextField();
@@ -870,7 +922,7 @@ public class MesClient extends JFrame {
         param1.setHorizontalAlignment(SwingConstants.CENTER);
         param1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param1.setBounds(136, 340, 70, 40);
-        param1.setVisible(false);
+        param1.setVisible(true);
         indexPanelA.add(param1);
         param1.setColumns(10);
 
@@ -881,14 +933,14 @@ public class MesClient extends JFrame {
         param2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param2.setColumns(10);
         param2.setBounds(345, 340, 70, 40);
-        param2.setVisible(false);
+        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.setVisible(false);
+        lblNewLabel_2.setVisible(true);
         indexPanelA.add(lblNewLabel_2);
 
         param3 = new JTextField();
@@ -898,14 +950,14 @@ public class MesClient extends JFrame {
         param3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param3.setColumns(10);
         param3.setBounds(136, 401, 70, 40);
-        param3.setVisible(false);
+        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.setVisible(false);
+        lblNewLabel_1_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1);
 
         param4 = new JTextField();
@@ -915,7 +967,7 @@ public class MesClient extends JFrame {
         param4.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param4.setColumns(10);
         param4.setBounds(345, 401, 70, 40);
-        param4.setVisible(false);
+        param4.setVisible(true);
         indexPanelA.add(param4);
 
         param5 = new JTextField();
@@ -925,14 +977,14 @@ public class MesClient extends JFrame {
         param5.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param5.setColumns(10);
         param5.setBounds(226, 470, 70, 40);
-        param5.setVisible(false);
+        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.setVisible(false);
+        lblNewLabel_1_1_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1_1);
 
         product_sn2 = new JTextField();
@@ -957,7 +1009,7 @@ public class MesClient extends JFrame {
         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.setVisible(false);
+        lblNewLabel_3.setVisible(true);
         indexPanelA.add(lblNewLabel_3);
 
         param21 = new JTextField();
@@ -967,14 +1019,14 @@ public class MesClient extends JFrame {
         param21.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param21.setColumns(10);
         param21.setBounds(638, 340, 70, 40);
-        param21.setVisible(false);
+        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.setVisible(false);
+        lblNewLabel_1_2.setVisible(true);
         indexPanelA.add(lblNewLabel_1_2);
 
         param22 = new JTextField();
@@ -984,14 +1036,14 @@ public class MesClient extends JFrame {
         param22.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param22.setColumns(10);
         param22.setBounds(852, 340, 70, 40);
-        param22.setVisible(false);
+        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.setVisible(false);
+        lblNewLabel_2_1.setVisible(true);
         indexPanelA.add(lblNewLabel_2_1);
 
         param23 = new JTextField();
@@ -1001,14 +1053,14 @@ public class MesClient extends JFrame {
         param23.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param23.setColumns(10);
         param23.setBounds(638, 401, 70, 40);
-        param23.setVisible(false);
+        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.setVisible(false);
+        lblNewLabel_1_1_2.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1_2);
 
         param24 = new JTextField();
@@ -1018,15 +1070,14 @@ public class MesClient extends JFrame {
         param24.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param24.setColumns(10);
         param24.setBounds(852, 401, 70, 40);
-        param24.setVisible(false);
+        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.setVisible(false);
-        lblNewLabel_1_1_1_1.setVisible(false);
+        lblNewLabel_1_1_1_1.setVisible(true);
         indexPanelA.add(lblNewLabel_1_1_1_1);
 
         param25 = new JTextField();
@@ -1036,7 +1087,7 @@ public class MesClient extends JFrame {
         param25.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
         param25.setColumns(10);
         param25.setBounds(742, 470, 70, 40);
-        param25.setVisible(false);
+        param25.setVisible(true);
         indexPanelA.add(param25);
 
         pxstatus1 = new JLabel("A");

+ 6 - 14
src/com/mes/ui/MesRevice.java

@@ -18,20 +18,12 @@ public class MesRevice {
                 String oprno = ProtocolParam.getOprno(mes_msg).trim();
                 String sn = ProtocolParam.getSn(mes_msg).trim();
                 System.out.println(":"+oprno);
-                if(oprno.equals("OP070A")){
-                    String barcode36 = MesClient.getBarcode(sn);//处理36为码
+                if(oprno.equals(MesClient.mes_gw1)){
+                    String barcode36 = MesClient.getBarcode(sn);
                     MesClient.getUser();
                     DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"A");
-                }else if(oprno.equals("OP070B")){
-                    String barcode36 = MesClient.getBarcode(sn);//处理36为码
-                    MesClient.getUser();
-                    DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"B");
-                }else if(oprno.equals("OP070C")){
-                    String barcode36 = MesClient.getBarcode(sn);//处理36为码
-                    MesClient.getUser();
-                    DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"A");
-                }else if(oprno.equals("OP070D")){
-                    String barcode36 = MesClient.getBarcode(sn);//处理36为码
+                }else if(oprno.equals(MesClient.mes_gw2)){
+                    String barcode36 = MesClient.getBarcode(sn);
                     MesClient.getUser();
                     DataUtil.startWork(MesClient.nettyClient,barcode36,MesClient.user20,"B");
                 }
@@ -60,12 +52,12 @@ public class MesRevice {
                 String oprno = ProtocolParam.getOprno(mes_msg).trim();
                 String sn = ProtocolParam.getSn(mes_msg).trim();
 
-                if(oprno.equals(MesClient.mes_gw+"A") || oprno.equals(MesClient.mes_gw+"C")){
+                if(oprno.equals(MesClient.mes_gw1)){
                     MesClient.mesQualityFlagA = true;
                     MesClient.pxstatus1.setText("A:可以加工,等待设备启动");
                     MesClient.curSna = MesClient.product_sn.getText();
                     MesClient.tjFlaga = 1;
-                }else{
+                }else if(oprno.equals(MesClient.mes_gw2)){
                     MesClient.mesQualityFlagB = true;
                     MesClient.pxstatus2.setText("B:可以加工,等待设备启动");
                     MesClient.curSnb = MesClient.product_sn2.getText();

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

@@ -15,7 +15,7 @@ public class OprnoUtil {
             "OP520", "OP530", "OP540"
     };
     public static String[] xtoprnodes = new String[]{
-            "镭雕二维码", "小总成焊接", "CMT焊接", "人工正面补焊", "人工反面补焊", "焊缝铣削", "焊缝打磨", "焊道检验",
+            "前后左右边框总成", "小总成焊接", "CMT焊接", "人工正面补焊", "人工反面补焊", "焊缝铣削", "焊缝打磨", "焊道检验",
             "框架找漏", "找漏返修", "找漏复检", "CNC总成正面加工", "CNC总成反面加工", "总成正反面干冰清洗", "框架清洁", "框架涂胶",
             "FDS", "清理溢胶", "冷板激光焊", "液冷板FSW", "封堵片焊接", "总成正面装配", "总成正面拉铆", "总成反面拉铆",
             "钉头涂胶", "防爆阀拉铆", "框架终检", "静置", "半成品气密", "底护板气密", "粘贴MPP", "总成反面装配",
@@ -32,7 +32,7 @@ public class OprnoUtil {
     public static String getGwDes(String lineSn,String oprno){
         String des = "";
         oprno = formatOprno(oprno);
-        if(lineSn.equals("XT")){
+        if(lineSn.equals("115XT")){
             int i = 0;
             for (String gw:xtoprnos){
                 if(gw.equals(oprno)){

+ 28 - 18
src/com/mes/ui/PlcUtil.java

@@ -1,6 +1,7 @@
 package com.mes.ui;
 
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
 import com.github.xingshuangs.iot.protocol.modbus.service.ModbusTcp;
 import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
 import com.mes.component.MyDialog;
@@ -19,16 +20,11 @@ public class PlcUtil {
         Boolean starta = s7PLC.readBoolean("DB1.2.2"); //A启动中
         Boolean startb = s7PLC.readBoolean("DB1.2.3"); //B启动中
 
-        String oprno = MesClient.mes_gw+"A";
-        if(startb){
-            oprno = MesClient.mes_gw+"B";
-        }
-        if(MesClient.mes_gwflag.equals("B")){
-            if(oprno.equals(MesClient.mes_gw+"A")){
-                oprno = MesClient.mes_gw+"C";
-            }else{
-                oprno = MesClient.mes_gw+"D";
-            }
+        String oprno;
+        if(MesClient.curFlag.equals("A")){
+            oprno = MesClient.mes_gw1;
+        }else{
+            oprno = MesClient.mes_gw2;
         }
 
         if(MesClient.tjFlaga == 2 || MesClient.tjFlagb == 2){ //运行中
@@ -86,11 +82,18 @@ public class PlcUtil {
                 MesClient.finish_ok_bt.setEnabled(true);
                 MesClient.finish_ng_bt.setEnabled(true);
 
-                Boolean sendret = DataUtil.sendQuality(MesClient.nettyClient,MesClient.product_sn.getText(),"OK",MesClient.user20,"A");
-                if(!sendret){
-                    MesClient.pxstatus1.setText("A:结果上传MES失败");
+//                Boolean sendret = DataUtil.sendQuality(MesClient.nettyClient,MesClient.product_sn.getText(),"OK",MesClient.user20,"A");
+                JSONObject reult = DataUtil.sendQualityPc(MesClient.product_sn.getText(),"OK",MesClient.user20,MesClient.mes_gw1,MesClient.mes_line_sn,MesClient.mes_server_ip);
+                if (reult != null && reult.getString("result").equalsIgnoreCase("true")){
+                    MesClient.status_menu.setText("A件提交成功");
+                    MesClient.pxstatus1.setText("A:提交成功");
+                    MesClient.resetScanA();
+                }else {
+                    MesClient.status_menu.setText("A件提交失败");
+                    MesClient.pxstatus1.setText("A:提交失败");
                     MesClient.tjStatusa = 1;
                 }
+
             }
         }
     }
@@ -102,8 +105,8 @@ public class PlcUtil {
                 MesClient.curFlag = "B";
                 MesClient.tjFlagb = 2;
                 MesClient.pxstatus2.setText("B:设备运行中");
-                MesClient.batch_scan_2.setEnabled(false);
-                MesClient.formatScanType(1);
+//                MesClient.batch_scan_2.setEnabled(false);
+//                MesClient.formatScanType(1);
                 PlcUtil.changeEnable(s7PLC,false);
             }
         }else if(MesClient.tjFlagb == 2){
@@ -114,9 +117,15 @@ public class PlcUtil {
                 MesClient.finish_ng_bt2.setEnabled(true);
                 MesClient.finish_ok_bt2.setEnabled(true);
 
-                Boolean sendret = DataUtil.sendQuality(MesClient.nettyClient,MesClient.product_sn2.getText(),"OK",MesClient.user20,"B");
-                if(!sendret){
-                    MesClient.pxstatus2.setText("B:结果上传MES失败");
+//                Boolean sendret = DataUtil.sendQuality(MesClient.nettyClient,MesClient.product_sn2.getText(),"OK",MesClient.user20,"B");
+                JSONObject result = DataUtil.sendQualityPc(MesClient.product_sn2.getText(),"OK",MesClient.user20,MesClient.mes_gw2,MesClient.mes_line_sn,MesClient.mes_server_ip);
+                if (result != null && result.getString("result").equalsIgnoreCase("true")){
+                    MesClient.status_menu.setText("B件提交成功");
+                    MesClient.pxstatus2.setText("B:提交成功");
+                    MesClient.resetScanB();
+                }else {
+                    MesClient.status_menu.setText("B件提交失败");
+                    MesClient.pxstatus2.setText("B:提交失败");
                     MesClient.tjStatusb = 1;
                 }
             }
@@ -192,6 +201,7 @@ public class PlcUtil {
 
         }catch (Exception e){
             e.printStackTrace();
+            return str;
         }
         return str;
     }

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

@@ -1,9 +1,9 @@
-mes.gw=OP070A
-mes.server_ip=127.0.0.1
-#mes.server_ip=192.168.20.99
+mes.gw=OP040A
+#mes.server_ip=127.0.0.1
+mes.server_ip=192.168.9.180
 mes.tcp_port=3000
 mes.heart_beat_cycle=60
-mes.line_sn=XT
+mes.line_sn=115XT
 mes.gwflag=A
 mes.gw1=OP040A
 mes.gw2=OP060A