package com.dy.pmsGlobal.util; public enum DeviceStatus { PENDING_PRODUCTION(0, "待生产"), ASSEMBLING(1, "组装中"), COMPLETED(2, "完成"), REPAIR(3, "维修"), WASTE(4, "报废"); //TEST_FAIL(5, "测试不通过"), //INSPECTION_FAIL(6, "品检不通过"); private final int code; private final String description; DeviceStatus(int code, String description) { this.code = code; this.description = description; } public int getCode() { return code; } public String getDescription() { return description; } // 根据code值获取对应的枚举值 public static DeviceStatus fromCode(int code) { for (DeviceStatus status : values()) { if (status.code == code) { return status; } } throw new IllegalArgumentException("未知的枚举code: " + code); } }