package com.foreverwin.mesnac.common.enums;

import java.text.MessageFormat;

/**
 * 数据库表HANDLE拼接
 *
 * @author Ervin Chen
 * @date 2020/2/5 14:50
 */

public enum HandleEnum {

    /**车间作业控制*/
    SFC( "SFCBO:", "SFCBO:{0},{1}" ),

    /**用户**/
    USER("UserBO:", "UserBO:{0},{1}"),

    /**物料清单**/
    BOM("BOMBO:","BOMBO:{0},{1},{2},{3}"),

    PRINT("PrintBO:", "PrintBO:{0},{1}"),

    /**叫料**/
    CALL_ITEM("CallItemBO:", "CallItemBO:{0},{1}"),

    /**工单*/
    SHOP_ORDER( "ShopOrderBO:", "ShopOrderBO:{0},{1}" ),

    /**车间作业控制*/
    SFC_BOM( "SFCBOMBO:", "SFCBOMBO:{0}" ),

    SFC_DATA( "SFCDataBO:", "SFCDataBO:{0},{1}" ),

    /**物料*/
    ITEM( "ItemBO:", "ItemBO:{0},{1},{2}" ),

    /**资源*/
    RESOURCE( "ResourceBO:", "ResourceBO:{0},{1}" ),

    /**设备状态**/
    STATUS("StatusBO:", "StatusBO:{0},{1}"),

    /**设备类型**/
    RESOURCE_TYPE("ResourceTypeBO:", "ResourceTypeBO:{0},{1}"),

    /****/
    RESOURCE_TYPE_RESOURCEBO("ResourceTypeResourceBO","ResourceTypeResourceBO:{0},{1}"),

    /**工艺路线*/
    ROUTER( "RouterBO:", "RouterBO:{0},{1},{2},{3}" ),

    ROUTER_OPERATION( "RouterOperationBO:", "RouterOperationBO:RouterStepBO:{0},{1}" ),

    /**库存*/
    INVENTORY( "InventoryBO:", "InventoryBO:{0},{1}" ),

    /**物料组*/
    ITEM_GROUP( "ItemGroupBO:", "ItemGroupBO:{0},{1}" ),

    /**数据字段*/
    DATA_FIELD( "DataFieldBO:", "DataFieldBO:{0},{1}" ),

    /**编码规则*/
    NEXT_NUMBER("NextNumberBO:","NextNumberBO:{0},{1}"),

    /**工序*/
    OPERATION( "OperationBO:", "OperationBO:{0},{1},{2}" ),

    /**工作中心**/
    WORK_CENTER("WorkCenterBO:", "WorkCenterBO:{0},{1}"),

    /****/
    SFC_DISPATCH("SfcDispatchBO:", "SfcDispatchBO:{0},{1}"),

    /**检验项目维护*/
    INSPECTION_ITEM("InspectionItemBO:","InspectionItemBO:{0},{1},{2}"),

    /**编码规则*/
    NEXT_NUMBER_CODE("NextNumberCodeBO:","NextNumberCodeBO:{0},{1},{2}"),

    /**设备检验计划**/
    RESOURCE_INSPECT_PLAN("ResourceInspectPlanBo","ResourceInspectPlanBo:{0},{1},{2}"),

    /**设备检验计划的设备清单：站点,点检计划HANDLE,设备HANDLE**/
    RESOURCE_INSPECT_RESOURCE("ResourceInspectResourceBo","ResourceInspectResourceBo:{0},{1},{2}"),

    /**设备检验任务**/
    RESOURCE_INSPECT_TASK("ResourceInspectTaskBo","ResourceInspectTaskBo:{0},{1}"),

    /**设备检验任务**/
    SPLIT_SFC("SplitSfcBo","SplitSfcBo:{0},{1}"),

    /**设备检验任务**/
    RESOURCE_REPAIR_TASK("ResourceRepairTaskBo","ResourceRepairTaskBo:{0},{1}"),

    /**物料批次**/
    ITEM_BATCH("ItemBatchBo", "ItemBatchBo:{0},{1},{2}"),

    /**产前准备任务**/
    PROD_READY_TASK("ProdReadyTaskBO", "ProdReadyTaskBO:{0},{1}"),

    /**产前准备任务**/
    PROD_READY_TASK_DETAIL("ProdReadyTaskDetailBO", "ProdReadyTaskDetailBO:{0},{1}"),

    /**设备检验任务的检验项**/
    RESOURCE_INSPECT_TASK_PARAM("ResourceInspectTaskParamBo","ResourceInspectTaskParamBo:{0},{1}"),

    /**异常单**/
    ABNORMAL_BILL("AbnormalBillBo","AbnormalBillBo:{0},{1}"),

    /**异常单详细表**/
    ABNORMAL_BILL_DISPOSE("AbnormalBillDisposeBo","AbnormalBillDisposeBo:{0},{1}"),

    /**不良代码**/
    NC_CODE("NCCodeBO","NCCodeBO:{0},{1}"),

    /**不良代码组**/
    NC_GROUP("NCGroupBO","NCGroupBO:{0},{1}"),

    /**数据类型**/
    DATA_TYPE("DataTypeBO", "DataTypeBO:{0},{1},{2}"),

    /**设备检验任务的检验项**/
    RESOURCE_INSPECT_TASK_SPARE("ResourceInspectTaskSpareBo","ResourceInspectTaskSpareBo:{0},{1}"),

    /**检验任务**/
    INSPECTION_TASK("InspectionBO:","InspectionBO:{0},{1}"),

    /**检验任务明细**/
    INSPECTION_TASK_DETAIL("InspectionTaskDetailBO:","InspectionTaskDetailBO:{0},{1}"),
    /**自报任务**/
    SELF_REPORT("SelfReportBO:","SelfReportBO:{0},{1}"),
    /**上料**/
    LOAD_INVENTORY("LoadInventoryBO:","LoadInventoryBO:{0},{1}"),

    /**用户**/
    USR("UserBO","UserBO:{0},{1}"),

    TOOL("ToolBO","ToolBO:{0},{1}"),

    USER_RESOURCE("UserResourceBo","UserResourceBo:{0},{1},{2}"),

    SFC_SCRAP("SfcScrapBo","SfcScrapBo:{0},{1}"),

    ABNORMAL_PLAN("AbnormalPlanBo","AbnormalPlanBo:{0},{1}");

    private String prefix;
    private String pattern;

    HandleEnum(String prefix, String pattern) {
        this.prefix = prefix;
        this.pattern = pattern;
    }

    public String getHandle(String... parts) {
        return MessageFormat.format(pattern, parts);
    }

    public String getPart(String handle, int position) {
        String handleParts = handle.replace(prefix, "");
        String[] parts = handleParts.split(",");
        if (position >= parts.length) {
            return null;
        } else {
            return parts[position];
        }
    }

    public String getPrefix() {
        return prefix;
    }
}
