package easydo.technology.enums;

import java.util.HashMap;
import java.util.Map;

public enum MESEnum {

    FLOW_NO_TYPE_PROCESS_STAGE("process_stage", "工序管理"),
    FLOW_NO_TYPE_PROCESS_ROUTE("process_route", "工艺路线"),
    FLOW_NO_TYPE_PRODUCT_MATERIAL("product_material", "物料管理"),
    FLOW_NO_TYPE_PRODUCT_BOM("product_bom", "bom清单"),
    FLOW_NO_TYPE_QUALITY_INSPECT_TOOL("quality_inspect_tool", "质检工具"),
    FLOW_NO_TYPE_QUALITY_INSPECT_FUNCTION("quality_inspect_function", "质检方法"),
    FLOW_NO_TYPE_QUALITY_INSPECT_PROGRAM("quality_inspect_program", "质检方案"),
    FLOW_NO_TYPE_CUSTOMER("customer", "供应商/客户"),
    FLOW_NO_TYPE_SALE_PLAN("sale_plan", "销售计划"),
    FLOW_NO_TYPE_SALE_ORDER("sale_order", "销售订单"),
    FLOW_NO_TYPE_WAREHOUSE("warehouse", "仓库管理"),
    FLOW_NO_TYPE_PURCHASE_PLAN("purchase_plan", "采购计划"),
    FLOW_NO_TYPE_PURCHASE_ORDER("purchase_order", "采购订单"),
    FLOW_NO_TYPE_OUTSOURCING_PLAN("outsourcing_plan", "委外计划"),

    PROCESS_STAGE_OF_CATEGORY_PREPARATION("preparation","准备工序"),
    PROCESS_STAGE_OF_CATEGORY_PROCESSING("processing","加工工序"),
    PROCESS_STAGE_OF_CATEGORY_INSPECTION("inspection","检验工序"),
    PROCESS_STAGE_OF_CATEGORY_AUXILIARY("auxiliary","辅助工序"),

    PROCESS_STAGE_OF_PROCESS_TYPE_SELF_MADE("self_made","自制"),
    PROCESS_STAGE_OF_PROCESS_TYPE_OUTSOURCING("outsourcing","委外"),

    PROCESS_STAGE_OF_CALCULATE_METHOD_BOTH_RATES("both_rates","计件+计时都支持"),
    PROCESS_STAGE_OF_CALCULATE_METHOD_PIECE_RATE("piece_rate","计件"),
    PROCESS_STAGE_OF_CALCULATE_METHOD_TIME_RATE("time_rate","计时"),
    PROCESS_STAGE_OF_CALCULATE_METHOD_NON_PROD_PAY("non_prod_pay","不计生产工资"),

    PROCESS_OF_STATUS_ENABLE("enable","启用"),
    PROCESS_OF_STATUS_DISABLE("disable","停用"),

    PRODUCT_MATERIAL_OF_NEED_TYPE_SELF_MADE("self_made", "自制"),
    PRODUCT_MATERIAL_OF_NEED_TYPE_OUT_PURCHASE("out_purchase", "外采"),
    PRODUCT_MATERIAL_OF_NEED_TYPE_OUTSOURCING("outsourcing", "委外"),

    PRODUCT_MATERIAL_OF_MATERIAL_TYPE_RAW_MATERIAL("raw_material", "原材料"),
    PRODUCT_MATERIAL_OF_MATERIAL_TYPE_SEMI_FINISHED("semi_finished", "半成品"),
    PRODUCT_MATERIAL_OF_MATERIAL_TYPE_FINISHED_PRODUCT("finished_product", "半成品"),
    PRODUCT_MATERIAL_OF_MATERIAL_TYPE_PACKAGING_MATERIAL("packaging_material", "包装材料"),
    PRODUCT_MATERIAL_OF_MATERIAL_TYPE_TRADE_GOODS("trade_goods", "贸易品"),

    QUALITY_INSPECT_PROGRAM_OF_STATUS_PENDING("pending", "待审批"),
    QUALITY_INSPECT_PROGRAM_OF_STATUS_APPROVED("approved", "同意"),
    QUALITY_INSPECT_PROGRAM_OF_STATUS_REJECTED("rejected", "拒绝"),

    QUALITY_INSPECT_PROGRAM_OF_TYPE_FULL("full", "全检"),
    QUALITY_INSPECT_PROGRAM_OF_TYPE_SAMPLING("sampling", "抽检"),

    SALE_PLAN_OF_STATUS_INACTIVE("inactive","待进行"),
    SALE_PLAN_OF_STATUS_ACTIVE("active","进行中"),
    SALE_PLAN_OF_STATUS_DONE("done","已完成"),

    SALE_ORDER_OF_STATUS_PENDING("pending", "待处理"),
    SALE_ORDER_OF_STATUS_PROCESSING("processing", "备货中"),
    SALE_ORDER_OF_STATUS_PARTIALLY("partially", "部分发货"),
    SALE_ORDER_OF_STATUS_SHIPPED("shipped", "已发货"),
    SALE_ORDER_OF_STATUS_COMPLETE("complete", "已完成"),

    FLOW_NO_TYPE_PRODUCT_PLAN("product_plan", "生产计划"),
    FLOW_NO_TYPE_PRODUCT_ORDER("product_order", "工单"),
    FLOW_NO_TYPE_PRODUCT_ORDER_DISPATCH("product_order_dispatch", "派工单"),
    FLOW_NO_TYPE_MATERIAL_REQUISITION("material_requisition", "领料单"),

    PRODUCT_PLAN_OF_STATUS_PENDING("pending", "待进行"),
    PRODUCT_PLAN_OF_STATUS_PROCESSING("processing", "进行中"),
    PRODUCT_PLAN_OF_STATUS_COMPLETE("complete", "已完成"),
    
