TaskStatusEnum.java 1.24 KB
package com.huaheng.common.utils;

public enum TaskStatusEnum {
    TASK1(1, "生成任务"),
    TASK10(10, "下达任务"),
    TASK20(20, "开始执行"),
    TASK30(30, "已经到站台"),
    TASK100(100, "已经完成");

//    TASK50(50, "XZ00014");
    private Integer taskStatusName;
    private String taskStatusCode;


    // 构造方法
    private TaskStatusEnum(Integer taskStatusName, String taskStatusCode) {
        this.taskStatusName = taskStatusName;
        this.taskStatusCode = taskStatusCode;
    }

    public static String getTaskStatusCode(Integer taskStatusName){
        for (TaskStatusEnum taskStatusEnum : TaskStatusEnum.values()) {
            if (taskStatusEnum.taskStatusName.equals(taskStatusName)){
                return taskStatusEnum.taskStatusCode;
            }
        }
        return null;
    }
    public static void main(String[] args) {
        TaskStatusEnum[] values = TaskStatusEnum.values();
//        for (TaskStatusEnum value : values) {
//            System.out.println(value + " taskStatusCode: " + value.taskStatusCode + " taskStatusName: " + value.taskStatusName);
//        }
//        System.out.println("======================");

        System.out.println(TaskStatusEnum.getTaskStatusCode(10));

    }

}