skyouc
2024-12-21 c635d78b479510ebe2556a420948effcd30a0731
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
package com.zy.asrs.wms.asrs.entity.enums;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wms.asrs.entity.LocType;
import com.zy.asrs.wms.asrs.service.LocTypeService;
 
import java.util.ArrayList;
import java.util.List;
 
public enum LocBindType {
 
    HEIGHT("locTypeHeight", "高低类型"),
    WEIGHT("locTypeWeight", "宽窄类型"),
    ;
 
 
    public String flag;
    public String desc;
 
    LocBindType(String flag, String desc) {
        this.flag = flag;
        this.desc = desc;
    }
 
    public long val() {
        LocTypeService service = SpringUtils.getBean(LocTypeService.class);
        LocType locType = service.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, flag));
        if (locType == null) {
            throw new CoolException("LocType Error!");
        }
        return locType.getId();
    }
 
    public List<Long> list() {
        LocTypeService service = SpringUtils.getBean(LocTypeService.class);
        LocType locType = service.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, flag));
        if (locType == null) {
            throw new CoolException("LocType Error!");
        }
 
        List<LocType> list = service.list(new LambdaQueryWrapper<LocType>().eq(LocType::getParentId, locType.getId()));
        ArrayList<Long> longs = new ArrayList<>();
        for (LocType type : list) {
            longs.add(type.getId());
        }
 
        if (longs.isEmpty()) {
            throw new CoolException("LocType Error!");
        }
        return longs;
    }
 
    public static LocBindType get(String flag) {
        for (LocBindType value : LocBindType.values()) {
            if (flag.equals(value.flag)) {
                return value;
            }
        }
        return null;
    }
 
 
}