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;
|
}
|
}
|