Fancy
2025-01-07 28f6317f7189d5c4a7e64f57dd6c7fc2011f8632
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
package com.dy.pmsGlobal.util;
 
public enum DeviceResult {
    PASS(1, "通过"),
    TEST_PASS(2, "测试通过"),
    INSPECTION_PASS(3, "品检通过"),
    REPAIR_PASS(4, "维修通过"),
    TEST_FAIL(5, "测试不通过"),
    INSPECTION_FAIL(6, "品检不通过"),
    WASTE(7, "报废");
 
    private final int code;
    private final String description;
 
    DeviceResult(int code, String description) {
        this.code = code;
        this.description = description;
    }
 
    public int getCode() {
        return code;
    }
 
    public String getDescription() {
        return description;
    }
 
    // 根据code值获取对应的枚举值
    public static DeviceResult fromCode(int code) {
        for (DeviceResult result : values()) {
            if (result.code == code) {
                return result;
            }
        }
        throw new IllegalArgumentException("未知的枚举code: " + code);
    }
}