package com.qmth.sop.common.enums;

import java.util.Objects;

/**
 * @Description: 唯一约束字段转换
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/13
 */
public enum FieldUniqueEnum {

    sys_user_UN_moblie_number("手机号"),

    sys_user_UN_login_name("登录名"),

    sys_org_UN_name("机构名称"),

    sys_role_UN_type("角色类型"),

    t_f_custom_flow_entity_UN_code("流程编码"),

    t_b_quality_problem_apply_UN_probem_no("质量问题编号"),

    t_b_ding_apply_UN_ding_exception_no("考勤异常编号"),

    sys_device_brand_un_brand("设备品牌"),

    sys_device_model_un("设备品牌-设备型号"),

    sys_device_un_serial_no("设备编号"),

    t_b_device_in_out_un_serial_no("设备出入编号"),

    t_b_sop_info_un_sop_no("sop编号"),

    t_b_delay_warn_un_code("预警编号"),

    t_b_project_exchange_un_exchange_no("项目计划变更编号"),

    t_b_violation_un_code("违规编号"),

    t_b_crm_un_crm_no("派单号"),

    t_b_ding_un("sop编号-用户id-签到年度-签到日期"),

    t_b_ding_submit_un("sop编号-人员档案id"),

    t_b_product_un_code("产品编号"),

    t_b_service_un_name("服务单元名称"),

    t_b_service_region_un("服务单元id-大区名称"),

    t_b_service_scope_un("服务单元id-派单编号"),

    t_b_user_archives_un_identity("身份证号"),

    t_b_user_archives_un_mobile_number("手机号"),

    t_b_user_archives_allocation_un("派单编号-人员档案id"),

    t_b_user_archives_supplier_un("人员档案id-供应商id"),

    sys_supplier_un_name("供应商名称");

    private String title;

    private FieldUniqueEnum(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    /**
     * 状态转换 toName
     *
     * @param value
     * @return
     */
    public static String convertToName(String value) {
        for (FieldUniqueEnum e : FieldUniqueEnum.values()) {
            if (Objects.equals(value.trim(), e.getTitle())) {
                return e.name();
            }
        }
        return null;
    }

    /**
     * 状态转换 toTitle
     *
     * @param value
     * @return
     */
    public static String convertToTitle(String value) {
        for (FieldUniqueEnum e : FieldUniqueEnum.values()) {
            if (value.trim().contains(e.name())) {
                return e.getTitle();
            }
        }
        return null;
    }
}
