#
Junjie
2024-04-07 3845999a338b696f62f76b217bb871d5e759b37b
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
package com.zy.asrs.wcs.core.model.enums;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.service.LocService;
import com.zy.asrs.wcs.core.utils.Utils;
 
public enum LiftCodeType {
 
    NONE(-1, -1, "未知", "0402001"),
    LIFT_2(2, 198, "2号提升机二维码", "0402001"),
    LIFT_1(1, 0, "1号提升机无二维码", "0800701"),
    ;
 
    public Integer liftNo;
    public Integer code;
    public String desc;
    public String standbyLocNo;//待机库位
 
    LiftCodeType(Integer liftNo, Integer code, String desc, String standbyLocNo) {
        this.liftNo = liftNo;
        this.code = code;
        this.desc = desc;
        this.standbyLocNo = standbyLocNo;
    }
 
    public static LiftCodeType query(Integer code) {
        for (LiftCodeType value : LiftCodeType.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return NONE;
    }
 
    public static String getLocNo(Integer liftNo, Integer lev, Long hostId) {
        LiftCodeType type = null;
        for (LiftCodeType value : LiftCodeType.values()) {
            if (value.liftNo.equals(liftNo)) {
                type = value;
                break;
            }
        }
 
        if (type == null) {
            return null;
        }
 
        LocService locService = SpringUtils.getBean(LocService.class);
        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
                .eq(Loc::getHostId, hostId)
                .eq(Loc::getCode, type.code)
                .eq(Loc::getLev, lev));
        if (loc == null) {
            return null;
        }
 
        return loc.getLocNo();
    }
 
 
    public static String getStandbyLocNo(Integer liftNo, Integer lev) {
        LiftCodeType type = null;
        for (LiftCodeType value : LiftCodeType.values()) {
            if (value.liftNo.equals(liftNo)) {
                type = value;
                break;
            }
        }
 
        if (type == null) {
            return null;
        }
 
        return Utils.getLocNo(Utils.getRow(type.standbyLocNo), Utils.getBay(type.standbyLocNo), lev);
    }
 
}