*
lsh
9 天以前 7133241a7ad244824dcb2fd4afb560e9214bfbad
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
package com.zy.core;
 
import com.core.common.SpringUtils;
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.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import javax.annotation.PreDestroy;
import java.util.ArrayList;
 
/**
 * 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 int i = 0;
    private int j = 0;
    private int k = 0;
    private int l = 0;
 
    /**
     * =====>>  开始工作
     */
    public void start(){
        thread = new Thread(this::cenAndDevRun);
        thread.start();
 
        thread2 = new Thread(this::jarRun);
        thread2.start();
    }
 
 
 
    private void cenAndDevRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                i++; if (i>5) i=0;
 
                // 间隔
                Thread.sleep(1000);
 
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
 
                mainService.generateStoreWrkFile(); // 组托
                mainService.generateStoreWrkFile464(); // 组托464
                mainService.generateStoreWrkFileSingle(); // 组托  双工位单伸   小料箱
                mainService.generateStoreWrkFileLarge(); // 组托  双工位单伸   大料箱
//                    mainService.generateStoreWrkFile0(); // WMS入库
 
                // 出库  ===>>  堆垛机出库站到出库站
                mainService.crnStnToOutStn();
                // 出库  ===>>  堆垛机出库站到出库站  工位2
                mainService.crnStnToOutStnTwo();
                // 入出库  ===>>  堆垛机入出库作业下发
                mainService.crnIoExecute();
                // 入出库  ===>>  堆垛机入出库作业下发  双工位堆垛机
                mainService.crnIoExecuteTwo();
                // 入出库  ===>>  堆垛机入出库作业下发  双工位堆垛机  拆分执行任务下发
                mainService.crnIoExecuteTwoExecute(i);//Execute
                if (i%2==0){
                    // 入库  ===>> 执行对工作档的完成操作
                    mainService.storeFinished();
                }else {
                    // 入库  ===>> 执行对工作档的完成操作  工位2
                    mainService.storeFinishedTwo();
                }
 
//                    // 异常信息记录
//                    mainService.recErr();
                // 入库  ===>> 空栈板初始化入库
                mainService.storeEmptyPlt();
                // 入库  ===>> 空栈板初始化入库  双工位单伸   小料箱
                mainService.storeEmptyPltSingle();
                // 入库  ===>> 空栈板初始化入库  双工位单伸   大料箱
                mainService.storeEmptyPltLarge();
                // 出库  ===>> 工作档信息写入led显示器
                mainService.ledExecute();
                // 其他   ===>> LED显示器复位,显示默认信息
                mainService.ledReset();
 
                mainService.signTrunBig();
 
 
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private void jarRun() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
 
                // 间隔
                Thread.sleep(1000);
 
                // 系统运行状态判断
                if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                    continue;
                }
                k++;
                if (k>5) {
                    k=0;
                    l++;
                    if (l>=3) l=0;
                }
                /************************************JAR调度************************************/
                mainService.stackingCompletionDriveTray();//分配硫化罐
                mainService.stackingCompletionDriveTray2();//分配硫化罐
 
                //Jar充电任务完成
                mainService.jarChargeComplete();
                //JarWrkMastExecute任务完成
                mainService.jarWrkMastExecuteGenerateComplete(k);
                //JarWrkMastExecute任务创建   //硫化罐
                mainService.jarWrkMastExecuteGenerate(k);
                //JarWrkMastExecute任务执行
                mainService.jarWrkMastExecuteAction(k,l);
                //Jar任务创建
                mainService.jarMastGenerate();
                //Jar任务完成
                mainService.jarMastGenerateComplete();
                //Jar充电任务创建
                mainService.jarChargeGenerate();
 
                /************************************JAR调度************************************/
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    @PreDestroy
    public void shutDown(){
        if (thread != null) thread.interrupt();
        if (thread2 != null) thread2.interrupt();
    }
 
}