doum
9 天以前 0201c32312f6478b2bde706607c8c6338e9e1d06
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
package com.doumee.core.device.model;
 
public enum ElectronicNotifyStatus {
 
    NOTFOUND("NOTFOUND", "未找到"),
    ACCEPTED("ACCEPTED", "已接受任务"),
    QUEUE("QUEUE", "队列中"),
    PROCESSING("PROCESSING", "执行中"),
    DELIVERED("DELIVERED", "已执行"),
    SUCCESS("SUCCESS", "成功"),
    NOTSUPPORT("NOTSUPPORT", "设备不支持"),
    FAIL("FAIL", "失败"),
    TIMEOUT("TIMEOUT", "任务超时"),
    CANCELED("CANCELED", "取消"),
    RESPONSE_TIMEOUT("RESPONSE_TIMEOUT", "设备响应超时"),
    RESPONSE_FAIL("RESPONSE_FAIL", "设备响应失败"),
    UNKOWN("UNKOWN", "未知");
 
    private final String code;
    private final String label;
 
    ElectronicNotifyStatus(String code, String label) {
        this.code = code;
        this.label = label;
    }
 
    public String getLabel() {
        return label;
    }
 
    public static ElectronicNotifyStatus fromCode(String code) {
        if (code == null) {
            return UNKOWN;
        }
        for (ElectronicNotifyStatus s : values()) {
            if (s.code.equalsIgnoreCase(code.trim())) {
                return s;
            }
        }
        return UNKOWN;
    }
 
    public boolean isTerminalSuccess() {
        return this == SUCCESS || this == DELIVERED;
    }
 
    public boolean isTerminalFail() {
        return this == FAIL || this == TIMEOUT || this == NOTSUPPORT || this == CANCELED
                || this == RESPONSE_TIMEOUT || this == RESPONSE_FAIL || this == NOTFOUND;
    }
 
    public boolean isInProgress() {
        return this == ACCEPTED || this == QUEUE || this == PROCESSING;
    }
}