ZengTao
2023-09-17 9afdf0e2256420cf8157f886808ec67794d11098
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.example.springboot.component;
 
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
 
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.SpianService;
import com.example.springboot.entity.Glass;
import com.example.springboot.mapper.AlarmMapper;
import com.example.springboot.mapper.SpianMapper;
 
public class PlcHold extends Thread {
 
  private AlarmMapper alarmMapper;
 
  @Autowired
  private JdbcConnections jdbcConnections;
  private SpianMapper spianMapper;
  private SpianService spianService;
 
  @Override
  public void run() {
 
    while (this != null) {
      try {
 
        Thread.sleep(500);
      } catch (InterruptedException e) {
        // \\ TODO Auto-generated catch block
        e.printStackTrace();
      }
      spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
      spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
      jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
 
      // 根据玻璃id获取订单号
      try {
        Glass glass = jdbcConnections.selectGlass(112);
 
        // System.out.println(glass.getOrderId());
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
 
      // spianService.selectout("11");
 
      // 判断进片请求
      List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);
      List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1);
     
 
      if (datas1List != null && datas1ListState != null) {
        // 获取prc进片请求数据
        boolean exist = datas1List.contains((short) 1);
        // 获取进片车状态
        boolean exist1 = datas1ListState.contains((short) 0);
        String glassid="";
        // 进片请求为1时
        if (exist = true) {
          // 当进片车空闲时
          if (exist1 = true) {
            // 获取进片id
            List<Short> datas1ListID = S7control.getinstance().ReadWord("DB106.26", 13);
            if (datas1ListID != null) {
              // 获取玻璃id
              for (Short list1 : datas1ListID) {
                glassid=glassid.concat(list1.toString());
                
              }
              spianService.selectAll(Short.parseShort(glassid));
            }
 
          }
          // System.out.println(exist);
        }
      }
 
      //spianService.selectAll((short) 111);
 
      List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 出片车状态
      //List<Short> outlist2 = S7control.getinstance().ReadWord("DB106.20", 1); // 出片任务完成
 
   
      if (outlist != null) {
        // 判断按订单出片
        boolean outstate = outlist.contains((short) 0);
       
        if (outstate = true) { // 出片车状态空闲时
            String orderid = spianMapper.SelectOrderout();
            if (orderid != null) {
              spianService.selectout(orderid);
            }      
        }
 
      }
 
      // 查询数据库
      // 推送到前端
 
    }
  }
 
}