*
lsh
1 天以前 a55f49c966b25bf983645830baf58d1ba102f942
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package com.zy.core;
 
import com.zy.asrs.service.impl.MainServiceImpl;
import com.zy.core.properties.SystemProperties;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.PreDestroy;
 
/**
 * WCS主流程
 * Created by vincent on 2020/8/6
 */
@Data
@Slf4j
@Component
public class MainProcess {
 
    @Autowired
    private MainServiceImpl mainService;
    // 所属线程
    private Thread thread;
    private Thread thread2;
    private Thread thread3;
    private Thread thread4;
 
    /**
     * =====>>  开始工作
     */
    public void start(){
        thread = new Thread(this::crnAndDevRun);
        thread.start();
 
        thread2 = new Thread(this::crnAndDevOtherRun);
        thread2.start();
 
        thread3 = new Thread(this::demoRun);
        thread3.start();
 
        thread4 = new Thread(this::demoOpenRun);
        thread4.start();
    }
 
    private void crnAndDevRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(1000);
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                // 系统演示模式运行状态判断
                if (SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    continue;
                }
                // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                mainService.generateStoreWrkFile(); // 组托
//                    mainService.generateStoreWrkFileIsEmptyMk(); // 组托  空托
                mainService.generateStoreWrkFileWalk(); // wms入库任务下发
                // 入出库  ===>>  堆垛机入出库作业下发
                mainService.crnIoExecute();
                // 入库  ===>> 执行对工作档的完成操作
                mainService.storeFinished();
                // 任务下发
                mainService.taskStart();
                // 出库  ===>>  堆垛机10分钟无任务则回到源点
                mainService.crnStnToOutStnSou();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private void crnAndDevOtherRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(400);
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                // 系统演示模式运行状态判断
                if (SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    continue;
                }
                // 出库  ===>>  堆垛机出库站到出库站
                mainService.crnStnToOutStn();
                // 堆垛机异常信息记录
                mainService.recCrnErr();
                // 输送线异常信息记录
//                    mainService.recDevErr();
                // 出库  ===>> 工作档信息写入led显示器
//                    mainService.ledExecute(9);
                // 其他  ===>> LED显示器复位,显示默认信息
//                    mainService.ledReset(10);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    private void demoRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(1000);
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                // 系统演示模式运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    continue;
                }
                // 入出库  ===>>  堆垛机入出库作业下发
                mainService.crnIoExecuteDemo();
                // 出库  ===>>  堆垛机出库站到出库站
                mainService.crnStnToOutStnDemo();
                // 任务下发
                mainService.taskStartDemo();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    private void demoOpenRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                // 间隔
                Thread.sleep(1000);
                // 系统演示模式运行状态变化
                if (SystemProperties.WCS_RUNNING_STATUS_DEMO.get()) {
                    if (SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE == 2){
                        boolean signHpMk = mainService.crnStnDEMOStop2();
                        if (signHpMk){
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 3;
                        }
                    } else if (SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE == 3){
                        boolean signHpMk = mainService.crnStnDEMOStop3();
                        if (signHpMk){
                            SystemProperties.WCS_RUNNING_STATUS_DEMO.set(false);
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 0;
                        }
                    }
                } else {
                     if (SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE == 1){
                        boolean signHpMk = mainService.crnStnDEMOOpen1();
                        if (signHpMk){
                            SystemProperties.WCS_RUNNING_STATUS_DEMO.set(true);
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 2;
                        } else {
                            SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 0;
                        }
                    } else {
                         boolean signHpMk = mainService.crnStnDEMOOpen0();
                         if (signHpMk){
                             SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 1;
                         } else {
                             SystemProperties.WCS_RUNNING_STATUS_DEMO_VALUE = 0;
                         }
                     }
                }
                // 其他  ===>> LED显示器显示时间
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    @PreDestroy
    public void shutDown(){
        if (thread != null) thread.interrupt();
        if (thread2 != null) thread2.interrupt();
        if (thread3 != null) thread3.interrupt();
        if (thread4 != null) thread4.interrupt();
    }
 
}