wuyouming666
2024-05-06 3dc8dcf5854bb90b9d5fb07ab449053ed6a361ae
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
package com.mes.common;
 
import cn.hutool.json.JSONObject;
 
import com.mes.downstorage.service.DownStorageCageService;
import com.mes.downworkstation.service.DownWorkstationService;
 
 
import com.mes.tools.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
@Component
@Slf4j
public class Plcdownglass {
 
    public static final String RESULT_IN = "1";
    public static final String RESULT_OUT = "2";
    public static final String RESULT_IN_OUT = "3";
 
    @Autowired
    private DownStorageCageService downStorageCageService;
    @Autowired
    private DownWorkstationService downWorkstationService;
 
 
    @Scheduled(fixedDelay = 300)
    public void PlcdownglassTask() throws InterruptedException {
        JSONObject jsonObject = new JSONObject();
        try {
            Thread.sleep(300);
 
 
            //                String result = S7control.getinstance().ReadWord("DB14.0", 1).get(0) + "";
//                String number = S7control.getinstance().ReadWord("DB14.2", 1).get(0) + "";
            String result = "2";
            String number = "1";
            // 进片请求
            if (RESULT_IN.equals(result)) {
                downStorageCageService.processInto(number);
            }
            // 出片请求
            else if (RESULT_OUT.equals(result)) {
                downStorageCageService.processOut();
            }
            // 进出片请求
            else if (RESULT_IN_OUT.equals(result)) {
                // 先出后进
                if (!downStorageCageService.processOut()) {
                    downStorageCageService.processInto(number);
                }
            }
 
            //下片更新
            downWorkstationService.insertdownglassinfo();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
}