wangxichen vor 1 Woche
Ursprung
Commit
8a8af28023

+ 12 - 147
src/com/mes/component/WorkJPanelOP20.java

@@ -2,29 +2,18 @@ package com.mes.component;
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
-import com.github.s7connector.api.DaveArea;
-import com.github.s7connector.api.S7Connector;
-import com.github.s7connector.api.S7Serializer;
-import com.github.s7connector.api.factory.S7ConnectorFactory;
-import com.github.s7connector.api.factory.S7SerializerFactory;
 import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
 import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
 import com.mes.ui.CacheData;
 import com.mes.ui.DataUtil;
 import com.mes.ui.MesClient;
-import com.mes.ui.ParamReq;
-import com.mes.util.DateLocalUtils;
 import com.mes.util.JdbcUtils;
-import com.mes.util.S7Util;
-//import com.mes.util.S7Utils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
 
@@ -71,21 +60,8 @@ public class WorkJPanelOP20 extends JPanel {
     public String plcIp1 = "192.168.90.81"; // plc1 西侧
     public String plcIp2 = "192.168.90.82"; // plc2 东侧
 
-    public String deviceIp = "";
-    public String deviceIp1 = "80.20.10.42";
-    public String deviceIp2 = "80.20.10.43";
-    public String deviceIp3 = "80.21.10.42";
-    public String deviceIp4 = "80.21.10.43";
-    // FSW3 机床IP 按现有规律暂定,待现场确认
-    public String deviceIp5 = "80.20.10.44"; // 西侧 FSW3
-    public String deviceIp6 = "80.21.10.44"; // 东侧 FSW3
-
-    public S7Connector s7Connector;
-
     public S7PLC s7PLC = null;
 
-    public S7PLC s7PLCFSW = null;
-
     public Integer workWidth = 470;
     public Integer workHeight = 300;
 
@@ -93,7 +69,7 @@ public class WorkJPanelOP20 extends JPanel {
 
     public String plcIp = ""; // 当前连接的 PLC IP
 
-    public JLabel ipLabel; // 界面显示 PLC/DB/机床IP
+    public JLabel ipLabel; // 界面显示 PLC/DB
 
     public String plcDb2 = "DB7003";
 
@@ -110,15 +86,9 @@ public class WorkJPanelOP20 extends JPanel {
 
     public Integer isScan = 1; // 1=西侧 2=东测
 
-    public Boolean fswOnline = true; //
-
     public String finallySn = "";
 
-    public List<String> hjparams = new ArrayList<>();
-
-    public Integer errflag = 0; // 1=报警 0=正常
-
-    public Integer errflag2 = 0;
+    public Integer errflag2 = 0; // PLC 故障报警标识 1=报警 0=正常
 
     public String fswDeviceName = "";
 
@@ -173,25 +143,17 @@ public class WorkJPanelOP20 extends JPanel {
         s7PLC.setConnectTimeout(800);
         s7PLC.setReceiveTimeout(800);
 
-        // 子工位 -> DB块 / 机床IP / 设备名(西侧 A/B/E,东侧 C/D/F,E/F 为新增 FSW3)
+        // 子工位 -> DB块 / 设备名(西侧 A/B/E,东侧 C/D/F,E/F 为新增 FSW3)
         switch (pos) {
-            case "A": plcDb = "DB7000"; deviceIp = deviceIp1; fswDeviceName = "西侧反面1号机"; break;
-            case "B": plcDb = "DB7001"; deviceIp = deviceIp2; fswDeviceName = "西侧反面2号机"; break;
-            case "E": plcDb = "DB7004"; deviceIp = deviceIp5; fswDeviceName = "西侧反面3号机"; break;
-            case "C": plcDb = "DB7000"; deviceIp = deviceIp3; fswDeviceName = "东侧反面1号机"; break;
-            case "D": plcDb = "DB7001"; deviceIp = deviceIp4; fswDeviceName = "东侧反面2号机"; break;
-            case "F": plcDb = "DB7004"; deviceIp = deviceIp6; fswDeviceName = "东侧反面3号机"; break;
+            case "A": plcDb = "DB7000"; fswDeviceName = "西侧反面1号机"; break;
+            case "B": plcDb = "DB7001"; fswDeviceName = "西侧反面2号机"; break;
+            case "E": plcDb = "DB7004"; fswDeviceName = "西侧反面3号机"; break;
+            case "C": plcDb = "DB7000"; fswDeviceName = "东侧反面1号机"; break;
+            case "D": plcDb = "DB7001"; fswDeviceName = "东侧反面2号机"; break;
+            case "F": plcDb = "DB7004"; fswDeviceName = "东侧反面3号机"; break;
             default: log.error("未知子工位:" + pos); break;
         }
 
-        log.info("deviceIp:"+deviceIp);
-
-        s7PLCFSW = new S7PLC(EPlcType.SINUMERIK_828D, deviceIp);
-
-        s7PLCFSW.setConnectTimeout(800);
-        s7PLCFSW.setReceiveTimeout(800);
-
-
         oprnoLabel = new JLabel(oprno+pos);
         oprnoLabel.setHorizontalAlignment(SwingConstants.CENTER);
         oprnoLabel.setForeground(Color.BLACK);
@@ -206,8 +168,8 @@ public class WorkJPanelOP20 extends JPanel {
         oprnoLabel2.setBounds(0, 12, workWidth / 5, 40);
         this.add(oprnoLabel2);
 
-        // 底部显示 PLC/DB/机床IP,机床离线时变红
-        ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb + " | 机床 " + deviceIp);
+        // 底部显示 PLC/DB
+        ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb);
         ipLabel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
         ipLabel.setForeground(Color.DARK_GRAY);
         ipLabel.setBounds(5, 230, workWidth*2/3 + 55, 26);
@@ -364,9 +326,6 @@ public class WorkJPanelOP20 extends JPanel {
 
 
         monitorDeviceStatus();
-//        if(pos.equals("A")||pos.equals("C")){
-//            monitorDeviceStatus();
-//        }
 
         resetScanA();
 
@@ -431,6 +390,7 @@ public class WorkJPanelOP20 extends JPanel {
         }, 1000,1000);
     }
 
+    // PLC 故障报警监控(安全门/急停/光栅/夹紧,读 PLC DB 块 .6.0~.6.3)
     public Timer cjTimerText3;
     public void monitorDeviceStatus() {
         if(cjTimerText3!=null) {
@@ -442,33 +402,6 @@ public class WorkJPanelOP20 extends JPanel {
 
                 if(MesClient.isLogin == 1 && isLocal == 0){
                     try{
-                        initS7();
-                        monitorDevice();
-                        boolean ret = S7Util.getFswAlarm(s7Connector);
-                        if(ret){
-                            errflag = 0;
-                        }
-                        if(!ret && errflag == 0 ){
-                            errflag = 1;
-                            DataUtil.deviceAlarm(oprno+pos,productSn.getText(),oprno+pos+"随动夹具报警",MesClient.user_menu.getText());
-                        }
-                        fswOnline = true;
-                    }catch (Exception e){
-                        log.info(e.getMessage());
-                        fswOnline = false;
-                    }
-
-                    if(fswOnline){
-                        oprnoLabel.setForeground(Color.BLACK);
-                        oprnoLabel2.setForeground(Color.BLACK);
-                        ipLabel.setForeground(Color.DARK_GRAY);
-                    }else{
-                        oprnoLabel.setForeground(Color.RED);
-                        oprnoLabel2.setForeground(Color.RED);
-                        ipLabel.setForeground(Color.RED);
-                    }
-
-                    try{
                         int ret = getAlarm();
                         if(ret == 0){
                             errflag2 = 0;
@@ -632,13 +565,6 @@ public class WorkJPanelOP20 extends JPanel {
             productSnFeeding.setText(sn);
             lastSn = sn;
 
-            // 判断刀具寿命
-//            Integer hjjs = S7Util.formatS7Int(s7Connector.read(DaveArea.DB, 9051, 2, 26));
-//            if(hjjs > 320){
-//                this.setMenuStatus("搅拌头达到使用寿命,请换搅拌头", -1);
-//                return;
-//            }
-
             // 查询工件质量
             JSONObject retObj = DataUtil.checkQuality(sn,oprno+pos,MesClient.user_menu.getText());
             if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
@@ -857,67 +783,6 @@ public class WorkJPanelOP20 extends JPanel {
         return true;
     }
 
-    public void initS7(){
-        try {
-            if(s7Connector == null) {
-                //PLC地址
-                String ipAddress = deviceIp;
-                log.info("deviceIp2:"+deviceIp);
-                //默认端口
-                int port = 102;
-                int rack=0;
-                int slot=3;
-                int timeout=5000;
-                s7Connector=
-                        S7ConnectorFactory
-                                .buildTCPConnector()
-                                .withHost(ipAddress)
-                                .withPort(port) //optional
-//								.withRack(rack) //optional
-//								.withSlot(slot) //optional
-                                .withTimeout(timeout) //连接超时时间
-                                .build();
-                S7Serializer s7Serializer2L = S7SerializerFactory.buildSerializer(s7Connector);
-            }
-        } catch (Exception e) { // 如果连接失败保存失败再次尝试连接一次
-            s7Connector = null;
-            e.printStackTrace();
-        }
-    }
-
-    public void monitorDevice(){
-        log.info("monitorDevice");
-        if(tjFlag == 2){
-            try{
-                String zzzs = String.valueOf(s7PLCFSW.readSpindleRate());
-                String jgsd = String.valueOf(s7PLCFSW.readFeedRate());
-//                String zzzs = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 0));
-//                String jgsd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 4));
-                String zzzb = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 8));
-                String ylz = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 12));
-                Integer hjjs = S7Util.formatS7Int(s7Connector.read(DaveArea.DB, 9051, 2, 26));
-                String hjcd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 28));
-                String hjms = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 32));
-                String record_time = DateLocalUtils.getCurrentTime();
-                hjparams.add(zzzs+"|"+jgsd+"|"+zzzb+"|"+ylz+"|"+hjjs+"|"+hjcd+"|"+hjms+"|"+record_time);
-                if (hjparams.size() == 60  && productSn.getText() != null && !productSn.getText().trim().isEmpty() ) {
-                    JdbcUtils.insertParamData(oprno+pos,MesClient.mes_line_sn,productSn.getText(), JSON.toJSONString(hjparams));
-                    hjparams = new ArrayList<>();
-                }
-            }catch (Exception e){
-                e.printStackTrace();
-                s7Connector = null;
-            }
-            log.info("monitorDevice:"+JSON.toJSONString(hjparams));
-        }else{
-            if(hjparams.size() > 0){
-                JdbcUtils.insertParamData(oprno,MesClient.mes_line_sn,lastSn, JSON.toJSONString(hjparams));
-                hjparams = new ArrayList<>();
-            }
-        }
-
-    }
-
     public int getAlarm(){
         boolean ret0 = readBoolean(plcDb+".6.0");
         if(ret0){

+ 12 - 140
src/com/mes/component/WorkJPanelOP30.java

@@ -2,32 +2,20 @@ package com.mes.component;
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
-import com.github.s7connector.api.DaveArea;
-import com.github.s7connector.api.S7Connector;
-import com.github.s7connector.api.S7Serializer;
-import com.github.s7connector.api.factory.S7ConnectorFactory;
-import com.github.s7connector.api.factory.S7SerializerFactory;
 import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
 import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
 import com.mes.ui.CacheData;
 import com.mes.ui.DataUtil;
 import com.mes.ui.MesClient;
-import com.mes.util.DateLocalUtils;
 import com.mes.util.JdbcUtils;
-import com.mes.util.S7Util;
-import com.mes.util.TCPClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 public class WorkJPanelOP30 extends JPanel {
 
@@ -72,19 +60,8 @@ public class WorkJPanelOP30 extends JPanel {
     public String plcIp1 = "192.168.90.81"; // plc1 西侧
     public String plcIp2 = "192.168.90.82"; // plc2 东侧
 
-    public String deviceIp = "";
-    public String deviceIp1 = "80.20.10.42";
-    public String deviceIp2 = "80.20.10.43";
-    public String deviceIp3 = "80.21.10.42";
-    public String deviceIp4 = "80.21.10.43";
-    // FSW3 机床IP 按现有规律暂定,待现场确认
-    public String deviceIp5 = "80.20.10.44"; // 西侧 FSW3
-    public String deviceIp6 = "80.21.10.44"; // 东侧 FSW3
-
     public S7PLC s7PLC = null;
 
-    public S7PLC s7PLCFSW = null;
-
     public Integer workWidth = 470;
     public Integer workHeight = 300;
 
@@ -92,14 +69,12 @@ public class WorkJPanelOP30 extends JPanel {
 
     public String plcIp = ""; // 当前连接的 PLC IP
 
-    public JLabel ipLabel; // 界面显示 PLC/DB/机床IP
+    public JLabel ipLabel; // 界面显示 PLC/DB
 
     public String plcDb2 = "DB7010";
 
     public String preSn = ""; // 扫码内容
 
-    public S7Connector s7Connector;
-
     public Integer tjFeedingFlag = 0; // 上料状态标识
     public Integer tjFlag = 0; // 1=可加工 2=设备运行中 3=加工结束
     public Integer tjStatus = 0; // 提交标识
@@ -113,14 +88,9 @@ public class WorkJPanelOP30 extends JPanel {
 
     public String finallySn = "";
 
-    public Boolean fswOnline = true;
-
-    public Integer errflag = 0; // 1=报警 0=正常
-
-    public Integer errflag2 = 0; // 1=报警 0=正常
+    public Integer errflag2 = 0; // PLC 故障报警标识 1=报警 0=正常
 
     public String fswDeviceName = "";
-    public List<String> hjparams = new ArrayList<>();
 
     public JLabel oprnoLabel;
     public JLabel oprnoLabel2;
@@ -169,21 +139,17 @@ public class WorkJPanelOP30 extends JPanel {
         s7PLC.setConnectTimeout(800);
         s7PLC.setReceiveTimeout(800);
 
-        // 子工位 -> DB块 / 机床IP / 设备名(西侧 A/B/E,东侧 C/D/F,E/F 为新增 FSW3)
+        // 子工位 -> DB块 / 设备名(西侧 A/B/E,东侧 C/D/F,E/F 为新增 FSW3)
         switch (pos) {
-            case "A": plcDb = "DB7010"; deviceIp = deviceIp1; fswDeviceName = "西侧正面1号机"; break;
-            case "B": plcDb = "DB7011"; deviceIp = deviceIp2; fswDeviceName = "西侧正面2号机"; break;
-            case "E": plcDb = "DB7014"; deviceIp = deviceIp5; fswDeviceName = "西侧正面3号机"; break;
-            case "C": plcDb = "DB7010"; deviceIp = deviceIp3; fswDeviceName = "东侧正面1号机"; break;
-            case "D": plcDb = "DB7011"; deviceIp = deviceIp4; fswDeviceName = "东侧正面2号机"; break;
-            case "F": plcDb = "DB7014"; deviceIp = deviceIp6; fswDeviceName = "东侧正面3号机"; break;
+            case "A": plcDb = "DB7010"; fswDeviceName = "西侧正面1号机"; break;
+            case "B": plcDb = "DB7011"; fswDeviceName = "西侧正面2号机"; break;
+            case "E": plcDb = "DB7014"; fswDeviceName = "西侧正面3号机"; break;
+            case "C": plcDb = "DB7010"; fswDeviceName = "东侧正面1号机"; break;
+            case "D": plcDb = "DB7011"; fswDeviceName = "东侧正面2号机"; break;
+            case "F": plcDb = "DB7014"; fswDeviceName = "东侧正面3号机"; break;
             default: log.error("未知子工位:" + pos); break;
         }
 
-        s7PLCFSW = new S7PLC(EPlcType.SINUMERIK_828D, deviceIp);
-        s7PLCFSW.setConnectTimeout(800);
-        s7PLCFSW.setReceiveTimeout(800);
-
         oprnoLabel = new JLabel(oprno+pos);
         oprnoLabel.setHorizontalAlignment(SwingConstants.CENTER);
         oprnoLabel.setForeground(Color.BLACK);
@@ -198,8 +164,8 @@ public class WorkJPanelOP30 extends JPanel {
         oprnoLabel2.setBounds(0, 12, workWidth / 5, 40);
         this.add(oprnoLabel2);
 
-        // 底部显示 PLC/DB/机床IP,机床离线时变红
-        ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb + " | 机床 " + deviceIp);
+        // 底部显示 PLC/DB
+        ipLabel = new JLabel("PLC " + plcIp + " | " + plcDb);
         ipLabel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
         ipLabel.setForeground(Color.DARK_GRAY);
         ipLabel.setBounds(5, 230, workWidth*2/3 + 55, 26);
@@ -417,6 +383,7 @@ public class WorkJPanelOP30 extends JPanel {
         }, 1000,1000);
     }
 
+    // PLC 故障报警监控(安全门/急停/光栅/夹紧,读 PLC DB 块 .6.0~.6.3)
     public Timer cjTimerText3;
     public void monitorDeviceStatus() {
         if(cjTimerText3!=null) {
@@ -427,33 +394,6 @@ public class WorkJPanelOP30 extends JPanel {
             public void run() {
                 if(MesClient.isLogin == 1 && isLocal == 0){
                     try{
-                        initS7();
-                        monitorDevice();
-                        boolean ret = S7Util.getFswAlarm(s7Connector);
-                        if(ret){
-                            errflag = 0;
-                        }
-                        if(!ret && errflag == 0 ){
-                            errflag = 1;
-                            DataUtil.deviceAlarm(oprno+pos,productSn.getText(),oprno+pos+"随动夹具报警",MesClient.user_menu.getText());
-                        }
-                        fswOnline = true;
-                    }catch (Exception e){
-                        log.info(e.getMessage());
-                        fswOnline = false;
-                    }
-
-                    if(fswOnline){
-                        oprnoLabel.setForeground(Color.BLACK);
-                        oprnoLabel2.setForeground(Color.BLACK);
-                        ipLabel.setForeground(Color.DARK_GRAY);
-                    }else{
-                        oprnoLabel.setForeground(Color.RED);
-                        oprnoLabel2.setForeground(Color.RED);
-                        ipLabel.setForeground(Color.RED);
-                    }
-
-                    try{
                         int ret = getAlarm();
                         if(ret == 0){
                             errflag2 = 0;
@@ -600,13 +540,6 @@ public class WorkJPanelOP30 extends JPanel {
             productSnFeeding.setText(sn);
             lastSn = sn;
 
-            // 判断刀具寿命
-//            Integer hjjs = S7Util.formatS7Int(s7Connector.read(DaveArea.DB, 9051, 2, 26));
-//            if(hjjs > 320){
-//                this.setMenuStatus("搅拌头达到使用寿命,请换搅拌头", -1);
-//                return;
-//            }
-
             // 查询工件质量
             JSONObject retObj = DataUtil.checkQuality(sn,oprno+pos,MesClient.user_menu.getText());
             if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
@@ -811,67 +744,6 @@ public class WorkJPanelOP30 extends JPanel {
         return true;
     }
 
-    public void monitorDevice(){
-        log.info("monitorDevice");
-        if(tjFlag == 2){
-            try{
-                String zzzs = String.valueOf(s7PLCFSW.readSpindleRate());
-                String jgsd = String.valueOf(s7PLCFSW.readFeedRate());
-//                String zzzs = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 0));
-//                String jgsd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 4));
-                String zzzb = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 8));
-                String ylz = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 12));
-                Integer hjjs = S7Util.formatS7Int(s7Connector.read(DaveArea.DB, 9051, 2, 26));
-                String hjcd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 28));
-                String hjms = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 32));
-                String record_time = DateLocalUtils.getCurrentTime();
-                hjparams.add(zzzs+"|"+jgsd+"|"+zzzb+"|"+ylz+"|"+hjjs+"|"+hjcd+"|"+hjms+"|"+record_time);
-                if (hjparams.size() == 60  && productSn.getText() != null && !productSn.getText().trim().isEmpty() ) {
-                    JdbcUtils.insertParamData(oprno+pos,MesClient.mes_line_sn,productSn.getText(), JSON.toJSONString(hjparams));
-                    hjparams = new ArrayList<>();
-                }
-            }catch (Exception e){
-                e.printStackTrace();
-                s7Connector = null;
-            }
-            log.info("monitorDevice:"+JSON.toJSONString(hjparams));
-        }else{
-            if(hjparams.size() > 0){
-                JdbcUtils.insertParamData(oprno,MesClient.mes_line_sn,lastSn, JSON.toJSONString(hjparams));
-                hjparams = new ArrayList<>();
-            }
-        }
-
-    }
-
-    public void initS7(){
-        try {
-            if(s7Connector == null) {
-                //PLC地址
-                String ipAddress = deviceIp;
-                log.info("deviceIp2:"+deviceIp);
-                //默认端口
-                int port = 102;
-                int rack=0;
-                int slot=3;
-                int timeout=5000;
-                s7Connector=
-                        S7ConnectorFactory
-                                .buildTCPConnector()
-                                .withHost(ipAddress)
-                                .withPort(port) //optional
-//								.withRack(rack) //optional
-//								.withSlot(slot) //optional
-                                .withTimeout(timeout) //连接超时时间
-                                .build();
-                S7Serializer s7Serializer2L = S7SerializerFactory.buildSerializer(s7Connector);
-            }
-        } catch (Exception e) { // 如果连接失败保存失败再次尝试连接一次
-            s7Connector = null;
-            e.printStackTrace();
-        }
-    }
-
     public int getAlarm(){
         boolean ret0 = readBoolean(plcDb+".6.0");
         if(ret0){

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

@@ -159,31 +159,6 @@ public class DataUtil {
         }
     }
 
-    public static JSONObject upParams(String upparams) {
-        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 url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductFsw/batchsave";
-            String params = "__ajax=json&params="+upparams;
-            System.out.println("params="+params);
-            String result = doPost(url,params);
-            System.out.println("result="+result);
-
-            if(result.equalsIgnoreCase("false")) {
-                return null;
-            }else {
-                return JSONObject.parseObject(result);
-            }
-        }catch (Exception e){
-            return null;
-        }
-    }
-
     public static String doPost(String httpUrl, String param) {
         HttpURLConnection connection = null;
         InputStream is = null;

+ 0 - 29
src/com/mes/ui/MesClient.java

@@ -125,8 +125,6 @@ public class MesClient extends JFrame {
 
                     startHeartBeatTimer();
 
-                    upParams();
-
 
                 }catch (Exception e){
                     log.error(e.getMessage());
@@ -135,33 +133,6 @@ public class MesClient extends JFrame {
         });
     }
 
-    public static Timer cjTimer3;
-    public static void upParams() {
-        if(cjTimer3!=null) {
-            cjTimer3.cancel();
-        }
-        cjTimer3 = new Timer();
-        cjTimer3.schedule(new TimerTask() {
-            public void run() {
-                try{
-                    List<ParamReq> prods = JdbcUtils.getParams();
-                    if(prods.size() > 0){
-                        // 定时上传参数
-                        JSONObject retObj = DataUtil.upParams(JSON.toJSONString(prods));
-                        if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
-                            // 更新sqlite已同步
-                            for(ParamReq prodReq:prods){
-                                JdbcUtils.updateProdSync(prodReq.getId(),1);
-                            }
-                        }
-                    }
-                }catch (Exception e){
-                    e.printStackTrace();
-                }
-            }
-        }, 1000,120*1000);
-    }
-
     //读配置文件
     private static void readProperty() throws IOException{
         String enconding = "UTF-8";

+ 0 - 58
src/com/mes/ui/ParamReq.java

@@ -1,58 +0,0 @@
-package com.mes.ui;
-
-public class ParamReq {
-    private Integer id;
-    private String oprno;
-    private String lineSn;
-    private String sn;
-    private String content;
-    private Integer sync;
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getOprno() {
-        return oprno;
-    }
-
-    public void setOprno(String oprno) {
-        this.oprno = oprno;
-    }
-
-    public String getLineSn() {
-        return lineSn;
-    }
-
-    public void setLineSn(String lineSn) {
-        this.lineSn = lineSn;
-    }
-
-    public String getSn() {
-        return sn;
-    }
-
-    public void setSn(String sn) {
-        this.sn = sn;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public Integer getSync() {
-        return sync;
-    }
-
-    public void setSync(Integer sync) {
-        this.sync = sync;
-    }
-}

+ 0 - 69
src/com/mes/util/JdbcUtils.java

@@ -3,7 +3,6 @@ package com.mes.util;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.mes.ui.CacheData;
-import com.mes.ui.ParamReq;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -102,49 +101,12 @@ public class JdbcUtils {
         statement.close();
     }
 
-	//插入数据
-	public static boolean insertParamData(String oprno, String line_sn, String sn,String content) {
-		if (sn == null || sn.trim().isEmpty()) {
-			return false;
-		}
-		JdbcUtils.getConn();
-		boolean ret = false;
-		String record_time = DateLocalUtils.getCurrentTime();
-		try {
-			// 确保连接已经打开
-			if (JdbcUtils.conn == null || JdbcUtils.conn.isClosed()) {
-				JdbcUtils.openConnection();
-			}
-			//创建连接对象,是Java的一个操作数据库的重要接口
-			Statement statement=conn.createStatement();
-			statement.executeUpdate("INSERT INTO bw_params (oprno,line_sn,sn,content,create_time) VALUES"
-					+ " ('"+oprno+"', '"+line_sn+"', '"+sn+"', '"+content+"','"+record_time+"')");//向数据库中插入数据
-			statement.close();
-			ret = true;
-		} catch (SQLException e) {
-			// TODO Auto-generated catch block
-			//e.printStackTrace();
-			ret = false;
-		}
-
-		return ret;
-	}
-
-	public static void updateProdSync(Integer id,Integer sync) throws SQLException {
-		Connection conn = JdbcUtils.getConn();
-		Statement statement=conn.createStatement();   //创建连接对象,是Java的一个操作数据库的重要接口
-		statement.executeUpdate("update bw_params set sync = "+sync + " where id = "+id);
-		statement.close();
-	}
-
 	public static CacheData getCache(String key) {
 		//SQL语句
 		String sql = "select id,sn,content from cache where sn = '"+key+"' order by id asc limit 1";
 		Connection conn = JdbcUtils.getConn();
 		Statement stmt=null;
 		ResultSet ret = null;
-		String password=null;
-		List<ParamReq> prods = new ArrayList<>();
 		String content = "";
 		try {
 			stmt = conn.createStatement();
@@ -198,37 +160,6 @@ public class JdbcUtils {
 		return true;
 	}
 
-	public static List<ParamReq> getParams() {
-		//SQL语句
-		String sql = "select id,oprno,line_sn,sn,content,sync from bw_params where sync = 0 order by id asc limit 100";
-		Connection conn = JdbcUtils.getConn();
-		Statement stmt=null;
-		ResultSet ret = null;
-		String password=null;
-		List<ParamReq> prods = new ArrayList<>();
-		try {
-			stmt = conn.createStatement();
-			//执行语句,得到结果集
-			ret = stmt.executeQuery(sql);
-			System.out.println("sql:"+ sql);
-			while (ret.next()) {
-				ParamReq cmtReq = new ParamReq();
-				cmtReq.setId(ret.getInt(1));
-				cmtReq.setOprno(ret.getString(2));
-				cmtReq.setLineSn(ret.getString(3));
-				cmtReq.setSn(ret.getString(4));
-				cmtReq.setContent(ret.getString(5));
-				cmtReq.setSync(Integer.valueOf(ret.getString(6)));
-				prods.add(cmtReq);
-			}
-			ret.close();
-			conn.close();//关闭连接
-		} catch (SQLException e1) {
-			e1.printStackTrace();
-		}
-		return prods;
-	}
-    
     //插入数据
     public static boolean insertData(String gw, String gy, String bw, String message_type, String sn) {
     	boolean ret = false;

+ 0 - 133
src/com/mes/util/S7Util.java

@@ -1,133 +0,0 @@
-package com.mes.util;
-
-import com.github.s7connector.api.DaveArea;
-import com.github.s7connector.api.S7Connector;
-import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.math.BigInteger;
-import java.text.DecimalFormat;
-
-public class S7Util {
-    public static final Logger log =  LoggerFactory.getLogger(S7Util.class);
-
-    public static Boolean getFswAlarm(S7Connector s7Connector){
-        byte[] bytes1 = s7Connector.read(DaveArea.DB, 9051, 1, 24);
-        int alarm242 = getBit(bytes1[0],5);
-        if(alarm242 == 1){
-            return false;
-        }
-        int alarm243 = getBit(bytes1[0],4);
-        if(alarm243 == 1){
-            return false;
-        }
-        int alarm244 = getBit(bytes1[0],3);
-        if(alarm244 == 1){
-            return false;
-        }
-        int alarm245 = getBit(bytes1[0],2);
-        if(alarm245 == 1){
-            return false;
-        }
-        int alarm246 = getBit(bytes1[0],1);
-        if(alarm246 == 1){
-            return false;
-        }
-        int alarm247 = getBit(bytes1[0],0);
-        if(alarm247 == 1){
-            return false;
-        }
-
-        byte[] bytes2 = s7Connector.read(DaveArea.DB, 9051, 1, 25);
-        int alarm250 = getBit(bytes2[0],7);
-        if(alarm250 == 1){
-            return false;
-        }
-
-        int alarm251 = getBit(bytes2[0],6);
-        if(alarm251 == 1){
-            return false;
-        }
-
-        int alarm252 = getBit(bytes2[0],5);
-        if(alarm252 == 1){
-            return false;
-        }
-
-        int alarm253 = getBit(bytes2[0],4);
-        if(alarm253 == 1){
-            return false;
-        }
-
-        int alarm254 = getBit(bytes2[0],3);
-        if(alarm254 == 1){
-            return false;
-        }
-
-        int alarm255 = getBit(bytes2[0],2);
-        if(alarm255 == 1){
-            return false;
-        }
-
-        int alarm256 = getBit(bytes2[0],1);
-        if(alarm256 == 1){
-            return false;
-        }
-
-        return true;
-
-    }
-
-    // 格式化s7取出的值
-    public static String formatS7Val(byte[] val){
-        int intValue = new BigInteger(xtob(val)).intValue();
-        float floatValue = Float.intBitsToFloat(intValue);
-
-        // 保留1位小数
-        DecimalFormat df = new DecimalFormat("#.#");
-        df.setMaximumFractionDigits(1);
-        String result = df.format(floatValue);
-        float roundedNum = Float.parseFloat(result);
-
-        return roundedNum+"";
-    }
-
-    // 转大端排序
-    private static byte[] xtob( byte[] bytes){
-        return bytes;
-//        // 创建新的byte数组并复制原始数据
-//        byte[] reversedBytes = new byte[bytes.length];
-//        System.arraycopy(bytes, 0, reversedBytes, 0, bytes.length);
-//
-//        // 反转byte数组元素的位置
-//        for (int i = 0; i < bytes.length / 2; i++) {
-//            byte temp = reversedBytes[i];
-//            reversedBytes[i] = reversedBytes[reversedBytes.length - 1 - i];
-//            reversedBytes[reversedBytes.length - 1 - i] = temp;
-//        }
-//        return reversedBytes;
-    }
-
-    private static String byteToBinaryString(byte[] byteArray) {
-        StringBuilder binaryString = new StringBuilder();
-        for (byte b : byteArray) {
-            binaryString.append(String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0'));
-        }
-        return binaryString.toString();
-    }
-
-    public static int getBit(byte b, int n) {
-        // 将byte转换为二进制字符串
-        String binaryString = Integer.toBinaryString(b & 0xFF);
-        // 补足位数到8位
-        binaryString = String.format("%8s", binaryString).replace(' ', '0');
-        // 获取第n位的字符,然后转换为整数
-        return binaryString.charAt(n) == '1' ? 1 : 0;
-    }
-
-    public static Integer formatS7Int(byte[] val){
-        return new BigInteger(xtob(val)).intValue();
-    }
-
-}

+ 0 - 120
src/com/mes/util/SinumerikUtil.java

@@ -1,120 +0,0 @@
-package com.mes.util;
-
-import com.github.s7connector.api.DaveArea;
-import com.github.s7connector.api.S7Connector;
-import com.github.s7connector.api.S7Serializer;
-import com.github.s7connector.api.factory.S7ConnectorFactory;
-import com.github.s7connector.api.factory.S7SerializerFactory;
-
-import java.math.BigInteger;
-import java.text.DecimalFormat;
-
-//西门子机床获取DB块数据
-public class SinumerikUtil {
-
-    private static Integer bigEndian = 0; // 是否转大端排序 0=不转 1=转
-
-    // 获取Float状态的数据
-    public static Float readFloat(S7Connector s7Connector, Short db, Short length, Short offset){
-        //第一个参数:DaveArea.DB 表示读取PLC的地址区域为DB
-        //第二个参数:DB地址,若plc中是DB1000,则填1000
-        //第三个参数:数据长度, <=plc中两个偏移量的间隔,当前偏移量为1000,下一个地址偏移量为1100,则长度可填 0-1000;
-        //第四个参数:偏移量
-        return formatS7Val(s7Connector.read(DaveArea.DB, db, length, offset));
-    }
-
-    // 获取Integer状态的数据
-    public static Integer readInt(S7Connector s7Connector, Short db, Short length, Short offset){
-        //第一个参数:DaveArea.DB 表示读取PLC的地址区域为DB
-        //第二个参数:DB地址,若plc中是DB1000,则填1000
-        //第三个参数:数据长度, <=plc中两个偏移量的间隔,当前偏移量为1000,下一个地址偏移量为1100,则长度可填 0-1000;
-        //第四个参数:偏移量
-        return formatS7Int(s7Connector.read(DaveArea.DB, db, length, offset));
-    }
-
-    // 获取FInteger状态的数据
-    public static Boolean readBoolean(S7Connector s7Connector, Short db, Short offset, Short position){
-        //第一个参数:DaveArea.DB 表示读取PLC的地址区域为DB
-        //第二个参数:DB地址,若plc中是DB1000,则填1000
-        //第三个参数:数据长度, <=plc中两个偏移量的间隔,当前偏移量为1000,下一个地址偏移量为1100,则长度可填 0-1000;
-        //第四个参数:偏移量
-        byte[] bytes = s7Connector.read(DaveArea.DB, db, 1, offset);
-        int ret = getBit(bytes[0], 7 - position);
-        return ret == 1?true:false;
-    }
-
-    public static int getBit(byte b, int n) {
-        // 将byte转换为二进制字符串
-        String binaryString = Integer.toBinaryString(b & 0xFF);
-        // 补足位数到8位
-        binaryString = String.format("%8s", binaryString).replace(' ', '0');
-        // 获取第n位的字符,然后转换为整数
-        return binaryString.charAt(n) == '1' ? 1 : 0;
-    }
-
-    // 格式化s7取出的值
-    private static float formatS7Val(byte[] val){
-        int intValue = new BigInteger(xtob(val)).intValue();
-        float floatValue = Float.intBitsToFloat(intValue);
-
-        // 保留1位小数
-        DecimalFormat df = new DecimalFormat("#.#");
-        df.setMaximumFractionDigits(1);
-        String result = df.format(floatValue);
-        float roundedNum = Float.parseFloat(result);
-
-        return roundedNum;
-    }
-
-    private static Integer formatS7Int(byte[] val){
-        return new BigInteger(xtob(val)).intValue();
-    }
-
-    public static S7Connector initS7(S7Connector s7Connector, String plcUrl){
-        try {
-            if(s7Connector == null) {
-
-                //PLC地址
-                String ipAddress = plcUrl;
-                //默认端口
-//				int port = 102;
-                int rack=0;
-                int slot=3;
-                int timeout=5000;
-                s7Connector=
-                        S7ConnectorFactory
-                                .buildTCPConnector()
-                                .withHost(ipAddress)
-//								.withPort(port) //optional
-//								.withRack(rack) //optional
-//								.withSlot(slot) //optional
-                                .withTimeout(timeout) //连接超时时间
-                                .build();
-                S7Serializer s7Serializer2L = S7SerializerFactory.buildSerializer(s7Connector);
-            }
-        } catch (Exception e) { // 如果连接失败保存失败再次尝试连接一次
-            s7Connector = null;
-            e.printStackTrace();
-        }
-        return s7Connector;
-    }
-
-    // 转大端排序
-    private static byte[] xtob( byte[] bytes){
-        if(bigEndian == 0){
-            return bytes;
-        }else{
-            // 创建新的byte数组并复制原始数据
-            byte[] reversedBytes = new byte[bytes.length];
-            System.arraycopy(bytes, 0, reversedBytes, 0, bytes.length);
-
-            // 反转byte数组元素的位置
-            for (int i = 0; i < bytes.length / 2; i++) {
-                byte temp = reversedBytes[i];
-                reversedBytes[i] = reversedBytes[reversedBytes.length - 1 - i];
-                reversedBytes[reversedBytes.length - 1 - i] = temp;
-            }
-            return reversedBytes;
-        }
-    }
-}