#
Junjie
3 天以前 6daf900a09adcca981f620744bf89851654d88e0
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
package com.zy.core;
 
import com.zy.asrs.service.impl.ForkMainServiceImpl;
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;
 
/**
 * WCS主流程
 * Created by vincent on 2020/8/6
 */
@Data
@Slf4j
@Component
public class MainProcess {
 
    @Value("${deviceExecuteConfig.liftType}")
    private String liftType;
    @Autowired
    private MainServiceImpl mainService;
    @Autowired
    private ForkMainServiceImpl forkMainService;
    // 所属线程
    private Thread thread;
    // 频率
    private int i = 0;
 
    /**
     * =====>>  开始工作
     */
    public void start(){
        if(liftType.equals("ForkLift")){
            initForkMain();
        }else {
            initMain();
        }
    }
 
    private void initMain() {
        thread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
 
                    // 间隔
                    Thread.sleep(300);
 
                    // 系统运行状态判断
                    if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                        continue;
                    }
 
                    //初始化实时地图
                    mainService.initRealtimeBasMap();
 
                    // 入库  ===>>  四向穿梭车入库作业下发
                    mainService.shuttleInExecute();
                    // 出库  ===>>  四向穿梭车出库作业下发
                    mainService.shuttleOutExecute();
//                    //四向穿梭车任务完成
//                    mainService.shuttleFinished();
                    //执行移库任务
                    mainService.shuttleLocMoveExecute();
                    //货叉提升机任务
                    mainService.forkLiftIoExecute();
                    //货叉提升机任务完成
                    mainService.forkLiftFinished();
                    //执行小车移动任务
                    mainService.shuttleMoveExecute();
                    // 异常信息记录
                    mainService.recErr();
                    // 穿梭车 ===>> 小车电量检测充电
                    mainService.loopShuttleCharge();
                    mainService.executeShuttleCharge();
 
                    //自动切换出入库模式
                    mainService.autoSwitchForkLiftIOMode();
 
                    // 间隔
                    Thread.sleep(200);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
    }
 
    private void initForkMain() {
        thread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
 
                    // 间隔
                    Thread.sleep(300);
 
                    // 系统运行状态判断
                    if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                        continue;
                    }
 
                    //初始化实时地图
                    forkMainService.initRealtimeBasMap();
 
                    //出库任务预调度提升机
                    forkMainService.outTaskPreviewDispatchForkLift();
 
                    // 入库  ===>>  四向穿梭车入库作业下发
                    forkMainService.shuttleInExecute();
                    // 出库  ===>>  四向穿梭车出库作业下发
                    forkMainService.shuttleOutExecute();
//                    //四向穿梭车任务完成
//                    mainService.shuttleFinished();
                    //执行移库任务
                    forkMainService.shuttleLocMoveExecute();
                    //货叉提升机任务
                    forkMainService.forkLiftIoExecute();
                    //货叉提升机任务完成
                    forkMainService.forkLiftFinished();
                    //执行小车移动任务
                    forkMainService.shuttleMoveExecute();
                    // 异常信息记录
                    forkMainService.recErr();
                    // 穿梭车 ===>> 小车电量检测充电
                    forkMainService.loopShuttleCharge();
                    forkMainService.executeShuttleCharge();
 
                    //自动切换出入库模式
                    forkMainService.autoSwitchForkLiftIOMode();
 
                    // 间隔
                    Thread.sleep(200);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
    }
 
    @PreDestroy
    public void shutDown(){
        if (thread != null) thread.interrupt();
    }
 
}