gaoluyang
昨天 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
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
package cn.iocoder.yudao.module.mes.enums.pro;
 
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
 
import java.util.Arrays;
 
/**
 * MES 工序计费类型枚举
 *
 * <p>决定报工工资的计算口径:
 * <ul>
 *   <li>计时:报工工资 = 本次报工工时 × 工资定额(元/小时)</li>
 *   <li>计件:报工工资 = 本次报工数量 × 工资定额(元/件)</li>
 * </ul>
 *
 * @author 超级管理员
 */
@Getter
@AllArgsConstructor
public enum MesProProcessBillingTypeEnum implements ArrayValuable<Integer> {
 
    TIME(1, "计时"),
    PIECE(2, "计件");
 
    public static final Integer[] ARRAYS = Arrays.stream(values())
            .map(MesProProcessBillingTypeEnum::getType).toArray(Integer[]::new);
 
    /**
     * 类型值
     */
    private final Integer type;
    /**
     * 类型名
     */
    private final String name;
 
    @Override
    public Integer[] array() {
        return ARRAYS;
    }
 
    public static MesProProcessBillingTypeEnum valueOfType(Integer type) {
        if (type == null) {
            return null;
        }
        return Arrays.stream(values()).filter(e -> e.getType().equals(type)).findFirst().orElse(null);
    }
 
    public static String getNameByType(Integer type) {
        MesProProcessBillingTypeEnum billingType = valueOfType(type);
        return billingType != null ? billingType.getName() : String.valueOf(type);
    }
 
}