    PRODUCT_ORDER_OF_STATUS_PENDING("pending", "待进行"),
    PRODUCT_ORDER_OF_STATUS_PROCESSING("processing", "进行中"),
    PRODUCT_ORDER_OF_STATUS_COMPLETE("complete", "已完成"),
    
    PRODUCT_ORDER_OF_PRIORITY_URGENT("urgent", "紧急"),
    PRODUCT_ORDER_OF_PRIORITY_HIGH("high", "高"),
    PRODUCT_ORDER_OF_PRIORITY_MEDIUM("medium", "中"),
    PRODUCT_ORDER_OF_PRIORITY_LOW("low", "低"),

    // 派工单领料状态
    DISPATCH_REQUISITION_STATUS_PENDING("pending", "未领料"),
    DISPATCH_REQUISITION_STATUS_PARTIALLY("partially", "部分领料"),
    DISPATCH_REQUISITION_STATUS_COMPLETE("complete", "已领料"),
    
    // 派工单状态
    PRODUCT_ORDER_DISPATCH_OF_STATUS_PENDING("pending", "未开始"),
    PRODUCT_ORDER_DISPATCH_OF_STATUS_PROCESSING("processing", "生产中"),
    PRODUCT_ORDER_DISPATCH_OF_STATUS_COMPLETED("completed", "已完工"),
    PRODUCT_ORDER_DISPATCH_OF_STATUS_REWORK("rework", "待返工"),
    
    // 领料单类型
    MATERIAL_REQUISITION_TYPE_AUTO("auto", "领料(自动生成)"),
    MATERIAL_REQUISITION_TYPE_MANUAL("manual", "补料(手动新增)"),
    
    // 领料单出库状态
    MATERIAL_REQUISITION_OUTBOUND_STATUS_APPLIED("applied", "申请完毕"),
    MATERIAL_REQUISITION_OUTBOUND_STATUS_PENDING("pending", "未出库"),
    MATERIAL_REQUISITION_OUTBOUND_STATUS_PARTIAL("partially", "部分出库"),
    MATERIAL_REQUISITION_OUTBOUND_STATUS_COMPLETED("completed", "出库完毕"),
    
    // 领料单状态
    MATERIAL_REQUISITION_OF_STATUS_PENDING("pending", "未领料"),
    MATERIAL_REQUISITION_OF_STATUS_COMPLETE("complete", "已领料"),
    
    // 报工单状态
    WORK_REPORT_OF_STATUS_PENDING("pending", "未开始"),
    WORK_REPORT_OF_STATUS_PARTIALLY("partially", "部分报工"),
    WORK_REPORT_OF_STATUS_COMPLETE("complete", "已完工"),
    
    PURCHASE_PLAN_OF_STATUS_PENDING("pending", "待进行"),
    PURCHASE_PLAN_OF_STATUS_PROCESSING("processing", "进行中"),
    PURCHASE_PLAN_OF_STATUS_COMPLETE("complete", "已完成"),
    
    PURCHASE_ORDER_OF_STATUS_PENDING("pending", "待处理"),
    PURCHASE_ORDER_OF_STATUS_PROCESSING("processing", "采购中"),
    PURCHASE_ORDER_OF_STATUS_RECEIVED("received", "已收货"),
    PURCHASE_ORDER_OF_STATUS_COMPLETE("complete", "已完成"),
    
    OUTSOURCING_PLAN_OF_STATUS_PENDING("pending", "待进行"),
    OUTSOURCING_PLAN_OF_STATUS_PROCESSING("processing", "进行中"),
    OUTSOURCING_PLAN_OF_STATUS_COMPLETE("complete", "已完成"),

    WAREHOUSE_RECORD_OF_TYPE_LOCK("lock", "锁定"),

    WAREHOUSE_RECORD_OF_REF_TYPE_PRODUCT("product", "生产计划"),
    WAREHOUSE_RECORD_OF_REF_TYPE_PURCHASE("purchase", "采购计划"),
    WAREHOUSE_RECORD_OF_REF_TYPE_OUTSOURCING("outsourcing", "委外计划"),

    OUTSOURCING_PLAN_OF_TYPE_PROCESS("process", "工序委外"),
    OUTSOURCING_PLAN_OF_TYPE_WHOLE("whole", "整单委外"),
    
    PURCHASE_ORDER_OF_CATEGORY_REGULAR("regular", "常规采购"),
    PURCHASE_ORDER_OF_CATEGORY_URGENT("urgent", "特急采购"),
    PURCHASE_ORDER_OF_CATEGORY_SPORADIC("sporadic", "零星采购"),
    PURCHASE_ORDER_OF_CATEGORY_BULK("bulk", "大量采购"),
    PURCHASE_ORDER_OF_CATEGORY_INTERNAL("internal", "集团内部采购"),

    PLAN_PRIORITY_URGENT("urgent", "紧急"),
    PLAN_PRIORITY_HIGH("high", "高"),
    PLAN_PRIORITY_MEDIUM("medium", "中"),
    PLAN_PRIORITY_LOW("low", "低"),
    ;

    MESEnum(String value, String comment) {
        this.value = value;
        this.comment = comment;
    }

    private static Map<String, MESEnum> typelookup = new HashMap<>();

    static {
        for (MESEnum mspEnum : MESEnum.values()) {
            typelookup.put(mspEnum.value, mspEnum);
        }
    }

    public static boolean isContainsValue(String type) {
        return typelookup.containsKey(type);
    }

    public static MESEnum forType(String type) {
        return typelookup.get(type);
    }

    private String value;
    private String comment;

    public String getValue() {
        return value;
    }

    public String getComment() {
        return comment;
    }


}
