Ver Fonte

添加定时任务定时获取工件码

dkk há 2 semanas atrás
pai
commit
8fb80338c6

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

@@ -23,7 +23,7 @@ public class DataUtil {
             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));
-            System.out.println("请求参数:"+params);
+
             return result;
         } catch (Exception e) {
             log.info("e="+e.getMessage());

+ 30 - 0
src/com/mes/ui/WorkStationPanel.java

@@ -35,6 +35,7 @@ public class WorkStationPanel extends JPanel {
     public static Object[][] rowData = null;
     
     private Timer heartBeatTimer;
+    private Timer getSnBeatTimer;
     private boolean iconREDFlag = true;
 
     public WorkStationPanel(String gw, String gwDes, String lineSn, String serverIp) {
@@ -44,6 +45,7 @@ public class WorkStationPanel extends JPanel {
         this.serverIp = serverIp;
         initUI();
         startHeartBeatTimer();
+        startGetCurSn();
     }
 
     private void initUI() {
@@ -335,6 +337,34 @@ public class WorkStationPanel extends JPanel {
         }, 100, 1000);
     }
 
+    private void startGetCurSn(){
+        if (getSnBeatTimer != null) {
+            getSnBeatTimer.cancel();
+        }
+        getSnBeatTimer = new Timer();
+        getSnBeatTimer.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                if (workStatus == 1) {
+                    return;
+                } else if (workStatus == 0) {
+                    JSONObject result = DataUtil.getCurSn(gw, serverIp, lineSn);
+                    // 正常处理结果
+                    if (result.containsKey("data")) {
+                        String data = result.getString("data");
+                        if (data != null && !data.isEmpty()) {
+                            productSnField.setText(data);
+                            checkQuality(data);
+                        } else {
+                            JOptionPane.showMessageDialog(WorkStationPanel.this, "获取工件码为空", "提示", JOptionPane.INFORMATION_MESSAGE);
+                        }
+                    }
+                }
+            }
+
+        }, 100, 1000);
+    }
+
     public void stopHeartBeat() {
         if (heartBeatTimer != null) {
             heartBeatTimer.cancel();

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

@@ -1,7 +1,7 @@
 # 产线配置
 mes.line_sn=HEVXT
-mes.server_ip=127.0.0.1
-#mes.server_ip=192.168.9.180
+#mes.server_ip=127.0.0.1
+mes.server_ip=192.168.9.180
 
 # 工位列表(支持多个工位,逗号分隔)
 mes.stations=OP100A,OP110A,OP120A,OP130A,OP140A,OP150A