自动化立体仓库 - WCS系统
#
Junjie
2025-01-14 900f7032f7e701efd4741c2bcabeaad969e5fd3f
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
package com.zy.core.model.protocol;
 
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasShuttleErr;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.BasShuttleErrService;
import com.zy.asrs.service.LocMastService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.ShuttleProtocolStatusType;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
 
import java.util.HashMap;
 
/**
 * 四向穿梭车
 */
@Slf4j
@Data
public class ShuttleProtocol implements Cloneable {
 
    //**********************必须存在属性**********************
    /**
     * 四向穿梭车号
     */
    private Integer shuttleNo;
 
    /**
     * 任务号
     */
    private Integer taskNo;
 
    /**
     * 当前小车状态(内部自我维护)
     */
    private Integer protocolStatus;
 
    /**
     * 当前小车作业状态枚举
     */
    private ShuttleProtocolStatusType protocolStatusType;
 
    /**
     * 源库位
     */
    private String sourceLocNo;
 
    /**
     * 目标库位
     */
    private String locNo;
 
    /**
     * 小车设备状态0:忙碌 1:空闲
     */
    private Integer deviceStatus;
 
    /**
     * 小车模式,0:手动 1:自动
     */
    private Integer mode;
 
    /**
     * 当前二维码
     * 0为空
     */
    private String currentCode;
 
    /**
     * 电池电量
     */
    private String batteryPower;
 
    /**
     * 错误编号
     */
    private String errorCode;
 
 
    //**********************非必须属性,实际使用中可能存在空值**********************
 
    /**
     * 电池温度
     */
    private String batteryTemp;
 
    /**
     * 是否顶升
     */
    private Boolean hasLift;
 
    /**
     * 是否有托盘
     */
    private Boolean hasPallet;
 
    /**
     * 行驶方向
     */
    private String runDirection;
 
    /**
     * 是否为充电状态
     */
    private Boolean hasCharge;
 
    /**
     * 电池电压
     */
    private Integer batteryVoltage;
 
    /**
     * 运行速度
     */
    private Integer speed;
 
 
    //**********************系统自身所需属性**********************
    /**
     * 作业标记 false表示正在作业
     */
    private Boolean pakMk = true;
 
    /**
     * 跑库状态
     */
    private Boolean moveLoc = false;
 
    /**
     * 跑库类型,0:跑轨道,1:跑库位
     */
    private Integer moveType = 0;
 
    /**
     * 跑库X起点
     */
    private Integer xStart = 0;
 
    /**
     * 跑库X终点
     */
    private Integer xTarget = 0;
 
    /**
     * 跑库X当前点位
     */
    private Integer xCurrent = 0;
 
    /**
     * 跑库Y起点
     */
    private Integer yStart = 0;
 
    /**
     * 跑库Y终点
     */
    private Integer yTarget = 0;
 
    /**
     * 跑库Y当前点位
     */
    private Integer yCurrent = 0;
 
    /**
     * 演示模式
     */
    private Boolean demo = false;
 
    /**
     * 日志采集时间
     */
    private Long deviceDataLog = System.currentTimeMillis();
 
    /**
     * 指令下发时间
     */
    private Long sendTime = 0L;
 
    /**
     * 最近一次在线时间
     */
    private Long lastOnlineTime = System.currentTimeMillis();
 
    /**
     * 扩展字段
     */
    private Object extend;
 
    public String getProtocolStatus$() {
        if (this.protocolStatusType == null) {
            return "";
        }
        return this.protocolStatusType.desc;
    }
 
    /**
     * 设置小车状态
     */
    public void setProtocolStatus(Integer status) {
        this.protocolStatus = status;
        this.protocolStatusType = ShuttleProtocolStatusType.get(status);
    }
 
    /**
     * 设置小车状态
     */
    public void setProtocolStatus(ShuttleProtocolStatusType status) {
        this.protocolStatus = status.id;
        this.protocolStatusType = status;
    }
 
    public Integer getTaskNo() {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        if (null != redisUtil) {
            Object o = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + this.shuttleNo);
            if (!Cools.isEmpty(o)) {
                this.taskNo = Integer.parseInt(String.valueOf(o));
            }
        }
        return this.taskNo == null ? 0 : this.taskNo;
    }
 
    public synchronized void setSyncTaskNo(Integer taskNo) {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        if (null != redisUtil) {
            redisUtil.set(RedisKeyType.SHUTTLE_FLAG.key + this.shuttleNo, taskNo);
            this.taskNo = taskNo;
        }
    }
 
    @Override
    public ShuttleProtocol clone() {
        try {
            return (ShuttleProtocol) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
 
    //通过当前二维码获取当前库位号
    public String getCurrentLocNo() {
        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
        if (locMastService == null) {
            return null;
        }
        //源库位(小车当前位置)
        LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode);
        if (currentLocMast == null) {
            return null;
        }
        return currentLocMast.getLocNo();
    }
 
    public String getStatusErrorCode$() {
        BasShuttleErrService basShuttleErrService = SpringUtils.getBean(BasShuttleErrService.class);
        if (this.errorCode == null) {
            return "";
        }
        BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(Integer.valueOf(this.errorCode));
        if (basShuttleErr == null) {
            return this.errorCode;
        }
        return basShuttleErr.getErrName();
    }
 
    public String getMode$() {
        if (this.mode == null) {
            return "";
        }
        if (this.mode == 0) {
            return "手动";
        } else if (this.mode == 1) {
            return "自动";
        }
 
        return "";
    }
 
    public String getDeviceStatus$() {
        if (this.deviceStatus == null) {
            return "";
        }
        if (this.deviceStatus == 0) {
            return "忙碌";
        } else if (this.deviceStatus == 1) {
            return "空闲";
        }
 
        return "";
    }
 
    public String getHasLift$() {
        if (this.hasLift == null) {
            return "";
        }
 
        return this.hasLift ? "Y" : "N";
    }
 
    public String getHasCharge$() {
        if (this.hasCharge == null) {
            return "";
        }
 
        return this.hasCharge ? "Y" : "N";
    }
 
    public String getHasPallet$() {
        if (this.hasPallet == null) {
            return "";
        }
 
        return this.hasPallet ? "Y" : "N";
    }
 
    public String getPakMk$() {
        if (this.pakMk == null) {
            return "";
        }
 
        return this.pakMk ? "Y" : "N";
    }
 
    public String getDemo$() {
        if (this.demo == null) {
            return "";
        }
 
        return this.demo ? "Y" : "N";
    }
 
    public HashMap<String, Object> getPoint() {
        HashMap<String, Object> map = new HashMap<>();
        if (this.currentCode == null) {
            return map;
        }
 
        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
        if (locMastService == null) {
            return map;
        }
 
        //源库位(小车当前位置)
        LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode);
        if (currentLocMast == null) {
            return map;
        }
 
        map.put("x", currentLocMast.getRow1());
        map.put("y", currentLocMast.getBay1());
        map.put("z", currentLocMast.getLev1());
        return map;
    }
 
}