#
vincentlu
2025-05-13 ebd2f4397a92c6a5096de1b86d59154363344720
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
package com.zy.acs.manager.manager.enums;
 
import com.zy.acs.framework.common.SpringUtils;
import com.zy.acs.manager.common.exception.BusinessException;
import com.zy.acs.manager.common.utils.DataFieldSortFunc;
import com.zy.acs.manager.manager.entity.BusSts;
import com.zy.acs.manager.manager.service.BusStsService;
 
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
public enum BusStsType implements DataFieldSortFunc {
 
    RECEIVE(1),
    PROGRESS(2),
    FINISH(3),
    CANCEL(4),
    ;
 
    public int dataSort;
 
    BusStsType(int dataSort) {
        this.dataSort = dataSort;
    }
 
    private static final Map<BusStsType, Long> cache = new EnumMap<>(BusStsType.class);
 
    public long val() {
        return cache.computeIfAbsent(this, key -> {
            BusStsService service = SpringUtils.getBean(BusStsService.class);
            BusSts busSts = service.selectByUuid(this.toString());
            if (busSts == null) {
                throw new BusinessException("BusStsType Error!");
            }
            return busSts.getId();
        });
    }
 
    @Override
    public List<String> getDataFieldSort() {
        return Arrays.stream(BusStsType.values())
                .sorted((e1, e2) -> Integer.compare(e1.dataSort, e2.dataSort))
                .map(Enum::name)
                .collect(Collectors.toList());
    }
 
}